Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 9527dcc

Browse files
authored
remove extension API status bar (#45921)
This was not used in any important way by any legacy extensions and is not used by the new code intel support. Removing this is part of our removal of the legacy extension API.
1 parent 50104d2 commit 9527dcc

26 files changed

+31
-915
lines changed

client/extension-api/src/sourcegraph.d.ts

-45
Original file line numberDiff line numberDiff line change
@@ -629,32 +629,6 @@ declare module 'sourcegraph' {
629629
readonly key: string
630630
}
631631

632-
/**
633-
* A text element displayed in an editor's status bar.
634-
* A status bar item can display tooltips on hover and execute commands on click
635-
*/
636-
export interface StatusBarItem {
637-
/** The text to display in the status bar */
638-
text: string
639-
640-
/** Tooltip text to display when hovering over the status bar item. */
641-
tooltip?: string
642-
643-
/** The id of and arguments to a command to execute when the status bar item is clicked */
644-
command?: { id: string; args?: any[] }
645-
}
646-
647-
/**
648-
* Represents a handle to a status bar item.
649-
*
650-
* To get an instance of {@link StatusBarItemType}, use
651-
* {@link sourcegraph.app.createStatusBarItemType}
652-
*/
653-
export interface StatusBarItemType {
654-
/** An opaque identifier. */
655-
readonly key: string
656-
}
657-
658632
export interface Directory {
659633
/**
660634
* The URI of the directory.
@@ -724,16 +698,6 @@ declare module 'sourcegraph' {
724698
*
725699
*/
726700
setDecorations(decorationType: TextDocumentDecorationType, decorations: TextDocumentDecoration[]): void
727-
728-
/**
729-
* Add a status bar item to this editor's status bar. If a status bar item already exists with the given
730-
* {@link StatusBarItemType}, it will be replaced.
731-
*
732-
* @see {@link StatusBarItemType}
733-
* @see {@link sourcegraph.app.createStatusBarItemType}
734-
*
735-
*/
736-
setStatusBarItem(statusBarItemType: StatusBarItemType, statusBarItem: StatusBarItem): void
737701
}
738702

739703
/**
@@ -1145,15 +1109,6 @@ declare module 'sourcegraph' {
11451109
*/
11461110
export function createDecorationType(): TextDocumentDecorationType
11471111

1148-
/**
1149-
* Creates a statusBarItemType that can be used to add a status bar item to
1150-
* the status bar of code views.
1151-
*
1152-
* Use this to create a unique handle to a status bar item, that can be applied to
1153-
* text editors using {@link setStatusBarItem}.
1154-
*/
1155-
export function createStatusBarItemType(): StatusBarItemType
1156-
11571112
/**
11581113
* Register a view provider, which provides the contents of a view.
11591114
*

client/shared/src/api/contract.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { SettingsCascade } from '../settings/settings'
1212

1313
import { SettingsEdit } from './client/services/settings'
1414
import { ExecutableExtension } from './extension/activation'
15-
import { StatusBarItemWithKey } from './extension/api/codeEditor'
1615
import { ProxySubscribable } from './extension/api/common'
1716
import {
1817
FileDecorationsByPath,
@@ -168,7 +167,6 @@ export interface FlatExtensionHostAPI {
168167
) => ProxySubscribable<ViewProviderResult[]>
169168

170169
getGlobalPageViews: (context: ViewContexts['global/page']) => ProxySubscribable<ViewProviderResult[]>
171-
getStatusBarItems: (viewerId: ViewerId) => ProxySubscribable<StatusBarItemWithKey[]>
172170

173171
// Content
174172
getLinkPreviews: (url: string) => ProxySubscribable<LinkPreviewMerged | null>

client/shared/src/api/extension/api/codeEditor.ts

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProxyMarked, proxyMarker } from 'comlink'
2-
import { isEqual, uniqueId } from 'lodash'
2+
import { isEqual } from 'lodash'
33
import { BehaviorSubject, Observable } from 'rxjs'
44
import * as sourcegraph from 'sourcegraph'
55

@@ -11,10 +11,6 @@ import { CodeEditorData, ViewerId } from '../../viewerTypes'
1111
import { createDecorationType } from './decorations'
1212
import { ExtensionDocument } from './textDocument'
1313

14-
export const createStatusBarItemType = (): sourcegraph.StatusBarItemType => ({ key: uniqueId('StatusBarItemType') })
15-
16-
export type StatusBarItemWithKey = sourcegraph.StatusBarItem & sourcegraph.StatusBarItemType
17-
1814
const DEFAULT_DECORATION_TYPE = createDecorationType()
1915

2016
/** @internal */
@@ -70,23 +66,6 @@ export class ExtensionCodeEditor implements sourcegraph.CodeEditor, ProxyMarked
7066
)
7167
}
7268

