diff --git a/client/src/components/Workflow/InvocationsList.test.js b/client/src/components/Workflow/InvocationsList.test.js index 389035e52c31..ddb3aa65d69b 100644 --- a/client/src/components/Workflow/InvocationsList.test.js +++ b/client/src/components/Workflow/InvocationsList.test.js @@ -134,9 +134,6 @@ describe("InvocationsList.vue", () => { axiosMock .onGet("/api/invocations", { params: { limit: 50, offset: 0, include_terminal: false } }) .reply(200, [mockInvocationData], { total_matches: "1" }); - const mockRouter = { - push: jest.fn(), - }; const propsData = { ownerGrid: false, loading: false, @@ -163,9 +160,6 @@ describe("InvocationsList.vue", () => { }, localVue, pinia, - mocks: { - $router: mockRouter, - }, }); }); @@ -201,10 +195,10 @@ describe("InvocationsList.vue", () => { expect(mockMethod).toHaveBeenCalled(); }); - it("calls executeWorkflow", async () => { - await wrapper.find('[data-workflow-run="workflowId"').trigger("click"); - expect(wrapper.vm.$router.push).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$router.push).toHaveBeenCalledWith("/workflows/run?id=workflowId"); + it("check run button", async () => { + const runButton = await wrapper.find('[data-workflow-run="workflowId"'); + + expect(runButton.attributes("href")).toBe("/workflows/run?id=workflowId"); }); it("should not render pager", async () => { diff --git a/client/src/components/Workflow/WorkflowActions.vue b/client/src/components/Workflow/WorkflowActions.vue index 52e7f5ae0526..122f0571aeec 100644 --- a/client/src/components/Workflow/WorkflowActions.vue +++ b/client/src/components/Workflow/WorkflowActions.vue @@ -13,7 +13,6 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BButton } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed, type ComputedRef } from "vue"; -import { useRouter } from "vue-router/composables"; import { getGalaxyInstance } from "@/app"; import { deleteWorkflow, updateWorkflow } from "@/components/Workflow/workflows.services"; @@ -43,7 +42,7 @@ type BaseAction = { size: "sm" | "md" | "lg"; component: "async" | "button"; variant: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link"; - onClick?: () => Promise | void; + onClick?: (e?: MouseEvent | KeyboardEvent) => void; }; interface AAction extends BaseAction { @@ -53,8 +52,7 @@ interface AAction extends BaseAction { interface BAction extends BaseAction { component: "button"; - href?: string; - onClick?: () => Promise | void; + to?: string; } const props = withDefaults(defineProps(), { @@ -66,7 +64,6 @@ const emit = defineEmits<{ (e: "toggleShowPreview", a?: boolean): void; }>(); -const router = useRouter(); const userStore = useUserStore(); const { isAnonymous } = storeToRefs(userStore); const { confirm } = useConfirmDialog(); @@ -88,16 +85,15 @@ const sourceType = computed(() => { } }); -function onExport() { - router.push(`/workflows/export?id=${props.workflow.id}`); -} - async function onToggleBookmark(checked: boolean) { await updateWorkflow(props.workflow.id, { show_in_tool_panel: checked, }); + emit("refreshList", true); + Toast.info(`Workflow ${checked ? "added to" : "removed from"} bookmarks`); + if (checked) { getGalaxyInstance().config.stored_workflow_menu_entries.push({ id: props.workflow.id, @@ -206,7 +202,7 @@ const menuActions: ComputedRef = computed(() => { icon: faFileExport, size: props.buttonSize, variant: "link", - onClick: () => onExport(), + to: `/workflows/export?id=${props.workflow.id}`, }, ]; }); @@ -235,6 +231,7 @@ const menuActions: ComputedRef = computed(() => { :size="action.size" :title="action.tooltip" :href="action.href" + :to="action.to" @click="action.onClick"> @@ -257,9 +254,10 @@ const menuActions: ComputedRef = computed(() => { v-for="action in menuActions.filter((a) => a.condition).reverse()" :key="action.class" :class="action.class" - :href="action.href ?? undefined" + :href="action.href" :title="action.title" :target="action.target" + :to="action.to" @click="action.onClick?.()"> {{ action.title }} diff --git a/client/src/components/Workflow/WorkflowActionsExtend.vue b/client/src/components/Workflow/WorkflowActionsExtend.vue index c7c2b92d3347..5f15d7142844 100644 --- a/client/src/components/Workflow/WorkflowActionsExtend.vue +++ b/client/src/components/Workflow/WorkflowActionsExtend.vue @@ -14,7 +14,6 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BButton } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed } from "vue"; -import { useRouter } from "vue-router/composables"; import { copyWorkflow, undeleteWorkflow } from "@/components/Workflow/workflows.services"; import { useConfirmDialog } from "@/composables/confirmDialog"; @@ -36,10 +35,9 @@ const props = withDefaults(defineProps(), { }); const emit = defineEmits<{ - (e: "refreshList", a?: boolean): void; + (e: "refreshList", overlayLoading?: boolean): void; }>(); -const router = useRouter(); const userStore = useUserStore(); const { confirm } = useConfirmDialog(); const { isAnonymous } = storeToRefs(useUserStore()); @@ -55,10 +53,6 @@ const shared = computed(() => { } }); -function onShare() { - router.push(`/workflows/sharing?id=${props.workflow.id}`); -} - async function onCopy() { const confirmed = await confirm("Are you sure you want to make a copy of this workflow?", "Copy workflow"); @@ -114,7 +108,7 @@ async function onRestore() { :size="buttonSize" title="Share" variant="outline-primary" - @click="onShare"> + :to="`/workflows/sharing?id=${workflow.id}`"> Share diff --git a/client/src/components/Workflow/WorkflowCard.vue b/client/src/components/Workflow/WorkflowCard.vue index d70b1655ff1a..f82a13870038 100644 --- a/client/src/components/Workflow/WorkflowCard.vue +++ b/client/src/components/Workflow/WorkflowCard.vue @@ -5,7 +5,6 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BButton } from "bootstrap-vue"; import { storeToRefs } from "pinia"; import { computed, ref } from "vue"; -import { useRouter } from "vue-router/composables"; import { copyWorkflow, updateWorkflow } from "@/components/Workflow/workflows.services"; import { Toast } from "@/composables/toast"; @@ -36,11 +35,10 @@ const props = withDefaults(defineProps(), { }); const emit = defineEmits<{ - (e: "refreshList", a?: boolean, b?: boolean): void; - (e: "tagClick", a: string): void; + (e: "tagClick", tag: string): void; + (e: "refreshList", overlayLoading?: boolean, b?: boolean): void; }>(); -const router = useRouter(); const userStore = useUserStore(); const { isAnonymous } = storeToRefs(userStore); @@ -93,10 +91,6 @@ const runButtonTitle = computed(() => { } }); -function onEdit() { - router.push(`/workflows/edit?id=${workflow.value.id}`); -} - async function onImport() { await copyWorkflow(workflow.value.id, workflow.value.owner); Toast.success("Workflow imported successfully"); @@ -194,7 +188,7 @@ async function onTagClick(tag: string) { class="workflow-edit-button" :title="editButtonTitle" variant="outline-primary" - @click="onEdit"> + :to="`/workflows/edit?id=${workflow.id}`"> Edit diff --git a/client/src/components/Workflow/WorkflowInvocationsCount.vue b/client/src/components/Workflow/WorkflowInvocationsCount.vue index 1d7041f6f1a6..9c3eecab16c6 100644 --- a/client/src/components/Workflow/WorkflowInvocationsCount.vue +++ b/client/src/components/Workflow/WorkflowInvocationsCount.vue @@ -3,7 +3,6 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faClock, faSitemap } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { onMounted, ref } from "vue"; -import { useRouter } from "vue-router/composables"; import { invocationCountsFetcher } from "@/api/workflows"; import localize from "@/utils/localization"; @@ -16,8 +15,6 @@ interface Props { const props = defineProps(); -const router = useRouter(); - const count = ref(undefined); async function initCounts() { @@ -32,10 +29,6 @@ async function initCounts() { } onMounted(initCounts); - -function onInvocations() { - router.push(`/workflows/${props.workflow.id}/invocations`); -}