mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-08 03:57:31 +00:00
Notebooks Gallery (#59)
* Initial commit * Address PR comments * Move notebook related stuff to NotebookManager and dynamically load it * Add New gallery callout and other UI tweaks * Update test snapshot
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import TabsBase from "./TabsBase";
|
||||
import * as React from "react";
|
||||
import { ReactAdapter } from "../../Bindings/ReactBindingHandler";
|
||||
import { NotebookViewerComponent } from "../Controls/NotebookViewer/NotebookViewerComponent";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import {
|
||||
NotebookViewerComponent,
|
||||
NotebookViewerComponentProps
|
||||
} from "../Controls/NotebookViewer/NotebookViewerComponent";
|
||||
import TabsBase from "./TabsBase";
|
||||
|
||||
/**
|
||||
* Notebook Viewer tab
|
||||
@@ -12,48 +14,32 @@ import { NotebookViewerComponent } from "../Controls/NotebookViewer/NotebookView
|
||||
class NotebookViewerComponentAdapter implements ReactAdapter {
|
||||
// parameters: true: show, false: hide
|
||||
public parameters: ko.Computed<boolean>;
|
||||
constructor(
|
||||
private notebookUrl: string,
|
||||
private notebookName: string,
|
||||
private container: ViewModels.Explorer,
|
||||
private notebookMetadata: DataModels.NotebookMetadata,
|
||||
private onNotebookMetadataChange: (newNotebookMetadata: DataModels.NotebookMetadata) => Promise<void>,
|
||||
private isLikedNotebook: boolean
|
||||
) {}
|
||||
constructor(private notebookUrl: string) {}
|
||||
|
||||
public renderComponent(): JSX.Element {
|
||||
return this.parameters() ? (
|
||||
<NotebookViewerComponent
|
||||
notebookUrl={this.notebookUrl}
|
||||
notebookMetadata={this.notebookMetadata}
|
||||
notebookName={this.notebookName}
|
||||
container={this.container}
|
||||
onNotebookMetadataChange={this.onNotebookMetadataChange}
|
||||
isLikedNotebook={this.isLikedNotebook}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
);
|
||||
const props: NotebookViewerComponentProps = {
|
||||
notebookUrl: this.notebookUrl,
|
||||
backNavigationText: undefined,
|
||||
onBackClick: undefined,
|
||||
onTagClick: undefined
|
||||
};
|
||||
|
||||
return this.parameters() ? <NotebookViewerComponent {...props} /> : <></>;
|
||||
}
|
||||
}
|
||||
|
||||
export default class NotebookViewerTab extends TabsBase implements ViewModels.Tab {
|
||||
private container: ViewModels.Explorer;
|
||||
public notebookViewerComponentAdapter: NotebookViewerComponentAdapter;
|
||||
public notebookUrl: string;
|
||||
|
||||
public notebookViewerComponentAdapter: NotebookViewerComponentAdapter;
|
||||
|
||||
constructor(options: ViewModels.NotebookViewerTabOptions) {
|
||||
super(options);
|
||||
this.container = options.container;
|
||||
this.notebookUrl = options.notebookUrl;
|
||||
this.notebookViewerComponentAdapter = new NotebookViewerComponentAdapter(
|
||||
options.notebookUrl,
|
||||
options.notebookName,
|
||||
options.container,
|
||||
options.notebookMetadata,
|
||||
options.onNotebookMetadataChange,
|
||||
options.isLikedNotebook
|
||||
);
|
||||
|
||||
this.notebookViewerComponentAdapter = new NotebookViewerComponentAdapter(options.notebookUrl);
|
||||
|
||||
this.notebookViewerComponentAdapter.parameters = ko.computed<boolean>(() => {
|
||||
if (this.isTemplateReady() && this.container.isNotebookEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user