2020-05-25 21:30:55 -05:00
|
|
|
import * as ko from "knockout";
|
|
|
|
import * as React from "react";
|
|
|
|
import { ReactAdapter } from "../../Bindings/ReactBindingHandler";
|
2020-06-30 11:47:21 -07:00
|
|
|
import * as ViewModels from "../../Contracts/ViewModels";
|
|
|
|
import {
|
|
|
|
NotebookViewerComponent,
|
|
|
|
NotebookViewerComponentProps
|
|
|
|
} from "../Controls/NotebookViewer/NotebookViewerComponent";
|
|
|
|
import TabsBase from "./TabsBase";
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notebook Viewer tab
|
|
|
|
*/
|
|
|
|
class NotebookViewerComponentAdapter implements ReactAdapter {
|
|
|
|
// parameters: true: show, false: hide
|
|
|
|
public parameters: ko.Computed<boolean>;
|
2020-06-30 11:47:21 -07:00
|
|
|
constructor(private notebookUrl: string) {}
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
public renderComponent(): JSX.Element {
|
2020-06-30 11:47:21 -07:00
|
|
|
const props: NotebookViewerComponentProps = {
|
|
|
|
notebookUrl: this.notebookUrl,
|
|
|
|
backNavigationText: undefined,
|
|
|
|
onBackClick: undefined,
|
|
|
|
onTagClick: undefined
|
|
|
|
};
|
|
|
|
|
|
|
|
return this.parameters() ? <NotebookViewerComponent {...props} /> : <></>;
|
2020-05-25 21:30:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class NotebookViewerTab extends TabsBase implements ViewModels.Tab {
|
|
|
|
private container: ViewModels.Explorer;
|
|
|
|
public notebookUrl: string;
|
|
|
|
|
2020-06-30 11:47:21 -07:00
|
|
|
public notebookViewerComponentAdapter: NotebookViewerComponentAdapter;
|
|
|
|
|
2020-05-25 21:30:55 -05:00
|
|
|
constructor(options: ViewModels.NotebookViewerTabOptions) {
|
|
|
|
super(options);
|
|
|
|
this.container = options.container;
|
|
|
|
this.notebookUrl = options.notebookUrl;
|
2020-06-30 11:47:21 -07:00
|
|
|
|
|
|
|
this.notebookViewerComponentAdapter = new NotebookViewerComponentAdapter(options.notebookUrl);
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
this.notebookViewerComponentAdapter.parameters = ko.computed<boolean>(() => {
|
|
|
|
if (this.isTemplateReady() && this.container.isNotebookEnabled()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getContainer(): ViewModels.Explorer {
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getTabsButtons(): ViewModels.NavbarButtonConfig[] {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
protected buildCommandBarOptions(): void {
|
|
|
|
this.updateNavbarWithTabsButtons();
|
|
|
|
}
|
|
|
|
}
|