Skip to content
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

🎨 [Frontend] Show trashedAt and trashedBy on Bin cards #7030

Merged
merged 29 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
56fa881
trash icon
odeimaiz Jan 13, 2025
1ed0135
Trash -> Bin
odeimaiz Jan 13, 2025
3e9c34c
Delete -> Delete permanently
odeimaiz Jan 13, 2025
30c8967
Merge branch 'master' into fix/trash-paging
odeimaiz Jan 13, 2025
90c9f4d
minor
odeimaiz Jan 13, 2025
5c89ba7
minor
odeimaiz Jan 13, 2025
aa41c1e
fix trash paging
odeimaiz Jan 13, 2025
5e3e8b5
minor
odeimaiz Jan 13, 2025
814898c
show trashed at in folder
odeimaiz Jan 13, 2025
ace6b69
workspace show trashed at
odeimaiz Jan 13, 2025
7d4ff8c
trashedAt in study cards
odeimaiz Jan 13, 2025
690fa62
trashed by in Workspace
odeimaiz Jan 13, 2025
0b4bf88
trashed by
odeimaiz Jan 13, 2025
4ae5bb7
WS: tooltip on title only
odeimaiz Jan 13, 2025
d09d41d
Merge branch 'master' into enh/show-trashed-at-date
odeimaiz Jan 14, 2025
9cb8a3c
[skip ci] rename
odeimaiz Jan 14, 2025
87072ca
Merge branch 'master' into enh/show-trashed-at-date
odeimaiz Jan 17, 2025
c8b38b6
[skip ci] trashedAt workspace and folder
odeimaiz Jan 17, 2025
606cecf
[skip ci] trashed at studies
odeimaiz Jan 17, 2025
b5baa85
[skip ci] trashedBy in folder
odeimaiz Jan 17, 2025
7863d91
[skip ci] DateAndBy
odeimaiz Jan 17, 2025
1f62068
[skip ci] reuse widget
odeimaiz Jan 17, 2025
d70c956
dateBy
odeimaiz Jan 17, 2025
e5913b7
minor
odeimaiz Jan 17, 2025
c5c019d
unused
odeimaiz Jan 17, 2025
4582722
"by me"
odeimaiz Jan 17, 2025
21d91c3
shorter date
odeimaiz Jan 17, 2025
86dc4f4
minor
odeimaiz Jan 17, 2025
09e4e97
Merge branch 'master' into enh/show-trashed-at-date
odeimaiz Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,27 @@ qx.Class.define("osparc.dashboard.CardBase", {
populateShareIcon: function(shareIcon, accessRights) {
const gids = Object.keys(accessRights).map(key => parseInt(key));

const groupsStore = osparc.store.Groups.getInstance();

// Icon
const groupsStore = osparc.store.Groups.getInstance();
const groupEveryone = groupsStore.getEveryoneGroup();
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
const organizations = groupsStore.getOrganizations();
const myGroupId = groupsStore.getMyGroupId();

const organizationIds = Object.keys(organizations).map(key => parseInt(key));
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
} else if (gids.length === 1) {
} else if (gids.length === 1 && gids[0] === myGroupId) {
shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON);
} else {
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER);
}

// Tooltip
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
const myGroupId = groupsStore.getMyGroupId();
if (gids.length === 0 || (gids.length === 1 && gids[0] === myGroupId)) {
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
if (canIWrite) {
shareIcon.set({
toolTipText: qx.locale.Manager.tr("Share")
Expand All @@ -180,6 +180,16 @@ qx.Class.define("osparc.dashboard.CardBase", {
return;
}

this.addHintFromGids(shareIcon, gids);
},

addHintFromGids: function(icon, gids) {
const groupsStore = osparc.store.Groups.getInstance();
const groupEveryone = groupsStore.getEveryoneGroup();
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
const organizations = groupsStore.getOrganizations();
const myGroupId = groupsStore.getMyGroupId();

const sharedGrps = [];
const groups = [];
groups.push(groupEveryone);
Expand All @@ -193,8 +203,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
}
});

const hint = new osparc.ui.hint.Hint(shareIcon);
shareIcon.addListener("mouseover", async () => {
const hint = new osparc.ui.hint.Hint(icon);
icon.addListener("mouseover", async () => {
hint.show();

// lazy load tooltip, this can be an expensive call
Expand Down Expand Up @@ -230,7 +240,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
}
}
}, this);
shareIcon.addListener("mouseout", () => hint.exclude(), this);
icon.addListener("mouseout", () => hint.exclude(), this);
},
},

