diff --git a/web/src/routes.tsx b/web/src/routes.tsx index b69aa6b300cf..1e34a5578c93 100644 --- a/web/src/routes.tsx +++ b/web/src/routes.tsx @@ -86,11 +86,6 @@ export const routes: readonly LayoutRouteProps[] = [ allExpanded={false} showSavedQueryModal={false} deployType={window.context.deployType} - onShowMoreResultsClick={() => undefined} - onExpandAllResultsToggle={() => undefined} - onSavedQueryModalClose={() => undefined} - onDidCreateSavedQuery={() => undefined} - onSaveQueryClick={() => undefined} didSave={false} /> ) : ( diff --git a/web/src/search/SearchConsolePage.tsx b/web/src/search/SearchConsolePage.tsx index b2202b1c84d7..1469047df6f9 100644 --- a/web/src/search/SearchConsolePage.tsx +++ b/web/src/search/SearchConsolePage.tsx @@ -20,8 +20,16 @@ import { parseSearchURL } from '.' interface SearchConsolePageProps extends ThemeProps, - SettingsCascadeProps, - Omit, + Omit< + SearchResultsListProps, + | 'extensionsController' + | 'onSavedQueryModalClose' + | 'onShowMoreResultsClick' + | 'onExpandAllResultsToggle' + | 'onSavedQueryModalClose' + | 'onDidCreateSavedQuery' + | 'onSaveQueryClick' + >, ExtensionsControllerProps<'executeCommand' | 'services' | 'extHostAPI'> { globbing: boolean history: H.History @@ -45,6 +53,9 @@ export const SearchConsolePage: React.FunctionComponent [searchQueries, props.patternType, props.extensionsController] ) ) + + const [allExpanded, setAllExpanded] = useState(false) + const options: Monaco.editor.IEditorOptions = { readOnly: false, minimap: { @@ -92,7 +103,7 @@ export const SearchConsolePage: React.FunctionComponent return () => disposable.dispose() }, [editorInstance, searchQueries, props.history]) - const calculateCount = (): number => { + const calculateCount = useCallback((): number => { // This function can only get called if the results were successfully loaded, // so casting is the right thing to do here const results = resultsOrError as GQL.ISearchResults @@ -104,8 +115,9 @@ export const SearchConsolePage: React.FunctionComponent return Math.max(results.matchCount * 2, 1000) } return Math.max(results.matchCount * 2 || 0, 1000) - } - const showMoreResults = (): void => { + }, [resultsOrError]) + + const showMoreResults = useCallback((): void => { // Requery with an increased max result count. if (!editorInstance) { return @@ -121,7 +133,16 @@ export const SearchConsolePage: React.FunctionComponent } editorInstance.setValue(query) props.history.push('/search/console?q=' + encodeURI(query)) - } + }, [props.history, calculateCount, editorInstance]) + + const onExpandAllResultsToggle = useCallback((): void => { + setAllExpanded(allExpanded => { + props.telemetryService.log(allExpanded ? 'allResultsExpanded' : 'allResultsCollapsed') + return allExpanded + }) + }, [setAllExpanded, props.telemetryService]) + + const voidCallback = useCallback(() => undefined, []) return (
@@ -152,7 +173,12 @@ export const SearchConsolePage: React.FunctionComponent ))}
diff --git a/web/src/search/results/SearchResultsInfoBar.tsx b/web/src/search/results/SearchResultsInfoBar.tsx index 507a1d910429..9f2173c829bc 100644 --- a/web/src/search/results/SearchResultsInfoBar.tsx +++ b/web/src/search/results/SearchResultsInfoBar.tsx @@ -42,6 +42,7 @@ interface SearchResultsInfoBarProps showDotComMarketing: boolean // Saved queries + showSavedQueryButton?: boolean onDidCreateSavedQuery: () => void onSaveQueryClick: () => void didSave: boolean @@ -216,7 +217,7 @@ export const SearchResultsInfoBar: React.FunctionComponent )} - {props.authenticatedUser && ( + {props.showSavedQueryButton && props.authenticatedUser && (