Skip to content

Commit f9df6a3

Browse files
authored
Merge branch 'master' into is347/collaboration-not-dev-feature
2 parents d7a90ac + c4cb923 commit f9df6a3

File tree

48 files changed

+718
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+718
-189
lines changed

api/specs/web-server/_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
FunctionGroupPathParams,
2424
)
2525
from simcore_service_webserver.functions._controller._functions_rest_schemas import (
26+
FunctionDeleteQueryParams,
2627
FunctionGetQueryParams,
2728
FunctionPathParams,
2829
FunctionsListQueryParams,
@@ -80,6 +81,7 @@ async def update_function(
8081
)
8182
async def delete_function(
8283
_path: Annotated[FunctionPathParams, Depends()],
84+
_query: Annotated[as_query(FunctionDeleteQueryParams), Depends()],
8385
): ...
8486

8587

packages/models-library/src/models_library/functions_errors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ class FunctionIDNotFoundError(FunctionBaseError):
1717
status_code: int = 404 # Not Found
1818

1919

20+
class FunctionHasJobsCannotDeleteError(FunctionBaseError):
21+
msg_template: str = (
22+
"Cannot delete function {function_id} because it has {jobs_count} associated job(s)."
23+
)
24+
status_code: int = 409 # Conflict
25+
26+
2027
class FunctionJobIDNotFoundError(FunctionBaseError):
2128
msg_template: str = "Function job {function_job_id} not found"
2229
status_code: int = 404 # Not Found

services/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ services:
14661466
retries: 50
14671467

14681468
traefik:
1469-
image: "traefik:v3.4.0@sha256:4cf907247939b5d20bf4eff73abd21cb413c339600dde76dbc94a874b2578a27"
1469+
image: "traefik:v3.5.2@sha256:07ff0c6c2114233b82e1de8e9f4fee9974470cd8d42c22e4e158538d950e19ae"
14701470
init: true
14711471
hostname: "{{.Node.Hostname}}-{{.Task.Slot}}"
14721472
command:

services/static-webserver/client/source/class/osparc/auth/Data.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ qx.Class.define("osparc.auth.Data", {
7575
check: "Number"
7676
},
7777

78-
username: {
78+
userName: {
7979
check: "String",
8080
init: null,
8181
nullable: false,
82-
event: "changeUsername",
82+
event: "changeUserName",
8383
},
8484

8585
email: {
@@ -139,12 +139,12 @@ qx.Class.define("osparc.auth.Data", {
139139
return osparc.utils.Utils.cookie.getCookie("user") === "logout";
140140
},
141141

142-
getFriendlyUsername: function() {
142+
getFriendlyUserName: function() {
143143
const firstName = this.getFirstName();
144144
if (firstName) {
145145
return firstName;
146146
}
147-
return this.getUsername();
147+
return this.getUserName();
148148
},
149149

150150
getFullName: function() {

services/static-webserver/client/source/class/osparc/auth/Manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ qx.Class.define("osparc.auth.Manager", {
258258
const authData = osparc.auth.Data.getInstance();
259259
authData.set({
260260
email: profile["login"],
261-
username: profile["userName"],
261+
userName: profile["userName"],
262262
firstName: profile["first_name"],
263263
lastName: profile["last_name"],
264264
expirationDate: profile["expirationDate"] ? new Date(profile["expirationDate"]) : null

services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ qx.Class.define("osparc.auth.ui.LoginView", {
7373
const email = new qx.ui.form.TextField().set({
7474
required: true
7575
});
76-
email.getContentElement().setAttribute("autocomplete", "username");
76+
email.getContentElement().setAttribute("autocomplete", "userName");
7777
osparc.utils.Utils.setIdToWidget(email, "loginUserEmailFld");
7878
this._form.add(email, " Email", qx.util.Validate.email(), "email");
7979
const focusEmail = () => {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,13 @@ qx.Class.define("osparc.dashboard.CardBase", {
914914
const currentUserGroupIds = osparc.study.Utils.state.getCurrentGroupIds(state);
915915
const usersStore = osparc.store.Users.getInstance();
916916
const userPromises = currentUserGroupIds.map(userGroupId => usersStore.getUser(userGroupId));
917-
const usernames = [];
917+
const userNames = [];
918918
let toolTip = "";
919919
let image = null;
920920
Promise.all(userPromises)
921921
.then(usersResult => {
922922
usersResult.forEach(user => {
923-
usernames.push(user.getUsername());
923+
userNames.push(user.getUserName());
924924
});
925925
})
926926
.catch(error => {
@@ -952,8 +952,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
952952
image = "@FontAwesome5Solid/lock/";
953953
break;
954954
}
955-
usernames.forEach(username => {
956-
toolTip += "<br>" + username;
955+
userNames.forEach(userName => {
956+
toolTip += "<br>" + userName;
957957
});
958958
this.__showBlockedCard(image, toolTip);
959959
});

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

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
16401640
return deleteButton;
16411641
},
16421642

1643-
1644-
16451643
__createSelectButton: function() {
16461644
const selectButton = new qx.ui.form.ToggleButton().set({
16471645
appearance: "form-button-outlined",
@@ -1794,12 +1792,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17941792
this._reloadCards();
17951793
},
17961794

1797-
__removeFromStudyList: function(studyId) {
1798-
const idx = this._resourcesList.findIndex(study => study["uuid"] === studyId);
1795+
__removeFromList: function(resourceUuid) {
1796+
const idx = this._resourcesList.findIndex(resource => resource["uuid"] === resourceUuid);
17991797
if (idx > -1) {
18001798
this._resourcesList.splice(idx, 1);
18011799
}
1802-
this._resourcesContainer.removeCard(studyId);
1800+
this._resourcesContainer.removeCard(resourceUuid);
18031801
},
18041802

18051803
_populateCardMenu: function(card) {
@@ -1812,7 +1810,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
18121810
this._populateTemplateCardMenu(card);
18131811
break;
18141812
case "function":
1815-
card.getChildControl("menu-selection-stack").exclude();
1813+
this.__populateFunctionCardMenu(card);
18161814
break;
18171815
}
18181816
},
@@ -1919,6 +1917,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19191917
card.evaluateMenuButtons();
19201918
},
19211919

1920+
__populateFunctionCardMenu: function(card) {
1921+
const menu = card.getMenu();
1922+
const functionData = card.getResourceData();
1923+
1924+
const deleteButton = this.__getDeleteFunctionMenuButton(functionData);
1925+
menu.add(deleteButton);
1926+
},
1927+
19221928
__getOpenLocationMenuButton: function(studyData) {
19231929
const openLocationButton = new qx.ui.menu.Button(this.tr("Open location"), "@FontAwesome5Solid/external-link-alt/12");
19241930
openLocationButton.addListener("execute", () => {
@@ -1994,7 +2000,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19942000
__doMoveStudy: function(studyData, destWorkspaceId, destFolderId) {
19952001
this.__moveStudyToWorkspace(studyData, destWorkspaceId) // first move to workspace
19962002
.then(() => this.__moveStudyToFolder(studyData, destFolderId)) // then move to folder
1997-
.then(() => this.__removeFromStudyList(studyData["uuid"]))
2003+
.then(() => this.__removeFromList(studyData["uuid"]))
19982004
.catch(err => osparc.FlashMessenger.logError(err));
19992005
},
20002006

@@ -2192,6 +2198,54 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21922198
return deleteButton;
21932199
},
21942200

2201+
__getDeleteFunctionMenuButton: function(functionData) {
2202+
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
2203+
deleteButton.set({
2204+
appearance: "menu-button"
2205+
});
2206+
osparc.utils.Utils.setIdToWidget(deleteButton, "functionItemMenuDelete");
2207+
deleteButton.addListener("execute", () => {
2208+
this.__popUpDeleteFunctionWindow(functionData, false);
2209+
}, this);
2210+
return deleteButton;
2211+
},
2212+
2213+
__popUpDeleteFunctionWindow: function(functionData, force, message) {
2214+
const win = this.__createConfirmDeleteWindow([functionData.title]);
2215+
win.setCaption(this.tr("Delete function"));
2216+
if (force) {
2217+
if (message) {
2218+
win.setMessage(message);
2219+
} else {
2220+
const msg = this.tr("The function has associated jobs. Are you sure you want to delete it?");
2221+
win.setMessage(msg);
2222+
}
2223+
}
2224+
win.center();
2225+
win.open();
2226+
win.addListener("close", () => {
2227+
if (win.getConfirmed()) {
2228+
this.__doDeleteFunction(functionData, force);
2229+
}
2230+
}, this);
2231+
},
2232+
2233+
__doDeleteFunction: function(functionData, force = false) {
2234+
osparc.store.Functions.deleteFunction(functionData.uuid, force)
2235+
.then(() => {
2236+
this.__removeFromList(functionData.uuid);
2237+
const msg = this.tr("Successfully deleted");
2238+
osparc.FlashMessenger.logAs(msg, "INFO");
2239+
})
2240+
.catch(err => {
2241+
if (err && err.status && err.status === 409) {
2242+
this.__popUpDeleteFunctionWindow(functionData, true, err.message);
2243+
} else {
2244+
osparc.FlashMessenger.logError(err);
2245+
}
2246+
});
2247+
},
2248+
21952249
__getStudyData: function(id) {
21962250
return this._resourcesList.find(study => study.uuid === id);
21972251
},
@@ -2303,7 +2357,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23032357
__untrashStudy: function(studyData) {
23042358
osparc.store.Study.getInstance().untrashStudy(studyData.uuid)
23052359
.then(() => {
2306-
this.__removeFromStudyList(studyData.uuid);
2360+
this.__removeFromList(studyData.uuid);
23072361
const msg = this.tr("Successfully restored");
23082362
osparc.FlashMessenger.logAs(msg, "INFO");
23092363
this._resourceFilter.evaluateTrashEmpty();
@@ -2315,7 +2369,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23152369
__trashStudy: function(studyData) {
23162370
osparc.store.Study.getInstance().trashStudy(studyData.uuid)
23172371
.then(() => {
2318-
this.__removeFromStudyList(studyData.uuid);
2372+
this.__removeFromList(studyData.uuid);
23192373
const msg = this.tr("Successfully deleted");
23202374
osparc.FlashMessenger.logAs(msg, "INFO");
23212375
this._resourceFilter.setTrashEmpty(false);
@@ -2353,7 +2407,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23532407
operationPromise = osparc.store.Study.getInstance().deleteStudy(studyData.uuid);
23542408
}
23552409
operationPromise
2356-
.then(() => this.__removeFromStudyList(studyData.uuid))
2410+
.then(() => this.__removeFromList(studyData.uuid))
23572411
.catch(err => osparc.FlashMessenger.logError(err))
23582412
.finally(() => this.resetSelection());
23592413
},

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ qx.Class.define("osparc.data.Resources", {
644644
method: "POST",
645645
url: statics.API + "/functions"
646646
},
647+
delete: {
648+
method: "DELETE",
649+
url: statics.API + "/functions/{functionId}?force={force}"
650+
},
647651
patch: {
648652
method: "PATCH",
649653
url: statics.API + "/functions/{functionId}?include_extras=true"
@@ -1127,10 +1131,14 @@ qx.Class.define("osparc.data.Resources", {
11271131
},
11281132
"poUsers": {
11291133
endpoints: {
1130-
search: {
1134+
searchByEmail: {
11311135
method: "GET",
11321136
url: statics.API + "/admin/user-accounts:search?email={email}"
11331137
},
1138+
searchByGroupId: {
1139+
method: "GET",
1140+
url: statics.API + "/admin/user-accounts:search?primary_group_id={gId}"
1141+
},
11341142
getPendingUsers: {
11351143
method: "GET",
11361144
url: statics.API + "/admin/user-accounts?review_status=PENDING"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ qx.Class.define("osparc.data.model.Conversation", {
304304
const extraContext = this.getExtraContext() || {};
305305
extraContext["appointment"] = appointment ? appointment.toISOString() : null;
306306
// OM: Supporters are not allowed to patch the conversation metadata yet
307-
const backendAllowsPatch = osparc.store.Products.getInstance().amIASupportUser() ? false : true;
307+
const backendAllowsPatch = osparc.store.Groups.getInstance().amIASupportUser() ? false : true;
308308
if (backendAllowsPatch) {
309309
return osparc.store.ConversationsSupport.getInstance().patchExtraContext(this.getConversationId(), extraContext)
310310
.then(() => {

0 commit comments

Comments
 (0)