Add two files of notebook component in Matser (#363)

* “minor changes”
This commit is contained in:
Chris-MS-896 2021-01-12 12:55:21 -06:00 committed by GitHub
parent 9247a6c4a2
commit b1ad80480e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,5 @@
import { Observable, of } from "rxjs"; import { Observable, of } from "rxjs";
import { AjaxRequest, AjaxResponse } from "rxjs/ajax"; import { AjaxRequest, AjaxResponse } from "rxjs/ajax";
import { ServerConfig } from "@nteract/types";
let fakeAjaxResponse: AjaxResponse = { let fakeAjaxResponse: AjaxResponse = {
originalEvent: <Event>(<unknown>undefined), originalEvent: <Event>(<unknown>undefined),
@ -12,7 +11,7 @@ let fakeAjaxResponse: AjaxResponse = {
responseType: "json" responseType: "json"
}; };
export const sessions = { export const sessions = {
create: (serverConfig: ServerConfig, body: object): Observable<AjaxResponse> => of(fakeAjaxResponse), create: (serverConfig: unknown, body: object): Observable<AjaxResponse> => of(fakeAjaxResponse),
__setResponse: (response: AjaxResponse) => { __setResponse: (response: AjaxResponse) => {
fakeAjaxResponse = response; fakeAjaxResponse = response;
}, },

View File

@ -11,7 +11,7 @@ import { stringifyNotebook } from "@nteract/commutable";
export class NotebookContentClient { export class NotebookContentClient {
constructor( constructor(
private notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>, private notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>,
private notebookBasePath: ko.Observable<string>, public notebookBasePath: ko.Observable<string>,
private contentProvider: IContentProvider private contentProvider: IContentProvider
) {} ) {}
@ -117,9 +117,12 @@ export class NotebookContentClient {
private async checkIfFilepathExists(filepath: string): Promise<boolean> { private async checkIfFilepathExists(filepath: string): Promise<boolean> {
const parentDirPath = NotebookUtil.getParentPath(filepath); const parentDirPath = NotebookUtil.getParentPath(filepath);
if (parentDirPath) {
const items = await this.fetchNotebookFiles(parentDirPath); const items = await this.fetchNotebookFiles(parentDirPath);
return items.some(value => FileSystemUtil.isPathEqual(value.path, filepath)); return items.some(value => FileSystemUtil.isPathEqual(value.path, filepath));
} }
return false;
}
/** /**
* *
@ -189,7 +192,7 @@ export class NotebookContentClient {
const dir = xhr.response; const dir = xhr.response;
const item = NotebookUtil.createNotebookContentItem(dir.name, dir.path, dir.type); const item = NotebookUtil.createNotebookContentItem(dir.name, dir.path, dir.type);
item.parent = parent; item.parent = parent;
parent.children.push(item); parent.children!.push(item);
return item; return item;
}); });
} }
@ -225,7 +228,7 @@ export class NotebookContentClient {
* Convert rx-jupyter type to our type * Convert rx-jupyter type to our type
* @param type * @param type
*/ */
private static getType(type: FileType): NotebookContentItemType { public static getType(type: FileType): NotebookContentItemType {
switch (type) { switch (type) {
case "directory": case "directory":
return NotebookContentItemType.Directory; return NotebookContentItemType.Directory;

View File

@ -68,6 +68,8 @@
"./src/Explorer/Tables/DataTable/CacheBase.ts", "./src/Explorer/Tables/DataTable/CacheBase.ts",
"./src/Explorer/Tables/Entities.ts", "./src/Explorer/Tables/Entities.ts",
"./src/Explorer/Tabs/TabComponents.ts", "./src/Explorer/Tabs/TabComponents.ts",
"./src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts",
"./src/Explorer/Notebook/NotebookContentClient.ts",
"./src/GitHub/GitHubConnector.ts", "./src/GitHub/GitHubConnector.ts",
"./src/Index.ts", "./src/Index.ts",
"./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts", "./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts",