diff --git a/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponentAdapter.tsx b/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponentAdapter.tsx deleted file mode 100644 index dde238c1e..000000000 --- a/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponentAdapter.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import ko from "knockout"; -import * as React from "react"; -import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; -import { - GalleryAndNotebookViewerComponentProps, - GalleryAndNotebookViewerComponent, -} from "./GalleryAndNotebookViewerComponent"; - -export class GalleryAndNotebookViewerComponentAdapter implements ReactAdapter { - private key: string; - public parameters: ko.Observable; - - constructor(private props: GalleryAndNotebookViewerComponentProps) { - this.reset(); - this.parameters = ko.observable(Date.now()); - } - - public renderComponent(): JSX.Element { - return ; - } - - public reset(): void { - this.key = `GalleryAndNotebookViewerComponent-${Date.now()}`; - } - - public triggerRender(): void { - window.requestAnimationFrame(() => this.parameters(Date.now())); - } -} diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 041d1b61c..5b3fcebc3 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -73,7 +73,6 @@ import { UploadItemsPane } from "./Panes/UploadItemsPane/UploadItemsPane"; import TableListViewModal from "./Tables/DataTable/TableEntityListViewModel"; import QueryViewModel from "./Tables/QueryBuilder/QueryViewModel"; import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient"; -import type { GalleryTabOptions } from "./Tabs/GalleryTab"; import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab"; import QueryTablesTab from "./Tabs/QueryTablesTab"; import { TabsManager } from "./Tabs/TabsManager"; @@ -1916,33 +1915,35 @@ export default class Explorer { const title = "Gallery"; const hashLocation = "gallery"; const GalleryTab = await (await import(/* webpackChunkName: "GalleryTab" */ "./Tabs/GalleryTab")).default; - - const galleryTabOptions: GalleryTabOptions = { - account: userContext.databaseAccount, - container: this, - junoClient: this.notebookManager?.junoClient, - selectedTab: selectedTab || GalleryTabKind.PublicGallery, - notebookUrl, - galleryItem, - isFavorite, - tabKind: ViewModels.CollectionTabKind.Gallery, - title: title, - tabPath: title, - hashLocation: hashLocation, - onUpdateTabsButtons: this.onUpdateTabsButtons, - isTabsContentExpanded: ko.observable(true), - onLoadStartKey: null, - }; - const galleryTab = this.tabsManager .getTabs(ViewModels.CollectionTabKind.Gallery) .find((tab) => tab.hashLocation() == hashLocation); if (galleryTab instanceof GalleryTab) { this.tabsManager.activateTab(galleryTab); - galleryTab.reset(galleryTabOptions); } else { - this.tabsManager.activateNewTab(new GalleryTab(galleryTabOptions)); + this.tabsManager.activateNewTab( + new GalleryTab( + { + tabKind: ViewModels.CollectionTabKind.Gallery, + title: title, + tabPath: title, + hashLocation: hashLocation, + onUpdateTabsButtons: this.onUpdateTabsButtons, + onLoadStartKey: null, + isTabsContentExpanded: ko.observable(true), + }, + { + account: userContext.databaseAccount, + container: this, + junoClient: this.notebookManager?.junoClient, + selectedTab: selectedTab || GalleryTabKind.PublicGallery, + notebookUrl, + galleryItem, + isFavorite, + } + ) + ); } } diff --git a/src/Explorer/Tabs/GalleryTab.tsx b/src/Explorer/Tabs/GalleryTab.tsx index 496b13cf8..32e809eeb 100644 --- a/src/Explorer/Tabs/GalleryTab.tsx +++ b/src/Explorer/Tabs/GalleryTab.tsx @@ -1,13 +1,14 @@ -import { DatabaseAccount } from "../../Contracts/DataModels"; -import * as ViewModels from "../../Contracts/ViewModels"; -import { IGalleryItem, JunoClient } from "../../Juno/JunoClient"; -import { GalleryAndNotebookViewerComponentProps } from "../Controls/NotebookGallery/GalleryAndNotebookViewerComponent"; -import { GalleryAndNotebookViewerComponentAdapter } from "../Controls/NotebookGallery/GalleryAndNotebookViewerComponentAdapter"; -import { GalleryTab as GalleryViewerTab, SortBy } from "../Controls/NotebookGallery/GalleryViewerComponent"; -import Explorer from "../Explorer"; +import React from "react"; +import type { DatabaseAccount } from "../../Contracts/DataModels"; +import type { TabOptions } from "../../Contracts/ViewModels"; +import type { IGalleryItem, JunoClient } from "../../Juno/JunoClient"; +import { GalleryAndNotebookViewerComponent as GalleryViewer } from "../Controls/NotebookGallery/GalleryAndNotebookViewerComponent"; +import type { GalleryTab as GalleryViewerTab } from "../Controls/NotebookGallery/GalleryViewerComponent"; +import { SortBy } from "../Controls/NotebookGallery/GalleryViewerComponent"; +import type Explorer from "../Explorer"; import TabsBase from "./TabsBase"; -export interface GalleryTabOptions extends ViewModels.TabOptions { +interface Props { account: DatabaseAccount; container: Explorer; junoClient: JunoClient; @@ -17,51 +18,16 @@ export interface GalleryTabOptions extends ViewModels.TabOptions { isFavorite?: boolean; } -/** - * Notebook gallery tab - */ export default class GalleryTab extends TabsBase { - public readonly html = '
'; - private container: Explorer; - private galleryAndNotebookViewerComponentProps: GalleryAndNotebookViewerComponentProps; - public galleryAndNotebookViewerComponentAdapter: GalleryAndNotebookViewerComponentAdapter; - - constructor(options: GalleryTabOptions) { + constructor(options: TabOptions, private props: Props) { super(options); - this.container = options.container; - - this.galleryAndNotebookViewerComponentProps = { - container: options.container, - junoClient: options.junoClient, - notebookUrl: options.notebookUrl, - galleryItem: options.galleryItem, - isFavorite: options.isFavorite, - selectedTab: options.selectedTab, - sortBy: SortBy.MostRecent, - searchText: undefined, - }; - this.galleryAndNotebookViewerComponentAdapter = new GalleryAndNotebookViewerComponentAdapter( - this.galleryAndNotebookViewerComponentProps - ); } - public reset(options: GalleryTabOptions) { - this.container = options.container; - - this.galleryAndNotebookViewerComponentProps.container = options.container; - this.galleryAndNotebookViewerComponentProps.junoClient = options.junoClient; - this.galleryAndNotebookViewerComponentProps.notebookUrl = options.notebookUrl; - this.galleryAndNotebookViewerComponentProps.galleryItem = options.galleryItem; - this.galleryAndNotebookViewerComponentProps.isFavorite = options.isFavorite; - this.galleryAndNotebookViewerComponentProps.selectedTab = options.selectedTab; - this.galleryAndNotebookViewerComponentProps.sortBy = SortBy.MostViewed; - this.galleryAndNotebookViewerComponentProps.searchText = undefined; - - this.galleryAndNotebookViewerComponentAdapter.reset(); - this.galleryAndNotebookViewerComponentAdapter.triggerRender(); + public render() { + return ; } public getContainer(): Explorer { - return this.container; + return this.props.container; } }