feat(ui): hide/show actions depends of permissions

This commit is contained in:
Denis Gukov 2023-08-26 21:09:31 +02:00
parent 4398544e91
commit a90c42c7aa
2 changed files with 15 additions and 2 deletions

View File

@ -21,8 +21,12 @@ export default {
},
data() {
const allowActions = this.allowActions();
const headers = this.getHeaders().filter((header) => allowActions || header.value !== 'actions');
return {
headers: this.getHeaders(),
headers,
items: null,
itemId: null,
@ -42,6 +46,10 @@ export default {
},
methods: {
allowActions() {
return this.can(USER_PERMISSIONS.manageProjectResources);
},
can(permission) {
// eslint-disable-next-line no-bitwise
return (this.userPermissions & permission) === permission;

View File

@ -74,7 +74,7 @@
import ItemListPageBase from '@/components/ItemListPageBase';
import TeamMemberForm from '@/components/TeamMemberForm.vue';
import axios from 'axios';
import { USER_ROLES } from '@/lib/constants';
import { USER_PERMISSIONS, USER_ROLES } from '@/lib/constants';
export default {
components: { TeamMemberForm },
@ -96,6 +96,10 @@ export default {
await this.loadItems();
},
allowActions() {
return this.can(USER_PERMISSIONS.manageProjectUsers);
},
getHeaders() {
return [
{
@ -122,6 +126,7 @@ export default {
sortable: false,
}];
},
getSingleItemUrl() {
return `/api/project/${this.projectId}/users/${this.itemId}`;
},