Skip to content

Commit

Permalink
Improve UI feedback when removing workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz committed Jun 17, 2018
1 parent c42e255 commit b499164
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
5 changes: 3 additions & 2 deletions src/wirecloud/platform/static/js/wirecloud/Workspace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2017 CoNWeT Lab., Universidad Politécnica de Madrid
* Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.
*
* This file is part of Wirecloud Platform.
*
Expand Down Expand Up @@ -453,9 +454,9 @@
* @returns {Wirecloud.Task}
*/
remove: function remove() {
return Wirecloud.removeWorkspace(this).then(function () {
return Wirecloud.removeWorkspace(this).then(() => {
this.dispatchEvent('remove');
}.bind(this));
});
},

/**
Expand Down
26 changes: 10 additions & 16 deletions src/wirecloud/platform/static/js/wirecloud/ui/WorkspaceView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2012-2017 (c) CoNWeT Lab., Universidad Politécnica de Madrid
* Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.
*
* This file is part of Wirecloud Platform.
*
Expand Down Expand Up @@ -417,22 +418,13 @@
return this.model.rename(name);
};

/**
* Removes the workspace currently loaded by this WorkspaceView from the WireCloud server.
*
* @returns {Wirecloud.Task}
*/
WorkspaceView.prototype.remove = function remove() {
return new Promise(function (resolve, reject) {
var dialog = new Wirecloud.ui.AlertWindowMenu(
utils.interpolate(utils.gettext('Do you really want to remove the "%(name)s" workspace?'), {
name: this.title
})
);
dialog.setHandler(function () {
this.model.remove().then(function () {
resolve();
}, function (reason) {
reject(reason);
});
}.bind(this));
dialog.show();
}.bind(this));
return this.model.remove();
};

WorkspaceView.prototype.publish = function publish(data) {
Expand Down Expand Up @@ -498,7 +490,9 @@

var on_workspace_remove = function on_workspace_remove(workspace) {
// Go to the wirecloud/home dashboard
Wirecloud.changeActiveWorkspace({owner: 'wirecloud', name: 'home'});
Wirecloud.UserInterfaceManager.monitorTask(
Wirecloud.changeActiveWorkspace({owner: 'wirecloud', name: 'home'})
);
};

var on_workspace_unload = function on_workspace_unload(workspace) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2016 CoNWeT Lab., Universidad Politécnica de Madrid
* Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.
*
* This file is part of Wirecloud Platform.
*
Expand Down Expand Up @@ -97,9 +98,16 @@
item.setDisabled(!this.workspace.model.isAllowed('update_preferences'));
items.push(item);

item = new se.MenuItem(utils.gettext("Remove"), function () {
this.remove();
}.bind(this.workspace));
item = new se.MenuItem(utils.gettext("Remove"), () => {
var dialog = new Wirecloud.ui.AlertWindowMenu(
utils.interpolate(utils.gettext('Do you really want to remove the "%(name)s" workspace?'), {
name: this.workspace.title
})
);
dialog.setHandler(() => {
return this.workspace.remove();
}).show();
});
item.addIconClass("fa fa-trash");
item.setDisabled(!this.workspace.model.isAllowed('remove'));
items.push(item);
Expand Down

0 comments on commit b499164

Please sign in to comment.