From cdbd5e32ce83021e0f7812362cbc21416bc1cf41 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Mon, 27 May 2024 10:05:16 +0200 Subject: [PATCH 01/20] Drop backend restrictions to switch to immutable histories --- lib/galaxy/webapps/base/webapp.py | 4 ++-- lib/galaxy/webapps/galaxy/controllers/history.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/webapps/base/webapp.py b/lib/galaxy/webapps/base/webapp.py index 0cd50260661..7874de2ef77 100644 --- a/lib/galaxy/webapps/base/webapp.py +++ b/lib/galaxy/webapps/base/webapp.py @@ -914,7 +914,7 @@ class GalaxyWebTransaction(base.DefaultWebTransaction, context.ProvidesHistoryCo return history def set_history(self, history): - if history and not history.deleted: + if history: self.galaxy_session.current_history = history self.sa_session.add(self.galaxy_session) with transaction(self.sa_session): @@ -932,7 +932,7 @@ class GalaxyWebTransaction(base.DefaultWebTransaction, context.ProvidesHistoryCo # Just return the current history if one exists and is not deleted. history = self.galaxy_session.current_history - if history and not history.deleted: + if history: return history # Look for an existing history that has the default name, is not diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index 3db60f29ad2..a50a7b35c52 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -325,7 +325,7 @@ class HistoryController(BaseUIController, SharableMixin, UsesAnnotations, UsesIt def set_as_current(self, trans, id, **kwargs): """Change the current user's current history to one with `id`.""" try: - history = self.history_manager.get_mutable(self.decode_id(id), trans.user, current_history=trans.history) + history = self.history_manager.get_owned(self.decode_id(id), trans.user, current_history=trans.history) trans.set_history(history) return self.history_data(trans, history) except exceptions.MessageException as msg_exc: From ead71fd8b4be7e1001f83d069221f781edbd6d24 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Mon, 27 May 2024 10:15:42 +0200 Subject: [PATCH 02/20] Move immutability restriction check from HistoryView to HistoryPanel --- .../History/CurrentHistory/HistoryPanel.vue | 14 +++++++++++--- client/src/components/History/HistoryView.vue | 18 ++---------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/client/src/components/History/CurrentHistory/HistoryPanel.vue b/client/src/components/History/CurrentHistory/HistoryPanel.vue index 759efea9a90..8268153099f 100644 --- a/client/src/components/History/CurrentHistory/HistoryPanel.vue +++ b/client/src/components/History/CurrentHistory/HistoryPanel.vue @@ -3,7 +3,7 @@ import { BAlert } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed, onMounted, type Ref, ref, set as VueSet, unref, watch } from "vue"; -import type { HistoryItemSummary, HistorySummaryExtended } from "@/api"; +import { type HistoryItemSummary, type HistorySummaryExtended, userOwnsHistory } from "@/api"; import { copyDataset } from "@/api/datasets"; import ExpandedItems from "@/components/History/Content/ExpandedItems"; import SelectedItems from "@/components/History/Content/SelectedItems"; @@ -15,6 +15,7 @@ import { startWatchingHistory } from "@/store/historyStore/model/watchHistory"; import { useEventStore } from "@/stores/eventStore"; import { useHistoryItemsStore } from "@/stores/historyItemsStore"; import { useHistoryStore } from "@/stores/historyStore"; +import { useUserStore } from "@/stores/userStore"; import { type Alias, getOperatorForAlias } from "@/utils/filtering"; import { setDrag } from "@/utils/setDrag"; @@ -49,7 +50,6 @@ interface Props { listOffset?: number; history: HistorySummaryExtended; filter?: string; - canEditHistory?: boolean; filterable?: boolean; isMultiViewItem?: boolean; } @@ -59,7 +59,6 @@ type ContentItemRef = Record | null const props = withDefaults(defineProps(), { listOffset: 0, filter: "", - canEditHistory: true, filterable: false, isMultiViewItem: false, }); @@ -90,6 +89,14 @@ const { lastCheckedTime, totalMatchesCount, isWatching } = storeToRefs(useHistor const historyStore = useHistoryStore(); const historyItemsStore = useHistoryItemsStore(); +const { currentUser } = storeToRefs(useUserStore()); + +const currentUserOwnsHistory = computed(() => { + return userOwnsHistory(currentUser.value, props.history); +}); +const canEditHistory = computed(() => { + return currentUserOwnsHistory.value && !props.history.deleted && !props.history.archived; +}); const historyUpdateTime = computed(() => { return props.history.update_time; @@ -542,6 +549,7 @@ function setItemDragstart( :is-watching="isWatching" :last-checked="lastCheckedTime" :show-controls="canEditHistory" + :owned-by-current-user="userOwnsHistory(currentUser, history)" :filter-text.sync="filterText" :hide-reload="isMultiViewItem" @reloadContents="reloadContents" /> diff --git a/client/src/components/History/HistoryView.vue b/client/src/components/History/HistoryView.vue index e185e751714..23ccb4f6220 100644 --- a/client/src/components/History/HistoryView.vue +++ b/client/src/components/History/HistoryView.vue @@ -35,12 +35,7 @@ :selected-collections.sync="selectedCollections" :show-controls="false" @view-collection="onViewCollection" /> - + @@ -87,23 +82,14 @@ export default { return this.currentHistory?.id == this.history?.id; }, isSetAsCurrentDisabled() { - return this.isCurrentHistory || this.history.archived || this.history.purged; + return this.isCurrentHistory; }, setAsCurrentTitle() { if (this.isCurrentHistory) { return "This history is already your current history."; } - if (this.history.archived) { - return "This history has been archived and cannot be set as your current history. Unarchive it first."; - } - if (this.history.purged) { - return "This history has been purged and cannot be set as your current history."; - } return "Switch to this history"; }, - canEditHistory() { - return this.userOwnsHistory && !this.history.archived && !this.history.purged; - }, showHistoryArchived() { return this.history.archived && this.userOwnsHistory; }, From ade613ab5ded00c7651f19c42c346803b4693a52 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Mon, 27 May 2024 10:18:11 +0200 Subject: [PATCH 03/20] Display history status in Panel --- .../CurrentHistory/HistoryMessages.vue | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/client/src/components/History/CurrentHistory/HistoryMessages.vue b/client/src/components/History/CurrentHistory/HistoryMessages.vue index 91e06beb75f..3d97f80dd24 100644 --- a/client/src/components/History/CurrentHistory/HistoryMessages.vue +++ b/client/src/components/History/CurrentHistory/HistoryMessages.vue @@ -1,10 +1,15 @@