Skip to content

Commit 6acf8f2

Browse files
committed
_applyOwner
1 parent 3aa1370 commit 6acf8f2

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
250250
_applyOwner: function(value, old) {
251251
const label = this.getChildControl("subtitle-text");
252252
if (osparc.utils.Resources.isFunction(this.getResourceData())) {
253-
const canIWrite = Boolean(this.getResourceData()["accessRights"]["write"]);
253+
// Functions don't have 'owner'
254+
const canIWrite = osparc.data.model.Function.canIWrite(this.getResourceData()["accessRights"]);
254255
label.setValue(canIWrite ? "My Function" : "Read Only");
255256
} else {
256257
const user = this.__createOwner(value);

services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
244244
_applyOwner: function(value, old) {
245245
const label = this.getChildControl("owner");
246246
if (osparc.utils.Resources.isFunction(this.getResourceData())) {
247-
const canIWrite = Boolean(this.getResourceData()["accessRights"]["write"]);
247+
// Functions don't have 'owner'
248+
const canIWrite = osparc.data.model.Function.canIWrite(this.getResourceData()["accessRights"]);
248249
label.setValue(canIWrite ? "My Function" : "Read Only");
249250
} else {
250251
const user = this.__createOwner(value);

services/static-webserver/client/source/class/osparc/data/model/Function.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ qx.Class.define("osparc.data.model.Function", {
155155
getProperties: function() {
156156
return Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.Function));
157157
},
158+
159+
canIWrite: function(accessRights) {
160+
const groupsStore = osparc.store.Groups.getInstance();
161+
const orgIDs = groupsStore.getOrganizationIds();
162+
orgIDs.push(groupsStore.getMyGroupId());
163+
if (orgIDs.length) {
164+
return osparc.share.CollaboratorsFunction.canGroupsWrite(accessRights, (orgIDs));
165+
}
166+
return false;
167+
}
158168
},
159169

160170
members: {
@@ -172,13 +182,7 @@ qx.Class.define("osparc.data.model.Function", {
172182

173183
canIWrite: function() {
174184
const accessRights = this.getAccessRights();
175-
const groupsStore = osparc.store.Groups.getInstance();
176-
const orgIDs = groupsStore.getOrganizationIds();
177-
orgIDs.push(groupsStore.getMyGroupId());
178-
if (orgIDs.length) {
179-
return osparc.share.CollaboratorsFunction.canGroupsWrite(accessRights, (orgIDs));
180-
}
181-
return false;
185+
return this.self().canIWrite(accessRights);
182186
},
183187

184188
patchFunction: function(functionChanges) {

0 commit comments

Comments
 (0)