Skip to content

Commit

Permalink
Remove old search UI
Browse files Browse the repository at this point in the history
Remove the `search_panel` feature flag tests and old search UI.
  • Loading branch information
robertknight committed Jan 25, 2024
1 parent aa8995d commit e4427ce
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 1,347 deletions.
4 changes: 1 addition & 3 deletions src/sidebar/components/HypothesisApp.tsx
Expand Up @@ -66,8 +66,6 @@ function HypothesisApp({

const isThirdParty = isThirdPartyService(settings);

const searchPanelEnabled = store.isFeatureEnabled('search_panel');

const login = async () => {
if (serviceConfig(settings)) {
// Let the host page handle the login request
Expand Down Expand Up @@ -166,7 +164,7 @@ function HypothesisApp({
<div className="container">
<ToastMessages />
<HelpPanel />
{searchPanelEnabled && <SearchPanel />}
<SearchPanel />
<ShareDialog shareTab={!isThirdParty} />

{route && (
Expand Down
14 changes: 2 additions & 12 deletions src/sidebar/components/SidebarView.tsx
Expand Up @@ -12,7 +12,6 @@ import SelectionTabs from './SelectionTabs';
import SidebarContentError from './SidebarContentError';
import ThreadList from './ThreadList';
import { useRootThread } from './hooks/use-root-thread';
import FilterStatus from './old-search/FilterStatus';
import FilterControls from './search/FilterControls';

export type SidebarViewProps = {
Expand Down Expand Up @@ -40,8 +39,6 @@ function SidebarView({
// Store state values
const store = useSidebarStore();
const focusedGroupId = store.focusedGroupId();
const hasSelection = store.hasSelectedAnnotations();
const hasAppliedFilter = store.hasAppliedFilter() || hasSelection;
const isLoading = store.isLoading();
const isLoggedIn = store.isLoggedIn();

Expand All @@ -67,19 +64,13 @@ function SidebarView({
const hasContentError =
hasDirectLinkedAnnotationError || hasDirectLinkedGroupError;

const searchPanelEnabled = store.isFeatureEnabled('search_panel');
const showTabs =
!hasContentError && (searchPanelEnabled || !hasAppliedFilter);

// Whether to render the old filter status UI. If no filter is active, this
// will render nothing.
const showFilterStatus = !hasContentError && !searchPanelEnabled;
const showTabs = !hasContentError;

// Whether to render the new filter UI. Note that when the search panel is
// open, filter controls are integrated into it. The UI may render nothing
// if no filters are configured or selection is active.
const isSearchPanelOpen = store.isSidebarPanelOpen('searchAnnotations');
const showFilterControls = searchPanelEnabled && !isSearchPanelOpen;
const showFilterControls = !hasContentError && !isSearchPanelOpen;

// Show a CTA to log in if successfully viewing a direct-linked annotation
// and not logged in
Expand Down Expand Up @@ -143,7 +134,6 @@ function SidebarView({
return (
<div>
<h2 className="sr-only">Annotations</h2>
{showFilterStatus && <FilterStatus />}
{showFilterControls && <FilterControls withCardContainer />}
<LoginPromptPanel onLogin={onLogin} onSignUp={onSignUp} />
{hasDirectLinkedAnnotationError && (
Expand Down
11 changes: 1 addition & 10 deletions src/sidebar/components/TopBar.tsx
Expand Up @@ -13,7 +13,6 @@ import PendingUpdatesButton from './PendingUpdatesButton';
import PressableIconButton from './PressableIconButton';
import SortMenu from './SortMenu';
import UserMenu from './UserMenu';
import SearchInput from './old-search/SearchInput';
import SearchIconButton from './search/SearchIconButton';
import StreamSearchInput from './search/StreamSearchInput';

Expand Down Expand Up @@ -70,10 +69,8 @@ function TopBar({
const loginLinkStyle = applyTheme(['accentColor'], settings);

const store = useSidebarStore();
const filterQuery = store.filterQuery();
const isLoggedIn = store.isLoggedIn();
const hasFetchedProfile = store.hasFetchedProfile();
const searchPanelEnabled = store.isFeatureEnabled('search_panel');

const toggleSharePanel = () => {
store.toggleSidebarPanel('shareGroupAnnotations');
Expand Down Expand Up @@ -118,13 +115,7 @@ function TopBar({
{isSidebar && (
<>
<PendingUpdatesButton />
{!searchPanelEnabled && (
<SearchInput
query={filterQuery || null}
onSearch={store.setFilterQuery}
/>
)}
{searchPanelEnabled && <SearchIconButton />}
<SearchIconButton />
<SortMenu />
<TopBarToggleButton
icon={ShareIcon}
Expand Down
38 changes: 0 additions & 38 deletions src/sidebar/components/hooks/test/use-root-thread-test.js
Expand Up @@ -64,42 +64,4 @@ describe('sidebar/components/hooks/use-root-thread', () => {
assert.equal(threadState.showTabs, showTabs);
});
});

[
// When using search UI, always filter by tab.
{ newSearchUI: true, hasFilter: true, hasSelection: false, showTabs: true },

// When using old search UI, only filter by tab if no selection or filter
// is active.
{
newSearchUI: false,
hasFilter: true,
hasSelection: false,
showTabs: false,
},
{
newSearchUI: false,
hasFilter: false,
hasSelection: true,
showTabs: false,
},
{
newSearchUI: false,
hasFilter: false,
hasSelection: false,
showTabs: true,
},
].forEach(({ newSearchUI, hasFilter, hasSelection, showTabs }) => {
it('if `search_panel` is disabled, does not filter by tab if there is a filter active', () => {
fakeStore.route.returns('sidebar');
fakeStore.isFeatureEnabled.withArgs('search_panel').returns(newSearchUI);
fakeStore.hasAppliedFilter.returns(hasFilter);
fakeStore.hasSelectedAnnotations.returns(hasSelection);

mount(<DummyComponent />);
const threadState = fakeThreadAnnotations.getCall(0).args[0];

assert.equal(threadState.showTabs, showTabs);
});
});
});
9 changes: 1 addition & 8 deletions src/sidebar/components/hooks/use-root-thread.ts
Expand Up @@ -18,14 +18,7 @@ export function useRootThread(): ThreadAnnotationsResult {
const route = store.route();
const selectionState = store.selectionState();
const filters = store.getFilterValues();

// This logic mirrors code in `SidebarView`. It can be simplified once
// the "search_panel" feature is turned on everywhere.
const searchPanelEnabled = store.isFeatureEnabled('search_panel');
const hasAppliedFilter =
store.hasAppliedFilter() || store.hasSelectedAnnotations();
const showTabs =
route === 'sidebar' && (searchPanelEnabled || !hasAppliedFilter);
const showTabs = route === 'sidebar';

const threadState = useMemo((): ThreadState => {
const selection = { ...selectionState, filterQuery: query, filters };
Expand Down

0 comments on commit e4427ce

Please sign in to comment.