Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 522d41f

Browse files
committed
feat: remove file tree
Reason: It is not the primary focus/draw of this extension, and we don't plan to make this available on other code hosts (so it leads to inconsistencies in product offerings among code hosts). BREAKING CHANGE: The GitHub file tree is removed. Use [Octotree](https://chrome.google.com/webstore/detail/octotree/bkhaagjahfmjljalopjnoealnfndnagc) instead for this feature.
1 parent c92792d commit 522d41f

File tree

20 files changed

+2
-1857
lines changed

20 files changed

+2
-1857
lines changed

src/browser/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export interface StorageItems {
4444
phabricatorURL: string
4545
inlineSymbolSearchEnabled: boolean
4646
renderMermaidGraphsEnabled: boolean
47-
repositoryFileTreeEnabled: boolean
4847
executeSearchEnabled: boolean
4948
sourcegraphRepoSearchToggled: boolean
5049
openEditorEnabled: boolean
@@ -89,7 +88,6 @@ export const defaultStorageItems: StorageItems = {
8988
phabricatorURL: '',
9089
inlineSymbolSearchEnabled: true,
9190
renderMermaidGraphsEnabled: false,
92-
repositoryFileTreeEnabled: true,
9391
executeSearchEnabled: false,
9492
sourcegraphRepoSearchToggled: true,
9593
openEditorEnabled: false,

src/extension/scripts/inject.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
setExecuteSearchEnabled,
1111
setInlineSymbolSearchEnabled,
1212
setRenderMermaidGraphsEnabled,
13-
setRepositoryFileTreeEnabled,
1413
setSourcegraphUrl,
1514
setUseExtensions,
1615
} from '../../shared/util/context'
@@ -82,9 +81,6 @@ function injectApplication(): void {
8281
setInlineSymbolSearchEnabled(
8382
items.inlineSymbolSearchEnabled === undefined ? false : items.inlineSymbolSearchEnabled
8483
)
85-
setRepositoryFileTreeEnabled(
86-
items.repositoryFileTreeEnabled === undefined ? true : items.repositoryFileTreeEnabled
87-
)
8884
setExecuteSearchEnabled(items.executeSearchEnabled === undefined ? true : items.executeSearchEnabled)
8985
injectGitHubApplication(extensionMarker)
9086
} else if (isSourcegraphServer || /^https?:\/\/(www.)?sourcegraph.com/.test(href)) {

src/libs/cli/config.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,6 @@ const setUrlCommand: OmniCLI.Command = {
4444
description: 'Set your primary Sourcegraph URL',
4545
}
4646

47-
function setFileTree([to]: string[]): void {
48-
if ((to && to === 'true') || to === 'false') {
49-
storage.setSync({
50-
repositoryFileTreeEnabled: to === 'true',
51-
})
52-
return
53-
}
54-
55-
storage.getSync(({ repositoryFileTreeEnabled }) =>
56-
storage.setSync({ repositoryFileTreeEnabled: !repositoryFileTreeEnabled })
57-
)
58-
}
59-
60-
function getSetFileTreeSuggestions(): Promise<OmniCLI.Suggestion[]> {
61-
return new Promise(resolve => {
62-
storage.getSync(({ repositoryFileTreeEnabled }) =>
63-
resolve([
64-
{
65-
content: repositoryFileTreeEnabled ? 'false' : 'true',
66-
description: `${repositoryFileTreeEnabled ? 'Disable' : 'Enable'} File Tree`,
67-
},
68-
])
69-
)
70-
})
71-
}
72-
73-
const setFileTreeCommand: OmniCLI.Command = {
74-
name: 'set-tree',
75-
action: setFileTree,
76-
getSuggestions: getSetFileTreeSuggestions,
77-
description: 'Set or toggle the File Tree',
78-
}
79-
8047
function setOpenFileOn([to]: string[]): void {
8148
if ((to && to === 'true') || to === 'false') {
8249
storage.setSync({
@@ -111,4 +78,4 @@ const setOpenFileOnCommand: OmniCLI.Command = {
11178
description: `Set whether you would like files to open on Sourcegraph of the given repo's code host`,
11279
}
11380

114-
export default [addUrlCommand, setUrlCommand, setFileTreeCommand, setOpenFileOnCommand]
81+
export default [addUrlCommand, setUrlCommand, setOpenFileOnCommand]

src/libs/cli/file.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ class FileCommand implements OmniCLI.Command {
5454

5555
public getSuggestions = ([queryPath]: string[]): OmniCLI.Suggestion[] => {
5656
if (this.repos.size === 0) {
57-
return [
58-
{
59-
content: 'set-tree true',
60-
description: 'Open a tab to a GitHub repo and enable the file tree to use the fuzzy file finder',
61-
},
62-
]
57+
return []
6358
}
6459

6560
const suggestions: FileSuggestion[] = []

src/libs/github/inject.tsx

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { combineLatest, forkJoin, from, of, Subject } from 'rxjs'
3131
import { filter, map, take, withLatestFrom } from 'rxjs/operators'
3232
import { Disposable } from 'vscode-languageserver'
3333
import { GitHubBlobUrl } from '.'
34-
import storage from '../../browser/storage'
3534
import { applyDecoration, createMessageTransports } from '../../shared/backend/extensions'
3635
import { createExtensionsContextController } from '../../shared/backend/extensions'
3736
import {
@@ -52,13 +51,11 @@ import { WithResolvedRev } from '../../shared/components/WithResolvedRev'
5251
import { AbsoluteRepoFile, DiffResolvedRevSpec } from '../../shared/repo'
5352
import { resolveRev, retryWhenCloneInProgressError } from '../../shared/repo/backend'
5453
import { hideTooltip } from '../../shared/repo/tooltips'
55-
import { RepoRevSidebar } from '../../shared/tree/RepoRevSidebar'
5654
import {
5755
eventLogger,
5856
getModeFromPath,
5957
inlineSymbolSearchEnabled,
6058
renderMermaidGraphsEnabled,
61-
repositoryFileTreeEnabled,
6259
sourcegraphUrl,
6360
useExtensions,
6461
} from '../../shared/util/context'
@@ -288,79 +285,12 @@ function inject(): void {
288285
injectServerBanner()
289286
injectOpenOnSourcegraphButton()
290287

291-
injectFileTree()
292288
injectMermaid()
293289

294290
initSearch()
295291
injectInlineSearch()
296292
}
297293

298-
function hideFileTree(): void {
299-
const tree = document.getElementById('sourcegraph-file-tree')
300-
document.body.style.marginLeft = '0px'
301-
if (!tree || !tree.parentNode) {
302-
return
303-
}
304-
tree.parentNode.removeChild(tree)
305-
}
306-
307-
const specChanges = new Subject<{ repoPath: string; commitID: string }>()
308-
309-
function injectFileTree(): void {
310-
if (!repositoryFileTreeEnabled) {
311-
return
312-
}
313-
const { repoPath } = parseURL()
314-
315-
if (!repoPath) {
316-
return
317-
}
318-
const pjaxContainer = document.getElementById('js-repo-pjax-container')
319-
if (!pjaxContainer) {
320-
return
321-
}
322-
323-
let container = document.getElementById('sourcegraph-file-tree-container') as HTMLElement
324-
let mount = document.getElementById('sourcegraph-file-tree') as HTMLElement
325-
if (!mount) {
326-
mount = document.createElement('div')
327-
mount.id = 'sourcegraph-file-tree'
328-
mount.className = 'tree-mount'
329-
mount.setAttribute('data-pjax', 'true')
330-
container = document.createElement('div')
331-
container.id = 'sourcegraph-file-tree-container'
332-
container.className = 'repo-rev-container'
333-
mount.appendChild(container)
334-
pjaxContainer.insertBefore(mount, pjaxContainer.firstElementChild!)
335-
}
336-
337-
const gitHubState = getGitHubState(window.location.href)
338-
if (!gitHubState) {
339-
return
340-
}
341-
if (document.querySelector('.octotree')) {
342-
storage.setSync({ repositoryFileTreeEnabled: false })
343-
hideFileTree()
344-
return
345-
}
346-
render(
347-
<WithResolvedRev
348-
component={RepoRevSidebar}
349-
className="repo-rev-container__sidebar"
350-
repoPath={repoPath}
351-
rev={gitHubState.rev}
352-
history={history}
353-
scrollRootSelector="#explorer"
354-
selectedPath={gitHubState.filePath}
355-
filePath={gitHubState.filePath}
356-
location={window.location}
357-
defaultBranch={'HEAD'}
358-
/>,
359-
container
360-
)
361-
specChanges.next({ repoPath, commitID: gitHubState.rev || '' })
362-
}
363-
364294
/**
365295
* injectCodeSnippetAnnotator annotates the given containers and adds a view file button.
366296
* @param containers The blob containers that holds the code snippet to be annotated.

src/shared/app.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ $theme-colors-light: (
8282
@import './repo/tooltips';
8383
@import './highlight';
8484
@import './options';
85-
@import './tree/tree';
86-
@import './tree/repoRevSidebar';
87-
@import './tree/resizable';
8885
@import './components/alerts';
8986
@import './components/symbols';
9087
@import './components/codeIntelStatusIndicator';

src/shared/components/Icons.tsx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,3 @@ export function makeCloseIcon(): HTMLElement {
4444
render(<CloseIcon size={17} />, el)
4545
return el
4646
}
47-
48-
export class ShowFileTree extends React.Component<any, {}> {
49-
public render(): JSX.Element {
50-
return (
51-
<IconBase viewBox="0 0 12 10" {...this.props}>
52-
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
53-
<g id="Vector" fillRule="nonzero" fill="#FFFFFF">
54-
<path
55-
d="M11,10 L1,10 C0.45,10 0,9.55 0,9 L0,1 C0,0.45 0.45,0 1,0 L11,0 C11.55,0 12,0.45 12,1 L12,9 C12,9.55 11.55,10 11,10 Z M3.5,1.25 C3.5,1.1 3.4,1 3.25,1 L1.25,1 C1.1,1 1,1.1 1,1.25 L1,8.75 C1,8.9 1.1,9 1.25,9 L3.25,9 C3.4,9 3.5,8.9 3.5,8.75 L3.5,1.25 Z M9.4,4.8 L6.9,3.05 C6.775,2.975 6.625,3 6.55,3.1 C6.525,3.15 6.5,3.2 6.5,3.25 L6.5,6.75 C6.5,6.9 6.625,7 6.75,7 C6.8,7 6.85,6.975 6.9,6.95 L9.4,5.2 C9.525,5.125 9.55,4.975 9.475,4.85 C9.45,4.825 9.425,4.8 9.4,4.8 Z"
56-
id="path0_fill"
57-
/>
58-
</g>
59-
</g>
60-
</IconBase>
61-
)
62-
}
63-
}
64-
65-
export class ToggleFileTree extends React.Component<any, {}> {
66-
public render(): JSX.Element {
67-
return (
68-
<IconBase viewBox="0 0 12 10" {...this.props}>
69-
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
70-
<g id="ToggleFileTree" fillRule="nonzero" fill="#FFFFFF">
71-
<path
72-
d="M11,10 L1,10 C0.45,10 0,9.55 0,9 L0,1 C0,0.45 0.45,0 1,0 L11,0 C11.55,0 12,0.45 12,1 L12,9 C12,9.55 11.55,10 11,10 Z M3.5,1.25 C3.5,1.1 3.4,1 3.25,1 L1.25,1 C1.1,1 1,1.1 1,1.25 L1,8.75 C1,8.9 1.1,9 1.25,9 L3.25,9 C3.4,9 3.5,8.9 3.5,8.75 L3.5,1.25 Z M9,3.25 C9,3.1 8.875,3 8.75,3 C8.7,3 8.65,3.025 8.6,3.05 L6.125,4.8 C6,4.875 5.975,5.025 6.05,5.15 C6.075,5.175 6.1,5.2 6.125,5.225 L8.6,6.975 C8.725,7.05 8.875,7.025 8.95,6.925 C8.975,6.875 9,6.825 9,6.775 L9,3.25 Z"
73-
id="path0_fill"
74-
/>
75-
</g>
76-
</g>
77-
</IconBase>
78-
)
79-
}
80-
}

src/shared/components/options/FeatureFlagCard.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export class FeatureFlagCard extends React.Component<Props, {}> {
1313
storage.setSync({ executeSearchEnabled: !this.props.storage.executeSearchEnabled })
1414
}
1515

16-
private onFileTreeToggled = () => {
17-
storage.setSync({ repositoryFileTreeEnabled: !this.props.storage.repositoryFileTreeEnabled })
18-
}
19-
2016
private onMermaidToggled = () => {
2117
const renderMermaidGraphsEnabled = !this.props.storage.renderMermaidGraphsEnabled
2218
storage.setSync({ renderMermaidGraphsEnabled })
@@ -34,7 +30,6 @@ export class FeatureFlagCard extends React.Component<Props, {}> {
3430
const {
3531
inlineSymbolSearchEnabled,
3632
renderMermaidGraphsEnabled,
37-
repositoryFileTreeEnabled,
3833
executeSearchEnabled,
3934
useExtensions,
4035
} = this.props.storage
@@ -56,16 +51,6 @@ export class FeatureFlagCard extends React.Component<Props, {}> {
5651
your code host.
5752
</Label>
5853
</FormGroup>
59-
<FormGroup check={true}>
60-
<Label check={true}>
61-
<Input
62-
onClick={this.onFileTreeToggled}
63-
defaultChecked={repositoryFileTreeEnabled}
64-
type="checkbox"
65-
/>{' '}
66-
GitHub file tree navigation.
67-
</Label>
68-
</FormGroup>
6954
<FormGroup check={true}>
7055
<Label check={true}>
7156
<Input

src/shared/repo/backend.tsx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -187,41 +187,6 @@ export function retryWhenCloneInProgressError<T>(): (v: Observable<T>) => Observ
187187
)
188188
}
189189

190-
export const fetchTree = memoizeObservable(
191-
(args: { repoPath: string; commitID: string }): Observable<string[]> =>
192-
queryGraphQL({
193-
ctx: getContext({ repoKey: args.repoPath }),
194-
request: `
195-
query FileTree($repoPath: String!, $commitID: String!) {
196-
repository(uri: $repoPath) {
197-
commit(rev: $commitID) {
198-
tree(recursive: true) {
199-
files {
200-
name
201-
}
202-
}
203-
}
204-
}
205-
}
206-
`,
207-
variables: args,
208-
}).pipe(
209-
map(({ data, errors }) => {
210-
if (
211-
!data ||
212-
!data.repository ||
213-
!data.repository.commit ||
214-
!data.repository.commit.tree ||
215-
!data.repository.commit.tree.files
216-
) {
217-
throw Object.assign(new Error((errors || []).map(e => e.message).join('\n')), { errors })
218-
}
219-
return data.repository.commit.tree.files.map(file => file.name)
220-
})
221-
),
222-
makeRepoURI
223-
)
224-
225190
export const listAllSearchResults = memoizeAsync(
226191
(ctx: { query: string }): Promise<number> =>
227192
queryGraphQL({

0 commit comments

Comments
 (0)