From 771466dcdd726b51e22192b6414cab7c04bd9a40 Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Wed, 12 Apr 2023 21:25:14 -0700 Subject: [PATCH 1/2] remove old isCodeInsightsEnabled guard that checked experimentalFeatures Code insights is no longer enabled/disabled with the `experimentalFeatures` object in user settings. That was a legacy from when it was an experimental feature. --- client/web/src/enterprise/insights/index.ts | 3 -- client/web/src/enterprise/routes.tsx | 3 +- .../utils/is-code-insights-enabled.ts | 43 ------------------- client/web/src/nav/GlobalNavbar.tsx | 4 +- schema/schema.go | 3 -- schema/settings.schema.json | 8 ---- 6 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 client/web/src/insights/utils/is-code-insights-enabled.ts diff --git a/client/web/src/enterprise/insights/index.ts b/client/web/src/enterprise/insights/index.ts index 99215a052ddbc..88e65185b33c4 100644 --- a/client/web/src/enterprise/insights/index.ts +++ b/client/web/src/enterprise/insights/index.ts @@ -1,5 +1,2 @@ // Public Insights components export { CodeInsightsRouter } from './CodeInsightsRouter' - -// Guard -export { isCodeInsightsEnabled } from '../../insights/utils/is-code-insights-enabled' diff --git a/client/web/src/enterprise/routes.tsx b/client/web/src/enterprise/routes.tsx index e5bb31e0502d9..06757c1a5e166 100644 --- a/client/web/src/enterprise/routes.tsx +++ b/client/web/src/enterprise/routes.tsx @@ -2,7 +2,6 @@ import { Navigate, RouteObject } from 'react-router-dom' import { lazyComponent } from '@sourcegraph/shared/src/util/lazyComponent' -import { isCodeInsightsEnabled } from '../insights/utils/is-code-insights-enabled' import { LegacyRoute } from '../LegacyRouteContext' import { routes } from '../routes' import { EnterprisePageRoutes } from '../routes.constants' @@ -60,7 +59,7 @@ export const enterpriseRoutes: RouteObject[] = [ element: ( } - condition={props => isCodeInsightsEnabled(props.settingsCascade)} + condition={({ codeInsightsEnabled }) => !!codeInsightsEnabled} /> ), }, diff --git a/client/web/src/insights/utils/is-code-insights-enabled.ts b/client/web/src/insights/utils/is-code-insights-enabled.ts deleted file mode 100644 index 7eb12522989ba..0000000000000 --- a/client/web/src/insights/utils/is-code-insights-enabled.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { isErrorLike } from '@sourcegraph/common' -import { SettingsExperimentalFeatures } from '@sourcegraph/shared/src/schema/settings.schema' -import { SettingsCascadeOrError } from '@sourcegraph/shared/src/settings/settings' - -/** - * Code insights display location setting to check setting for particular view - * to show code insights components. - */ -interface CodeInsightsDisplayLocation { - homepage: boolean - directory: boolean -} - -/** - * Feature guard for code insights. - * - * @param settingsCascade - settings cascade object - * @param views - Map with display location of insights {@link CodeInsightsDisplayLocation} - */ -export function isCodeInsightsEnabled( - settingsCascade: SettingsCascadeOrError, - views: Partial = {} -): boolean { - if (isErrorLike(settingsCascade.final)) { - return false - } - - const final = settingsCascade.final - const viewsKeys = Object.keys(views) as (keyof CodeInsightsDisplayLocation)[] - const experimentalFeatures: SettingsExperimentalFeatures = final?.experimentalFeatures ?? {} - - if (experimentalFeatures.codeInsights === false) { - return false - } - - return viewsKeys.every(viewKey => { - if (views[viewKey]) { - return !!final?.[`insights.displayLocation.${viewKey}`] - } - - return true - }) -} diff --git a/client/web/src/nav/GlobalNavbar.tsx b/client/web/src/nav/GlobalNavbar.tsx index 1f85d37aafcbe..a430b3d10b6a0 100644 --- a/client/web/src/nav/GlobalNavbar.tsx +++ b/client/web/src/nav/GlobalNavbar.tsx @@ -29,7 +29,6 @@ import { useFuzzyFinderFeatureFlags } from '../components/fuzzyFinder/FuzzyFinde import { useFeatureFlag } from '../featureFlags/useFeatureFlag' import { useRoutesMatch } from '../hooks' import { CodeInsightsProps } from '../insights/types' -import { isCodeInsightsEnabled } from '../insights/utils/is-code-insights-enabled' import { NotebookProps } from '../notebooks' import { OwnConfigProps } from '../own/OwnConfigProps' import { EnterprisePageRoutes, PageRoutes } from '../routes.constants' @@ -168,8 +167,7 @@ export const GlobalNavbar: React.FunctionComponent Date: Wed, 12 Apr 2023 21:30:37 -0700 Subject: [PATCH 2/2] rm other unused code insights settings JSON Schema types --- client/web/BUILD.bazel | 1 - schema/schema.go | 62 +------------- schema/settings.schema.json | 161 ------------------------------------ 3 files changed, 1 insertion(+), 223 deletions(-) diff --git a/client/web/BUILD.bazel b/client/web/BUILD.bazel index e5c8008ec78bf..63d0caf223bcc 100644 --- a/client/web/BUILD.bazel +++ b/client/web/BUILD.bazel @@ -1010,7 +1010,6 @@ ts_project( "src/initBuildInfo.ts", "src/insights/Icons.tsx", "src/insights/types.ts", - "src/insights/utils/is-code-insights-enabled.ts", "src/insights/utils/use-series-toggle.ts", "src/jscontext.ts", "src/lsif/html.ts", diff --git a/schema/schema.go b/schema/schema.go index 0591f669816b6..65d1d8bcdedd3 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -238,23 +238,6 @@ type AzureDevOpsConnection struct { // Username description: A username for authentication with the Azure DevOps code host. Username string `json:"username"` } -type BackendInsight struct { - // Description description: The description of this insight - Description string `json:"description,omitempty"` - Filters *InsightFilters `json:"filters,omitempty"` - // Series description: Each query will be represented by one line on the chart. - Series []*BackendInsightSeries `json:"series"` - // Title description: The short title of this insight - Title string `json:"title"` -} -type BackendInsightSeries struct { - // Name description: The name to use for the series in the graph. - Name string `json:"name"` - // Query description: Performs a search query and shows the number of results returned. - Query string `json:"query"` - // Stroke description: The color of the line for the series. - Stroke string `json:"stroke,omitempty"` -} type BatchChangeRolloutWindow struct { // Days description: Day(s) the window applies to. If omitted, this rule applies to all days of the week. Days []string `json:"days,omitempty"` @@ -1319,40 +1302,6 @@ type ImportChangesets struct { // Repository description: The repository name as configured on your Sourcegraph instance. Repository string `json:"repository"` } -type Insight struct { - // Description description: The description of this insight - Description string `json:"description"` - // Id description: A globally unique identifier for this insight. - Id string `json:"id"` - // Series description: Series of data to show for this insight - Series []*InsightSeries `json:"series"` - // Title description: The short title of this insight - Title string `json:"title"` -} -type InsightDashboard struct { - Id string `json:"id"` - // InsightIds description: Insights ids that will be included in the dashboard. - InsightIds []string `json:"insightIds,omitempty"` - // Title description: Title of the dashboard. - Title string `json:"title"` -} - -// InsightFilters description: Performs a filter -type InsightFilters struct { - ExcludeRepoRegexp string `json:"excludeRepoRegexp"` - IncludeRepoRegexp string `json:"includeRepoRegexp"` - Repositories []string `json:"repositories,omitempty"` -} -type InsightSeries struct { - // Label description: The label to use for the series in the graph. - Label string `json:"label"` - // RepositoriesList description: Performs a search query and shows the number of results returned. - RepositoriesList []any `json:"repositoriesList,omitempty"` - // Search description: Performs a search query and shows the number of results returned. - Search string `json:"search,omitempty"` - // Webhook description: (not yet supported) Fetch data from a webhook URL. - Webhook string `json:"webhook,omitempty"` -} // JVMPackagesConnection description: Configuration for a connection to a JVM packages repository. type JVMPackagesConnection struct { @@ -2031,10 +1980,7 @@ type Settings struct { // HistoryPreferAbsoluteTimestamps description: Show absolute timestamps in the history panel and only show relative timestamps (e.g.: "5 days ago") in tooltip when hovering. HistoryPreferAbsoluteTimestamps bool `json:"history.preferAbsoluteTimestamps,omitempty"` // InsightsAggregationsExtendedTimeout description: The number of seconds to execute the aggregation for when running in extended timeout mode. This value should always be less than any proxy timeout if one exists. The maximum value is equal to searchLimits.maxTimeoutSeconds - InsightsAggregationsExtendedTimeout int `json:"insights.aggregations.extendedTimeout,omitempty"` - InsightsDisplayLocationDirectory *bool `json:"insights.displayLocation.directory,omitempty"` - InsightsDisplayLocationHomepage *bool `json:"insights.displayLocation.homepage,omitempty"` - InsightsDisplayLocationInsightsPage *bool `json:"insights.displayLocation.insightsPage,omitempty"` + InsightsAggregationsExtendedTimeout int `json:"insights.aggregations.extendedTimeout,omitempty"` // Motd description: DEPRECATED: Use `notices` instead. // // An array (often with just one element) of messages to display at the top of all pages, including for unauthenticated users. Users may dismiss a message (and any message with the same string value will remain dismissed for the user). @@ -2125,9 +2071,6 @@ func (v *Settings) UnmarshalJSON(data []byte) error { delete(m, "history.defaultPageSize") delete(m, "history.preferAbsoluteTimestamps") delete(m, "insights.aggregations.extendedTimeout") - delete(m, "insights.displayLocation.directory") - delete(m, "insights.displayLocation.homepage") - delete(m, "insights.displayLocation.insightsPage") delete(m, "motd") delete(m, "notices") delete(m, "openInEditor") @@ -2161,8 +2104,6 @@ type SettingsExperimentalFeatures struct { ClientSearchResultRanking *string `json:"clientSearchResultRanking,omitempty"` // CodeInsightsCompute description: Enables Compute powered Code Insights CodeInsightsCompute *bool `json:"codeInsightsCompute,omitempty"` - // CodeInsightsLandingPage description: DEPRECATED: Enables code insights landing page layout. - CodeInsightsLandingPage *bool `json:"codeInsightsLandingPage,omitempty"` // CodeInsightsRepoUI description: Specifies which (code insight repo) editor to use for repo query UI CodeInsightsRepoUI *string `json:"codeInsightsRepoUI,omitempty"` // CodeMonitoringWebHooks description: Shows code monitor webhook and Slack webhook actions in the UI, allowing users to configure them. @@ -2244,7 +2185,6 @@ func (v *SettingsExperimentalFeatures) UnmarshalJSON(data []byte) error { delete(m, "batchChangesExecution") delete(m, "clientSearchResultRanking") delete(m, "codeInsightsCompute") - delete(m, "codeInsightsLandingPage") delete(m, "codeInsightsRepoUI") delete(m, "codeMonitoringWebHooks") delete(m, "enableCodeMirrorFileView") diff --git a/schema/settings.schema.json b/schema/settings.schema.json index afd4aef454c12..aa1ee5283edcb 100644 --- a/schema/settings.schema.json +++ b/schema/settings.schema.json @@ -13,15 +13,6 @@ "type": "object", "additionalProperties": true, "properties": { - "codeInsightsLandingPage": { - "deprecated": true, - "description": "DEPRECATED: Enables code insights landing page layout.", - "type": "boolean", - "default": false, - "!go": { - "pointer": true - } - }, "codeInsightsRepoUI": { "description": "Specifies which (code insight repo) editor to use for repo query UI", "type": "string", @@ -518,27 +509,6 @@ "pointer": true } }, - "insights.displayLocation.insightsPage": { - "type": "boolean", - "default": true, - "!go": { - "pointer": true - } - }, - "insights.displayLocation.directory": { - "type": "boolean", - "default": true, - "!go": { - "pointer": true - } - }, - "insights.displayLocation.homepage": { - "type": "boolean", - "default": true, - "!go": { - "pointer": true - } - }, "insights.aggregations.extendedTimeout": { "description": "The number of seconds to execute the aggregation for when running in extended timeout mode. This value should always be less than any proxy timeout if one exists. The maximum value is equal to searchLimits.maxTimeoutSeconds", "type": "integer", @@ -555,137 +525,6 @@ } }, "definitions": { - "BackendInsight": { - "type": "object", - "required": ["title", "series"], - "properties": { - "title": { - "type": "string", - "description": "The short title of this insight" - }, - "description": { - "type": "string", - "description": "The description of this insight" - }, - "series": { - "type": "array", - "description": "Each query will be represented by one line on the chart.", - "items": { - "$ref": "#/definitions/BackendInsightSeries" - } - }, - "filters": { - "$ref": "#/definitions/InsightFilters" - } - } - }, - "BackendInsightSeries": { - "type": "object", - "additionalProperties": false, - "required": ["name", "query"], - "properties": { - "name": { - "type": "string", - "description": "The name to use for the series in the graph." - }, - "query": { - "type": "string", - "description": "Performs a search query and shows the number of results returned." - }, - "stroke": { - "type": "string", - "description": "The color of the line for the series." - } - } - }, - "InsightFilters": { - "type": "object", - "description": "Performs a filter", - "required": ["includeRepoRegexp", "excludeRepoRegexp"], - "properties": { - "includeRepoRegexp": { - "type": "string" - }, - "excludeRepoRegexp": { - "type": "string" - }, - "repositories": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "InsightDashboard": { - "type": "object", - "required": ["id", "title"], - "properties": { - "title": { - "description": "Title of the dashboard.", - "type": "string" - }, - "id": { - "type": "string" - }, - "insightIds": { - "description": "Insights ids that will be included in the dashboard.", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "Insight": { - "type": "object", - "additionalProperties": false, - "required": ["title", "description", "series", "id"], - "properties": { - "title": { - "type": "string", - "description": "The short title of this insight" - }, - "description": { - "type": "string", - "description": "The description of this insight" - }, - "series": { - "type": "array", - "description": "Series of data to show for this insight", - "items": { - "$ref": "#/definitions/InsightSeries" - } - }, - "id": { - "type": "string", - "description": "A globally unique identifier for this insight." - } - } - }, - "InsightSeries": { - "type": "object", - "additionalProperties": false, - "required": ["label"], - "properties": { - "label": { - "type": "string", - "description": "The label to use for the series in the graph." - }, - "repositoriesList": { - "type": "array", - "description": "Performs a search query and shows the number of results returned." - }, - "search": { - "type": "string", - "description": "Performs a search query and shows the number of results returned." - }, - "webhook": { - "type": "string", - "description": "(not yet supported) Fetch data from a webhook URL." - } - } - }, "SearchScope": { "type": "object", "additionalProperties": false,