From 821362831c88fc9daa1d8bc47bad31166f9caf3c Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Mon, 28 Aug 2023 11:41:20 +0200 Subject: [PATCH] fix(ui): check perm for template --- web/src/views/project/TemplateView.vue | 20 ++++++++++++++++++-- web/src/views/project/Templates.vue | 12 ++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/web/src/views/project/TemplateView.vue b/web/src/views/project/TemplateView.vue index 58b5547fa..b0095123f 100644 --- a/web/src/views/project/TemplateView.vue +++ b/web/src/views/project/TemplateView.vue @@ -68,7 +68,7 @@ @yes="remove()" /> - + mdi-delete @@ -100,6 +101,7 @@ mdi-content-copy @@ -107,6 +109,7 @@ mdi-pencil @@ -214,7 +217,12 @@ import YesNoDialog from '@/components/YesNoDialog.vue'; import EditDialog from '@/components/EditDialog.vue'; import TemplateForm from '@/components/TemplateForm.vue'; import TaskList from '@/components/TaskList.vue'; -import { TEMPLATE_TYPE_ACTION_TITLES, TEMPLATE_TYPE_ICONS, TEMPLATE_TYPE_TITLES } from '@/lib/constants'; +import { + TEMPLATE_TYPE_ACTION_TITLES, + TEMPLATE_TYPE_ICONS, + TEMPLATE_TYPE_TITLES, + USER_PERMISSIONS, +} from '@/lib/constants'; import ObjectRefsDialog from '@/components/ObjectRefsDialog.vue'; import NewTaskDialog from '@/components/NewTaskDialog.vue'; @@ -225,6 +233,7 @@ export default { props: { projectId: Number, + userPermissions: Number, }, data() { @@ -242,10 +251,17 @@ export default { itemRefs: null, itemRefsDialog: null, newTaskDialog: null, + USER_PERMISSIONS, }; }, computed: { + canUpdate() { + const perm = USER_PERMISSIONS.manageProjectResources; + // eslint-disable-next-line no-bitwise + return (this.userPermissions & perm) === perm; + }, + viewId() { if (/^-?\d+$/.test(this.$route.params.viewId)) { return parseInt(this.$route.params.viewId, 10); diff --git a/web/src/views/project/Templates.vue b/web/src/views/project/Templates.vue index deab47baa..fd279694d 100644 --- a/web/src/views/project/Templates.vue +++ b/web/src/views/project/Templates.vue @@ -169,8 +169,12 @@ :tooltip="item.last_task.message" />
- {{ $t('by', {user_name: item.last_task.user_name, formatDate: item.last_task.created| - formatDate}) }} + {{ + $t('by', { + user_name: item.last_task.user_name, formatDate: item.last_task.created | + formatDate + }) + }}
@@ -328,6 +332,10 @@ export default { await this.loadViews(); }, + allowActions() { + return true; + }, + getViewUrl(viewId) { if (viewId == null) { return `/project/${this.projectId}/templates`;