73-
private _statusBarItemsByType = new Map<sourcegraph.StatusBarItemType, StatusBarItemWithKey>()
74-
75-
private _mergedStatusBarItems = new BehaviorSubject<StatusBarItemWithKey[]>([])
76-
public get mergedStatusBarItems(): Observable<StatusBarItemWithKey[]> {
77-
return this._mergedStatusBarItems
78-
}
79-
80-
public setStatusBarItem(
81-
statusBarItemType: sourcegraph.StatusBarItemType,
82-
statusBarItem: sourcegraph.StatusBarItem
83-
): void {
84-
this._statusBarItemsByType.set(statusBarItemType, { ...statusBarItem, ...statusBarItemType })
85-
this._mergedStatusBarItems.next(
86-
[...this._statusBarItemsByType.values()].flat().filter(statusBarItem => isValidStatusBarItem(statusBarItem))
87-
)
88-
}
89-
9069
public update(data: Pick<CodeEditorData, 'selections'>): void {
9170
const newSelections = data.selections.map(selection => Selection.fromPlain(selection))
9271

@@ -113,8 +92,6 @@ const isEmptyObjectDeep = (value: any): boolean =>
11392
const isDecorationEmpty = ({ range, isWholeLine, ...contents }: clientType.TextDocumentDecoration): boolean =>
11493
isEmptyObjectDeep(contents)
11594

116-
const isValidStatusBarItem = ({ key, text }: StatusBarItemWithKey): boolean => !!key && !!text
117-
11895
function fromTextDocumentDecoration(decoration: sourcegraph.TextDocumentDecoration): clientType.TextDocumentDecoration {
11996
return {
12097
...decoration,

client/shared/src/api/extension/extensionApi.ts

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { Location, MarkupKind, Position, Range, Selection } from '@sourcegraph/e
1010
import { ClientAPI } from '../client/api/api'
1111
import { syncRemoteSubscription } from '../util'
1212

13-
import { createStatusBarItemType } from './api/codeEditor'
1413
import { proxySubscribable } from './api/common'
1514
import { createDecorationType } from './api/decorations'
1615
import { DocumentHighlightKind } from './api/documentHighlights'
@@ -240,7 +239,6 @@ export function createExtensionAPIFactory(
240239
}
241240
},
242241
createDecorationType,
243-
createStatusBarItemType,
244242
// `log` is implemented on extension activation
245243
log: noop,
246244
}

client/shared/src/api/extension/extensionHostApi.ts

-18
Original file line numberDiff line numberDiff line change
@@ -489,24 +489,6 @@ export function createExtensionHostAPI(state: ExtensionHostState): FlatExtension
489489

490490
getGlobalPageViews: context => proxySubscribable(callViewProviders(context, state.globalPageViewProviders)),
491491

492-
getStatusBarItems: ({ viewerId }) => {
493-
const viewer = getViewer(viewerId)
494-
if (viewer.type !== 'CodeEditor') {
495-
return proxySubscribable(EMPTY)
496-
}
497-
498-
return proxySubscribable(
499-
viewer.mergedStatusBarItems.pipe(
500-
debounceTime(0),
501-
map(statusBarItems =>
502-
statusBarItems.sort(
503-
(a, b) => a.text[0].toLowerCase().charCodeAt(0) - b.text[0].toLowerCase().charCodeAt(0)
504-
)
505-
)
506-
)
507-
)
508-
},
509-
510492
// Content
511493
getLinkPreviews: (url: string) =>
512494
proxySubscribable(

client/shared/src/codeintel/legacy-extensions/api.ts

-26
Original file line numberDiff line numberDiff line change
@@ -216,32 +216,6 @@ export interface TextDocumentDecorationType {
216216
readonly key: string
217217
}
218218

219-
/**
220-
* A text element displayed in an editor's status bar.
221-
* A status bar item can display tooltips on hover and execute commands on click
222-
*/
223-
export interface StatusBarItem {
224-
/** The text to display in the status bar */
225-
text: string
226-
227-
/** Tooltip text to display when hovering over the status bar item. */
228-
tooltip?: string
229-
230-
/** The id of and arguments to a command to execute when the status bar item is clicked */
231-
command?: { id: string; args?: any[] }
232-
}
233-
234-
/**
235-
* Represents a handle to a status bar item.
236-
*
237-
* To get an instance of {@link StatusBarItemType}, use
238-
* {@link sourcegraph.app.createStatusBarItemType}
239-
*/
240-
export interface StatusBarItemType {
241-
/** An opaque identifier. */
242-
readonly key: string
243-
}
244-
245219
export interface Directory {
246220
/**
247221
* The URI of the directory.

client/web/src/codeintel/ReferencesPanel.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ const SideBlob: React.FunctionComponent<React.PropsWithChildren<SideBlobProps>>
743743
nav={props.blobNav}
744744
history={history}
745745
location={location}
746-
disableStatusBar={true}
747746
disableDecorations={true}
748747
wrapCode={true}
749748
className={styles.sideBlobCode}

client/web/src/components/diff/FileDiffHunks.module.scss

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
margin-bottom: 1rem;
33
}
44

5-
.status-bar {
6-
background-color: var(--code-bg);
7-
height: 2rem;
8-
}
9-
105
.body {
116
border: 1px solid var(--border-color);
127
border-radius: var(--border-radius);

client/web/src/components/diff/FileDiffHunks.tsx

+1-63
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react'
33
import classNames from 'classnames'
44
import * as H from 'history'
55
import { combineLatest, from, NEVER, Observable, of, ReplaySubject, Subscription } from 'rxjs'
6-
import { distinctUntilKeyChanged, filter, first, map, switchMap, tap } from 'rxjs/operators'
6+
import { filter, first, map, switchMap, tap } from 'rxjs/operators'
77
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect'
88

99
import { findPositionsFromEvents } from '@sourcegraph/codeintellify'
@@ -15,7 +15,6 @@ import { ThemeProps } from '@sourcegraph/shared/src/theme'
1515
import { toURIWithPath } from '@sourcegraph/shared/src/util/url'
1616
import { useObservable } from '@sourcegraph/wildcard'
1717

18-
import { StatusBar } from '../../extensions/components/StatusBar'
1918
import { FileDiffFields } from '../../graphql-operations'
2019
import { DiffMode } from '../../repo/commit/RepositoryCommitPage'
2120
import { diffDomFunctions } from '../../repo/compare/dom-functions'
@@ -53,7 +52,6 @@ export interface FileHunksProps extends ThemeProps {
5352
lineNumbers: boolean
5453

5554
className: string
56-
location: H.Location
5755
history: H.History
5856
/** Reflect selected line in url */
5957
persistLines?: boolean
@@ -67,7 +65,6 @@ export const FileDiffHunks: React.FunctionComponent<React.PropsWithChildren<File
6765
hunks,
6866
isLightTheme,
6967
lineNumbers,
70-
location,
7168
extensionInfo,
7269
persistLines,
7370
diffMode,
@@ -140,30 +137,6 @@ export const FileDiffHunks: React.FunctionComponent<React.PropsWithChildren<File
140137
[extensionInfoChanges]
141138
)
142139

143-
const getHeadStatusBarItems = useCallback(
144-
() =>
145-
baseAndHeadViewerIds.pipe(
146-
distinctUntilKeyChanged('headViewerId'),
147-
switchMap(({ headViewerId, extensionHostAPI }) =>
148-
headViewerId ? wrapRemoteObservable(extensionHostAPI.getStatusBarItems(headViewerId)) : of(null)
149-
),
150-
map(statusBarItems => statusBarItems || [])
151-
),
152-
[baseAndHeadViewerIds]
153-
)
154-
155-
const getBaseStatusBarItems = useCallback(
156-
() =>
157-
baseAndHeadViewerIds.pipe(
158-
distinctUntilKeyChanged('baseViewerId'),
159-
switchMap(({ baseViewerId, extensionHostAPI }) =>
160-
baseViewerId ? wrapRemoteObservable(extensionHostAPI.getStatusBarItems(baseViewerId)) : of(null)
161-
),
162-
map(statusBarItems => statusBarItems || [])
163-
),
164-
[baseAndHeadViewerIds]
165-
)
166-
167140
// Listen for line decorations from extensions
168141
useObservable(
169142
useMemo(
@@ -227,41 +200,6 @@ export const FileDiffHunks: React.FunctionComponent<React.PropsWithChildren<File
227200

228201
return (
229202
<div className={styles.body}>
230-
{extensionInfo && (
231-
<div className={classNames('w-100', isSplitMode && 'd-flex ')}>
232-
{/* Always render base status bar even though it isn't displayed in unified mode
233-
in order to prevent overloading the extension host with messages (`api.getStatusBarItems`) on
234-
mode switch, which noticeably decreases status bar performance. */}
235-
{extensionInfo.extensionsController !== null && window.context.enableLegacyExtensions ? (
236-
<>
237-
<StatusBar
238-
getStatusBarItems={getBaseStatusBarItems}
239-
className={classNames(
240-
isSplitMode && 'flex-1 w-50',
241-
'border-bottom border-top-0',
242-
styles.statusBar
243-
)}
244-
statusBarItemClassName="mx-0"
245-
extensionsController={extensionInfo.extensionsController}
246-
location={location}
247-
badgeText="BASE"
248-
/>
249-
<StatusBar
250-
getStatusBarItems={getHeadStatusBarItems}
251-
className={classNames(
252-
isSplitMode && 'w-50',
253-
'flex-1 border-bottom border-top-0',
254-
styles.statusBar
255-
)}
256-
statusBarItemClassName="mx-0"
257-
extensionsController={extensionInfo.extensionsController}
258-
location={location}
259-
badgeText="HEAD"
260-
/>
261-
</>
262-
) : null}
263-
</div>
264-
)}
265203
<div className={classNames(styles.fileDiffHunks, className)} ref={nextBlobElement}>
266204
{hunks.length === 0 ? (
267205
<div className="text-muted m-2">No changes</div>

client/web/src/components/diff/FileDiffNode.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export const FileDiffNode: React.FunctionComponent<React.PropsWithChildren<FileD
160160
fileDiffAnchor={anchor}
161161
history={history}
162162
isLightTheme={isLightTheme}
163-
location={location}
164163
persistLines={persistLines}
165164
extensionInfo={
166165
extensionInfo && {

client/web/src/enterprise/batches/BatchSpecNode.module.scss

+1-3
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@
188188
}
189189

190190
:global(.bottom-spacer) {
191-
// Give room to view the last few lines of code
192-
// without the floating status bar getting in the way.
193-
height: calc(var(--blob-status-bar-height) + var(--blob-status-bar-vertical-gap) + 1.5rem);
191+
height: 1.5rem;
194192
}
195193

196194
&--wrapped {

0 commit comments

Comments
 (0)