@jupyterlab/filebrowser
Advanced tools
Comparing version 0.15.4 to 0.16.0
@@ -400,11 +400,8 @@ "use strict"; | ||
var model = this._model; | ||
var promises = []; | ||
var items = this._sortedItems; | ||
var paths = items.map(function (item) { return item.path; }); | ||
algorithm_1.each(this._model.sessions(), function (session) { | ||
var promises = algorithm_1.toArray(this._model.sessions()).filter(function (session) { | ||
var index = algorithm_1.ArrayExt.firstIndexOf(paths, session.path); | ||
if (_this._selection[items[index].name]) { | ||
promises.push(model.manager.services.sessions.shutdown(session.id)); | ||
} | ||
}); | ||
return _this._selection[items[index].name]; | ||
}).map(function (session) { return model.manager.services.sessions.shutdown(session.id); }); | ||
return Promise.all(promises).then(function () { | ||
@@ -533,3 +530,3 @@ return undefined; | ||
if (_this.isDisposed) { | ||
return; | ||
throw new Error('File browser is disposed.'); | ||
} | ||
@@ -539,3 +536,3 @@ var items = _this._sortedItems; | ||
if (index === -1) { | ||
return; | ||
throw new Error('Item does not exist.'); | ||
} | ||
@@ -680,4 +677,3 @@ _this._selectItem(index, false); | ||
while (nodes.length > items.length) { | ||
var node = nodes.pop(); | ||
content.removeChild(node); | ||
content.removeChild(nodes.pop()); | ||
} | ||
@@ -692,3 +688,3 @@ // Add any missing item nodes. | ||
// Remove extra classes from the nodes. | ||
algorithm_1.each(nodes, function (item) { | ||
nodes.forEach(function (item) { | ||
item.classList.remove(SELECTED_CLASS); | ||
@@ -699,30 +695,29 @@ item.classList.remove(RUNNING_CLASS); | ||
// Add extra classes to item nodes based on widget state. | ||
for (var i = 0, n = items.length; i < n; ++i) { | ||
items.forEach(function (item, i) { | ||
var node = nodes[i]; | ||
var item = items[i]; | ||
var ft = this._manager.registry.getFileTypeForModel(item); | ||
var ft = _this._manager.registry.getFileTypeForModel(item); | ||
renderer.updateItemNode(node, item, ft); | ||
if (this._selection[item.name]) { | ||
if (_this._selection[item.name]) { | ||
node.classList.add(SELECTED_CLASS); | ||
if (this._isCut && this._model.path === this._prevPath) { | ||
if (_this._isCut && _this._model.path === _this._prevPath) { | ||
node.classList.add(CUT_CLASS); | ||
} | ||
} | ||
} | ||
}); | ||
// Handle the selectors on the widget node. | ||
var selectedNames = Object.keys(this._selection); | ||
if (selectedNames.length > 1) { | ||
this.addClass(MULTI_SELECTED_CLASS); | ||
} | ||
if (selectedNames.length) { | ||
var selected = Object.keys(this._selection).length; | ||
if (selected) { | ||
this.addClass(SELECTED_CLASS); | ||
if (selected > 1) { | ||
this.addClass(MULTI_SELECTED_CLASS); | ||
} | ||
} | ||
// Handle file session statuses. | ||
var paths = algorithm_1.toArray(algorithm_1.map(items, function (item) { return item.path; })); | ||
var paths = items.map(function (item) { return item.path; }); | ||
algorithm_1.each(this._model.sessions(), function (session) { | ||
var index = algorithm_1.ArrayExt.firstIndexOf(paths, session.path); | ||
var node = nodes[index]; | ||
node.classList.add(RUNNING_CLASS); | ||
var name = session.kernel.name; | ||
var specs = _this._model.specs; | ||
node.classList.add(RUNNING_CLASS); | ||
if (specs) { | ||
@@ -1248,5 +1243,12 @@ name = specs.kernelspecs[name].display_name; | ||
} | ||
if (!docmanager_1.isValidFileName(newName)) { | ||
apputils_1.showErrorMessage('Rename Error', Error("\"" + newName + "\" is not a valid name for a file. " + | ||
"Names must have nonzero length, " + | ||
"and cannot include \"/\", \"\\\", or \":\"")); | ||
_this._inRename = false; | ||
return original; | ||
} | ||
if (_this.isDisposed) { | ||
_this._inRename = false; | ||
return Promise.reject('Disposed'); | ||
throw new Error('File browser is disposed.'); | ||
} | ||
@@ -1266,5 +1268,6 @@ var manager = _this._manager; | ||
_this._inRename = false; | ||
return Promise.reject('Disposed'); | ||
throw new Error('File browser is disposed.'); | ||
} | ||
if (_this._inRename) { | ||
// No need to catch because `newName` will always exit. | ||
_this.selectItemByName(newName); | ||
@@ -1330,10 +1333,10 @@ } | ||
} | ||
var name = args.newValue.name; | ||
if (args.type === 'new' && name) { | ||
this.selectItemByName(name).then(function () { | ||
if (!_this.isDisposed && newValue.type === 'directory') { | ||
_this._doRename(); | ||
} | ||
}); | ||
if (args.type !== 'new' || !name) { | ||
return; | ||
} | ||
this.selectItemByName(name).then(function () { | ||
if (!_this.isDisposed && newValue.type === 'directory') { | ||
_this._doRename(); | ||
} | ||
}).catch(function () { }); | ||
}; | ||
@@ -1349,3 +1352,4 @@ /** | ||
var basename = coreutils_1.PathExt.basename(args); | ||
this.selectItemByName(basename); | ||
this.selectItemByName(basename) | ||
.catch(function () { }); | ||
}; | ||
@@ -1352,0 +1356,0 @@ return DirListing; |
@@ -133,2 +133,6 @@ import { IChangedArgs, IStateDB } from '@jupyterlab/coreutils'; | ||
/** | ||
* Populate the model's sessions collection. | ||
*/ | ||
private _populateSessions(models); | ||
/** | ||
* Start the internal refresh timer. | ||
@@ -135,0 +139,0 @@ */ |
@@ -405,9 +405,3 @@ "use strict"; | ||
FileBrowserModel.prototype._onRunningChanged = function (sender, models) { | ||
var _this = this; | ||
this._sessions.length = 0; | ||
algorithm_1.each(models, function (model) { | ||
if (_this._paths.has(model.path)) { | ||
_this._sessions.push(model); | ||
} | ||
}); | ||
this._populateSessions(models); | ||
this._refreshed.emit(void 0); | ||
@@ -420,12 +414,13 @@ }; | ||
var path = this._model.path; | ||
var value = change.oldValue; | ||
if (value && value.path && coreutils_1.PathExt.dirname(value.path) === path) { | ||
this._fileChanged.emit(change); | ||
var sessions = this.manager.services.sessions; | ||
var oldValue = change.oldValue, newValue = change.newValue; | ||
var value = oldValue && oldValue.path && | ||
coreutils_1.PathExt.dirname(oldValue.path) === path ? oldValue | ||
: newValue && newValue.path && coreutils_1.PathExt.dirname(newValue.path) === path | ||
? newValue : undefined; | ||
// If either the old value or the new value is in the current path, update. | ||
if (value) { | ||
this._scheduleUpdate(); | ||
return; | ||
} | ||
value = change.newValue; | ||
if (value && value.path && coreutils_1.PathExt.dirname(value.path) === path) { | ||
this._populateSessions(sessions.running()); | ||
this._fileChanged.emit(change); | ||
this._scheduleUpdate(); | ||
return; | ||
@@ -435,2 +430,14 @@ } | ||
/** | ||
* Populate the model's sessions collection. | ||
*/ | ||
FileBrowserModel.prototype._populateSessions = function (models) { | ||
var _this = this; | ||
this._sessions.length = 0; | ||
algorithm_1.each(models, function (model) { | ||
if (_this._paths.has(model.path)) { | ||
_this._sessions.push(model); | ||
} | ||
}); | ||
}; | ||
/** | ||
* Start the internal refresh timer. | ||
@@ -445,2 +452,6 @@ */ | ||
} | ||
if (document.hidden) { | ||
// Don't poll when nobody's looking. | ||
return; | ||
} | ||
var date = new Date().getTime(); | ||
@@ -447,0 +458,0 @@ if ((date - _this._lastRefresh) > _this._refreshDuration) { |
{ | ||
"name": "@jupyterlab/filebrowser", | ||
"version": "0.15.4", | ||
"version": "0.16.0", | ||
"description": "JupyterLab - FileBrowser Widget", | ||
@@ -33,7 +33,7 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/apputils": "^0.15.4", | ||
"@jupyterlab/coreutils": "^1.0.6", | ||
"@jupyterlab/docmanager": "^0.15.4", | ||
"@jupyterlab/docregistry": "^0.15.4", | ||
"@jupyterlab/services": "^1.1.4", | ||
"@jupyterlab/apputils": "^0.16.0", | ||
"@jupyterlab/coreutils": "^1.1.0", | ||
"@jupyterlab/docmanager": "^0.16.0", | ||
"@jupyterlab/docregistry": "^0.16.0", | ||
"@jupyterlab/services": "^2.0.0", | ||
"@phosphor/algorithm": "^1.1.2", | ||
@@ -40,0 +40,0 @@ "@phosphor/commands": "^1.4.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
316654
4073
1
+ Added@jupyterlab/apputils@0.16.4(transitive)
+ Added@jupyterlab/codeeditor@0.16.2(transitive)
+ Added@jupyterlab/codemirror@0.16.3(transitive)
+ Added@jupyterlab/docmanager@0.16.3(transitive)
+ Added@jupyterlab/docregistry@0.16.3(transitive)
+ Added@jupyterlab/rendermime@0.16.3(transitive)
+ Added@jupyterlab/services@2.0.3(transitive)
+ Addedansi_up@3.0.0(transitive)
+ Addedcodemirror@5.35.0(transitive)
+ Addedreact@16.2.0(transitive)
+ Addedreact-dom@16.2.1(transitive)
- Removed@jupyterlab/apputils@0.15.5(transitive)
- Removed@jupyterlab/codeeditor@0.15.8(transitive)
- Removed@jupyterlab/codemirror@0.15.4(transitive)
- Removed@jupyterlab/docmanager@0.15.5(transitive)
- Removed@jupyterlab/docregistry@0.15.5(transitive)
- Removed@jupyterlab/rendermime@0.15.4(transitive)
- Removed@jupyterlab/services@1.1.4(transitive)
- Removedansi_up@1.3.0(transitive)
- Removedcodemirror@5.24.2(transitive)
- Removedreact@16.0.0(transitive)
- Removedreact-dom@16.0.1(transitive)
Updated@jupyterlab/apputils@^0.16.0
Updated@jupyterlab/coreutils@^1.1.0
Updated@jupyterlab/services@^2.0.0