Expand Down Expand Up @@ -308,6 +318,18 @@ qx.Class.define("osparc.dashboard.CardBase", {
nullable: true
},

trashedAt: {
check: "Date",
apply: "_applyTrasehdAt",
nullable: true
},

trashedBy: {
check: "Number",
apply: "_applyTrashedBy",
nullable: true
},

classifiers: {
check: "Array"
},
Expand Down Expand Up @@ -457,6 +479,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
owner,
accessRights: resourceData.accessRights ? resourceData.accessRights : {},
lastChangeDate: resourceData.lastChangeDate ? new Date(resourceData.lastChangeDate) : null,
trashedAt: resourceData.trashedAt ? new Date(resourceData.trashedAt) : null,
trashedBy: resourceData.trashedBy || null,
icon: resourceData.thumbnail || this.self().PRODUCT_ICON,
state: resourceData.state ? resourceData.state : {},
classifiers: resourceData.classifiers && resourceData.classifiers ? resourceData.classifiers : [],
Expand Down Expand Up @@ -523,6 +547,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
throw new Error("Abstract method called!");
},

_applyTrasehdAt: function(value, old) {
throw new Error("Abstract method called!");
},

_applyTrashedBy: function(value, old) {
throw new Error("Abstract method called!");
},

_applyAccessRights: function(value, old) {
throw new Error("Abstract method called!");
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
nullable: true,
apply: "__applyLastModified"
},

trashedAt: {
check: "Date",
nullable: true,
apply: "__applyTrashedAt"
},

trashedBy: {
check: "Number",
nullable: true,
apply: "__applyTrashedBy"
},
},

members: {
Expand All @@ -107,16 +119,12 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
}
case "title":
control = new qx.ui.basic.Label().set({
anonymous: true,
font: "text-14",
});
this._add(control, osparc.dashboard.FolderButtonBase.POS.TITLE);
break;
case "last-modified":
control = new qx.ui.basic.Label().set({
anonymous: true,
font: "text-12",
});
case "date-by":
control = new osparc.ui.basic.DateAndBy();
this._add(control, osparc.dashboard.FolderButtonBase.POS.SUBTITLE);
break;
case "menu-button": {
Expand Down Expand Up @@ -150,6 +158,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
folder.bind("parentFolderId", this, "parentFolderId");
folder.bind("name", this, "title");
folder.bind("lastModified", this, "lastModified");
folder.bind("trashedAt", this, "trashedAt");
folder.bind("trashedBy", this, "trashedBy");

osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId());

Expand Down Expand Up @@ -222,15 +232,36 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {

__applyTitle: function(value) {
const label = this.getChildControl("title");
label.setValue(value);

this.setToolTipText(value);
label.set({
value,
toolTipText: value,
});
},

__applyLastModified: function(value) {
if (value) {
const label = this.getChildControl("last-modified");
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Last modified"),
})
}
},

__applyTrashedAt: function(value) {
if (value && value.getTime() !== new Date(0).getTime()) {
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Moved to the bin"),
});
}
},

__applyTrashedBy: function(gid) {
if (gid) {
const dateBy = this.getChildControl("date-by");
dateBy.setGroupid(gid);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,8 @@ qx.Class.define("osparc.dashboard.GridButtonBase", {
layout.add(control, {flex: 1});
break;
}
case "modified-text":
control = new qx.ui.basic.Label().set({
textColor: "contrasted-text-dark",
alignY: "middle",
rich: true,
anonymous: true,
font: "text-12",
allowGrowY: false
});
case "date-by":
control = new osparc.ui.basic.DateAndBy();
layout = this.getChildControl("footer");
layout.add(control, this.self().FPOS.MODIFIED);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,37 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {

// overridden
_applyLastChangeDate: function(value, old) {
if (value && (this.isResourceType("study") || this.isResourceType("template"))) {
const label = this.getChildControl("modified-text");
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
if (value) {
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Last modified"),
});
}
}
},

// overridden
_applyTrasehdAt: function(value) {
if (value && value.getTime() !== new Date(0).getTime()) {
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Moved to the bin"),
});
}
}
},

// overridden
_applyTrashedBy: function(gid) {
if (gid) {
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.setGroupId(gid);
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
column: osparc.dashboard.ListButtonBase.POS.SHARED
});
break;
case "last-change":
case "date-text":
control = new qx.ui.basic.Label().set({
anonymous: true,
font: "text-13",
allowGrowY: false,
minWidth: 120,
Expand Down Expand Up @@ -191,10 +190,39 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
return control || this.base(arguments, id);
},

// overridden
_applyLastChangeDate: function(value, old) {
if (value) {
const label = this.getChildControl("last-change");
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Last modified"),
});
}
}
},

// overridden
_applyTrasehdAt: function(value) {
if (value && value.getTime() !== new Date(0).getTime()) {
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.set({
date: value,
toolTipText: this.tr("Moved to the bin"),
});
}
}
},

// overridden
_applyTrashedBy: function(gid) {
if (gid) {
if (this.isResourceType("study") || this.isResourceType("template")) {
const dateBy = this.getChildControl("date-by");
dateBy.setGroupId(gid);
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", {
MENU: 2,
},
FPOS: {
MODIFIED: 0
DATE: 0,
}
},

Expand Down
Loading
Loading