[go: nahoru, domu]

Skip to content

Commit

Permalink
ui: fix device delete permission in device details
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo R.S. Joao <leonardo.joao@ossystems.com.br>
  • Loading branch information
leonardojoao authored and otavio committed Feb 23, 2022
1 parent 201a572 commit b8c089e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
48 changes: 40 additions & 8 deletions ui/src/components/device/DeviceDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,33 @@
</span>
</v-tooltip>

<v-list-item @click.stop="openDialog('deviceDeleteShow')">
<DeviceDelete
:uid="device.uid"
:redirect="true"
:show.sync="deviceDeleteShow"
data-test="deviceDelete-component"
/>
</v-list-item>
<v-tooltip
bottom
:disabled="hasAuthorizationRemove"
>
<template #activator="{ on, attrs }">
<div
v-bind="attrs"
v-on="on"
>
<v-list-item
:disabled="!hasAuthorizationRemove"
@click.stop="openDialog('deviceDeleteShow')"
>
<DeviceDelete
:uid="device.uid"
:redirect="true"
:show.sync="deviceDeleteShow"
data-test="deviceDelete-component"
/>
</v-list-item>
</div>
</template>

<span>
You don't have this kind of authorization.
</span>
</v-tooltip>
</v-card>
</v-menu>
</v-toolbar>
Expand Down Expand Up @@ -233,6 +252,7 @@ export default {
deviceDeleteShow: false,
renameAction: 'rename',
updateAction: 'deviceUpdate',
removeAction: 'remove',
};
},
Expand Down Expand Up @@ -260,6 +280,18 @@ export default {
return false;
},
hasAuthorizationRemove() {
const role = this.$store.getters['auth/role'];
if (role !== '') {
return hasPermission(
this.$authorizer.role[role],
this.$actions.device[this.removeAction],
);
}
return false;
},
},
async created() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ exports[`DeviceDetails Offline Device Renders the component 1`] = `
<v-tooltip-stub opendelay="0" closedelay="0" bottom="true" openonclick="true" openonhover="true" openonfocus="true" contentclass="" maxwidth="auto" nudgebottom="0" nudgeleft="0" nudgeright="0" nudgetop="0" nudgewidth="0" tag="span"> <span>
You don't have this kind of authorization.
</span></v-tooltip-stub>
<v-list-item-stub activeclass="" tag="div">
<devicedelete-stub uid="a582b47a" redirect="true" data-test="deviceDelete-component"></devicedelete-stub>
</v-list-item-stub>
<v-tooltip-stub opendelay="0" closedelay="0" bottom="true" openonclick="true" openonhover="true" openonfocus="true" contentclass="" maxwidth="auto" nudgebottom="0" nudgeleft="0" nudgeright="0" nudgetop="0" nudgewidth="0" tag="span"> <span>
You don't have this kind of authorization.
</span></v-tooltip-stub>
</v-card-stub>
</v-menu-stub>
</v-toolbar-stub>
Expand Down Expand Up @@ -120,9 +120,9 @@ exports[`DeviceDetails Online Device and owner Renders the component 1`] = `
<v-tooltip-stub opendelay="0" closedelay="0" bottom="true" disabled="true" openonclick="true" openonhover="true" openonfocus="true" contentclass="" maxwidth="auto" nudgebottom="0" nudgeleft="0" nudgeright="0" nudgetop="0" nudgewidth="0" tag="span"> <span>
You don't have this kind of authorization.
</span></v-tooltip-stub>
<v-list-item-stub activeclass="" tag="div">
<devicedelete-stub uid="a582b47a" redirect="true" data-test="deviceDelete-component"></devicedelete-stub>
</v-list-item-stub>
<v-tooltip-stub opendelay="0" closedelay="0" bottom="true" disabled="true" openonclick="true" openonhover="true" openonfocus="true" contentclass="" maxwidth="auto" nudgebottom="0" nudgeleft="0" nudgeright="0" nudgetop="0" nudgewidth="0" tag="span"> <span>
You don't have this kind of authorization.
</span></v-tooltip-stub>
</v-card-stub>
</v-menu-stub>
</v-toolbar-stub>
Expand Down

0 comments on commit b8c089e

Please sign in to comment.