add scaledown action to mgmt nodes

This commit is contained in:
Nancy Butler 2021-08-06 12:20:25 -07:00
parent f9df160d19
commit a021c9421d
3 changed files with 35 additions and 2 deletions

View File

@ -2498,6 +2498,7 @@ node:
taints: Taints taints: Taints
actions: actions:
downloadSSHKey: Download SSH Key downloadSSHKey: Download SSH Key
scaleDown: Scale Down
persistentVolume: persistentVolume:
pluginConfiguration: pluginConfiguration:

View File

@ -96,7 +96,13 @@ export default {
}; };
}, },
watch: {
showNodes(neu) {
if (neu) {
this.$store.dispatch('rancher/findAll', { type: NORMAN.NODE });
}
}
},
computed: { computed: {
defaultTab() { defaultTab() {
if (this.showRegistration && !this.machines?.length) { if (this.showRegistration && !this.machines?.length) {

View File

@ -1,5 +1,5 @@
import { MANAGEMENT_NODE } from '@/config/labels-annotations'; import { MANAGEMENT_NODE } from '@/config/labels-annotations';
import { CAPI, MANAGEMENT, NODE } from '@/config/types'; import { CAPI, MANAGEMENT, NODE, NORMAN } from '@/config/types';
import { NAME as EXPLORER } from '@/config/product/explorer'; import { NAME as EXPLORER } from '@/config/product/explorer';
import { listNodeRoles } from '@/models/cluster/node'; import { listNodeRoles } from '@/models/cluster/node';
import { insertAt } from '@/utils/array'; import { insertAt } from '@/utils/array';
@ -8,6 +8,7 @@ import { downloadFile } from '@/utils/download';
export default { export default {
_availableActions() { _availableActions() {
const out = this._standardActions; const out = this._standardActions;
const normanAction = this.normanNode?.actions || {};
const downloadKeys = { const downloadKeys = {
action: 'downloadKeys', action: 'downloadKeys',
@ -16,8 +17,17 @@ export default {
label: this.t('node.actions.downloadSSHKey'), label: this.t('node.actions.downloadSSHKey'),
}; };
const scaleDown = {
action: 'scaleDown',
enabled: !!normanAction.scaledown,
icon: 'icon icon-fw icon-x',
label: this.t('node.actions.scaleDown'),
bulkable: true,
};
insertAt(out, 0, { divider: true }); insertAt(out, 0, { divider: true });
insertAt(out, 0, downloadKeys); insertAt(out, 0, downloadKeys);
insertAt(out, 0, scaleDown);
return out; return out;
}, },
@ -66,12 +76,28 @@ export default {
return this.$rootGetters['management/byId'](MANAGEMENT.NODE_POOL, nodePoolID); return this.$rootGetters['management/byId'](MANAGEMENT.NODE_POOL, nodePoolID);
}, },
normanNode() {
const normanNodeId = this.id.replace('/', ':');
return this.$rootGetters['rancher/byId'](NORMAN.NODE, normanNodeId);
},
downloadKeys() { downloadKeys() {
return () => { return () => {
downloadFile(this.status.nodeName, this.status.rkeNode.sshKey, 'application/octet-stream'); downloadFile(this.status.nodeName, this.status.rkeNode.sshKey, 'application/octet-stream');
}; };
}, },
scaleDown() {
return async(resources) => {
const safeResources = Array.isArray(resources) ? resources : [this];
await Promise.all(safeResources.map((node) => {
return node.normanNode.doAction('scaledown');
}));
};
},
provisioningCluster() { provisioningCluster() {
return this.$getters['all'](CAPI.RANCHER_CLUSTER).find(c => c.name === this.namespace); return this.$getters['all'](CAPI.RANCHER_CLUSTER).find(c => c.name === this.namespace);
}, },