|
@@ -10,7 +10,7 @@ import {
|
|
|
} from '@jupyterlab/apputils';
|
|
|
|
|
|
import {
|
|
|
- DocumentManager, IDocumentManager
|
|
|
+ DocumentManager, IDocumentManager, showErrorMessage
|
|
|
} from '@jupyterlab/docmanager';
|
|
|
|
|
|
import {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
} from '@jupyterlab/docregistry';
|
|
|
|
|
|
import {
|
|
|
- IServiceManager
|
|
|
+ Contents, IServiceManager
|
|
|
} from '@jupyterlab/services';
|
|
|
|
|
|
|
|
@@ -121,12 +121,20 @@ function addCommands(app: JupyterLab, docManager: IDocumentManager, palette: ICo
|
|
|
|
|
|
commands.addCommand(CommandIDs.newUntitled, {
|
|
|
execute: args => {
|
|
|
+ const errorMessage = args.error as string || 'Error';
|
|
|
+ let options: Partial<Contents.ICreateOptions> = {
|
|
|
+ type: args.type as Contents.ContentType,
|
|
|
+ path: args.path as string
|
|
|
+ };
|
|
|
+
|
|
|
if (args.type === 'file') {
|
|
|
- args.ext = args.ext || '.txt';
|
|
|
+ options.ext = args.ext as string || '.txt';
|
|
|
}
|
|
|
|
|
|
- return docManager.services.contents.newUntitled(args);
|
|
|
- }
|
|
|
+ return docManager.services.contents.newUntitled(options)
|
|
|
+ .catch(error => showErrorMessage(errorMessage, error));
|
|
|
+ },
|
|
|
+ label: args => args.label as string || 'New Folder'
|
|
|
});
|
|
|
|
|
|
commands.addCommand(CommandIDs.restoreCheckpoint, {
|