Skip to content

Commit

Permalink
Merge pull request #167 from aalves08/160-block-delete-mach-inv-based…
Browse files Browse the repository at this point in the history
…-condition

Block deletion of machines from "inventory of machines"
  • Loading branch information
aalves08 authored Feb 27, 2024
2 parents 3f3ee5a + 34a1943 commit 0338242
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/elemental/models/elemental.cattle.io.machineinventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export default class MachineInventory extends ElementalResource {
get _availableActions() {
const out = super._availableActions;

if (this.cannotBeDeletedByUi) {
const i = out.findIndex(act => act.action === 'promptRemove');

if (i >= 0) {
out.splice(i, 1);
}
}

if (this.canCreateCluster) {
out.push({
action: 'createCluster',
Expand Down Expand Up @@ -97,4 +105,14 @@ export default class MachineInventory extends ElementalResource {
return this.$rootGetters['i18n/t']('resourceTable.groupLabel.notInACluster');
}
}

get cannotBeDeletedByUi() {
let cannotBeDeletedByUi = false;

if (this.status?.conditions && this.status?.conditions.find(c => c.type === 'AdoptionReady' && c.status === 'True')) {
cannotBeDeletedByUi = true;
}

return cannotBeDeletedByUi;
}
}

0 comments on commit 0338242

Please sign in to comment.