Skip to content

Commit

Permalink
Only display optional activities when user clicks on more
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed May 29, 2024
1 parent 852ddd1 commit 7d3cbe3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
8 changes: 2 additions & 6 deletions client/src/components/ActivityBar/ActivityBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,7 @@ watch(
:to="activity.to"
@click="onToggleSidebar()" />
<ActivityItem
v-else-if="
['admin', 'tools', 'visualizations', 'multiview', 'invocation'].includes(
activity.id
)
"
v-else-if="activity.id === 'admin' || activity.panel"
:id="`activity-${activity.id}`"
:key="activity.id"
:icon="activity.icon"
Expand Down Expand Up @@ -219,7 +215,7 @@ watch(
icon="ellipsis-h"
:is-active="isActiveSideBar('settings')"
title="More"
tooltip="Edit preferences"
tooltip="View additional activities"
@click="onToggleSidebar('settings')" />
<ActivityItem
v-if="isAdmin"
Expand Down
15 changes: 9 additions & 6 deletions client/src/components/ActivityBar/ActivitySettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { storeToRefs } from "pinia";
import { computed, type ComputedRef } from "vue";
import { useActivityAction } from "@/composables/useActivityAction";
import { type Activity, useActivityStore } from "@/stores/activityStore";
library.add({
Expand All @@ -22,6 +23,7 @@ const props = defineProps<{
const activityStore = useActivityStore();
const { activities } = storeToRefs(activityStore);
const activityAction = useActivityAction();
const filteredActivities = computed(() => {
if (props.query?.length > 0) {
Expand All @@ -45,8 +47,6 @@ const foundActivities: ComputedRef<boolean> = computed(() => {
return filteredActivities.value.length > 0;
});
function onClick(activity: Activity) {}
function onFavorite(activity: Activity) {
if (activity.optional) {
activity.visible = !activity.visible;
Expand All @@ -62,7 +62,10 @@ function onRemove(activity: Activity) {
<div class="activity-settings rounded no-highlight">
<div v-if="foundActivities" class="activity-settings-content">
<div v-for="activity in filteredActivities" :key="activity.id">
<button class="activity-settings-item p-2 cursor-pointer" @click="onClick(activity)">
<button
v-if="activity.optional"
class="activity-settings-item p-2 cursor-pointer"
@click="activityAction.executeActivity(activity)">
<div class="d-flex justify-content-between align-items-start">
<span class="d-flex justify-content-between w-100">
<span>
Expand All @@ -71,7 +74,7 @@ function onRemove(activity: Activity) {
activity.title || "No title available"
}}</span>
</span>
<div v-if="activity.optional">
<div>
<BButton
v-if="activity.mutable"
v-b-tooltip.hover
Expand All @@ -88,7 +91,7 @@ function onRemove(activity: Activity) {
size="sm"
title="Hide in Activity Bar"
variant="link"
@click="onFavorite(activity)">
@click.stop="onFavorite(activity)">
<FontAwesomeIcon icon="fas fa-star" fa-fw />
</BButton>
<BButton
Expand All @@ -97,7 +100,7 @@ function onRemove(activity: Activity) {
size="sm"
title="Show in Activity Bar"
variant="link"
@click="onFavorite(activity)">
@click.stop="onFavorite(activity)">
<FontAwesomeIcon icon="far fa-star" fa-fw />
</BButton>
</div>
Expand Down
21 changes: 21 additions & 0 deletions client/src/composables/useActivityAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useRouter } from "vue-router/composables";

import { type Activity } from "@/stores/activityStore";
import { useUserStore } from "@/stores/userStore";

export function useActivityAction() {
const router = useRouter();
const userStore = useUserStore();
const executeActivity = (activity: Activity) => {
if (activity.panel) {
userStore.toggleSideBar(activity.id);
}
if (activity.to) {
router.push(activity.to);
}
};

return {
executeActivity,
};
}
14 changes: 13 additions & 1 deletion client/src/stores/activitySetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ 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.",
description: "Displays currently running interactive tools (ITs), if these are enabled by the administrator.",
icon: "fa-laptop",
id: "interactivetools",
mutable: false,
optional: false,
panel: false,
title: "Interactive Tools",
tooltip: "Show active interactive tools",
to: "/interactivetool_entry_points/list",
Expand All @@ -24,6 +25,7 @@ export const Activities = [
id: "upload",
mutable: false,
optional: false,
panel: false,
title: "Upload",
to: null,
tooltip: "Download from URL or upload files from disk",
Expand All @@ -36,6 +38,7 @@ export const Activities = [
id: "tools",
mutable: false,
optional: false,
panel: true,
title: "Tools",
to: null,
tooltip: "Search and run tools",
Expand All @@ -48,6 +51,7 @@ export const Activities = [
id: "workflows",
mutable: false,
optional: true,
panel: false,
title: "Workflows",
to: "/workflows/list",
tooltip: "Search and run workflows",
Expand All @@ -60,6 +64,7 @@ export const Activities = [
id: "invocation",
mutable: false,
optional: true,
panel: true,
title: "Workflow Invocations",
tooltip: "Show all workflow runs",
to: null,
Expand All @@ -72,6 +77,7 @@ export const Activities = [
id: "visualizations",
mutable: false,
optional: true,
panel: true,
title: "Visualization",
to: null,
tooltip: "Visualize datasets",
Expand All @@ -84,6 +90,7 @@ export const Activities = [
id: "histories",
mutable: false,
optional: true,
panel: false,
title: "Histories",
tooltip: "Show all histories",
to: "/histories/list",
Expand All @@ -96,6 +103,7 @@ export const Activities = [
id: "multiview",
mutable: false,
optional: true,
panel: true,
title: "History Multiview",
tooltip: "Select histories to show in History Multiview",
to: "/histories/view_multiple",
Expand All @@ -108,6 +116,7 @@ export const Activities = [
id: "datasets",
mutable: false,
optional: true,
panel: false,
title: "Datasets",
tooltip: "Show all datasets",
to: "/datasets/list",
Expand All @@ -120,6 +129,7 @@ export const Activities = [
id: "pages",
mutable: false,
optional: true,
panel: false,
title: "Pages",
tooltip: "Show all pages",
to: "/pages/list",
Expand All @@ -136,6 +146,7 @@ export function convertDropData(data: EventData): Activity | null {
id: `dataset-${data.id}`,
mutable: true,
optional: true,
panel: false,
title: data.name as string,
tooltip: "View your dataset",
to: `/datasets/${data.id}/preview`,
Expand All @@ -150,6 +161,7 @@ export function convertDropData(data: EventData): Activity | null {
id: `workflow-${data.id}`,
mutable: true,
optional: true,
panel: false,
title: data.name as string,
tooltip: data.name as string,
to: `/workflows/run?id=${data.id}`,
Expand Down
2 changes: 2 additions & 0 deletions client/src/stores/activityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface Activity {
mutable: boolean;
// indicate wether this activity can be disabled by the user
optional: boolean;
// specifiy wether this activity utilizes the side panel
panel: boolean;
// title to be displayed in the activity bar
title: string;
// route to be executed upon selecting the activity
Expand Down

0 comments on commit 7d3cbe3

Please sign in to comment.