fix(ui): check perm for template

This commit is contained in:
Denis Gukov 2023-08-28 11:41:20 +02:00
parent 37e7c4aca1
commit 821362831c
2 changed files with 28 additions and 4 deletions

View File

@ -68,7 +68,7 @@
@yes="remove()"
/>
<v-toolbar flat >
<v-toolbar flat>
<v-app-bar-nav-icon @click="showDrawer()"></v-app-bar-nav-icon>
<v-toolbar-title class="breadcrumbs">
<router-link
@ -93,6 +93,7 @@
icon
color="error"
@click="askDelete()"
v-if="canUpdate"
>
<v-icon>mdi-delete</v-icon>
</v-btn>
@ -100,6 +101,7 @@
<v-btn
icon
@click="copyDialog = true"
v-if="canUpdate"
>
<v-icon>mdi-content-copy</v-icon>
</v-btn>
@ -107,6 +109,7 @@
<v-btn
icon
@click="editDialog = true"
v-if="canUpdate"
>
<v-icon>mdi-pencil</v-icon>
</v-btn>
@ -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);

View File

@ -169,8 +169,12 @@
:tooltip="item.last_task.message"
/>
<div style="color: gray; font-size: 14px;">
{{ $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
})
}}
</div>
</div>
</template>
@ -328,6 +332,10 @@ export default {
await this.loadViews();
},
allowActions() {
return true;
},
getViewUrl(viewId) {
if (viewId == null) {
return `/project/${this.projectId}/templates`;