Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only show allowed actions #19

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading