diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.test.ts b/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.test.ts index f6308952b587..6964145c03b6 100644 --- a/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.test.ts +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.test.ts @@ -1,4 +1,5 @@ import { createTestingPinia } from "@pinia/testing"; +import { getFakeRegisteredUser } from "@tests/test-data"; import { shallowMount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; @@ -81,14 +82,9 @@ async function mountWorkflowInvocationHeader(ownsWorkflow = true, hasReturnBtn = }); const userStore = useUserStore(); - userStore.currentUser = { - id: "1", - email: "test@mail.test", - tags_used: [], - isAnonymous: false, - total_disk_usage: 0, + userStore.currentUser = getFakeRegisteredUser({ username: ownsWorkflow ? WORKFLOW_OWNER : OTHER_USER, - }; + }); return { wrapper }; } diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.vue b/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.vue index d6f0142d5040..93b47c32b4f5 100644 --- a/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.vue +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationHeader.vue @@ -3,13 +3,15 @@ import { faClock } from "@fortawesome/free-regular-svg-icons"; import { faArrowLeft, faEdit, faHdd, faSitemap, faUpload } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { BAlert, BButton, BButtonGroup } from "bootstrap-vue"; +import { storeToRefs } from "pinia"; import { computed, ref } from "vue"; import { RouterLink } from "vue-router"; +import { isRegisteredUser } from "@/api"; import type { WorkflowInvocationElementView } from "@/api/invocations"; import { useWorkflowInstance } from "@/composables/useWorkflowInstance"; import { useUserStore } from "@/stores/userStore"; -import { Workflow } from "@/stores/workflowStore"; +import type { Workflow } from "@/stores/workflowStore"; import localize from "@/utils/localization"; import { errorMessageAsString } from "@/utils/simple-error"; @@ -31,10 +33,10 @@ const props = defineProps(); const { workflow } = useWorkflowInstance(props.invocation.workflow_id); -const userStore = useUserStore(); +const { currentUser, isAnonymous } = storeToRefs(useUserStore()); const owned = computed(() => { - if (userStore.currentUser && workflow.value) { - return userStore.currentUser.username === workflow.value.owner; + if (isRegisteredUser(currentUser.value) && workflow.value) { + return currentUser.value.username === workflow.value.owner; } else { return false; } @@ -129,7 +131,7 @@ function getWorkflowName(): string { v-else v-b-tooltip.hover.noninteractive size="sm" - :disabled="userStore.isAnonymous" + :disabled="isAnonymous" :title="localize('Import this workflow')" :icon="faUpload" variant="outline-primary"