Преглед на файлове

work in progress -- broken state

Afshin Darian преди 8 години
родител
ревизия
e1a90e84ba
променени са 4 файла, в които са добавени 25 реда и са изтрити 16 реда
  1. 18 3
      packages/docmanager/src/dialogs.ts
  2. 1 5
      packages/filebrowser/src/buttons.ts
  3. 1 1
      packages/filebrowser/src/dialogs.ts
  4. 5 7
      packages/filebrowser/src/listing.ts

+ 18 - 3
packages/docmanager/src/dialogs.ts

@@ -100,7 +100,7 @@ function renameFile(manager: DocumentManager, container: IFileContainer, oldPath
       };
       return showDialog(options).then(button => {
         if (button.accept) {
-          return model.overwrite(oldPath, newPath);
+          return Private.overwrite(oldPath, newPath);
         }
       });
     } else {
@@ -252,6 +252,7 @@ class CreateFromHandler extends Widget {
    * Open the file and return the document widget.
    */
   private _open(): Promise<Widget> {
+    let oldPath = this._orig.name;
     let file = this.inputNode.value;
     let widgetName = this._widgetName;
     let kernelValue = this.kernelDropdownNode ? this.kernelDropdownNode.value
@@ -260,8 +261,8 @@ class CreateFromHandler extends Widget {
     if (kernelValue !== 'null') {
       kernelId = JSON.parse(kernelValue) as Kernel.IModel;
     }
-    if (file !== this._orig.name) {
-      let promise = renameFile(this._model, this._orig.name, file);
+    if (file !== oldPath) {
+      let promise = renameFile(this._manager, this._container, oldPath, file);
       return promise.then((contents: Contents.IModel) => {
         if (!contents) {
           return null;
@@ -304,6 +305,20 @@ namespace Private {
     return body;
   }
 
+  /**
+   * Overwrite a file.
+   *
+   * @param path - The path to the original file.
+   *
+   * @param newPath - The path to the new file.
+   *
+   * @returns A promise containing the new file contents model.
+   */
+  export
+  function overwrite(path: string, newPath: string): Promise<Contents.IModel> {
+    return Promise.reject('temporary');
+  }
+
   /**
    * Rename a file or directory.
    *

+ 1 - 5
packages/filebrowser/src/buttons.ts

@@ -26,13 +26,9 @@ import {
 } from '@jupyterlab/apputils';
 
 import {
-  DocumentManager
+  createFromDialog, DocumentManager
 } from '@jupyterlab/docmanager';
 
-import {
-  createFromDialog
-} from './dialogs';
-
 import {
   FileBrowserModel
 } from './model';

+ 1 - 1
packages/filebrowser/src/dialogs.ts

@@ -2,7 +2,7 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  Contents, Kernel
+  Kernel
 } from '@jupyterlab/services';
 
 import {

+ 5 - 7
packages/filebrowser/src/listing.ts

@@ -38,13 +38,9 @@ import {
 } from '@jupyterlab/coreutils';
 
 import {
-  DocumentManager
+  DocumentManager, renameFile
 } from '@jupyterlab/docmanager';
 
-import {
-  renameFile
-} from './dialogs';
-
 import {
   FileBrowserModel
 } from './model';
@@ -986,7 +982,7 @@ class DirListing extends Widget {
     let names = event.mimeData.getData(utils.CONTENTS_MIME) as string[];
     for (let name of names) {
       let newPath = path + name;
-      promises.push(renameFile(this._model, name, newPath));
+      promises.push(renameFile(this._manager, this._model, name, newPath));
     }
     Promise.all(promises).catch(error => {
       utils.showErrorMessage('Move Error', error);
@@ -1216,7 +1212,9 @@ class DirListing extends Widget {
       if (this.isDisposed) {
         return;
       }
-      return renameFile(this._model, original, newName).catch(error => {
+
+      const promise = renameFile(this._manager, this._model, original, newName);
+      return promise.catch(error => {
         utils.showErrorMessage('Rename Error', error);
         return original;
       }).then(() => {