mirror of https://github.com/rancher/dashboard.git
Ensure remove respects ability to skip confirmation
This commit is contained in:
parent
db6146dc3c
commit
6590903a44
|
|
@ -41,7 +41,7 @@ export default {
|
|||
}
|
||||
};
|
||||
},
|
||||
computed: { ...mapState('action-menu', ['showPromptRemove']) },
|
||||
computed: { ...mapState('action-menu', ['showPromptRemove', 'toRemove']) },
|
||||
watch: {
|
||||
async showPromptRemove(show, ...args) {
|
||||
if (!show) {
|
||||
|
|
@ -49,6 +49,12 @@ export default {
|
|||
// ... however in this use case it doesn't happen so do it manually (the removed resources are not globalRoleBindings and not spoofed)
|
||||
await this.updateRows(true);
|
||||
}
|
||||
},
|
||||
async toRemove(resources) {
|
||||
if (resources?.length === 0) {
|
||||
await this.refreshGroupMemberships(() => {});
|
||||
await this.updateRows(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ export default {
|
|||
enabled: true,
|
||||
},
|
||||
{
|
||||
action: 'unassignGroupRoles',
|
||||
action: 'promptUnassignGroupRoles',
|
||||
altAction: 'unassignGroupRoles',
|
||||
label: this.t('action.unassign'),
|
||||
icon: 'icon icon-trash',
|
||||
bulkable: true,
|
||||
|
|
@ -52,10 +53,9 @@ export default {
|
|||
];
|
||||
},
|
||||
|
||||
unassignGroupRoles() {
|
||||
promptUnassignGroupRoles() {
|
||||
return (resources = this) => {
|
||||
const principals = Array.isArray(resources) ? resources : [resources];
|
||||
|
||||
const globalRoleBindings = this.$rootGetters['management/all'](MANAGEMENT.GLOBAL_ROLE_BINDING)
|
||||
.filter(globalRoleBinding => principals.find(principal => principal.id === globalRoleBinding.groupPrincipalName));
|
||||
|
||||
|
|
@ -63,4 +63,16 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
unassignGroupRoles() {
|
||||
return async(resources = this) => {
|
||||
const principals = Array.isArray(resources) ? resources : [resources];
|
||||
const globalRoleBindings = this.$rootGetters['management/all'](MANAGEMENT.GLOBAL_ROLE_BINDING)
|
||||
.filter(globalRoleBinding => principals.find(principal => principal.id === globalRoleBinding.groupPrincipalName));
|
||||
|
||||
await Promise.all(globalRoleBindings.map(resource => resource.remove()));
|
||||
|
||||
// There is no dialog to close, but this can be watched and used to refresh the group principles
|
||||
this.$dispatch('promptRemove', null);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import LazyImage from '@/components/LazyImage';
|
|||
import AppSummaryGraph from '@/components/formatter/AppSummaryGraph';
|
||||
import { sortBy } from '@/utils/sort';
|
||||
import { LEGACY } from '@/store/features';
|
||||
import { isAlternate } from '@/utils/platform';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
|
@ -151,8 +152,15 @@ export default {
|
|||
app.goToUpgrade(version, true);
|
||||
},
|
||||
|
||||
remove(app) {
|
||||
app.promptRemove();
|
||||
remove(app, event) {
|
||||
const alt = isAlternate(event);
|
||||
|
||||
if (!alt) {
|
||||
app.promptRemove();
|
||||
} else {
|
||||
// User held alt key, so don't prompt
|
||||
app.remove();
|
||||
}
|
||||
},
|
||||
|
||||
install(chart) {
|
||||
|
|
@ -380,13 +388,13 @@ export default {
|
|||
<button class="btn btn-sm role-secondary" @click="openV1Tool(opt.chart.legacyPage)" v-html="t('catalog.tools.action.manage')" />
|
||||
</template>
|
||||
<template v-else-if="opt.app && opt.upgradeAvailable && !opt.chart.legacy">
|
||||
<button class="btn btn-sm role-secondary" @click="remove(opt.app)">
|
||||
<button class="btn btn-sm role-secondary" @click="remove(opt.app, $event)">
|
||||
<i class="icon icon-delete icon-lg" />
|
||||
</button>
|
||||
<button class="btn btn-sm role-secondary" @click="edit(opt.app, opt.app.upgradeAvailable)" v-html="t('catalog.tools.action.upgrade')" />
|
||||
</template>
|
||||
<template v-else-if="opt.app">
|
||||
<button class="btn btn-sm role-secondary" @click="remove(opt.app)">
|
||||
<button class="btn btn-sm role-secondary" @click="remove(opt.app, $event)">
|
||||
<i class="icon icon-delete icon-lg" />
|
||||
</button>
|
||||
<button class="btn btn-sm role-secondary" @click="edit(opt.app)" v-html="t('catalog.tools.action.edit')" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue