mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
feat(ui): hide/show actions depends of permissions
This commit is contained in:
parent
4398544e91
commit
a90c42c7aa
@ -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;
|
||||
|
@ -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}`;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user