Skip to content

Commit

Permalink
Merge pull request #17531 from guerler/enable_activity_bar
Browse files Browse the repository at this point in the history
Enables activity bar by default
  • Loading branch information
dannon authored Mar 5, 2024
2 parents f18739b + 90b0238 commit 5c5f3aa
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 79 deletions.
1 change: 1 addition & 0 deletions client/src/components/ActivityBar/ActivityBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ localVue.use(PiniaVuePlugin);

function testActivity(id, newOptions = {}) {
const defaultOptions = {
anonymous: true,
id: `test-${id}`,
description: "test-description",
icon: "test-icon",
Expand Down
31 changes: 21 additions & 10 deletions client/src/components/ActivityBar/ActivityBar.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { computed, type Ref, ref } from "vue";
import { computed, type Ref, ref, watch } from "vue";
import { useRoute } from "vue-router/composables";
import draggable from "vuedraggable";
import { useConfig } from "@/composables/config";
import { useHashedUserId } from "@/composables/hashedUserId";
import { convertDropData } from "@/stores/activitySetup";
import { type Activity, useActivityStore } from "@/stores/activityStore";
import { useEventStore } from "@/stores/eventStore";
Expand All @@ -25,15 +26,15 @@ const { config, isConfigLoaded } = useConfig();
const route = useRoute();
const userStore = useUserStore();
const { hashedUserId } = useHashedUserId();
const eventStore = useEventStore();
const activityStore = useActivityStore();
const { isAnonymous } = storeToRefs(userStore);
const emit = defineEmits(["dragstart"]);
// sync built-in activities with cached activities
activityStore.sync();
// activities from store
const { activities } = storeToRefs(activityStore);
Expand All @@ -44,6 +45,9 @@ const dragItem: Ref<Activity | null> = ref(null);
// drag state
const isDragging = ref(false);
// sync built-in activities with cached activities
activityStore.sync();
/**
* Checks if the route of an activity is currently being visited and panels are collapsed
*/
Expand Down Expand Up @@ -114,14 +118,21 @@ function onDragOver(evt: MouseEvent) {
/**
* Tracks the state of activities which expand or collapse the sidepanel
*/
function onToggleSidebar(toggle: string, to: string | null = null) {
function onToggleSidebar(toggle: string = "", to: string | null = null) {
// if an activity's dedicated panel/sideBar is already active
// but the route is different, don't collapse
if (toggle && to && !(route.path === to) && isActiveSideBar(toggle)) {
return;
}
userStore.toggleSideBar(toggle);
}
watch(
() => hashedUserId.value,
() => {
activityStore.sync();
}
);
</script>

<template>
Expand All @@ -143,7 +154,7 @@ function onToggleSidebar(toggle: string, to: string | null = null) {
@start="isDragging = true"
@end="isDragging = false">
<div v-for="(activity, activityIndex) in activities" :key="activityIndex">
<div v-if="activity.visible">
<div v-if="activity.visible && (activity.anonymous || !isAnonymous)">
<UploadItem
v-if="activity.id === 'upload'"
:id="`activity-${activity.id}`"
Expand All @@ -152,7 +163,7 @@ function onToggleSidebar(toggle: string, to: string | null = null) {
:title="activity.title"
:tooltip="activity.tooltip" />
<InteractiveItem
v-else-if="activity.id === 'interactivetools'"
v-else-if="activity.to && activity.id === 'interactivetools'"
:id="`activity-${activity.id}`"
:key="activity.id"
:icon="activity.icon"
Expand All @@ -169,7 +180,7 @@ function onToggleSidebar(toggle: string, to: string | null = null) {
:is-active="panelActivityIsActive(activity)"
:title="activity.title"
:tooltip="activity.tooltip"
:to="activity.to"
:to="activity.to || ''"
@click="onToggleSidebar(activity.id, activity.to)" />
<ActivityItem
v-else-if="activity.to"
Expand All @@ -185,9 +196,9 @@ function onToggleSidebar(toggle: string, to: string | null = null) {
</div>
</draggable>
</b-nav>
<b-nav vertical class="flex-nowrap p-1">
<b-nav v-if="!isAnonymous" vertical class="flex-nowrap p-1">
<NotificationItem
v-if="!isAnonymous && isConfigLoaded && config.enable_notification_system"
v-if="isConfigLoaded && config.enable_notification_system"
id="activity-notifications"
icon="bell"
:is-active="isActiveSideBar('notifications') || isActiveRoute('/user/notifications')"
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Panels/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { filterTools, getValidPanelItems, getValidToolsInCurrentView, getValidTo
import ToolSearch from "./Common/ToolSearch.vue";
import ToolSection from "./Common/ToolSection.vue";
import UploadButton from "@/components/Upload/UploadButton.vue";
const SECTION_IDS_TO_EXCLUDE = ["expression_tools"]; // if this isn't the Workflow Editor panel
Expand Down Expand Up @@ -253,7 +252,6 @@ function setButtonText() {
@onQuery="(q) => (query = q)"
@onResults="onResults" />
<section v-if="!propShowAdvanced">
<UploadButton />
<div v-if="hasResults && resultPanel" class="pb-2">
<b-button size="sm" class="w-100" @click="onToggle">
<FontAwesomeIcon :icon="buttonIcon" />
Expand Down
62 changes: 0 additions & 62 deletions client/src/components/Upload/UploadButton.vue

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/composables/usePanels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function usePanels() {
return true;
});

const showActivityBar = computed(() => showPanels.value && userStore.showActivityBar && !userStore.isAnonymous);
const showActivityBar = computed(() => showPanels.value && userStore.showActivityBar);
const showToolbox = computed(() => showPanels.value && !showActivityBar.value);

return {
Expand Down
7 changes: 4 additions & 3 deletions client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ patchRouterPush(VueRouter);
function redirectAnon() {
const Galaxy = getGalaxyInstance();
if (!Galaxy.user || !Galaxy.user.id) {
return "/";
return "/login/start";
}
}

Expand Down Expand Up @@ -451,9 +451,9 @@ export function getRouter(Galaxy) {
path: "user/permissions",
component: UserDatasetPermissions,
redirect: redirectAnon(),
props: (route) => ({
props: {
userId: Galaxy.user.id,
}),
},
},
{
path: "user/:formId",
Expand Down Expand Up @@ -520,6 +520,7 @@ export function getRouter(Galaxy) {
{
path: "workflows/invocations",
component: UserInvocations,
redirect: redirectAnon(),
},
{
path: "workflows/invocations/report",
Expand Down
11 changes: 11 additions & 0 deletions client/src/stores/activitySetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { type EventData } from "@/stores/eventStore";

export const Activities = [
{
anonymous: false,
description: "Displays currently active interactive tools (ITs), if these are enabled by the administrator.",
icon: "fa-laptop",
id: "interactivetools",
Expand All @@ -17,6 +18,7 @@ export const Activities = [
visible: true,
},
{
anonymous: true,
description: "Opens a data dialog, allowing uploads from URL, pasted content or disk.",
icon: "upload",
id: "upload",
Expand All @@ -28,6 +30,7 @@ export const Activities = [
visible: true,
},
{
anonymous: true,
description: "Displays the tool panel to search and access all available tools.",
icon: "wrench",
id: "tools",
Expand All @@ -39,6 +42,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays a panel to search and access workflows.",
icon: "sitemap",
id: "workflows",
Expand All @@ -50,6 +54,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays all workflow runs.",
icon: "fa-list",
id: "invocation",
Expand All @@ -61,6 +66,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays the list of available visualizations.",
icon: "chart-bar",
id: "visualizations",
Expand All @@ -72,6 +78,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays the list of all histories.",
icon: "fa-hdd",
id: "histories",
Expand All @@ -83,6 +90,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays the history selector panel and opens History Multiview in the center panel.",
icon: "fa-columns",
id: "multiview",
Expand All @@ -94,6 +102,7 @@ export const Activities = [
visible: true,
},
{
anonymous: false,
description: "Displays all of your datasets across all histories.",
icon: "fa-folder",
id: "datasets",
Expand All @@ -109,6 +118,7 @@ export const Activities = [
export function convertDropData(data: EventData): Activity | null {
if (data.history_content_type === "dataset") {
return {
anonymous: true,
description: "Displays this dataset.",
icon: "fa-file",
id: `dataset-${data.id}`,
Expand All @@ -122,6 +132,7 @@ export function convertDropData(data: EventData): Activity | null {
}
if (data.model_class === "StoredWorkflow") {
return {
anonymous: false,
description: data.description as string,
icon: "fa-play",
id: `workflow-${data.id}`,
Expand Down
3 changes: 3 additions & 0 deletions client/src/stores/activityStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useActivityStore } from "@/stores/activityStore";
jest.mock("./activitySetup", () => ({
Activities: [
{
anonymous: false,
description: "a-description",
icon: "a-icon",
id: "a-id",
Expand All @@ -21,6 +22,7 @@ jest.mock("./activitySetup", () => ({

const newActivities = [
{
anonymous: false,
description: "a-description-new",
icon: "a-icon-new",
id: "a-id",
Expand All @@ -32,6 +34,7 @@ const newActivities = [
visible: false,
},
{
anonymous: false,
description: "b-description-new",
icon: "b-icon-new",
id: "b-id",
Expand Down
11 changes: 11 additions & 0 deletions client/src/stores/activityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ import { useUserLocalStorage } from "@/composables/userLocalStorage";
import { Activities } from "./activitySetup";

export interface Activity {
// determine wether an anonymous user can access this activity
anonymous: boolean;
// description of the activity
description: string;
// unique identifier
id: string;
// icon to be displayed in activity bar
icon: string;
// indicate if this activity can be modified and/or deleted
mutable: boolean;
// indicate wether this activity can be disabled by the user
optional: boolean;
// title to be displayed in the activity bar
title: string;
// route to be executed upon selecting the activity
to: string | null;
// tooltip to be displayed when hovering above the icon
tooltip: string;
// indicate wether the activity should be visible by default
visible: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const useUserStore = defineStore("userStore", () => {

// explicitly pass current User, because userStore might not exist yet
const toggledSideBar = useUserLocalStorage("user-store-toggled-side-bar", "tools", currentUser);
const showActivityBar = useUserLocalStorage("user-store-show-activity-bar", false, currentUser);
const showActivityBar = useUserLocalStorage("user-store-show-activity-bar", true, currentUser);
const preferredListViewMode = useUserLocalStorage("user-store-preferred-list-view-mode", "grid", currentUser);

let loadPromise: Promise<void> | null = null;
Expand Down

0 comments on commit 5c5f3aa

Please sign in to comment.