Skip to content

Commit 0456796

Browse files
authored
Added warning dialogue to ActivityDelete action (#1339)
* Added warning dialogue to ActivityDelete action * Combine the warning dialogues into a single choice
1 parent 086ee4b commit 0456796

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

activity_browser/actions/activity/activity_delete.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,30 @@ def run(activity_keys: List[tuple]):
2727
# retrieve activity objects from the controller using the provided keys
2828
activities = [bd.get_activity(key) for key in activity_keys]
2929

30+
warning_text = f"Are you certain you want to delete {len(activities)} activity/activities?"
31+
3032
# check for downstream processes
3133
if any(len(act.upstream()) > 0 for act in activities):
3234
# warning text
33-
text = (
34-
"One or more activities have downstream processes. Deleting these activities will remove the "
35-
"exchange from the downstream processes, this can't be undone.\n\nAre you sure you want to "
36-
"continue?"
35+
warning_text += (
36+
"\n\nOne or more activities have downstream processes. Deleting these activities will remove the "
37+
"exchange from the downstream processes as well."
3738
)
3839

39-
# alert the user
40-
choice = QtWidgets.QMessageBox.warning(
41-
application.main_window,
42-
"Activity/Activities has/have downstream processes",
43-
text,
44-
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
45-
QtWidgets.QMessageBox.No,
46-
)
40+
# alert the user
41+
choice = QtWidgets.QMessageBox.warning(
42+
application.main_window,
43+
"Deleting activity/activities",
44+
warning_text,
45+
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
46+
QtWidgets.QMessageBox.No,
47+
)
48+
49+
# return if the user cancels
50+
if choice == QtWidgets.QMessageBox.No:
51+
return
52+
4753

48-
# return if the user cancels
49-
if choice == QtWidgets.QMessageBox.No:
50-
return
5154

5255
# use the activity controller to delete multiple activities
5356
for act in activities:

0 commit comments

Comments
 (0)