From 8bafe33933520c1228b93b7d27cdd7789fed43e5 Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Fri, 23 Feb 2024 12:14:01 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8:=20update=20`WorkflowCard`=20button?= =?UTF-8?q?=20titles=20for=20Anonymous=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Workflow/WorkflowCard.vue | 54 +++++++++++++++---- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/client/src/components/Workflow/WorkflowCard.vue b/client/src/components/Workflow/WorkflowCard.vue index a8d73b0e97bd..6b92f0e939a2 100644 --- a/client/src/components/Workflow/WorkflowCard.vue +++ b/client/src/components/Workflow/WorkflowCard.vue @@ -3,6 +3,7 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faEdit, faEye, faPen, faUpload } from "@fortawesome/free-solid-svg-icons"; 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"; @@ -42,6 +43,8 @@ const emit = defineEmits<{ const router = useRouter(); const userStore = useUserStore(); +const { isAnonymous } = storeToRefs(userStore); + const showRename = ref(false); const showPreview = ref(false); @@ -60,6 +63,35 @@ const description = computed(() => { return null; } }); +const editButtonTitle = computed(() => { + if (isAnonymous.value) { + return "Log in to edit Workflow"; + } else { + if (workflow.value.deleted) { + return "You cannot edit a deleted workflow. Restore it first."; + } else { + return "Edit Workflow"; + } + } +}); +const importedButtonTitle = computed(() => { + if (isAnonymous.value) { + return "Log in to import workflow"; + } else { + return "Import this workflow to edit"; + } +}); +const runButtonTitle = computed(() => { + if (isAnonymous.value) { + return "Log in to run workflow"; + } else { + if (workflow.value.deleted) { + return "You cannot run a deleted workflow. Restore it first."; + } else { + return "Run workflow"; + } + } +}); function onEdit() { router.push(`/workflows/edit?id=${workflow.value.id}`); @@ -119,7 +151,7 @@ async function onTagClick(tag: string) {
- + @@ -155,16 +187,12 @@ async function onTagClick(tag: string) {
@@ -175,20 +203,24 @@ async function onTagClick(tag: string) { v-else v-b-tooltip.hover size="sm" - title="Import this workflow to edit" + :disabled="isAnonymous" + :title="importedButtonTitle" :icon="faUpload" variant="outline-primary" :action="onImport"> Import - +