From f7ae6ff9d74be432fa9b63e5f4f1b1e4502759c1 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Tue, 22 Nov 2022 15:57:48 +0800 Subject: [PATCH] fix: Fix quick creating keypair in creating instance Use public code for quick creating keypair when create cloud instance. Change-Id: Ib0af8339fa8436ebeee958fd3f653ce0caa88a9d --- .../actions/StepCreate/SystemStep/index.jsx | 51 ++----------------- .../Instance/actions/StepCreate/index.less | 11 ---- 2 files changed, 3 insertions(+), 59 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 2f1bff0d..28ab3878 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import React from 'react'; import { inject, observer } from 'mobx-react'; import globalKeyPairStore from 'stores/nova/keypair'; import globalServerStore from 'stores/nova/instance'; @@ -27,10 +26,8 @@ import { } from 'resources/nova/hypervisor'; import { physicalNodeTypes } from 'resources/nova/instance'; import { getOptions } from 'utils'; -import CreateKeyPair from 'pages/compute/containers/Keypair/actions/Create'; -import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; +import { getKeyPairHeader } from 'resources/nova/keypair'; import { has } from 'lodash'; -import styles from '../index.less'; export class SystemStep extends Base { init() { @@ -184,7 +181,7 @@ export class SystemStep extends Base { allowed = () => Promise.resolve(); async getKeypairs() { - return this.keyPairStore.fetchList(); + await this.keyPairStore.fetchList(); } getHypervisors() { @@ -216,26 +213,6 @@ export class SystemStep extends Base { return this.sourceInfo && this.sourceInfo.os_admin_user; } - onFinishCreateKeyPair = async () => { - const { createdItem } = this.keyPairStore; - const result = await this.getKeypairs(); - const newItem = result.find((it) => it.name === (createdItem || {}).name); - if (newItem) { - const initKeyPair = { - selectedRowKeys: [newItem.id], - selectedRows: [newItem], - }; - this.setState( - { - initKeyPair, - }, - () => { - this.updateDefaultValue(); - } - ); - } - }; - onValuesChange = (changedFields) => { if (has(changedFields, 'serverGroup')) { this.onServerGroupChange(changedFields.serverGroup); @@ -249,28 +226,6 @@ export class SystemStep extends Base { }); }; - getKeyPairHeader() { - const { isLoading } = this.keyPairStore.list || {}; - if (isLoading) { - return null; - } - return ( -
- - {t( - 'The key pair allows you to SSH into your newly created instance. You can select an existing key pair, import a key pair, or generate a new key pair.' - )} - - - - -
- ); - } - get formItems() { const { loginType, more = false, physicalNodeType } = this.state; const isPassword = loginType === this.loginTypes[1].value; @@ -314,7 +269,7 @@ export class SystemStep extends Base { isLoading: this.keyPairStore.list.isLoading, required: !isPassword, hidden: isPassword, - header: this.getKeyPairHeader(), + header: getKeyPairHeader(this), initValue: initKeyPair, tip: t( 'The SSH key is a way to remotely log in to the instance. The cloud platform only helps to keep the public key. Please keep your private key properly.' diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/index.less b/src/pages/compute/containers/Instance/actions/StepCreate/index.less index d25136f1..911b2fe0 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/index.less +++ b/src/pages/compute/containers/Instance/actions/StepCreate/index.less @@ -8,14 +8,3 @@ .number-input { min-width: 165px; } - -.action-wrapper { - margin-left: 8px; - - :global { - .ant-btn-link { - padding: 5.6px 15px !important; - border-color: @primary-color; - } - } -}