Chore: remove search console (#63322)

The search console page is broken, is not used or maintained, and is
only referenced by a series of blog posts years ago. We have product
support to remove it.
This commit is contained in:
Camden Cheek 2024-06-19 11:05:03 -06:00 committed by GitHub
parent 611dcfa806
commit db7a268c34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 3 additions and 213 deletions

View File

@ -302,10 +302,6 @@ export const useSettings = (): Settings | null => {
const defaultFeatures: SettingsExperimentalFeatures = {
codeMonitoring: true,
/**
* Whether we show the multiline editor at /search/console
*/
showMultilineSearchConsole: false,
codeMonitoringWebHooks: true,
showCodeMonitoringLogs: true,
showFullTreeContext: false,

View File

@ -1419,7 +1419,6 @@ ts_project(
"src/savedSearches/SavedSearchUpdateForm.tsx",
"src/search-jobs/utility.ts",
"src/search/QuickLinks.tsx",
"src/search/SearchConsolePage.tsx",
"src/search/SearchPageWrapper.tsx",
"src/search/autocompletion/hooks.ts",
"src/search/autocompletion/source.ts",

View File

@ -62,7 +62,6 @@ export const LegacyLayout: FC<LegacyLayoutProps> = props => {
const isSearchRelatedPage = (routeMatch === PageRoutes.RepoContainer || routeMatch?.startsWith('/search')) ?? false
const isSearchHomepage = location.pathname === '/search' && !parseSearchURLQuery(location.search)
const isSearchConsolePage = routeMatch?.startsWith('/search/console')
const isSearchJobsPage = routeMatch?.startsWith(PageRoutes.SearchJobs)
const isSearchNotebooksPage = routeMatch?.startsWith(PageRoutes.Notebooks)
const isCodySearchPage = routeMatch === PageRoutes.CodySearch
@ -188,7 +187,6 @@ export const LegacyLayout: FC<LegacyLayoutProps> = props => {
isSearchRelatedPage &&
!isSearchHomepage &&
!isCommunitySearchContextPage &&
!isSearchConsolePage &&
!isSearchNotebooksPage &&
!isCodySearchPage &&
!isSearchJobsPage

View File

@ -2,7 +2,6 @@ import { useEffect } from 'react'
import { Navigate, useNavigate, type RouteObject } from 'react-router-dom'
import { useExperimentalFeatures } from '@sourcegraph/shared/src/settings/settings'
import { lazyComponent } from '@sourcegraph/shared/src/util/lazyComponent'
import { codyProRoutes } from './cody/codyProRoutes'
@ -12,7 +11,6 @@ import { PageRoutes } from './routes.constants'
import { isSearchJobsEnabled } from './search-jobs/utility'
const SiteAdminArea = lazyComponent(() => import('./site-admin/SiteAdminArea'), 'SiteAdminArea')
const SearchConsolePage = lazyComponent(() => import('./search/SearchConsolePage'), 'SearchConsolePage')
const SignInPage = lazyComponent(() => import('./auth/SignInPage'), 'SignInPage')
const RequestAccessPage = lazyComponent(() => import('./auth/RequestAccessPage'), 'RequestAccessPage')
const SignUpPage = lazyComponent(() => import('./auth/SignUpPage'), 'SignUpPage')
@ -244,20 +242,6 @@ export const routes: RouteObject[] = [
/>
),
},
{
path: PageRoutes.SearchConsole,
element: (
<LegacyRoute
render={props => (
<SearchConsolePageOrRedirect
{...props}
telemetryRecorder={props.platformContext.telemetryRecorder}
/>
)}
condition={({ licenseFeatures }) => licenseFeatures.isCodeSearchEnabled}
/>
),
},
{
path: PageRoutes.Welcome,
// This route is deprecated after we removed the post-sign-up page experimental feature, but we keep it for now to not break links.
@ -441,16 +425,6 @@ export const routes: RouteObject[] = [
},
]
function SearchConsolePageOrRedirect(props: LegacyLayoutRouteContext): JSX.Element {
const showMultilineSearchConsole = useExperimentalFeatures(features => features.showMultilineSearchConsole)
return showMultilineSearchConsole ? (
<SearchConsolePage {...props} />
) : (
<Navigate replace={true} to={PageRoutes.Search} />
)
}
function SearchPageOrUpsellPage(props: LegacyLayoutRouteContext): JSX.Element {
const { isCodeSearchEnabled } = props.licenseFeatures
if (!isCodeSearchEnabled) {

View File

@ -1,28 +0,0 @@
.results {
overflow: auto;
}
.editor {
background-color: var(--input-bg);
padding: 0.25rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
&:focus,
&:focus-within {
border-color: var(--border-active-color) !important;
}
:global(.cm-scroller) {
overflow: auto;
}
:global(.cm-editor) {
flex: 1;
max-height: 100%;
}
}

View File

@ -1,135 +0,0 @@
import React, { useCallback, useEffect, useMemo } from 'react'
import classNames from 'classnames'
import { useLocation, useNavigate } from 'react-router-dom'
import { BehaviorSubject, of } from 'rxjs'
import { debounceTime } from 'rxjs/operators'
import {
StreamingSearchResultsList,
type StreamingSearchResultsListProps,
CodeMirrorQueryInput,
createDefaultSuggestions,
} from '@sourcegraph/branded'
import { LATEST_VERSION } from '@sourcegraph/shared/src/search/stream'
import { fetchStreamSuggestions } from '@sourcegraph/shared/src/search/suggestions'
import { TelemetryV2Props } from '@sourcegraph/shared/src/telemetry'
import { LoadingSpinner, Button, useObservable } from '@sourcegraph/wildcard'
import { PageTitle } from '../components/PageTitle'
import { SearchPatternType } from '../graphql-operations'
import type { OwnConfigProps } from '../own/OwnConfigProps'
import { parseSearchURLQuery, parseSearchURLPatternType, type SearchStreamingProps } from '.'
import styles from './SearchConsolePage.module.scss'
interface SearchConsolePageProps
extends SearchStreamingProps,
Omit<StreamingSearchResultsListProps, 'allExpanded' | 'executedQuery' | 'showSearchContext'>,
OwnConfigProps,
TelemetryV2Props {
isMacPlatform: boolean
}
export const SearchConsolePage: React.FunctionComponent<React.PropsWithChildren<SearchConsolePageProps>> = props => {
const location = useLocation()
const navigate = useNavigate()
const { streamSearch, isSourcegraphDotCom } = props
const searchQuery = useMemo(
() => new BehaviorSubject<string>(parseSearchURLQuery(location.search) ?? ''),
[location.search]
)
const patternType = useMemo(
() => parseSearchURLPatternType(location.search) || SearchPatternType.structural,
[location.search]
)
const triggerSearch = useCallback(() => {
navigate('/search/console?q=' + encodeURIComponent(searchQuery.value))
}, [navigate, searchQuery])
const transformedQuery = useMemo(() => {
let query = parseSearchURLQuery(location.search)
query = query?.replace(/\/\/.*/g, '') || ''
return query
}, [location.search])
const autocompletion = useMemo(
() =>
createDefaultSuggestions({
fetchSuggestions: query => fetchStreamSuggestions(query),
isSourcegraphDotCom,
}),
[isSourcegraphDotCom]
)
const onEnter = useCallback(() => {
triggerSearch()
return true
}, [triggerSearch])
const onChange = useCallback(
(value: string) => {
searchQuery.next(value)
},
[searchQuery]
)
// Fetch search results when the `q` URL query parameter changes
const results = useObservable(
useMemo(
() =>
streamSearch(of(transformedQuery), {
version: LATEST_VERSION,
patternType: patternType ?? SearchPatternType.standard,
caseSensitive: false,
trace: undefined,
}).pipe(debounceTime(500)),
[patternType, transformedQuery, streamSearch]
)
)
useEffect(() => props.telemetryRecorder.recordEvent('search.console', 'view'), [props.telemetryRecorder])
return (
<div className="w-100 p-2">
<PageTitle title="Search console" />
<div className="d-flex overflow-hidden h-100">
<div className="flex-1 p-1 d-flex flex-column">
<div className={styles.editor}>
<CodeMirrorQueryInput
className="d-flex flex-column overflow-hidden"
patternType={patternType}
interpretComments={true}
value={searchQuery.value}
multiLine={true}
extension={autocompletion}
onEnter={onEnter}
onChange={onChange}
/>
</div>
<Button className="mt-2" onClick={triggerSearch} variant="primary">
Search &nbsp; {props.isMacPlatform ? <kbd></kbd> : <kbd>Ctrl</kbd>}+<kbd></kbd>
</Button>
</div>
<div className={classNames('flex-1 p-1', styles.results)}>
{results &&
(results.state === 'loading' ? (
<LoadingSpinner />
) : (
<StreamingSearchResultsList
{...props}
allExpanded={false}
results={results}
executedQuery={location.search}
showQueryExamplesOnNoResultsPage={false}
/>
))}
</div>
</div>
</div>
)
}

View File

@ -68,7 +68,6 @@ export const Layout: React.FC<LegacyLayoutProps> = props => {
const isSearchRelatedPage =
(isRepositoryRelatedPage || routeMatches.some(routeMatch => routeMatch.pathname.startsWith('/search'))) ?? false
const isSearchHomepage = location.pathname === '/search' && !parseSearchURLQuery(location.search)
const isSearchConsolePage = routeMatches.some(routeMatch => routeMatch.pathname.startsWith('/search/console'))
const isSearchNotebooksPage = routeMatches.some(routeMatch => routeMatch.pathname.startsWith(PageRoutes.Notebooks))
const isCodySearchPage = routeMatches.some(routeMatch => routeMatch.pathname.startsWith(PageRoutes.CodySearch))
@ -217,7 +216,6 @@ export const Layout: React.FC<LegacyLayoutProps> = props => {
isSearchRelatedPage &&
!isSearchHomepage &&
!isCommunitySearchContextPage &&
!isSearchConsolePage &&
!isSearchNotebooksPage &&
!isCodySearchPage
}

View File

@ -2,7 +2,6 @@
// This is set from an environment variable
"experimentalFeatures": {
"batchChangesExecution": true,
"showMultilineSearchConsole": true,
"codeMonitoring": true,
"enableLazyBlobSyntaxHighlighting": true,
"enableLazyFileResultSyntaxHighlighting": true,

View File

@ -174,13 +174,13 @@ func TestMergeSettings(t *testing.T) {
},
right: &schema.Settings{
ExperimentalFeatures: &schema.SettingsExperimentalFeatures{
ShowMultilineSearchConsole: pointers.Ptr(false),
BatchChangesExecution: pointers.Ptr(false),
},
},
expected: &schema.Settings{
ExperimentalFeatures: &schema.SettingsExperimentalFeatures{
CodeMonitoringWebHooks: pointers.Ptr(true),
ShowMultilineSearchConsole: pointers.Ptr(false),
CodeMonitoringWebHooks: pointers.Ptr(true),
BatchChangesExecution: pointers.Ptr(false),
},
},
}, {

View File

@ -2587,8 +2587,6 @@ type SettingsExperimentalFeatures struct {
SearchResultsAggregations *bool `json:"searchResultsAggregations,omitempty"`
// ShowCodeMonitoringLogs description: Shows code monitoring logs tab.
ShowCodeMonitoringLogs *bool `json:"showCodeMonitoringLogs,omitempty"`
// ShowMultilineSearchConsole description: Enables the multiline search console at search/console
ShowMultilineSearchConsole *bool `json:"showMultilineSearchConsole,omitempty"`
// SymbolKindTags description: Show the initial letter of the symbol kind instead of icons.
SymbolKindTags bool `json:"symbolKindTags,omitempty"`
Additional map[string]any `json:"-"` // additionalProperties not explicitly defined in the schema
@ -2650,7 +2648,6 @@ func (v *SettingsExperimentalFeatures) UnmarshalJSON(data []byte) error {
delete(m, "searchQueryInput")
delete(m, "searchResultsAggregations")
delete(m, "showCodeMonitoringLogs")
delete(m, "showMultilineSearchConsole")
delete(m, "symbolKindTags")
if len(m) > 0 {
v.Additional = make(map[string]any, len(m))

View File

@ -54,14 +54,6 @@
"pointer": true
}
},
"showMultilineSearchConsole": {
"description": "Enables the multiline search console at search/console",
"type": "boolean",
"default": false,
"!go": {
"pointer": true
}
},
"fuzzyFinder": {
"description": "Enables fuzzy finder with the keyboard shortcut `Cmd+K` on macOS and `Ctrl+K` on Linux/Windows.",
"type": "boolean",