Skip to content

🎨 [Frontend] Enhance: syncing tree #6687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 8, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ qx.Class.define("osparc.dashboard.MoveResourceTo", {
const item = selection.getItem(0);
this.__selectedWorkspaceId = item.getWorkspaceId();
this.__selectedFolderId = item.getFolderId();
moveButton.setEnabled(this.__currentWorkspaceId !== this.__selectedWorkspaceId || this.__currentFolderId !== this.__selectedFolderId);
if (this.__selectedWorkspaceId === -1) {
// "Shared Workspaces"
moveButton.setEnabled(false);
} else {
// In principle, valid location
// disable if it's the current location
moveButton.setEnabled(this.__currentWorkspaceId !== this.__selectedWorkspaceId || this.__currentFolderId !== this.__selectedFolderId);
}
}
}, this);
moveButton.addListener("execute", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {

osparc.store.Workspaces.getInstance().addListener("workspaceRemoved", e => {
const workspace = e.getData();
this.__removeWorkspace(workspace);
this.__workspaceRemoved(workspace);
}, this);

this.getSelection().addListener("change", () => {
Expand Down Expand Up @@ -227,11 +227,21 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
this.__populateFolder(workspaceModel, workspace.getWorkspaceId(), null);
},

__removeWorkspace: function(workspace) {
__workspaceRemoved: function(workspace) {
// remove it from the tree
const sharedWorkspaceModel = this.__getModel(-1, null);
const idx = sharedWorkspaceModel.getChildren().toArray().findIndex(w => workspace.getWorkspaceId() === w.getWorkspaceId());
if (idx > -1) {
sharedWorkspaceModel.getChildren().toArray().splice(idx, 1);
sharedWorkspaceModel.getChildren().removeAt(idx);
}

// remove it from the cached models
const modelFound = this.__getModel(workspace.getWorkspaceId(), null);
if (modelFound) {
const index = this.__models.indexOf(modelFound);
if (index > -1) { // only splice array when item is found
this.__models.splice(index, 1); // 2nd parameter means remove one item only
}
}
},

Expand Down Expand Up @@ -283,7 +293,19 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
if (parentModel) {
const idx = parentModel.getChildren().toArray().findIndex(c => folder.getWorkspaceId() === c.getWorkspaceId() && folder.getFolderId() === c.getFolderId());
if (idx > -1) {
parentModel.getChildren().toArray().splice(idx, 1);
parentModel.getChildren().removeAt(idx);
}
}

if (oldParentFolderId === undefined) {
// it was removed, not moved
// remove it from the cached models
const modelFound = this.__getModel(folder.getWorkspaceId(), folder.getParentFolderId());
if (modelFound) {
const index = this.__models.indexOf(modelFound);
if (index > -1) { // only splice array when item is found
this.__models.splice(index, 1); // 2nd parameter means remove one item only
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ qx.Class.define("osparc.data.model.IframeHandler", {
this.__unresponsiveRetries = 5;
this.__nodeState();

this.getIFrame().resetSource();
if (this.getIFrame()) {
this.getIFrame().resetSource();
}
},

__initIFrame: function() {
Expand Down Expand Up @@ -365,7 +367,9 @@ qx.Class.define("osparc.data.model.IframeHandler", {

// will switch to the loading page
node.resetServiceUrl();
this.getIFrame().resetSource();
if (this.getIFrame()) {
this.getIFrame().resetSource();
}
this.fireEvent("iframeChanged");
}
},
Expand Down Expand Up @@ -396,8 +400,10 @@ qx.Class.define("osparc.data.model.IframeHandler", {
const status = node.getStatus().getInteractive();
// it might have been stopped
if (["running", "ready"].includes(status)) {
this.getIFrame().resetSource();
this.getIFrame().setSource(node.getServiceUrl());
if (this.getIFrame()) {
this.getIFrame().resetSource();
this.getIFrame().setSource(node.getServiceUrl());
}

// fire event to force switching to iframe's content:
// it is required in those cases where the native 'load' event isn't triggered (voila)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ qx.Class.define("osparc.desktop.organizations.MembersList", {
}
})
.catch(err => {
osparc.FlashMessenger.getInstance().logAs(this.tr("Something went wrong adding the user"), "ERROR");
const errorMessage = err["message"] || this.tr("Something went wrong adding the user");
osparc.FlashMessenger.getInstance().logAs(errorMessage, "ERROR");
console.error(err);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
createOrgBtn.addListener("execute", function() {
const newOrg = true;
const orgEditor = new osparc.editor.OrganizationEditor(newOrg);
const title = this.tr("Organization Details Editor");
const title = this.tr("New Organization");
const win = osparc.ui.window.Window.popUpInWindow(orgEditor, title, 400, 250);
orgEditor.addListener("createOrg", () => {
this.__createOrganization(win, orgEditor.getChildControl("create"), orgEditor);
Expand Down Expand Up @@ -298,7 +298,8 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
});
})
.catch(err => {
osparc.FlashMessenger.getInstance().logAs(this.tr("Something went wrong creating ") + name, "ERROR");
const errorMessage = err["message"] || this.tr("Something went wrong creating ") + name;
osparc.FlashMessenger.getInstance().logAs(errorMessage, "ERROR");
button.setFetching(false);
console.error(err);
})
Expand Down
Loading