Summary: See D38829381. Reviewed By: d16r Differential Revision: D38837720 fbshipit-source-id: c576e16ebb5a0afd5e6dfc71adb3cf0c2361e9a3
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow strict-local
|
|
*/
|
|
|
|
import {
|
|
BookmarksSidebar,
|
|
SaveBookmarkDialog,
|
|
SearchBar,
|
|
Timeline,
|
|
} from './components';
|
|
import {
|
|
appMatchPatternsToAutoCompleteProvider,
|
|
bookmarksToAutoCompleteProvider,
|
|
} from './util/autoCompleteProvider';
|
|
import React, {useMemo} from 'react';
|
|
import {useValue, usePlugin, Layout} from 'flipper-plugin';
|
|
import {plugin} from './plugin';
|
|
|
|
export function Component() {
|
|
const instance = usePlugin(plugin);
|
|
const bookmarks = useValue(instance.bookmarks);
|
|
const appMatchPatterns = useValue(instance.appMatchPatterns);
|
|
const saveBookmarkURI = useValue(instance.saveBookmarkURI);
|
|
const shouldShowSaveBookmarkDialog = useValue(
|
|
instance.shouldShowSaveBookmarkDialog,
|
|
);
|
|
const currentURI = useValue(instance.currentURI);
|
|
const navigationEvents = useValue(instance.navigationEvents);
|
|
|
|
const autoCompleteProviders = useMemo(
|
|
() => [
|
|
bookmarksToAutoCompleteProvider(bookmarks),
|
|
appMatchPatternsToAutoCompleteProvider(appMatchPatterns),
|
|
],
|
|
[bookmarks, appMatchPatterns],
|
|
);
|
|
return (
|
|
<Layout.Container grow>
|
|
<SearchBar
|
|
providers={autoCompleteProviders}
|
|
bookmarks={bookmarks}
|
|
onNavigate={instance.navigateTo}
|
|
onFavorite={instance.onFavorite}
|
|
uriFromAbove={currentURI}
|
|
/>
|
|
<Timeline
|
|
bookmarks={bookmarks}
|
|
events={navigationEvents}
|
|
onNavigate={instance.navigateTo}
|
|
onFavorite={instance.onFavorite}
|
|
/>
|
|
<BookmarksSidebar
|
|
bookmarks={bookmarks}
|
|
onRemove={instance.removeBookmark}
|
|
onNavigate={instance.navigateTo}
|
|
/>
|
|
<SaveBookmarkDialog
|
|
shouldShow={shouldShowSaveBookmarkDialog}
|
|
uri={saveBookmarkURI}
|
|
onHide={() => {
|
|
instance.shouldShowSaveBookmarkDialog.set(false);
|
|
}}
|
|
edit={saveBookmarkURI != null ? bookmarks.has(saveBookmarkURI) : false}
|
|
onSubmit={instance.addBookmark}
|
|
onRemove={instance.removeBookmark}
|
|
/>
|
|
</Layout.Container>
|
|
);
|
|
}
|