Forráskód Böngészése

Add file-operations:delete-file command.

Afshin Darian 8 éve
szülő
commit
512a79f74c

+ 17 - 1
packages/docmanager-extension/src/index.ts

@@ -10,7 +10,7 @@ import {
 } from '@jupyterlab/apputils';
 
 import {
-  DocumentManager, IDocumentManager, showErrorMessage
+  Actions, DocumentManager, IDocumentManager, showErrorMessage
 } from '@jupyterlab/docmanager';
 
 import {
@@ -26,6 +26,9 @@ import {
  * The command IDs used by the document manager plugin.
  */
 namespace CommandIDs {
+  export
+  const deleteFile = 'file-operations:delete-file';
+
   export
   const save = 'file-operations:save';
 
@@ -110,6 +113,19 @@ function addCommands(app: JupyterLab, docManager: IDocumentManager, palette: ICo
     execute: () => { app.shell.closeAll(); }
   });
 
+  commands.addCommand(CommandIDs.deleteFile, {
+    execute: args => {
+      const path = args['path'] as string;
+      const basePath = (args['basePath'] as string) || '';
+
+      if (!path) {
+        const command = CommandIDs.deleteFile;
+        throw new Error(`A non-empty path is required for ${command}.`);
+      }
+      return Actions.deleteFile(docManager.services, path, basePath);
+    }
+  });
+
   commands.addCommand(CommandIDs.open, {
     execute: args => {
       let path = args['path'] as string;

+ 1 - 1
packages/docmanager/src/actions.ts

@@ -45,7 +45,7 @@ namespace Actions {
    *
    * @param manager - The service manager used to delete.
    *
-   * @param: path - The path to the file to be deleted.
+   * @param path - The path to the file to be deleted.
    *
    * @param basePath - The base path to resolve against, defaults to ''.
    *