Remove route handlers (#909)

* Remove tab handlers

* Fix tests
This commit is contained in:
victor-meng
2021-06-23 21:54:37 -07:00
committed by GitHub
parent 6b35ab03f2
commit 59655eed5f
20 changed files with 5 additions and 630 deletions

View File

@@ -18,7 +18,6 @@ import * as ViewModels from "../Contracts/ViewModels";
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
import { useSidePanel } from "../hooks/useSidePanel";
import { IGalleryItem, JunoClient } from "../Juno/JunoClient";
import { RouteHandler } from "../RouteHandlers/RouteHandler";
import { ExplorerSettings } from "../Shared/ExplorerSettings";
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
@@ -138,7 +137,6 @@ export default class Explorer {
userContext.authType === AuthType.ResourceToken
? this.refreshDatabaseForResourceToken()
: this.refreshAllDatabases(true);
RouteHandler.getInstance().initHandler();
await this._refreshNotebooksEnabledStateForAccount();
this.isNotebookEnabled(
userContext.authType !== AuthType.ResourceToken &&
@@ -899,7 +897,6 @@ export default class Explorer {
tabPath: notebookContentItem.path,
collection: null,
masterKey: userContext.masterKey || "",
hashLocation: "notebooks",
isTabsContentExpanded: ko.observable(true),
onLoadStartKey: null,
container: this,
@@ -1199,30 +1196,27 @@ export default class Explorer {
public openNotebookTerminal(kind: ViewModels.TerminalKind) {
let title: string;
let hashLocation: string;
switch (kind) {
case ViewModels.TerminalKind.Default:
title = "Terminal";
hashLocation = "terminal";
break;
case ViewModels.TerminalKind.Mongo:
title = "Mongo Shell";
hashLocation = "mongo-shell";
break;
case ViewModels.TerminalKind.Cassandra:
title = "Cassandra Shell";
hashLocation = "cassandra-shell";
break;
default:
throw new Error("Terminal kind: ${kind} not supported");
}
const terminalTabs: TerminalTab[] = this.tabsManager.getTabs(ViewModels.CollectionTabKind.Terminal, (tab) =>
tab.hashLocation().startsWith(hashLocation)
const terminalTabs: TerminalTab[] = this.tabsManager.getTabs(
ViewModels.CollectionTabKind.Terminal,
(tab) => tab.tabTitle() === title
) as TerminalTab[];
let index = 1;
@@ -1237,7 +1231,6 @@ export default class Explorer {
title: `${title} ${index}`,
tabPath: `${title} ${index}`,
collection: null,
hashLocation: `${hashLocation} ${index}`,
isTabsContentExpanded: ko.observable(true),
onLoadStartKey: null,
container: this,
@@ -1255,11 +1248,10 @@ export default class Explorer {
isFavorite?: boolean
) {
const title = "Gallery";
const hashLocation = "gallery";
const GalleryTab = await (await import(/* webpackChunkName: "GalleryTab" */ "./Tabs/GalleryTab")).default;
const galleryTab = this.tabsManager
.getTabs(ViewModels.CollectionTabKind.Gallery)
.find((tab) => tab.hashLocation() == hashLocation);
.find((tab) => tab.tabTitle() == title);
if (galleryTab instanceof GalleryTab) {
this.tabsManager.activateTab(galleryTab);
@@ -1268,9 +1260,8 @@ export default class Explorer {
new GalleryTab(
{
tabKind: ViewModels.CollectionTabKind.Gallery,
title: title,
title,
tabPath: title,
hashLocation: hashLocation,
onLoadStartKey: null,
isTabsContentExpanded: ko.observable(true),
},