diff --git a/app/javascript/dashboard/components-next/captain/assistant/AssistantCard.vue b/app/javascript/dashboard/components-next/captain/assistant/AssistantCard.vue index 8c2b9b749..7c75ec1a3 100644 --- a/app/javascript/dashboard/components-next/captain/assistant/AssistantCard.vue +++ b/app/javascript/dashboard/components-next/captain/assistant/AssistantCard.vue @@ -3,6 +3,7 @@ import { computed } from 'vue'; import { useToggle } from '@vueuse/core'; import { useI18n } from 'vue-i18n'; import { dynamicTime } from 'shared/helpers/timeHelper'; +import { usePolicy } from 'dashboard/composables/usePolicy'; import CardLayout from 'dashboard/components-next/CardLayout.vue'; import DropdownMenu from 'dashboard/components-next/dropdown-menu/DropdownMenu.vue'; @@ -28,31 +29,41 @@ const props = defineProps({ }); const emit = defineEmits(['action']); +const { checkPermissions } = usePolicy(); const { t } = useI18n(); const [showActionsDropdown, toggleDropdown] = useToggle(); -const menuItems = computed(() => [ - { - label: t('CAPTAIN.ASSISTANTS.OPTIONS.VIEW_CONNECTED_INBOXES'), - value: 'viewConnectedInboxes', - action: 'viewConnectedInboxes', - icon: 'i-lucide-link', - }, - { - label: t('CAPTAIN.ASSISTANTS.OPTIONS.EDIT_ASSISTANT'), - value: 'edit', - action: 'edit', - icon: 'i-lucide-pencil-line', - }, - { - label: t('CAPTAIN.ASSISTANTS.OPTIONS.DELETE_ASSISTANT'), - value: 'delete', - action: 'delete', - icon: 'i-lucide-trash', - }, -]); +const menuItems = computed(() => { + const allOptions = [ + { + label: t('CAPTAIN.ASSISTANTS.OPTIONS.VIEW_CONNECTED_INBOXES'), + value: 'viewConnectedInboxes', + action: 'viewConnectedInboxes', + icon: 'i-lucide-link', + }, + ]; + + if (checkPermissions(['administrator'])) { + allOptions.push( + { + label: t('CAPTAIN.ASSISTANTS.OPTIONS.EDIT_ASSISTANT'), + value: 'edit', + action: 'edit', + icon: 'i-lucide-pencil-line', + }, + { + label: t('CAPTAIN.ASSISTANTS.OPTIONS.DELETE_ASSISTANT'), + value: 'delete', + action: 'delete', + icon: 'i-lucide-trash', + } + ); + } + + return allOptions; +}); const lastUpdatedAt = computed(() => dynamicTime(props.updatedAt)); diff --git a/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue b/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue index e541ee5cf..d6e546581 100644 --- a/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue +++ b/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue @@ -3,6 +3,7 @@ import { computed } from 'vue'; import { useToggle } from '@vueuse/core'; import { useI18n } from 'vue-i18n'; import { dynamicTime } from 'shared/helpers/timeHelper'; +import { usePolicy } from 'dashboard/composables/usePolicy'; import CardLayout from 'dashboard/components-next/CardLayout.vue'; import DropdownMenu from 'dashboard/components-next/dropdown-menu/DropdownMenu.vue'; @@ -32,25 +33,33 @@ const props = defineProps({ }); const emit = defineEmits(['action']); +const { checkPermissions } = usePolicy(); const { t } = useI18n(); const [showActionsDropdown, toggleDropdown] = useToggle(); -const menuItems = computed(() => [ - { - label: t('CAPTAIN.DOCUMENTS.OPTIONS.VIEW_RELATED_RESPONSES'), - value: 'viewRelatedQuestions', - action: 'viewRelatedQuestions', - icon: 'i-ph-tree-view-duotone', - }, - { - label: t('CAPTAIN.DOCUMENTS.OPTIONS.DELETE_DOCUMENT'), - value: 'delete', - action: 'delete', - icon: 'i-lucide-trash', - }, -]); +const menuItems = computed(() => { + const allOptions = [ + { + label: t('CAPTAIN.DOCUMENTS.OPTIONS.VIEW_RELATED_RESPONSES'), + value: 'viewRelatedQuestions', + action: 'viewRelatedQuestions', + icon: 'i-ph-tree-view-duotone', + }, + ]; + + if (checkPermissions(['administrator'])) { + allOptions.push({ + label: t('CAPTAIN.DOCUMENTS.OPTIONS.DELETE_DOCUMENT'), + value: 'delete', + action: 'delete', + icon: 'i-lucide-trash', + }); + } + + return allOptions; +}); const createdAt = computed(() => dynamicTime(props.createdAt)); diff --git a/app/javascript/dashboard/components-next/captain/assistant/ResponseCard.vue b/app/javascript/dashboard/components-next/captain/assistant/ResponseCard.vue index bfd62be0c..312f2ad34 100644 --- a/app/javascript/dashboard/components-next/captain/assistant/ResponseCard.vue +++ b/app/javascript/dashboard/components-next/captain/assistant/ResponseCard.vue @@ -7,6 +7,7 @@ import { dynamicTime } from 'shared/helpers/timeHelper'; import CardLayout from 'dashboard/components-next/CardLayout.vue'; import DropdownMenu from 'dashboard/components-next/dropdown-menu/DropdownMenu.vue'; import Button from 'dashboard/components-next/button/Button.vue'; +import Policy from 'dashboard/components/policy.vue'; const props = defineProps({ id: { @@ -107,8 +108,9 @@ const handleDocumentableClick = () => { {{ question }}
-
+