Skip to content

Commit

Permalink
Merge branch 'release_24.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Mar 14, 2024
2 parents 999f3d5 + 42581d7 commit bd3e94a
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 48 deletions.
13 changes: 11 additions & 2 deletions client/src/components/Grid/GridHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { useUserStore } from "@/stores/userStore";
import Heading from "@/components/Common/Heading.vue";
import LoginRequired from "@/components/Common/LoginRequired.vue";
import GridList from "@/components/Grid/GridList.vue";
import HistoryArchive from "@/components/History/Archiving/HistoryArchive.vue";
const userStore = useUserStore();
library.add(faPlus);
interface Props {
activeList?: "my" | "shared" | "published";
activeList?: "archived" | "my" | "shared" | "published";
username?: string;
}
Expand Down Expand Up @@ -64,9 +65,17 @@ const props = withDefaults(defineProps<Props>(), {
<BNavItem id="histories-published-tab" :active="activeList === 'published'" to="/histories/list_published">
Public Histories
</BNavItem>
<BNavItem id="histories-published-tab" :active="activeList === 'archived'" to="/histories/archived">
Archived Histories
</BNavItem>
</BNav>
<GridList v-if="activeList === 'my'" :grid-config="historiesGridConfig" embedded />
<GridList v-else-if="activeList === 'shared'" :grid-config="historiesSharedGridConfig" embedded />
<GridList v-else :grid-config="historiesPublishedGridConfig" :username-search="props.username" embedded />
<GridList
v-else-if="activeList === 'published'"
:grid-config="historiesPublishedGridConfig"
:username-search="props.username"
embedded />
<HistoryArchive v-else />
</div>
</template>
3 changes: 1 addition & 2 deletions client/src/components/History/Archiving/HistoryArchive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ async function onImportCopy(history: ArchivedHistorySummary) {
</script>
<template>
<section id="archived-histories" class="d-flex flex-column">
<h1>Archived Histories</h1>
<div>
<DelayedInput
:query="searchText"
class="m-1 mb-3"
placeholder="Search by name"
placeholder="search by name"
@change="updateSearchQuery" />
<BAlert v-if="isLoading" variant="info" show>
<LoadingSpan v-if="isLoading" message="Loading archived histories" />
Expand Down
30 changes: 19 additions & 11 deletions client/src/components/History/CurrentHistory/HistoryNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
BDropdownDivider,
BDropdownItem,
BDropdownText,
BFormCheckbox,
BModal,
BSpinner,
} from "bootstrap-vue";
Expand Down Expand Up @@ -63,19 +64,28 @@ interface Props {
historiesLoading?: boolean;
}
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
title: "Histories",
historiesLoading: false,
});
const showSwitchModal = ref(false);
const purgeHistory = ref(false);
const userStore = useUserStore();
const historyStore = useHistoryStore();
const { isAnonymous } = storeToRefs(userStore);
const { totalHistoryCount } = storeToRefs(historyStore);
function onDelete() {
if (purgeHistory.value) {
historyStore.deleteHistory(props.history.id, true);
} else {
historyStore.deleteHistory(props.history.id, false);
}
}
function userTitle(title: string) {
if (isAnonymous.value) {
return localize("Log in to") + " " + localize(title);
Expand Down Expand Up @@ -264,16 +274,14 @@ function userTitle(title: string) {
id="delete-history-modal"
title="Delete History?"
title-tag="h2"
@ok="historyStore.deleteHistory(history.id, false)">
<p v-localize>Really delete the current history?</p>
</BModal>

<BModal
id="purge-history-modal"
title="Permanently Delete History?"
title-tag="h2"
@ok="historyStore.deleteHistory(history.id, true)">
<p v-localize>Really delete the current history permanently? This cannot be undone.</p>
@ok="onDelete"
@show="purgeHistory = false">
<p v-localize>
Do you also want to permanently delete the history <i class="ml-1">{{ history.name }}</i>
</p>
<BFormCheckbox id="purge-history" v-model="purgeHistory">
<span v-localize>Yes, permanently delete this history.</span>
</BFormCheckbox>
</BModal>
</div>
</template>
4 changes: 0 additions & 4 deletions client/src/entry/analysis/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ export function fetchMenu(options = {}) {
url: "/interactivetool_entry_points/list",
});
}
userTab.menu.push({
title: _l("Archived Histories"),
url: "/histories/archived",
});
if (Galaxy.config.enable_notification_system) {
userTab.menu.push({
title: _l("Notifications"),
Expand Down
6 changes: 4 additions & 2 deletions client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import { patchRouterPush } from "./router-push";

import AboutGalaxy from "@/components/AboutGalaxy.vue";
import GridVisualization from "@/components/Grid/GridVisualization.vue";
import HistoryArchive from "@/components/History/Archiving/HistoryArchive.vue";
import HistoryArchiveWizard from "@/components/History/Archiving/HistoryArchiveWizard.vue";
import HistoryDatasetPermissions from "@/components/History/HistoryDatasetPermissions.vue";
import NotificationsList from "@/components/Notifications/NotificationsList.vue";
Expand Down Expand Up @@ -288,7 +287,10 @@ export function getRouter(Galaxy) {
},
{
path: "histories/archived",
component: HistoryArchive,
component: GridHistory,
props: {
activeList: "archived",
},
},
{
path: "histories/list",
Expand Down
55 changes: 28 additions & 27 deletions lib/galaxy/webapps/base/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,11 @@ def _ensure_valid_session(self, session_cookie: str, create: bool = True) -> Non
galaxy_session = self.__create_new_session(prev_galaxy_session, user_for_new_session)
galaxy_session_requires_flush = True
self.galaxy_session = galaxy_session
if self.webapp.name == "galaxy":
self.get_or_create_default_history()
self.__update_session_cookie(name=session_cookie)
else:
self.galaxy_session = galaxy_session
if self.webapp.name == "galaxy":
self.get_or_create_default_history()
# Do we need to flush the session?
if galaxy_session_requires_flush:
self.sa_session.add(galaxy_session)
Expand Down Expand Up @@ -814,10 +814,10 @@ def _associate_user_history(self, user, prev_galaxy_session=None):
and not users_last_session.current_history.deleted
):
history = users_last_session.current_history
elif not history:
history = self.get_history(create=True, most_recent=True)
if history not in self.galaxy_session.histories:
self.galaxy_session.add_history(history)
if not history:
history = self.new_history()
if history.user is None:
history.user = user
self.galaxy_session.current_history = history
Expand Down Expand Up @@ -927,29 +927,30 @@ def get_or_create_default_history(self):
Gets or creates a default history and associates it with the current
session.
"""

# There must be a user to fetch a default history.
if not self.galaxy_session.user:
return self.new_history()

# Look for default history that (a) has default name + is not deleted and
# (b) has no datasets. If suitable history found, use it; otherwise, create
# new history.
stmt = select(self.app.model.History).filter_by(
user=self.galaxy_session.user, name=self.app.model.History.default_name, deleted=False
)
unnamed_histories = self.sa_session.scalars(stmt)
default_history = None
for history in unnamed_histories:
if history.empty:
# Found suitable default history.
default_history = history
break

# Set or create history.
if default_history:
history = default_history
self.set_history(history)
history = self.galaxy_session.current_history
if history and not history.deleted:
return history

user = self.galaxy_session.user
if user:
# Look for default history that (a) has default name + is not deleted and
# (b) has no datasets. If suitable history found, use it; otherwise, create
# new history.
stmt = select(self.app.model.History).filter_by(
user=user, name=self.app.model.History.default_name, deleted=False
)
unnamed_histories = self.sa_session.scalars(stmt)
default_history = None
for history in unnamed_histories:
if history.empty:
# Found suitable default history.
default_history = history
break

# Set or create history.
if default_history:
history = default_history
self.set_history(history)
else:
history = self.new_history()

Expand Down
22 changes: 22 additions & 0 deletions lib/galaxy_test/api/test_authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,25 @@ def test_tool_runner_session_cookie_handling(self):
current_history_json_response.raise_for_status()
current_history = current_history_json_response.json()
assert current_history["contents_active"]["active"] == 1

def test_anon_history_creation(self):
# First request:
# We don't create any histories, just return a session cookie
response = get(self.url)
cookie = {"galaxysession": response.cookies["galaxysession"]}
# Check that we don't have any histories (API doesn't auto-create new histories)
histories_response = get(
urljoin(
self.url,
"api/histories",
)
)
assert not histories_response.json()
# Second request, we know client follows conventions by including cookies,
# default history is created.
get(self.url, cookies=cookie)
second_histories_response = get(
urljoin(self.url, "history/current_history_json"),
cookies=cookie,
)
assert second_histories_response.json()

0 comments on commit bd3e94a

Please sign in to comment.