Added support for notebook viewer link injection (#124)

* Added support for notebook viewer link injection

* updated tests
This commit is contained in:
Srinath Narayanan
2020-08-10 01:53:51 -07:00
committed by GitHub
parent 455a6ac81b
commit 95f1efc03f
15 changed files with 101 additions and 33 deletions

View File

@@ -26,6 +26,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
private imageSrc: string;
private notebookObject: ImmutableNotebook;
private parentDomElement: HTMLElement;
private isLinkInjectionEnabled: boolean;
constructor(private container: Explorer, private junoClient: JunoClient) {
this.parameters = ko.observable(Date.now());
@@ -62,19 +63,21 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
name: string,
author: string,
notebookContent: string | ImmutableNotebook,
parentDomElement: HTMLElement
parentDomElement: HTMLElement,
isLinkInjectionEnabled: boolean
): void {
this.name = name;
this.author = author;
if (typeof notebookContent === "string") {
this.content = notebookContent as string;
} else {
this.content = JSON.stringify(toJS(notebookContent as ImmutableNotebook));
this.content = JSON.stringify(toJS(notebookContent));
this.notebookObject = notebookContent;
}
this.parentDomElement = parentDomElement;
this.isOpened = true;
this.isLinkInjectionEnabled = isLinkInjectionEnabled;
this.triggerRender();
}
@@ -102,7 +105,8 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
this.tags?.split(","),
this.author,
this.imageSrc,
this.content
this.content,
this.isLinkInjectionEnabled
);
if (!response.data) {
throw new Error(`Received HTTP ${response.status} when publishing ${name} to gallery`);

View File

@@ -276,7 +276,8 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
isSample: false,
downloads: 0,
favorites: 0,
views: 0
views: 0,
newCellId: undefined
}}
isFavorite={false}
showDownload={true}

View File

@@ -93,6 +93,7 @@ exports[`PublishNotebookPaneComponent renders 1`] = `
"id": undefined,
"isSample": false,
"name": "SampleNotebook.ipynb",
"newCellId": undefined,
"tags": Array [
"",
],