From 78eafe1aec9d312ee53c554936527ab78752b178 Mon Sep 17 00:00:00 2001 From: Jordi Bunster Date: Thu, 6 May 2021 17:20:25 -0700 Subject: [PATCH] Remove NotebookViewerTab (#749) [Preview this branch](https://cosmos-explorer-preview.azurewebsites.net/pull/749) --- src/Explorer/Explorer.tsx | 36 +----------- src/Explorer/Tabs/NotebookViewerTab.tsx | 73 ------------------------- 2 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 src/Explorer/Tabs/NotebookViewerTab.tsx diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 47af1ae40..223ab657c 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -1,6 +1,5 @@ -import * as ko from "knockout"; import { IChoiceGroupProps } from "@fluentui/react"; -import * as path from "path"; +import * as ko from "knockout"; import Q from "q"; import React from "react"; import _ from "underscore"; @@ -1843,39 +1842,6 @@ export default class Explorer { } } - public async openNotebookViewer(notebookUrl: string) { - const title = path.basename(notebookUrl); - const hashLocation = notebookUrl; - const NotebookViewerTab = await ( - await import(/* webpackChunkName: "NotebookViewerTab" */ "./Tabs/NotebookViewerTab") - ).default; - - const notebookViewerTab = this.tabsManager.getTabs(ViewModels.CollectionTabKind.NotebookV2).find((tab) => { - return tab.hashLocation() == hashLocation && tab instanceof NotebookViewerTab && tab.notebookUrl === notebookUrl; - }); - - if (notebookViewerTab) { - this.tabsManager.activateNewTab(notebookViewerTab); - } else { - const notebookViewerTab = new NotebookViewerTab({ - account: userContext.databaseAccount, - tabKind: ViewModels.CollectionTabKind.NotebookViewer, - node: null, - title: title, - tabPath: title, - collection: null, - hashLocation: hashLocation, - isTabsContentExpanded: ko.observable(true), - onLoadStartKey: null, - onUpdateTabsButtons: this.onUpdateTabsButtons, - container: this, - notebookUrl, - }); - - this.tabsManager.activateNewTab(notebookViewerTab); - } - } - public onNewCollectionClicked(databaseId?: string): void { if (userContext.apiType === "Cassandra") { this.cassandraAddCollectionPane.open(); diff --git a/src/Explorer/Tabs/NotebookViewerTab.tsx b/src/Explorer/Tabs/NotebookViewerTab.tsx deleted file mode 100644 index 677ca21a8..000000000 --- a/src/Explorer/Tabs/NotebookViewerTab.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import * as ko from "knockout"; -import * as React from "react"; -import { ReactAdapter } from "../../Bindings/ReactBindingHandler"; -import { DatabaseAccount } from "../../Contracts/DataModels"; -import * as ViewModels from "../../Contracts/ViewModels"; -import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; -import { - NotebookViewerComponent, - NotebookViewerComponentProps, -} from "../Controls/NotebookViewer/NotebookViewerComponent"; -import Explorer from "../Explorer"; -import TabsBase from "./TabsBase"; - -interface NotebookViewerTabOptions extends ViewModels.TabOptions { - account: DatabaseAccount; - container: Explorer; - notebookUrl: string; -} - -/** - * Notebook Viewer tab - */ -class NotebookViewerComponentAdapter implements ReactAdapter { - // parameters: true: show, false: hide - public parameters: ko.Computed; - constructor(private notebookUrl: string) {} - - public renderComponent(): JSX.Element { - const props: NotebookViewerComponentProps = { - notebookUrl: this.notebookUrl, - backNavigationText: undefined, - onBackClick: undefined, - onTagClick: undefined, - }; - - return this.parameters() ? : <>; - } -} - -export default class NotebookViewerTab extends TabsBase { - public readonly html = '
'; - private container: Explorer; - public notebookUrl: string; - - public notebookViewerComponentAdapter: NotebookViewerComponentAdapter; - - constructor(options: NotebookViewerTabOptions) { - super(options); - this.container = options.container; - this.notebookUrl = options.notebookUrl; - - this.notebookViewerComponentAdapter = new NotebookViewerComponentAdapter(options.notebookUrl); - - this.notebookViewerComponentAdapter.parameters = ko.computed(() => { - if (this.isTemplateReady() && this.container.isNotebookEnabled()) { - return true; - } - return false; - }); - } - - public getContainer(): Explorer { - return this.container; - } - - protected getTabsButtons(): CommandButtonComponentProps[] { - return []; - } - - protected buildCommandBarOptions(): void { - this.updateNavbarWithTabsButtons(); - } -}