Migrated plugins/navigation/index to TypeScript
Summary: Migrated plugins/navigation/index.js to plugins/navigation/index.tsx Reviewed By: passy Differential Revision: D17181195 fbshipit-source-id: da64547ff001cee2be2d728443a3c189785c51f3
This commit is contained in:
committed by
Facebook Github Bot
parent
470c8ca65e
commit
be6a99c8f9
@@ -13,45 +13,39 @@ import {
|
|||||||
SearchBar,
|
SearchBar,
|
||||||
Timeline,
|
Timeline,
|
||||||
RequiredParametersDialog,
|
RequiredParametersDialog,
|
||||||
} from './components/index.tsx';
|
} from './components';
|
||||||
import {
|
import {
|
||||||
removeBookmark,
|
removeBookmark,
|
||||||
readBookmarksFromDB,
|
readBookmarksFromDB,
|
||||||
writeBookmarkToDB,
|
writeBookmarkToDB,
|
||||||
} from './util/indexedDB.tsx';
|
} from './util/indexedDB';
|
||||||
import {
|
import {
|
||||||
appMatchPatternsToAutoCompleteProvider,
|
appMatchPatternsToAutoCompleteProvider,
|
||||||
bookmarksToAutoCompleteProvider,
|
bookmarksToAutoCompleteProvider,
|
||||||
DefaultProvider,
|
DefaultProvider,
|
||||||
} from './util/autoCompleteProvider.tsx';
|
} from './util/autoCompleteProvider';
|
||||||
import {getAppMatchPatterns} from './util/appMatchPatterns.tsx';
|
import {getAppMatchPatterns} from './util/appMatchPatterns';
|
||||||
import {getRequiredParameters, filterOptionalParameters} from './util/uri.tsx';
|
import {getRequiredParameters, filterOptionalParameters} from './util/uri';
|
||||||
|
import {State, PersistedState, Bookmark, NavigationEvent} from './types';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import type {
|
export default class extends FlipperPlugin<State, any, PersistedState> {
|
||||||
State,
|
|
||||||
PersistedState,
|
|
||||||
Bookmark,
|
|
||||||
NavigationEvent,
|
|
||||||
} from './flow-types';
|
|
||||||
|
|
||||||
export default class extends FlipperPlugin<State, {}, PersistedState> {
|
|
||||||
static title = 'Navigation';
|
static title = 'Navigation';
|
||||||
static id = 'Navigation';
|
static id = 'Navigation';
|
||||||
static icon = 'directions';
|
static icon = 'directions';
|
||||||
static keyboardActions = ['clear'];
|
|
||||||
|
|
||||||
static defaultPersistedState: PersistedState = {
|
static defaultPersistedState = {
|
||||||
navigationEvents: [],
|
navigationEvents: [],
|
||||||
bookmarks: new Map<string, Bookmark>(),
|
bookmarks: new Map<string, Bookmark>(),
|
||||||
currentURI: '',
|
currentURI: '',
|
||||||
bookmarksProvider: new DefaultProvider(),
|
bookmarksProvider: DefaultProvider(),
|
||||||
appMatchPatterns: [],
|
appMatchPatterns: [],
|
||||||
appMatchPatternsProvider: new DefaultProvider(),
|
appMatchPatternsProvider: DefaultProvider(),
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
shouldShowSaveBookmarkDialog: false,
|
shouldShowSaveBookmarkDialog: false,
|
||||||
saveBookmarkURI: null,
|
saveBookmarkURI: null as (string | null),
|
||||||
shouldShowURIErrorDialog: false,
|
shouldShowURIErrorDialog: false,
|
||||||
requiredParameters: [],
|
requiredParameters: [],
|
||||||
};
|
};
|
||||||
@@ -59,8 +53,7 @@ export default class extends FlipperPlugin<State, {}, PersistedState> {
|
|||||||
static persistedStateReducer = (
|
static persistedStateReducer = (
|
||||||
persistedState: PersistedState,
|
persistedState: PersistedState,
|
||||||
method: string,
|
method: string,
|
||||||
payload: NavigationEvent,
|
) => {
|
||||||
): $Shape<PersistedState> => {
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
@@ -124,12 +117,6 @@ export default class extends FlipperPlugin<State, {}, PersistedState> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onKeyboardAction = (action: string) => {
|
|
||||||
if (action === 'clear') {
|
|
||||||
this.props.setPersistedState({navigationEvents: []});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
navigateTo = (query: string) => {
|
navigateTo = (query: string) => {
|
||||||
const filteredQuery = filterOptionalParameters(query);
|
const filteredQuery = filterOptionalParameters(query);
|
||||||
this.props.setPersistedState({currentURI: filteredQuery});
|
this.props.setPersistedState({currentURI: filteredQuery});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "flipper-plugin-navigation",
|
"name": "flipper-plugin-navigation",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "index.js",
|
"main": "index.tsx",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"title": "Navigation",
|
"title": "Navigation",
|
||||||
"icon": "directions",
|
"icon": "directions",
|
||||||
|
|||||||
Reference in New Issue
Block a user