Skip to content

Commit

Permalink
fix: only show allowed actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbgap committed May 15, 2024
1 parent 2b2a83e commit cf3e28c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/components/AlertDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@
<span>{{ $t('Unshelve') }}</span>
</v-tooltip>

<v-tooltip bottom>
<v-tooltip
v-if="isAlertAlarmModel()"
bottom
>
<v-btn
slot="activator"
:disabled="isClosed(item.status)"
Expand All @@ -155,7 +158,10 @@
<span>{{ $t('Close') }}</span>
</v-tooltip>

<v-tooltip bottom>
<v-tooltip
v-if="haveDeleteScope()"
bottom
>
<v-btn
slot="activator"
icon
Expand Down Expand Up @@ -962,6 +968,14 @@ export default {
getNotes() {
this.$store.dispatch('alerts/getNotes', this.id)
},
haveDeleteScope(){
const scopes = this.$store.getters['auth/scopes']
if (this.$config.delete_alert_scope_enforced) return scopes.includes('admin') || scopes.includes('admin:alerts') || scopes.includes('delete:alerts')
else return scopes.includes('admin') || scopes.includes('admin:alerts') || scopes.includes('write') || scopes.includes('write:alerts') || scopes.includes('delete:alerts')
},
isAlertAlarmModel(){
return !this.$config.alarm_model.name.includes('ISA 18')
},
isOpen(status) {
return status == 'open' || status == 'NORM' || status == 'UNACK' || status == 'RTNUN'
},
Expand Down
11 changes: 10 additions & 1 deletion src/components/AlertList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
</v-btn>

<v-btn
v-if="!isClosed(props.item.status)"
v-if="!isClosed(props.item.status) && isAlertAlarmModel()"
flat
icon
small
Expand All @@ -404,6 +404,7 @@
</v-icon>
</v-btn>
<v-btn
v-if="haveDeleteScope()"
flat
icon
small
Expand Down Expand Up @@ -661,6 +662,14 @@ export default {
isClosed(status) {
return status == 'closed'
},
haveDeleteScope(){
const scopes = this.$store.getters['auth/scopes']
if (this.$config.delete_alert_scope_enforced) return scopes.includes('admin') || scopes.includes('admin:alerts') || scopes.includes('delete:alerts')
else return scopes.includes('admin') || scopes.includes('admin:alerts') || scopes.includes('write') || scopes.includes('write:alerts') || scopes.includes('delete:alerts')
},
isAlertAlarmModel(){
return !this.$config.alarm_model.name.includes('ISA 18')
},
takeAction: debounce(function(id, action) {
this.$store
.dispatch('alerts/takeAction', [id, action, ''])
Expand Down

0 comments on commit cf3e28c

Please sign in to comment.