mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
web: use generated Settings type (#42987)
This commit is contained in:
parent
622ab43975
commit
468283ff14
@ -93,7 +93,7 @@ describe('FileSearchResult', () => {
|
||||
subjects: [
|
||||
{
|
||||
lastID: 1,
|
||||
settings: { 'search.contextLines': '3' },
|
||||
settings: { 'search.contextLines': 3 },
|
||||
extensions: null,
|
||||
subject: {
|
||||
__typename: 'User' as const,
|
||||
|
||||
@ -122,19 +122,19 @@ describe('mergeSettings', () => {
|
||||
b?: { [key: string]: { [key: string]: string }[] }
|
||||
} & Settings
|
||||
>([
|
||||
{ quicklinks: [{ name: 'main repo', value: '/github.com/org/main-repo' }] },
|
||||
{ quicklinks: [{ name: 'About Sourcegraph', value: 'https://docs.internal/about-sourcegraph' }] },
|
||||
{ quicklinks: [{ name: 'main repo', url: '/github.com/org/main-repo' }] },
|
||||
{ quicklinks: [{ name: 'About Sourcegraph', url: 'https://docs.internal/about-sourcegraph' }] },
|
||||
{
|
||||
quicklinks: [
|
||||
{ name: 'mycorp extensions', value: 'https://sourcegraph.com/extensions?query=mycorp%2F' },
|
||||
{ name: 'mycorp extensions', url: 'https://sourcegraph.com/extensions?query=mycorp%2F' },
|
||||
],
|
||||
},
|
||||
])
|
||||
).toEqual({
|
||||
quicklinks: [
|
||||
{ name: 'main repo', value: '/github.com/org/main-repo' },
|
||||
{ name: 'About Sourcegraph', value: 'https://docs.internal/about-sourcegraph' },
|
||||
{ name: 'mycorp extensions', value: 'https://sourcegraph.com/extensions?query=mycorp%2F' },
|
||||
{ name: 'main repo', url: '/github.com/org/main-repo' },
|
||||
{ name: 'About Sourcegraph', url: 'https://docs.internal/about-sourcegraph' },
|
||||
{ name: 'mycorp extensions', url: 'https://sourcegraph.com/extensions?query=mycorp%2F' },
|
||||
],
|
||||
}))
|
||||
test('merges search.repositoryGroups property', () =>
|
||||
@ -229,6 +229,7 @@ describe('mergeSettings', () => {
|
||||
{
|
||||
'search.savedQueries': [
|
||||
{
|
||||
key: '1',
|
||||
description: 'global saved query',
|
||||
query: 'type:diff global',
|
||||
notify: true,
|
||||
@ -238,6 +239,7 @@ describe('mergeSettings', () => {
|
||||
{
|
||||
'search.savedQueries': [
|
||||
{
|
||||
key: '2',
|
||||
description: 'org saved query',
|
||||
query: 'type:diff org',
|
||||
notify: true,
|
||||
@ -247,6 +249,7 @@ describe('mergeSettings', () => {
|
||||
{
|
||||
'search.savedQueries': [
|
||||
{
|
||||
key: '3',
|
||||
description: 'user saved query',
|
||||
query: 'type:diff user',
|
||||
notify: true,
|
||||
@ -257,16 +260,19 @@ describe('mergeSettings', () => {
|
||||
).toEqual({
|
||||
'search.savedQueries': [
|
||||
{
|
||||
key: '1',
|
||||
description: 'global saved query',
|
||||
query: 'type:diff global',
|
||||
notify: true,
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
description: 'org saved query',
|
||||
query: 'type:diff org',
|
||||
notify: true,
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
description: 'user saved query',
|
||||
query: 'type:diff user',
|
||||
notify: true,
|
||||
|
||||
@ -3,6 +3,7 @@ import { cloneDeep, isFunction } from 'lodash'
|
||||
import { createAggregateError, ErrorLike, isErrorLike, parseJSONCOrError } from '@sourcegraph/common'
|
||||
|
||||
import * as GQL from '../schema'
|
||||
import { Settings as GeneratedSettingsType } from '../schema/settings.schema'
|
||||
|
||||
/**
|
||||
* A dummy type to represent the "subject" for client settings (i.e., settings stored in the client application,
|
||||
@ -15,30 +16,9 @@ export interface IClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* A subset of the settings JSON Schema type containing the minimum needed by this library.
|
||||
* A JSON Settings Schema type containing properties to prevent its misuse in a place of SettingsCascade.
|
||||
*/
|
||||
export interface Settings {
|
||||
extensions?: { [extensionID: string]: boolean }
|
||||
'codeIntel.referencesPanel'?: 'tree-view' | 'tabbed'
|
||||
experimentalFeatures?: {
|
||||
batchChangesExecution?: boolean
|
||||
showSearchContext?: boolean
|
||||
showSearchContextManagement?: boolean
|
||||
fuzzyFinder?: boolean
|
||||
fuzzyFinderAll?: boolean
|
||||
fuzzyFinderCaseInsensitiveFileCountThreshold?: number
|
||||
fuzzyFinderActions?: boolean
|
||||
clientSearchResultRanking?: string
|
||||
coolCodeIntel?: boolean
|
||||
codeIntelRepositoryBadge?: {
|
||||
enabled: boolean
|
||||
forNerds?: boolean
|
||||
}
|
||||
enableGoImportsSearchQueryTransform?: boolean
|
||||
enableLegacyExtensions?: boolean
|
||||
enableLazyFileResultSyntaxHighlighting?: boolean
|
||||
enableMergedFileSymbolSidebar?: boolean
|
||||
}
|
||||
export interface Settings extends GeneratedSettingsType {
|
||||
[key: string]: any
|
||||
|
||||
// These properties should never exist on Settings but do exist on SettingsCascade. This makes it so the
|
||||
|
||||
@ -9,6 +9,7 @@ import { pretendProxySubscribable, pretendRemote } from '../api/util'
|
||||
import { Controller } from '../extensions/controller'
|
||||
import { PlatformContext } from '../platform/context'
|
||||
import { AggregateStreamingSearchResults, ContentMatch, RepositoryMatch } from '../search/stream'
|
||||
import { SettingsCascade } from '../settings/settings'
|
||||
|
||||
export const CHUNK_MATCH_RESULT: ContentMatch = {
|
||||
type: 'content',
|
||||
@ -615,10 +616,10 @@ export const HIGHLIGHTED_FILE_LINES_LONG_REQUEST = sinon.fake((parameters: Fetch
|
||||
of(parameters.ranges.map(range => HIGHLIGHTED_FILE_LINES_LONG[0].slice(range.startLine, range.endLine)))
|
||||
)
|
||||
|
||||
export const NOOP_SETTINGS_CASCADE = {
|
||||
export const NOOP_SETTINGS_CASCADE = ({
|
||||
subjects: null,
|
||||
final: null,
|
||||
}
|
||||
} as any) as SettingsCascade
|
||||
|
||||
export const extensionsController: Controller = {
|
||||
executeCommand: () => Promise.resolve(),
|
||||
|
||||
@ -25,7 +25,7 @@ describe('Notices', () => {
|
||||
test('no notices', () =>
|
||||
expect(
|
||||
renderWithBrandedContext(
|
||||
<Notices location="home" settingsCascade={{ subjects: [], final: { notices: null } }} />
|
||||
<Notices location="home" settingsCascade={{ subjects: [], final: { notices: undefined } }} />
|
||||
).asFragment()
|
||||
).toMatchSnapshot())
|
||||
})
|
||||
|
||||
@ -11,7 +11,7 @@ import { EditorSettings } from './editor-settings'
|
||||
* @returns A function to open the current location in your preferred editor
|
||||
*/
|
||||
export const useOpenCurrentUrlInEditor = (): ((
|
||||
editorSettings: EditorSettings,
|
||||
editorSettings: EditorSettings | undefined,
|
||||
externalServiceType: string | undefined,
|
||||
sourcegraphURL: string,
|
||||
editorIndex?: number
|
||||
@ -19,7 +19,7 @@ export const useOpenCurrentUrlInEditor = (): ((
|
||||
const location = useLocation()
|
||||
return useCallback(
|
||||
(
|
||||
editorSettings: EditorSettings,
|
||||
editorSettings: EditorSettings | undefined,
|
||||
externalServiceType: string | undefined,
|
||||
sourcegraphURL: string,
|
||||
editorIndex = 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user