fix keypair showing in magnum service

If the keypair was deleted, show xxx (the resource has been deleted)

Closes-Bug: #2004545
Change-Id: Ibe812917fbdd158a167c18abd2ac5713f743f9c4
This commit is contained in:
xusongfu 2023-02-02 18:13:23 +08:00
parent 021bde48ef
commit c5953f174a
7 changed files with 65 additions and 35 deletions

View File

@ -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')})`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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