1 import { useEffect } from 'react';
2 import { useLocation } from 'react-router';
4 import { c, msgid } from 'ttag';
6 import { SHARE_MEMBER_PERMISSIONS } from '@proton/shared/lib/drive/permissions';
8 // TODO: handle with container
9 import { useActiveShare } from '../../../hooks/drive/useActiveShare';
10 import { useSearchView } from '../../../store';
11 import { extractSearchParameters } from '../../../store/_search/utils';
12 import { FileBrowserStateProvider } from '../../FileBrowser';
13 import DriveToolbar from '../Drive/DriveToolbar';
14 import ToolbarRow from '../ToolbarRow/ToolbarRow';
15 import { Search } from './Search';
17 export function SearchView() {
18 const { activeFolder, setDefaultRoot } = useActiveShare();
19 useEffect(setDefaultRoot, []);
21 const location = useLocation();
22 const query = extractSearchParameters(location);
24 const searchView = useSearchView(activeFolder.shareId, query);
27 <FileBrowserStateProvider itemIds={searchView.items.map(({ linkId }) => linkId)}>
30 <span className="text-strong pl-1">
32 ? c('Title').t`Searching…`
33 : c('Title').ngettext(
34 msgid`Found ${searchView.numberOfResults} result`,
35 `Found ${searchView.numberOfResults} results`,
36 searchView.numberOfResults
42 //TODO: We don't support search view and direct sharing so we assume that user is owner.
43 permissions={SHARE_MEMBER_PERMISSIONS.OWNER}
44 shareId={activeFolder.shareId}
45 linkId={activeFolder.linkId}
46 items={searchView.items}
47 showOptionsForNoSelection={false}
51 <Search shareId={activeFolder.shareId} searchView={searchView} />
52 </FileBrowserStateProvider>