From ac1edd6e9785c45b58a69debab99b9480a696177 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Mon, 28 Nov 2022 16:00:46 +0800 Subject: [PATCH] Fix keypair in magnum 1.The form items value will be resetted, when create a new keypair 2.Same issue when create instance Closes-Bug: #1998077 Change-Id: Ie0021cbddc4c8730d604e4892a8cfa878a5bcb95 --- .../Instance/actions/StepCreate/SystemStep/index.jsx | 5 +---- .../actions/StepCreate/StepNodeSpec/index.jsx | 9 ++------- .../ClusterTemplates/actions/StepCreate/index.jsx | 6 +++--- .../Clusters/actions/StepCreate/StepInfo/index.jsx | 4 ---- src/resources/nova/keypair.jsx | 4 ++-- src/stores/magnum/clusterTemplates.js | 8 +++++++- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx index 28ab3878..d5c55d33 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx @@ -154,10 +154,7 @@ export class SystemStep extends Base { selectedRows: this.serverGroups.filter((it) => it.id === servergroup), }; } - const { initKeyPair, name } = this.state; - if (initKeyPair) { - data.keypair = initKeyPair; - } + const { name } = this.state; if (name) { data.name = name; } diff --git a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNodeSpec/index.jsx b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNodeSpec/index.jsx index b70ac9aa..a683aa50 100644 --- a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNodeSpec/index.jsx +++ b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/StepNodeSpec/index.jsx @@ -102,11 +102,6 @@ export class StepNodeSpec extends Base { get defaultValue() { let values = {}; - const { initKeyPair } = this.state; - if (initKeyPair) { - values.keypairs = initKeyPair; - } - if (this.isEdit) { const { extra: { @@ -134,7 +129,7 @@ export class StepNodeSpec extends Base { values.images = { selectedRowKeys: [image_id] }; } if (keypair_id) { - values.keypairs = { selectedRowKeys: [keypair_id] }; + values.keypair = { selectedRowKeys: [keypair_id] }; } } return values; @@ -169,7 +164,7 @@ export class StepNodeSpec extends Base { columns: this.imageColumns, }, { - name: 'keypairs', + name: 'keypair', label: t('Keypair'), type: 'select-table', data: this.keypairs, diff --git a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/index.jsx b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/index.jsx index d20bccde..c9b8b5c9 100644 --- a/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/index.jsx +++ b/src/pages/container-infra/containers/ClusterTemplates/actions/StepCreate/index.jsx @@ -98,7 +98,7 @@ export class StepCreate extends StepAction { masterFlavor, additionalLabels, images, - keypairs, + keypair, externalNetwork, fixedNetwork, fixedSubnet, @@ -127,8 +127,8 @@ export class StepCreate extends StepAction { if (images) { body.image_id = images.selectedRowKeys[0]; } - if (keypairs) { - body.keypair_id = keypairs.selectedRowKeys[0]; + if (keypair) { + body.keypair_id = keypair.selectedRowKeys[0]; } if (fixedNetwork) { body.fixed_network = fixedNetwork.selectedRowKeys[0]; diff --git a/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepInfo/index.jsx b/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepInfo/index.jsx index 2bd5a971..61a639f0 100644 --- a/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepInfo/index.jsx +++ b/src/pages/container-infra/containers/Clusters/actions/StepCreate/StepInfo/index.jsx @@ -63,10 +63,6 @@ export class StepInfo extends Base { get defaultValue() { const values = {}; - const { initKeyPair } = this.state; - if (initKeyPair) { - values.keypair = initKeyPair; - } const { template } = this.locationParams; if (template) { diff --git a/src/resources/nova/keypair.jsx b/src/resources/nova/keypair.jsx index 4e14e60d..51623127 100644 --- a/src/resources/nova/keypair.jsx +++ b/src/resources/nova/keypair.jsx @@ -17,7 +17,7 @@ import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; import CreateKeyPair from 'pages/compute/containers/Keypair/actions/Create'; import styles from './keypair.less'; -export const getKeyPairHeader = (self) => { +export const getKeyPairHeader = (self, name = 'keypair') => { const onFinishCreateKeyPair = async () => { await self.getKeypairs(); // refresh keypairs const { createdItem } = self.keyPairStore; @@ -34,7 +34,7 @@ export const getKeyPairHeader = (self) => { initKeyPair, }, () => { - self.updateDefaultValue(); + self.updateFormValue(name, newItem); } ); } diff --git a/src/stores/magnum/clusterTemplates.js b/src/stores/magnum/clusterTemplates.js index c32cc1e9..3c49bb63 100644 --- a/src/stores/magnum/clusterTemplates.js +++ b/src/stores/magnum/clusterTemplates.js @@ -15,6 +15,7 @@ import Base from 'stores/base'; import client from 'client'; import { action } from 'mobx'; +import { isBoolean } from 'lodash'; export class ClusterTemplatesStore extends Base { get client() { @@ -43,7 +44,12 @@ export class ClusterTemplatesStore extends Base { ) .map((key) => ({ path: `/${key}`, - value: key === 'labels' ? JSON.stringify(body[key] || {}) : body[key], + value: + key === 'labels' + ? JSON.stringify(body[key] || {}) + : isBoolean(body[key]) + ? `${body[key]}` + : body[key], op: [null, undefined, ''].includes(body[key]) ? 'remove' : 'replace', })); return this.submitting(this.client.patch(id, newBody));