diff --git a/assets/translations/en-us.yaml b/assets/translations/en-us.yaml index 01bfac548e..310e52ecb1 100644 --- a/assets/translations/en-us.yaml +++ b/assets/translations/en-us.yaml @@ -2498,6 +2498,7 @@ node: taints: Taints actions: downloadSSHKey: Download SSH Key + scaleDown: Scale Down persistentVolume: pluginConfiguration: diff --git a/detail/provisioning.cattle.io.cluster.vue b/detail/provisioning.cattle.io.cluster.vue index ea3ff933b3..6ec3df889f 100644 --- a/detail/provisioning.cattle.io.cluster.vue +++ b/detail/provisioning.cattle.io.cluster.vue @@ -96,7 +96,13 @@ export default { }; }, - + watch: { + showNodes(neu) { + if (neu) { + this.$store.dispatch('rancher/findAll', { type: NORMAN.NODE }); + } + } + }, computed: { defaultTab() { if (this.showRegistration && !this.machines?.length) { diff --git a/models/management.cattle.io.node.js b/models/management.cattle.io.node.js index ae82db7535..0921fb40f1 100644 --- a/models/management.cattle.io.node.js +++ b/models/management.cattle.io.node.js @@ -1,5 +1,5 @@ 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 { listNodeRoles } from '@/models/cluster/node'; import { insertAt } from '@/utils/array'; @@ -8,6 +8,7 @@ import { downloadFile } from '@/utils/download'; export default { _availableActions() { const out = this._standardActions; + const normanAction = this.normanNode?.actions || {}; const downloadKeys = { action: 'downloadKeys', @@ -16,8 +17,17 @@ export default { 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, downloadKeys); + insertAt(out, 0, scaleDown); return out; }, @@ -66,12 +76,28 @@ export default { return this.$rootGetters['management/byId'](MANAGEMENT.NODE_POOL, nodePoolID); }, + normanNode() { + const normanNodeId = this.id.replace('/', ':'); + + return this.$rootGetters['rancher/byId'](NORMAN.NODE, normanNodeId); + }, + downloadKeys() { return () => { 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() { return this.$getters['all'](CAPI.RANCHER_CLUSTER).find(c => c.name === this.namespace); },