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
This commit is contained in:
xusongfu 2022-11-28 16:00:46 +08:00
parent 8401c5b546
commit ac1edd6e97
6 changed files with 15 additions and 21 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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];

View File

@ -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) {

View File

@ -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);
}
);
}

View File

@ -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));