Skip to content

Commit

Permalink
BUG: Fix for reflexsoar/reflex-api#198 - There was no UI component fo…
Browse files Browse the repository at this point in the history
…r deleting a Role
  • Loading branch information
n3tsurge committed Jun 20, 2022
1 parent dda4721 commit 9989a5e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ const mutations = {
save_role(state, role) {
state.role = role
},
remove_role(state, uuid) {
state.roles = state.roles.filter(role => role.uuid !== uuid)
},
save_credential(state, credential) {
state.credential = credential
},
Expand Down
32 changes: 30 additions & 2 deletions src/views/RolesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<td class="text-right">
<CButton :disabled="!current_user.role.permissions.add_role" size="sm" color="secondary" @click="cloneRole(item.uuid)"><CIcon name="cil-copy"/></CButton>&nbsp;
<CButton :disabled="!current_user.role.permissions.update_role" size="sm" color="primary" @click="editRole(item.uuid)"><CIcon name="cilPencil"/></CButton>&nbsp;
<CButton :disabled="!current_user.role.permissions.delete_role" size="sm" color="danger" @click="promptDelete(item.uuid)"><CIcon name="cilTrash"/></CButton>
<CButton v-if="item.system_generated === null || item.system_generated === false" :disabled="!current_user.role.permissions.delete_role || (item.members ? item.members.length : 0) > 0" size="sm" color="danger" @click="promptDelete(item.uuid)"><CIcon name="cilTrash"/></CButton>
</td>
</template>
</CDataTable>
Expand Down Expand Up @@ -105,6 +105,22 @@
<CButton v-if="modal_mode === 'create'" @click="createRole()" color="primary">Create</CButton>
</template>
</CModal>
<CModal title="Delete Role" color="danger" :centered="true" :show.sync="delete_modal">
<CForm id="deleteRoleForm" @submit.prevent="deleteRole(role.uuid)">
Are you sure you want to delete <b>{{role.name}}</b>? Type the role name in the box below to confirm your intent.
<CForm id="delete-confirm">
<CInput
v-model="delete_confirm"
label="Username"
required
></CInput>
</CForm>
</CForm>
<template #footer>
<CButton @click="dismiss()" color="secondary">No</CButton>
<CButton type="submit" form="deleteRoleForm" color="danger">Yes</CButton>
</template>
</CModal>
</div>
</template>

Expand Down Expand Up @@ -195,7 +211,17 @@ export default {
})
},
promptDelete(uuid) {
console.log(uuid)
this.role = this.roles.find(role => role.uuid === uuid)
this.delete_modal = true
},
deleteRole(uuid) {
let confirm = this.delete_confirm
if(this.role.name === confirm) {
this.$store.dispatch('deleteRole', {uuid: uuid}).then(resp => {
this.delete_confirm = ""
this.delete_modal = false
})
}
},
cloneRole(uuid) {
Object.assign(this.role, this.roles.find(role => role.uuid === uuid))
Expand Down Expand Up @@ -253,6 +279,8 @@ export default {
active_tab: 0,
role_modal: false,
modal_mode: 'create',
delete_modal: false,
delete_confirm: "",
role: {},
organization_filter: null,
empty_role: {
Expand Down

0 comments on commit 9989a5e

Please sign in to comment.