Skip to content

Commit

Permalink
fix(ui): check perm for template
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Aug 28, 2023
1 parent 37e7c4a commit 8213628
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
20 changes: 18 additions & 2 deletions web/src/views/project/TemplateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -93,20 +93,23 @@
icon
color="error"
@click="askDelete()"
v-if="canUpdate"
>
<v-icon>mdi-delete</v-icon>
</v-btn>

<v-btn
icon
@click="copyDialog = true"
v-if="canUpdate"
>
<v-icon>mdi-content-copy</v-icon>
</v-btn>

<v-btn
icon
@click="editDialog = true"
v-if="canUpdate"
>
<v-icon>mdi-pencil</v-icon>
</v-btn>
Expand Down Expand Up @@ -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';
Expand All @@ -225,6 +233,7 @@ export default {
props: {
projectId: Number,
userPermissions: Number,
},
data() {
Expand All @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions web/src/views/project/Templates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -328,6 +332,10 @@ export default {
await this.loadViews();
},
allowActions() {
return true;
},
getViewUrl(viewId) {
if (viewId == null) {
return `/project/${this.projectId}/templates`;
Expand Down

0 comments on commit 8213628

Please sign in to comment.