mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
Update dependency @sourcegraph/tsconfig to v4 (#2260)
This commit is contained in:
parent
8c8f348d7b
commit
563b528eb4
@ -12,8 +12,8 @@ export const noopMigration: MigrateFunc = () => ({})
|
||||
|
||||
export function provideMigrations(area: chrome.storage.StorageArea): MigratableStorageArea {
|
||||
const migrations = new Subject<MigrateFunc>()
|
||||
const getCalls = new ReplaySubject<any[]>()
|
||||
const setCalls = new ReplaySubject<any[]>()
|
||||
const getCalls = new ReplaySubject<Parameters<chrome.storage.StorageArea['get']>>()
|
||||
const setCalls = new ReplaySubject<Parameters<chrome.storage.StorageArea['set']>>()
|
||||
|
||||
const migrated = migrations.pipe(
|
||||
switchMap(
|
||||
@ -38,18 +38,20 @@ export function provideMigrations(area: chrome.storage.StorageArea): MigratableS
|
||||
const initializedSets = migrated.pipe(switchMap(() => setCalls))
|
||||
|
||||
initializedSets.subscribe(args => {
|
||||
area.set.apply(area, args)
|
||||
area.set(...args)
|
||||
})
|
||||
|
||||
initializedGets.subscribe(args => {
|
||||
area.get.apply(area, args)
|
||||
// Cast is needed because Parameters<> doesn't include overloads
|
||||
area.get(...(args as Parameters<chrome.storage.StorageArea['get']>))
|
||||
})
|
||||
|
||||
const get: chrome.storage.StorageArea['get'] = (...args) => {
|
||||
// Cast is needed because Parameters<> doesn't include overloads
|
||||
const get: chrome.storage.StorageArea['get'] = ((...args: Parameters<chrome.storage.StorageArea['get']>) => {
|
||||
getCalls.next(args)
|
||||
}
|
||||
}) as chrome.storage.StorageArea['get']
|
||||
|
||||
const set: chrome.storage.StorageArea['set'] = (...args) => {
|
||||
const set: chrome.storage.StorageArea['set'] = (...args: Parameters<chrome.storage.StorageArea['set']>) => {
|
||||
setCalls.next(args)
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
"@gql2ts/language-typescript": "^1.9.0",
|
||||
"@sourcegraph/prettierrc": "^2.2.0",
|
||||
"@sourcegraph/stylelint-config": "^1.1.1",
|
||||
"@sourcegraph/tsconfig": "^3.0.0",
|
||||
"@sourcegraph/tsconfig": "^4.0.0",
|
||||
"@sourcegraph/tslint-config": "^12.3.1",
|
||||
"@storybook/addon-actions": "^4.1.4",
|
||||
"@storybook/addon-console": "^1.1.0",
|
||||
|
||||
@ -4,6 +4,7 @@ import * as React from 'react'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Subject } from 'rxjs'
|
||||
import { distinctUntilChanged, startWith } from 'rxjs/operators'
|
||||
import { Key } from 'ts-key-enum'
|
||||
import { AbsoluteRepo } from '../../../shared/src/util/url'
|
||||
import { dirname } from '../util/path'
|
||||
import { TreeRoot } from './TreeRoot'
|
||||
@ -120,17 +121,83 @@ export class Tree extends React.PureComponent<Props, State> {
|
||||
public node: TreeNode
|
||||
private treeElement: HTMLElement | null
|
||||
|
||||
private handlers: { [index: string]: () => void } = {
|
||||
// tslint:disable-next-line:no-unbound-method
|
||||
ArrowDown: this.onArrowDown,
|
||||
// tslint:disable-next-line:no-unbound-method
|
||||
ArrowUp: this.onArrowUp,
|
||||
// tslint:disable-next-line:no-unbound-method
|
||||
ArrowLeft: this.onArrowLeft,
|
||||
// tslint:disable-next-line:no-unbound-method
|
||||
ArrowRight: this.onArrowRight,
|
||||
// tslint:disable-next-line:no-unbound-method
|
||||
Enter: this.onEnter,
|
||||
private keyHandlers: Record<string, () => void> = {
|
||||
[Key.ArrowDown]: () => {
|
||||
// This case gets called whenever we are going _down_ the tree
|
||||
if (this.state.selectedNode) {
|
||||
this.selectNode(nextChild(this.state.selectedNode, 0))
|
||||
}
|
||||
},
|
||||
[Key.ArrowUp]: () => {
|
||||
if (this.state.selectedNode) {
|
||||
this.selectNode(prevChild(this.state.selectedNode, this.state.selectedNode.index))
|
||||
}
|
||||
},
|
||||
[Key.ArrowLeft]: () => {
|
||||
const selectedNodePath =
|
||||
this.state.selectedNode.path !== '' ? this.state.selectedNode.path : this.props.activePath
|
||||
const isOpenDir = this.isExpanded(selectedNodePath)
|
||||
if (isOpenDir) {
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: false,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
return
|
||||
}
|
||||
const parent = this.state.selectedNode.parent
|
||||
if (parent !== null && parent.parent !== null) {
|
||||
this.selectNode(parent)
|
||||
return
|
||||
}
|
||||
|
||||
this.selectNode(prevChild(this.state.selectedNode, this.state.selectedNode.index))
|
||||
},
|
||||
[Key.ArrowRight]: () => {
|
||||
const selectedNodePath =
|
||||
this.state.selectedNode.path !== '' ? this.state.selectedNode.path : this.props.activePath
|
||||
const nodeDomElement = getDomElement(selectedNodePath)
|
||||
if (nodeDomElement) {
|
||||
const isDirectory = Boolean(nodeDomElement.getAttribute('data-tree-is-directory'))
|
||||
if (!this.isExpanded(selectedNodePath) && isDirectory) {
|
||||
// First, show the group (but don't update selection)
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: true,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
} else {
|
||||
this.selectNode(nextChild(this.state.selectedNode, 0))
|
||||
}
|
||||
}
|
||||
},
|
||||
[Key.Enter]: () => {
|
||||
const selectedNodePath = this.state.selectedNode.path
|
||||
const nodeDomElement = getDomElement(selectedNodePath)
|
||||
if (nodeDomElement) {
|
||||
const isDirectory = Boolean(nodeDomElement.getAttribute('data-tree-is-directory'))
|
||||
if (isDirectory) {
|
||||
const isOpen = this.isExpanded(selectedNodePath)
|
||||
if (isOpen) {
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: false,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
this.selectNode(this.state.selectedNode)
|
||||
return
|
||||
}
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: true,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
}
|
||||
this.selectNode(this.state.selectedNode)
|
||||
this.setActiveNode(this.state.selectedNode)
|
||||
this.props.history.push(this.state.selectedNode.url)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
constructor(props: Props) {
|
||||
@ -258,87 +325,10 @@ export class Tree extends React.PureComponent<Props, State> {
|
||||
this.node.childNodes[index] = node
|
||||
}
|
||||
|
||||
private onArrowDown(): void {
|
||||
// This case gets called whenever we are going _down_ the tree
|
||||
if (this.state.selectedNode) {
|
||||
this.selectNode(nextChild(this.state.selectedNode, 0))
|
||||
}
|
||||
}
|
||||
|
||||
private onArrowUp(): void {
|
||||
if (this.state.selectedNode) {
|
||||
this.selectNode(prevChild(this.state.selectedNode, this.state.selectedNode.index))
|
||||
}
|
||||
}
|
||||
|
||||
private isExpanded(path: string): boolean {
|
||||
return this.state.resolveTo.includes(path)
|
||||
}
|
||||
|
||||
private onArrowLeft(): void {
|
||||
const selectedNodePath =
|
||||
this.state.selectedNode.path !== '' ? this.state.selectedNode.path : this.props.activePath
|
||||
const isOpenDir = this.isExpanded(selectedNodePath)
|
||||
if (isOpenDir) {
|
||||
this.expandDirectoryChanges.next({ path: selectedNodePath, expanded: false, node: this.state.selectedNode })
|
||||
return
|
||||
}
|
||||
const parent = this.state.selectedNode.parent
|
||||
if (parent !== null && parent.parent !== null) {
|
||||
this.selectNode(parent)
|
||||
return
|
||||
}
|
||||
|
||||
this.selectNode(prevChild(this.state.selectedNode, this.state.selectedNode.index))
|
||||
}
|
||||
|
||||
private onArrowRight(): void {
|
||||
const selectedNodePath =
|
||||
this.state.selectedNode.path !== '' ? this.state.selectedNode.path : this.props.activePath
|
||||
const nodeDomElement = getDomElement(selectedNodePath)
|
||||
if (nodeDomElement) {
|
||||
const isDirectory = Boolean(nodeDomElement.getAttribute('data-tree-is-directory'))
|
||||
if (!this.isExpanded(selectedNodePath) && isDirectory) {
|
||||
// First, show the group (but don't update selection)
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: true,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
} else {
|
||||
this.selectNode(nextChild(this.state.selectedNode, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private onEnter(): void {
|
||||
const selectedNodePath = this.state.selectedNode.path
|
||||
const nodeDomElement = getDomElement(selectedNodePath)
|
||||
if (nodeDomElement) {
|
||||
const isDirectory = Boolean(nodeDomElement.getAttribute('data-tree-is-directory'))
|
||||
if (isDirectory) {
|
||||
const isOpen = this.isExpanded(selectedNodePath)
|
||||
if (isOpen) {
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: false,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
this.selectNode(this.state.selectedNode)
|
||||
return
|
||||
}
|
||||
this.expandDirectoryChanges.next({
|
||||
path: selectedNodePath,
|
||||
expanded: true,
|
||||
node: this.state.selectedNode,
|
||||
})
|
||||
}
|
||||
this.selectNode(this.state.selectedNode)
|
||||
this.setActiveNode(this.state.selectedNode)
|
||||
this.props.history.push(this.state.selectedNode.url)
|
||||
}
|
||||
}
|
||||
|
||||
private selectNode = (node: TreeNode): void => {
|
||||
if (node) {
|
||||
const root = (this.props.scrollRootSelector
|
||||
@ -364,10 +354,10 @@ export class Tree extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private onKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {
|
||||
const handler = this.handlers[event.key]
|
||||
const handler = this.keyHandlers[event.key]
|
||||
if (handler) {
|
||||
event.preventDefault()
|
||||
handler.call(this, event)
|
||||
handler()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1528,10 +1528,10 @@
|
||||
stylelint-config-standard "^18.2.0"
|
||||
stylelint-scss "^3.3.0"
|
||||
|
||||
"@sourcegraph/tsconfig@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/@sourcegraph/tsconfig/-/tsconfig-3.0.0.tgz#dfd8a0072d55a219118f58cfbca71336b58991b2"
|
||||
integrity sha512-/2Q4lAQvHPGkddV7+4FRBgJPIzWw0e364kYq3IkD22H9eHJdA0KHfKXAKmWQjbtVpWSQeNPyVJ1pT5emfef4TQ==
|
||||
"@sourcegraph/tsconfig@^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npmjs.org/@sourcegraph/tsconfig/-/tsconfig-4.0.0.tgz#dd2a406f90760bb789fd89fde4bd0a8d681f2767"
|
||||
integrity sha512-jxrhKbek4yu1HUDpUhqR9hAGFiUgaJ9NIM+c8JEkAnvpW67ab1AUFWb82aSVfZWX1UVqfR84AMr7xP3E8LlL+A==
|
||||
|
||||
"@sourcegraph/tslint-config@^12.3.1":
|
||||
version "12.3.1"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user