diff --git a/src/pages/container-infra/containers/ClusterTemplates/Detail/BaseDetail.jsx b/src/pages/container-infra/containers/ClusterTemplates/Detail/BaseDetail.jsx index f1b19d45..56541c4b 100644 --- a/src/pages/container-infra/containers/ClusterTemplates/Detail/BaseDetail.jsx +++ b/src/pages/container-infra/containers/ClusterTemplates/Detail/BaseDetail.jsx @@ -165,13 +165,13 @@ export class BaseDetail extends Base { original_image_id, image: { name: imageName } = {}, keypair_id, + original_keypair_id, flavor_id, original_flavor_id, flavor: { name: flavorName } = {}, master_flavor_id, original_master_flavor_id, masterFlavor: { name: masterFlavorName } = {}, - selfKeypair, } = this.detailData; const imageUrl = original_image_id ? `${original_image_id} (${t('The resource has been deleted')})` @@ -181,12 +181,13 @@ export class BaseDetail extends Base { }) : '-'; - const keypairUrl = - keypair_id && selfKeypair - ? this.getLinkRender('keypairDetail', keypair_id, { - id: keypair_id, - }) - : keypair_id || '-'; + const keypairUrl = original_keypair_id + ? `${original_keypair_id} (${t('The resource has been deleted')})` + : keypair_id + ? this.getLinkRender('keypairDetail', keypair_id, { + id: keypair_id, + }) + : '-'; const flavorUrl = original_flavor_id ? `${original_flavor_id} (${t('The resource has been deleted')})` diff --git a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNetwork/index.jsx b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNetwork/index.jsx index b7953a8c..bd29cb24 100644 --- a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNetwork/index.jsx +++ b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNetwork/index.jsx @@ -106,14 +106,16 @@ export class StepNetwork extends Base { http_proxy, https_proxy, no_proxy, - externalNetwork: { - selectedRowKeys: [external_network_id], - selectedRows: [externalNetwork], - }, dns_nameserver, master_lb_enabled, floating_ip_enabled, }; + if (external_network_id) { + values.externalNetwork = { + selectedRowKeys: [external_network_id], + selectedRows: [externalNetwork], + }; + } if (fixed_network) { values.fixedNetwork = fixedNetworkContext || { selectedRowKeys: [fixed_network], diff --git a/src/pages/container-infra/containers/Clusters/Detail/BaseDetail.jsx b/src/pages/container-infra/containers/Clusters/Detail/BaseDetail.jsx index 01146008..010aeb58 100644 --- a/src/pages/container-infra/containers/Clusters/Detail/BaseDetail.jsx +++ b/src/pages/container-infra/containers/Clusters/Detail/BaseDetail.jsx @@ -101,9 +101,11 @@ export class BaseDetail extends Base { } get miscellaneousCard() { - const { keypair } = this.detailData; + const { original_keypair, keypair } = this.detailData; - const keypairUrl = keypair + const keypairUrl = original_keypair + ? `${original_keypair} (${t('The resource has been deleted')})` + : keypair ? this.getLinkRender('keypairDetail', keypair, { id: keypair, }) diff --git a/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepNodeSpec/index.jsx b/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepNodeSpec/index.jsx index e0c8864e..8c72b9a0 100644 --- a/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepNodeSpec/index.jsx +++ b/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepNodeSpec/index.jsx @@ -93,8 +93,7 @@ export class StepNodeSpec extends Base { const { context: { keypair, masterFlavor, flavor, master_count, node_count } = {}, } = this.props; - const { master_flavor_id, flavor_id, keypair_id, selfKeypair } = - this.templateDetail; + const { master_flavor_id, flavor_id, keypair_id } = this.templateDetail; return { master_count: master_count || 1, @@ -110,7 +109,7 @@ export class StepNodeSpec extends Base { selectedRows: this.flavors.filter((it) => it.id === flavor_id), }, keypair: keypair || { - selectedRowKeys: keypair_id && selfKeypair ? [keypair_id] : [], + selectedRowKeys: keypair_id ? [keypair_id] : [], selectedRows: this.keypairs.filter((it) => it.id === keypair_id), }, }; @@ -121,12 +120,10 @@ export class StepNodeSpec extends Base { context: { clusterTemplate = {}, keypair, masterFlavor, flavor } = {}, } = this.props; const { selectedRows = [] } = clusterTemplate; - const { master_flavor_id, flavor_id, keypair_id, selfKeypair } = - selectedRows[0] || {}; + const { master_flavor_id, flavor_id, keypair_id } = selectedRows[0] || {}; const { initKeyPair = keypair } = this.state; - const templateHasSelfKeypair = keypair_id && selfKeypair; const templateInitKeypair = { - selectedRowKeys: keypair_id && selfKeypair ? [keypair_id] : [], + selectedRowKeys: keypair_id ? [keypair_id] : [], selectedRows: this.keypairs.filter((it) => it.id === keypair_id), }; @@ -148,8 +145,7 @@ export class StepNodeSpec extends Base { type: 'select-table', required: true, data: this.keypairs, - initValue: - initKeyPair || (templateHasSelfKeypair && templateInitKeypair), + initValue: initKeyPair || templateInitKeypair, isLoading: this.keyPairStore.list.isLoading, header: getKeyPairHeader(this), tip: t( diff --git a/src/resources/magnum/template.js b/src/resources/magnum/template.js index 1dffcddf..10ee9d7b 100644 --- a/src/resources/magnum/template.js +++ b/src/resources/magnum/template.js @@ -42,8 +42,8 @@ export const getBaseTemplateColumns = (self) => [ isHideable: true, dataIndex: 'keypair_id', hidden: self.isAdminPage, - render: (value, row) => { - if (value && row.selfKeypair) { + render: (value) => { + if (value) { return self.getLinkRender('keypairDetail', value, { id: value }); } return value || '-'; diff --git a/src/stores/magnum/clusterTemplates.js b/src/stores/magnum/clusterTemplates.js index 32e689bd..17180df0 100644 --- a/src/stores/magnum/clusterTemplates.js +++ b/src/stores/magnum/clusterTemplates.js @@ -92,8 +92,9 @@ export class ClusterTemplatesStore extends Base { const { keypairs = [] } = (await client.nova.keypairs.list()) || {}; return newData.map((it) => { const keypair = keypairs.find((k) => k?.keypair?.name === it.keypair_id); - if (keypair) { - it.selfKeypair = true; + if (!keypair) { + it.original_keypair_id = it.keypair_id; + it.keypair_id = null; } return it; }); @@ -119,8 +120,9 @@ export class ClusterTemplatesStore extends Base { const keypair = keypairs.find( (k) => k?.keypair?.name === item.keypair_id ); - if (keypair) { - item.selfKeypair = true; // Don't need to reset keypair_id to null if not matched + if (!keypair) { + item.original_keypair_id = item.keypair_id; + item.keypair_id = null; } } if (fr.status === 'fulfilled') { diff --git a/src/stores/magnum/clusters.js b/src/stores/magnum/clusters.js index 57a1513d..3ba90ca4 100644 --- a/src/stores/magnum/clusters.js +++ b/src/stores/magnum/clusters.js @@ -61,6 +61,23 @@ export class ClustersStore extends Base { return this.client.resize(id, newbody); } + async listDidFetch(items, _, filters) { + if (!items.length) return items; + const { shouldFetchProject } = filters; + const newData = await this.listDidFetchProject(items, { + all_projects: shouldFetchProject, + }); + const { keypairs = [] } = (await client.nova.keypairs.list()) || {}; + return newData.map((it) => { + const keypair = keypairs.find((k) => k?.keypair?.name === it.keypair); + if (!keypair) { + it.original_keypair = it.keypair; + it.keypair = null; + } + return it; + }); + } + async detailDidFetch(item) { const template = (await this.templateClient.show(item.cluster_template_id)) || {}; @@ -75,13 +92,23 @@ export class ClustersStore extends Base { const masterFlavorId = item.master_flavor_id || templateMasterFlavorId; const fixedNetworkId = item.fixed_network || templateFixedNetworkId; const fixedSubnetId = item.fixed_subnet || templateSubnetId; - const [fr = {}, mfr = {}, fx = {}, sub = {}, stack] = await allSettled([ - flavorId ? this.flavorClient.show(flavorId) : {}, - masterFlavorId ? this.flavorClient.show(masterFlavorId) : {}, - fixedNetworkId ? this.networkClient.show(fixedNetworkId) : {}, - fixedSubnetId ? this.subnetClient.show(fixedSubnetId) : {}, - item.stack_id ? this.stackClient.list({ id: item.stack_id }) : {}, - ]); + const [kp = {}, fr = {}, mfr = {}, fx = {}, sub = {}, stack] = + await allSettled([ + client.nova.keypairs.list(), + flavorId ? this.flavorClient.show(flavorId) : {}, + masterFlavorId ? this.flavorClient.show(masterFlavorId) : {}, + fixedNetworkId ? this.networkClient.show(fixedNetworkId) : {}, + fixedSubnetId ? this.subnetClient.show(fixedSubnetId) : {}, + item.stack_id ? this.stackClient.list({ id: item.stack_id }) : {}, + ]); + if (kp.status === 'fulfilled') { + const { keypairs = [] } = kp.value; + const keypair = keypairs.find((k) => k?.keypair?.name === item.keypair); + if (!keypair) { + item.original_keypair = item.keypair; + item.keypair = null; + } + } if (fr.status === 'fulfilled') { const { flavor } = fr.value; item.flavor = flavor;