fix: Fix quick creating keypair in creating instance
Use public code for quick creating keypair when create cloud instance. Change-Id: Ib0af8339fa8436ebeee958fd3f653ce0caa88a9d
This commit is contained in:
parent
a0ec4f5f7c
commit
f7ae6ff9d7
@ -12,7 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import globalKeyPairStore from 'stores/nova/keypair';
|
import globalKeyPairStore from 'stores/nova/keypair';
|
||||||
import globalServerStore from 'stores/nova/instance';
|
import globalServerStore from 'stores/nova/instance';
|
||||||
@ -27,10 +26,8 @@ import {
|
|||||||
} from 'resources/nova/hypervisor';
|
} from 'resources/nova/hypervisor';
|
||||||
import { physicalNodeTypes } from 'resources/nova/instance';
|
import { physicalNodeTypes } from 'resources/nova/instance';
|
||||||
import { getOptions } from 'utils';
|
import { getOptions } from 'utils';
|
||||||
import CreateKeyPair from 'pages/compute/containers/Keypair/actions/Create';
|
import { getKeyPairHeader } from 'resources/nova/keypair';
|
||||||
import ItemActionButtons from 'components/Tables/Base/ItemActionButtons';
|
|
||||||
import { has } from 'lodash';
|
import { has } from 'lodash';
|
||||||
import styles from '../index.less';
|
|
||||||
|
|
||||||
export class SystemStep extends Base {
|
export class SystemStep extends Base {
|
||||||
init() {
|
init() {
|
||||||
@ -184,7 +181,7 @@ export class SystemStep extends Base {
|
|||||||
allowed = () => Promise.resolve();
|
allowed = () => Promise.resolve();
|
||||||
|
|
||||||
async getKeypairs() {
|
async getKeypairs() {
|
||||||
return this.keyPairStore.fetchList();
|
await this.keyPairStore.fetchList();
|
||||||
}
|
}
|
||||||
|
|
||||||
getHypervisors() {
|
getHypervisors() {
|
||||||
@ -216,26 +213,6 @@ export class SystemStep extends Base {
|
|||||||
return this.sourceInfo && this.sourceInfo.os_admin_user;
|
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) => {
|
onValuesChange = (changedFields) => {
|
||||||
if (has(changedFields, 'serverGroup')) {
|
if (has(changedFields, 'serverGroup')) {
|
||||||
this.onServerGroupChange(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 (
|
|
||||||
<div style={{ marginBottom: 10 }}>
|
|
||||||
<span>
|
|
||||||
{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.'
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<span className={styles['action-wrapper']}>
|
|
||||||
<ItemActionButtons
|
|
||||||
actions={{ moreActions: [{ action: CreateKeyPair }] }}
|
|
||||||
onFinishAction={this.onFinishCreateKeyPair}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { loginType, more = false, physicalNodeType } = this.state;
|
const { loginType, more = false, physicalNodeType } = this.state;
|
||||||
const isPassword = loginType === this.loginTypes[1].value;
|
const isPassword = loginType === this.loginTypes[1].value;
|
||||||
@ -314,7 +269,7 @@ export class SystemStep extends Base {
|
|||||||
isLoading: this.keyPairStore.list.isLoading,
|
isLoading: this.keyPairStore.list.isLoading,
|
||||||
required: !isPassword,
|
required: !isPassword,
|
||||||
hidden: isPassword,
|
hidden: isPassword,
|
||||||
header: this.getKeyPairHeader(),
|
header: getKeyPairHeader(this),
|
||||||
initValue: initKeyPair,
|
initValue: initKeyPair,
|
||||||
tip: t(
|
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.'
|
'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.'
|
||||||
|
@ -8,14 +8,3 @@
|
|||||||
.number-input {
|
.number-input {
|
||||||
min-width: 165px;
|
min-width: 165px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-wrapper {
|
|
||||||
margin-left: 8px;
|
|
||||||
|
|
||||||
:global {
|
|
||||||
.ant-btn-link {
|
|
||||||
padding: 5.6px 15px !important;
|
|
||||||
border-color: @primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user