From b1ad80480e6b3a1ad68f6ba25e58d2dd054fd9f2 Mon Sep 17 00:00:00 2001 From: Chris-MS-896 <64865559+Chris-MS-896@users.noreply.github.com> Date: Tue, 12 Jan 2021 12:55:21 -0600 Subject: [PATCH] Add two files of notebook component in Matser (#363) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * “minor changes” --- .../NotebookComponent/__mocks__/rx-jupyter.ts | 3 +-- src/Explorer/Notebook/NotebookContentClient.ts | 13 ++++++++----- tsconfig.strict.json | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts b/src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts index 564527eec..1b02ef08e 100644 --- a/src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts +++ b/src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts @@ -1,6 +1,5 @@ import { Observable, of } from "rxjs"; import { AjaxRequest, AjaxResponse } from "rxjs/ajax"; -import { ServerConfig } from "@nteract/types"; let fakeAjaxResponse: AjaxResponse = { originalEvent: (undefined), @@ -12,7 +11,7 @@ let fakeAjaxResponse: AjaxResponse = { responseType: "json" }; export const sessions = { - create: (serverConfig: ServerConfig, body: object): Observable => of(fakeAjaxResponse), + create: (serverConfig: unknown, body: object): Observable => of(fakeAjaxResponse), __setResponse: (response: AjaxResponse) => { fakeAjaxResponse = response; }, diff --git a/src/Explorer/Notebook/NotebookContentClient.ts b/src/Explorer/Notebook/NotebookContentClient.ts index d745c7e4f..60358d306 100644 --- a/src/Explorer/Notebook/NotebookContentClient.ts +++ b/src/Explorer/Notebook/NotebookContentClient.ts @@ -11,7 +11,7 @@ import { stringifyNotebook } from "@nteract/commutable"; export class NotebookContentClient { constructor( private notebookServerInfo: ko.Observable, - private notebookBasePath: ko.Observable, + public notebookBasePath: ko.Observable, private contentProvider: IContentProvider ) {} @@ -117,8 +117,11 @@ export class NotebookContentClient { private async checkIfFilepathExists(filepath: string): Promise { const parentDirPath = NotebookUtil.getParentPath(filepath); - const items = await this.fetchNotebookFiles(parentDirPath); - return items.some(value => FileSystemUtil.isPathEqual(value.path, filepath)); + if (parentDirPath) { + const items = await this.fetchNotebookFiles(parentDirPath); + return items.some(value => FileSystemUtil.isPathEqual(value.path, filepath)); + } + return false; } /** @@ -189,7 +192,7 @@ export class NotebookContentClient { const dir = xhr.response; const item = NotebookUtil.createNotebookContentItem(dir.name, dir.path, dir.type); item.parent = parent; - parent.children.push(item); + parent.children!.push(item); return item; }); } @@ -225,7 +228,7 @@ export class NotebookContentClient { * Convert rx-jupyter type to our type * @param type */ - private static getType(type: FileType): NotebookContentItemType { + public static getType(type: FileType): NotebookContentItemType { switch (type) { case "directory": return NotebookContentItemType.Directory; diff --git a/tsconfig.strict.json b/tsconfig.strict.json index e9fca85d6..c7b506fa4 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -68,6 +68,8 @@ "./src/Explorer/Tables/DataTable/CacheBase.ts", "./src/Explorer/Tables/Entities.ts", "./src/Explorer/Tabs/TabComponents.ts", + "./src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts", + "./src/Explorer/Notebook/NotebookContentClient.ts", "./src/GitHub/GitHubConnector.ts", "./src/Index.ts", "./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts",