diff --git a/.eslintignore b/.eslintignore index a082fb74f..3346de4bf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -97,7 +97,6 @@ src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.ts src/Explorer/Menus/ContextMenu.ts src/Explorer/MostRecentActivity/MostRecentActivity.ts -src/Explorer/Notebook/FileSystemUtil.ts src/Explorer/Notebook/NotebookClientV2.ts src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts src/Explorer/Notebook/NotebookComponent/__mocks__/rx-jupyter.ts diff --git a/src/Explorer/Controls/NotebookGallery/Cards/GalleryCardComponent.tsx b/src/Explorer/Controls/NotebookGallery/Cards/GalleryCardComponent.tsx index 54cac8db5..2f81cbb2b 100644 --- a/src/Explorer/Controls/NotebookGallery/Cards/GalleryCardComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/Cards/GalleryCardComponent.tsx @@ -18,7 +18,7 @@ import { } from "office-ui-fabric-react"; import * as React from "react"; import { IGalleryItem } from "../../../../Juno/JunoClient"; -import { FileSystemUtil } from "../../../Notebook/FileSystemUtil"; +import * as FileSystemUtil from "../../../Notebook/FileSystemUtil"; import CosmosDBLogo from "../../../../../images/CosmosDB-logo.svg"; export interface GalleryCardComponentProps { diff --git a/src/Explorer/Controls/NotebookViewer/NotebookMetadataComponent.tsx b/src/Explorer/Controls/NotebookViewer/NotebookMetadataComponent.tsx index 19962c554..ecdd12034 100644 --- a/src/Explorer/Controls/NotebookViewer/NotebookMetadataComponent.tsx +++ b/src/Explorer/Controls/NotebookViewer/NotebookMetadataComponent.tsx @@ -14,7 +14,7 @@ import { } from "office-ui-fabric-react"; import * as React from "react"; import { IGalleryItem } from "../../../Juno/JunoClient"; -import { FileSystemUtil } from "../../Notebook/FileSystemUtil"; +import * as FileSystemUtil from "../../Notebook/FileSystemUtil"; import "./NotebookViewerComponent.less"; import CosmosDBLogo from "../../../../images/CosmosDB-logo.svg"; import { InfoComponent } from "../NotebookGallery/InfoComponent/InfoComponent"; diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 9c775b74f..758c3f604 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -44,7 +44,7 @@ import { DialogProps, TextFieldProps } from "./Controls/Dialog"; import { GalleryTab } from "./Controls/NotebookGallery/GalleryViewerComponent"; import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter"; import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent"; -import { FileSystemUtil } from "./Notebook/FileSystemUtil"; +import * as FileSystemUtil from "./Notebook/FileSystemUtil"; import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem"; import { NotebookUtil } from "./Notebook/NotebookUtil"; import AddCollectionPane from "./Panes/AddCollectionPane"; diff --git a/src/Explorer/Notebook/FileSystemUtil.ts b/src/Explorer/Notebook/FileSystemUtil.ts index ec0899d41..41bb06b8a 100644 --- a/src/Explorer/Notebook/FileSystemUtil.ts +++ b/src/Explorer/Notebook/FileSystemUtil.ts @@ -1,37 +1,33 @@ -// Utilities for file system - -export class FileSystemUtil { - /** - * file list returns path starting with ./blah - * rename returns simply blah. - * Both are the same. This method only handles these two cases and no other complicated paths that may contain .. - * ./ inside the path. - * TODO: this should go away when not using jupyter for file operations and use normalized paths. - * @param path1 - * @param path2 - */ - public static isPathEqual(path1: string, path2: string): boolean { - const normalize = (path: string): string => { - const dotSlash = "./"; - if (path.indexOf(dotSlash) === 0) { - path = path.substring(dotSlash.length); - } - return path; - }; - - return normalize(path1) === normalize(path2); - } - - /** - * Remove extension - * @param path - * @param extension Without the ".". e.g. "ipynb" (and not ".ipynb") - */ - public static stripExtension(path: string, extension: string): string { - const splitted = path.split("."); - if (splitted[splitted.length - 1] === extension) { - splitted.pop(); +/** + * file list returns path starting with ./blah + * rename returns simply blah. + * Both are the same. This method only handles these two cases and no other complicated paths that may contain .. + * ./ inside the path. + * TODO: this should go away when not using jupyter for file operations and use normalized paths. + * @param path1 + * @param path2 + */ +export function isPathEqual(path1: string, path2: string): boolean { + const normalize = (path: string): string => { + const dotSlash = "./"; + if (path.indexOf(dotSlash) === 0) { + path = path.substring(dotSlash.length); } - return splitted.join("."); - } + return path; + }; + + return normalize(path1) === normalize(path2); +} + +/** + * Remove extension + * @param path + * @param extension Without the ".". e.g. "ipynb" (and not ".ipynb") + */ +export function stripExtension(path: string, extension: string): string { + const splitted = path.split("."); + if (splitted[splitted.length - 1] === extension) { + splitted.pop(); + } + return splitted.join("."); } diff --git a/src/Explorer/Notebook/NotebookComponent/epics.ts b/src/Explorer/Notebook/NotebookComponent/epics.ts index 2914c6d8e..544f80bf4 100644 --- a/src/Explorer/Notebook/NotebookComponent/epics.ts +++ b/src/Explorer/Notebook/NotebookComponent/epics.ts @@ -44,7 +44,7 @@ import { CdbAppState } from "./types"; import { decryptJWTToken } from "../../../Utils/AuthorizationUtils"; import * as TextFile from "./contents/file/text-file"; import { NotebookUtil } from "../NotebookUtil"; -import { FileSystemUtil } from "../FileSystemUtil"; +import * as FileSystemUtil from "../FileSystemUtil"; import * as cdbActions from "../NotebookComponent/actions"; import { Areas } from "../../../Common/Constants"; diff --git a/src/Explorer/Notebook/NotebookContentClient.ts b/src/Explorer/Notebook/NotebookContentClient.ts index 44ab852ee..6679a7e1d 100644 --- a/src/Explorer/Notebook/NotebookContentClient.ts +++ b/src/Explorer/Notebook/NotebookContentClient.ts @@ -1,12 +1,11 @@ -import * as DataModels from "../../Contracts/DataModels"; -import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem"; -import * as StringUtils from "../../Utils/StringUtils"; -import { FileSystemUtil } from "./FileSystemUtil"; -import { NotebookUtil } from "./NotebookUtil"; - -import { ServerConfig, IContent, IContentProvider, FileType, IEmptyContent } from "@nteract/core"; -import { AjaxResponse } from "rxjs/ajax"; import { stringifyNotebook } from "@nteract/commutable"; +import { FileType, IContent, IContentProvider, IEmptyContent, ServerConfig } from "@nteract/core"; +import { AjaxResponse } from "rxjs/ajax"; +import * as DataModels from "../../Contracts/DataModels"; +import * as StringUtils from "../../Utils/StringUtils"; +import * as FileSystemUtil from "./FileSystemUtil"; +import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem"; +import { NotebookUtil } from "./NotebookUtil"; export class NotebookContentClient { constructor( diff --git a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx index 704257fc5..e6028b29e 100644 --- a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx @@ -14,7 +14,7 @@ import { handleError, getErrorMessage, getErrorStack } from "../../Common/ErrorH import { GalleryTab } from "../Controls/NotebookGallery/GalleryViewerComponent"; import { traceFailure, traceStart, traceSuccess } from "../../Shared/Telemetry/TelemetryProcessor"; import { Action } from "../../Shared/Telemetry/TelemetryConstants"; -import { FileSystemUtil } from "../Notebook/FileSystemUtil"; +import * as FileSystemUtil from "../Notebook/FileSystemUtil"; export class PublishNotebookPaneAdapter implements ReactAdapter { parameters: ko.Observable; diff --git a/src/Explorer/Panes/PublishNotebookPaneComponent.tsx b/src/Explorer/Panes/PublishNotebookPaneComponent.tsx index 559bf3b09..1075ae5c2 100644 --- a/src/Explorer/Panes/PublishNotebookPaneComponent.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneComponent.tsx @@ -1,7 +1,7 @@ import { ITextFieldProps, Stack, Text, TextField, Dropdown, IDropdownProps } from "office-ui-fabric-react"; import * as React from "react"; import { GalleryCardComponent } from "../Controls/NotebookGallery/Cards/GalleryCardComponent"; -import { FileSystemUtil } from "../Notebook/FileSystemUtil"; +import * as FileSystemUtil from "../Notebook/FileSystemUtil"; import "./PublishNotebookPaneComponent.less"; import Html2Canvas from "html2canvas"; import { ImmutableNotebook } from "@nteract/commutable/src"; diff --git a/src/NotebookViewer/NotebookViewer.tsx b/src/NotebookViewer/NotebookViewer.tsx index 6af59d062..815e38c75 100644 --- a/src/NotebookViewer/NotebookViewer.tsx +++ b/src/NotebookViewer/NotebookViewer.tsx @@ -10,7 +10,7 @@ import { import { IGalleryItem, JunoClient } from "../Juno/JunoClient"; import * as GalleryUtils from "../Utils/GalleryUtils"; import { GalleryHeaderComponent } from "../Explorer/Controls/Header/GalleryHeaderComponent"; -import { FileSystemUtil } from "../Explorer/Notebook/FileSystemUtil"; +import * as FileSystemUtil from "../Explorer/Notebook/FileSystemUtil"; import { GalleryTab } from "../Explorer/Controls/NotebookGallery/GalleryViewerComponent"; const onInit = async () => {