fix: Fix select table loading in form

Add loading when SelectTable component fetch data

Change-Id: If36411e74304061d305fb61b7954e1e564ce40e1
This commit is contained in:
zhangjingwei 2021-07-18 09:17:09 +08:00 committed by Jingwei.Zhang
parent 4135fc378d
commit 20a309ef83
40 changed files with 145 additions and 19 deletions

View File

@ -125,6 +125,10 @@ export default class SelectTable extends React.Component {
this.sortOrder = props.defaultSortOrder; this.sortOrder = props.defaultSortOrder;
} }
componentDidMount() {
this.getData();
}
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (!isEqual(prevProps.backendPageStore, this.props.backendPageStore)) { if (!isEqual(prevProps.backendPageStore, this.props.backendPageStore)) {
this.getData(); this.getData();

View File

@ -94,6 +94,7 @@ export default class ManageAccess extends ModalAction {
type: 'select-table', type: 'select-table',
isMulti: true, isMulti: true,
required: true, required: true,
isLoading: this.projectStore.list.isLoading,
datas: this.projects, datas: this.projects,
...projectTableOptions, ...projectTableOptions,
}, },

View File

@ -72,6 +72,7 @@ export default class AccessTypeSetting extends Base {
hidden: !showChoose, hidden: !showChoose,
required: showChoose, required: showChoose,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
]; ];

View File

@ -91,6 +91,7 @@ export default class ManageHost extends ModalAction {
type: 'select-table', type: 'select-table',
isMulti: true, isMulti: true,
datas: this.computeHosts, datas: this.computeHosts,
isLoading: globalComputeHostStore.list.isLoading,
filterParams: [ filterParams: [
{ {
label: t('Host'), label: t('Host'),

View File

@ -141,6 +141,7 @@ class CreateForm extends FormAction {
required: this.isAdminPage, required: this.isAdminPage,
hidden: !this.isAdminPage, hidden: !this.isAdminPage,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
{ {
@ -207,6 +208,7 @@ class CreateForm extends FormAction {
isMulti: true, isMulti: true,
hidden: !isShare, hidden: !isShare,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
{ {

View File

@ -92,6 +92,7 @@ export default class ManageAccess extends ModalAction {
isMulti: true, isMulti: true,
required: true, required: true,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
]; ];

View File

@ -40,6 +40,7 @@ export default class AssociateFip extends ModalAction {
canAssociateFloatingIPs: [], canAssociateFloatingIPs: [],
canReachSubnetIdsWithRouterId: [], canReachSubnetIdsWithRouterId: [],
routerIdWithExternalNetworkInfo: [], routerIdWithExternalNetworkInfo: [],
portLoading: true,
}; };
} }
@ -64,6 +65,7 @@ export default class AssociateFip extends ModalAction {
const interfaces = await getInterfaceWithReason(instanceInterfaces); const interfaces = await getInterfaceWithReason(instanceInterfaces);
this.setState({ this.setState({
interfaces, interfaces,
portLoading: false,
}); });
} }
@ -105,7 +107,7 @@ export default class AssociateFip extends ModalAction {
} }
get formItems() { get formItems() {
const { fixed_ip, canAssociateFloatingIPs } = this.state; const { canAssociateFloatingIPs, portLoading, fipLoading } = this.state;
return [ return [
{ {
name: 'instance', name: 'instance',
@ -119,6 +121,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.ports, datas: this.ports,
isLoading: portLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {
@ -153,7 +156,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: canAssociateFloatingIPs, datas: canAssociateFloatingIPs,
hidden: !fixed_ip, isLoading: fipLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -176,6 +176,7 @@ export default class AttachInterface extends ModalAction {
type: 'select-table', type: 'select-table',
required: isManua, required: isManua,
datas: this.subnets, datas: this.subnets,
isLoading: this.subnetStore.list.isLoading,
hidden: !isManua, hidden: !isManua,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [

View File

@ -145,6 +145,10 @@ export default class BaseStep extends Base {
}; };
get formItems() { get formItems() {
const { image } = this.locationParams;
const imageLoading = image
? this.imageStore.isLoading
: this.imageStore.list.isLoading;
return [ return [
{ {
name: 'project', name: 'project',
@ -187,6 +191,7 @@ export default class BaseStep extends Base {
label: t('Operating System'), label: t('Operating System'),
type: 'select-table', type: 'select-table',
datas: this.images, datas: this.images,
isLoading: imageLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -98,6 +98,7 @@ export default class SystemStep extends Base {
label: t('Keypair'), label: t('Keypair'),
type: 'select-table', type: 'select-table',
datas: this.keypairs, datas: this.keypairs,
isLoading: this.keyPairStore.list.isLoading,
isMulti: false, isMulti: false,
required: !isPassword, required: !isPassword,
hidden: isPassword, hidden: isPassword,

View File

@ -29,6 +29,7 @@ export default class DetachInterface extends ModalAction {
init() { init() {
this.store = new ServerStore(); this.store = new ServerStore();
this.getPorts(); this.getPorts();
this.state.portLoading = true;
} }
get name() { get name() {
@ -60,8 +61,11 @@ export default class DetachInterface extends ModalAction {
return portsMap; return portsMap;
} }
getPorts() { async getPorts() {
this.store.fetchInterfaceList({ id: this.item.id }); await this.store.fetchInterfaceList({ id: this.item.id });
this.setState({
portLoading: false,
});
} }
get defaultValue() { get defaultValue() {
@ -82,6 +86,7 @@ export default class DetachInterface extends ModalAction {
); );
get formItems() { get formItems() {
const { portLoading } = this.state;
return [ return [
{ {
name: 'instance', name: 'instance',
@ -95,6 +100,7 @@ export default class DetachInterface extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.ports, datas: this.ports,
isLoading: portLoading,
isMulti: true, isMulti: true,
filterParams: [ filterParams: [
{ {

View File

@ -98,6 +98,7 @@ export default class DetachIsoVolume extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.volumes, datas: this.volumes,
isLoading: this.volumeStore.list.isLoading,
isMulti: true, isMulti: true,
filterParams: [ filterParams: [
{ {

View File

@ -93,6 +93,7 @@ export default class DetachVolume extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.volumes, datas: this.volumes,
isLoading: this.volumeStore.list.isLoading,
filterParams: [ filterParams: [
{ {
label: t('Name'), label: t('Name'),

View File

@ -121,6 +121,9 @@ export default class LiveMigrate extends ModalAction {
label: t('Target Compute Host'), label: t('Target Compute Host'),
type: 'select-table', type: 'select-table',
datas: this.hypervisors, datas: this.hypervisors,
isLoading:
this.hypervisorStore.list.isLoading &&
globalComputeHostStore.list.isLoading,
isMulti: false, isMulti: false,
extra: t( extra: t(
'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.' 'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.'

View File

@ -142,6 +142,8 @@ export default class ManageSecurityGroup extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.ports, datas: this.ports,
isLoading:
this.portStore.list.isLoading && this.portStoreOrigin.list.isLoading,
isMulti: false, isMulti: false,
onChange: this.onPortChange, onChange: this.onPortChange,
filterParams: [ filterParams: [

View File

@ -118,6 +118,9 @@ export default class LiveMigrate extends ModalAction {
label: t('Target Compute Host'), label: t('Target Compute Host'),
type: 'select-table', type: 'select-table',
datas: this.hypervisors, datas: this.hypervisors,
isLoading:
this.hypervisorStore.list.isLoading &&
globalComputeHostStore.list.isLoading,
isMulti: false, isMulti: false,
extra: t( extra: t(
'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.' 'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.'

View File

@ -144,6 +144,7 @@ export default class Rebuild extends ModalAction {
label: t('Operating System'), label: t('Operating System'),
type: 'select-table', type: 'select-table',
datas: this.images, datas: this.images,
isLoading: this.imageStore.list.isLoading,
required: true, required: true,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [

View File

@ -307,6 +307,10 @@ export default class BaseStep extends Base {
}; };
get formItems() { get formItems() {
const { image } = this.locationParams;
const imageLoading = image
? this.imageStore.isLoading
: this.imageStore.list.isLoading;
return [ return [
{ {
name: 'project', name: 'project',
@ -359,6 +363,7 @@ export default class BaseStep extends Base {
label: t('Operating System'), label: t('Operating System'),
type: 'select-table', type: 'select-table',
datas: this.images, datas: this.images,
isLoading: imageLoading,
required: this.sourceTypeIsImage, required: this.sourceTypeIsImage,
isMulti: false, isMulti: false,
hidden: !this.sourceTypeIsImage, hidden: !this.sourceTypeIsImage,
@ -381,6 +386,7 @@ export default class BaseStep extends Base {
label: t('Bootable Volume'), label: t('Bootable Volume'),
type: 'select-table', type: 'select-table',
datas: this.volumes, datas: this.volumes,
isLoading: this.volumeStore.list.isLoading,
required: this.sourceTypeIsVolume, required: this.sourceTypeIsVolume,
isMulti: false, isMulti: false,
hidden: !this.sourceTypeIsVolume, hidden: !this.sourceTypeIsVolume,

View File

@ -216,6 +216,7 @@ export default class SystemStep extends Base {
label: t('Keypair'), label: t('Keypair'),
type: 'select-table', type: 'select-table',
datas: this.keypairs, datas: this.keypairs,
isLoading: this.keyPairStore.list.isLoading,
isMulti: false, isMulti: false,
required: !isPassword, required: !isPassword,
hidden: isPassword, hidden: isPassword,
@ -279,6 +280,7 @@ export default class SystemStep extends Base {
hidden: !this.hasAdminRole || !more || !isManually, hidden: !this.hasAdminRole || !more || !isManually,
required: isManually, required: isManually,
datas: this.hypervisors, datas: this.hypervisors,
isLoading: this.hypervisorStore.list.isLoading,
extra: t( extra: t(
'You can manually specify a physical node to create an instance.' 'You can manually specify a physical node to create an instance.'
), ),
@ -291,6 +293,7 @@ export default class SystemStep extends Base {
type: 'select-table', type: 'select-table',
hidden: !more, hidden: !more,
datas: this.serverGroups, datas: this.serverGroups,
isLoading: this.serverGroupStore.list.isLoading,
extra: t( extra: t(
'Using server groups, you can create cloud hosts on the same/different physical nodes as much as possible to meet the affinity/non-affinity requirements of business applications.' 'Using server groups, you can create cloud hosts on the same/different physical nodes as much as possible to meet the affinity/non-affinity requirements of business applications.'
), ),

View File

@ -332,10 +332,13 @@ export default class FlavorSelectTable extends Component {
render() { render() {
const { value } = this.props; const { value } = this.props;
const isLoading =
this.settingStore.list.isLoading && this.flavorStore.list.isLoading;
const props = { const props = {
columns: this.columns, columns: this.columns,
datas: this.flavors, datas: this.flavors,
tableHeader: this.renderTableHeander(), tableHeader: this.renderTableHeander(),
isLoading,
filterParams: [ filterParams: [
{ {
label: t('Name'), label: t('Name'),

View File

@ -114,6 +114,7 @@ export default class Manage extends ModalAction {
label: t('Resource Types'), label: t('Resource Types'),
type: 'select-table', type: 'select-table',
datas: this.resourceTypes, datas: this.resourceTypes,
isLoading: this.store.resourceTypeLoading,
isMulti: true, isMulti: true,
filterParams: [ filterParams: [
{ {

View File

@ -59,8 +59,8 @@ export default class Edit extends ModalAction {
} }
async getFipAlreadyUsedPorts() { async getFipAlreadyUsedPorts() {
const detail = await globalPortForwardingStore.getFipAlreadyUsedPorts({ const detail = await globalPortForwardingStore.fetchList({
fipID: this.item.fip.id, fipId: this.item.fip.id,
}); });
this.setState({ this.setState({
alreadyUsedPorts: detail || [], alreadyUsedPorts: detail || [],
@ -68,6 +68,9 @@ export default class Edit extends ModalAction {
} }
async getInitialPortFixedIPs() { async getInitialPortFixedIPs() {
this.setState({
fixedIpLoading: true,
});
const { internal_port_id, internal_ip_address } = this.item; const { internal_port_id, internal_ip_address } = this.item;
const portDetail = await globalPortStore.fetchDetail({ const portDetail = await globalPortStore.fetchDetail({
id: internal_port_id, id: internal_port_id,
@ -143,6 +146,9 @@ export default class Edit extends ModalAction {
} }
handlePortSelect = async (data) => { handlePortSelect = async (data) => {
this.setState({
fixedIpLoading: true,
});
const { canReachSubnetIdsWithRouterId } = this.state; const { canReachSubnetIdsWithRouterId } = this.state;
const interfacesWithReason = await getInterfaceWithReason( const interfacesWithReason = await getInterfaceWithReason(
data.selectedRows data.selectedRows
@ -156,6 +162,7 @@ export default class Edit extends ModalAction {
this.setState({ this.setState({
portFixedIPs, portFixedIPs,
fixed_ip_address: undefined, fixed_ip_address: undefined,
fixedIpLoading: false,
}); });
this.formRef.current && this.formRef.current &&
@ -181,7 +188,7 @@ export default class Edit extends ModalAction {
data.internal_port_id = selectedRows[0].id; data.internal_port_id = selectedRows[0].id;
return globalPortForwardingStore.edit( return globalPortForwardingStore.edit(
{ {
fipID: this.item.fip.id, fipId: this.item.fip.id,
id: this.item.id, id: this.item.id,
}, },
data data

View File

@ -39,7 +39,7 @@ export default class PortForwarding extends Base {
updateFetchParams = (params) => { updateFetchParams = (params) => {
const { id, all_projects, ...rest } = params; const { id, all_projects, ...rest } = params;
return { return {
fipID: id, fipId: id,
fipInfo: this.props.detail, fipInfo: this.props.detail,
...rest, ...rest,
}; };

View File

@ -116,6 +116,20 @@ export default class Associate extends ModalAction {
}; };
handleInstanceSelect = async (data) => { handleInstanceSelect = async (data) => {
this.setState({
instanceLoading: true,
});
if (data.selectedRows.length === 0) {
this.setState({
instanceFixedIPs: interfacesWithReasons,
instanceLoading: false,
});
return Promise.resolve().then(() => {
this.formRef.current.setFieldsValue({
port: null,
});
});
}
const { id } = data.selectedRows[0]; const { id } = data.selectedRows[0];
// interface // interface
const instanceInterfaces = await globalServerStore.fetchInterfaceList({ const instanceInterfaces = await globalServerStore.fetchInterfaceList({
@ -130,6 +144,7 @@ export default class Associate extends ModalAction {
); );
this.setState({ this.setState({
instanceFixedIPs: interfacesWithReasons, instanceFixedIPs: interfacesWithReasons,
instanceLoading: false,
}); });
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
this.formRef.current.setFieldsValue({ this.formRef.current.setFieldsValue({
@ -139,6 +154,9 @@ export default class Associate extends ModalAction {
}; };
handlePortSelect = async (data) => { handlePortSelect = async (data) => {
this.setState({
fixedIpLoading: true,
});
const { canReachSubnetIdsWithRouterId } = this.state; const { canReachSubnetIdsWithRouterId } = this.state;
const interfacesWithReason = await getInterfaceWithReason( const interfacesWithReason = await getInterfaceWithReason(
data.selectedRows data.selectedRows
@ -151,6 +169,7 @@ export default class Associate extends ModalAction {
this.setState({ this.setState({
portFixedIPs, portFixedIPs,
fixedIpLoading: false,
}); });
return Promise.resolve().then(() => { return Promise.resolve().then(() => {
this.formRef.current.setFieldsValue({ this.formRef.current.setFieldsValue({
@ -200,7 +219,11 @@ export default class Associate extends ModalAction {
get formItems() { get formItems() {
// console.log(toJS(this.store.list.data)); // console.log(toJS(this.store.list.data));
const { resourceType = 'instance', instanceFixedIPs } = this.state; const {
resourceType = 'instance',
instanceFixedIPs,
instanceLoading,
} = this.state;
const ret = [ const ret = [
{ {
name: 'floatingIp', name: 'floatingIp',
@ -239,6 +262,7 @@ export default class Associate extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: instanceFixedIPs, datas: instanceFixedIPs,
isLoading: instanceLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -54,8 +54,8 @@ export default class CreateDNAT extends ModalAction {
} }
async getFipAlreadyUsedPorts() { async getFipAlreadyUsedPorts() {
const detail = await globalPortForwardingStore.getFipAlreadyUsedPorts({ const detail = await globalPortForwardingStore.fetchList({
fipID: this.item.id, fipId: this.item.id,
}); });
this.setState({ this.setState({
alreadyUsedPorts: detail || [], alreadyUsedPorts: detail || [],
@ -85,6 +85,9 @@ export default class CreateDNAT extends ModalAction {
} }
handlePortSelect = async (data) => { handlePortSelect = async (data) => {
this.setState({
fixedIpLoading: true,
});
const { canReachSubnetIdsWithRouterId } = this.state; const { canReachSubnetIdsWithRouterId } = this.state;
const interfacesWithReason = await getInterfaceWithReason( const interfacesWithReason = await getInterfaceWithReason(
data.selectedRows data.selectedRows
@ -98,6 +101,7 @@ export default class CreateDNAT extends ModalAction {
this.setState({ this.setState({
portFixedIPs, portFixedIPs,
fixed_ip_address: undefined, fixed_ip_address: undefined,
fixedIpLoading: false,
}); });
this.formRef.current && this.formRef.current &&

View File

@ -38,6 +38,7 @@ export default class AssociateFip extends ModalAction {
portFixedIPs: [], portFixedIPs: [],
canAssociateFloatingIPs: [], canAssociateFloatingIPs: [],
canReachSubnetIdsWithRouterId: [], canReachSubnetIdsWithRouterId: [],
portLoading: true,
}; };
} }
@ -69,6 +70,7 @@ export default class AssociateFip extends ModalAction {
const interfaces = await getInterfaceWithReason(buildInterfaces); const interfaces = await getInterfaceWithReason(buildInterfaces);
this.setState({ this.setState({
interfaces, interfaces,
portLoading: false,
}); });
} }
@ -107,7 +109,7 @@ export default class AssociateFip extends ModalAction {
}; };
get formItems() { get formItems() {
const { fixed_ip, canAssociateFloatingIPs } = this.state; const { canAssociateFloatingIPs, portLoading, fipLoading } = this.state;
return [ return [
{ {
name: 'lb', name: 'lb',
@ -121,6 +123,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.ports, datas: this.ports,
isLoading: portLoading,
disabledFunc: (record) => !record.available, disabledFunc: (record) => !record.available,
onChange: this.handleFixedIPChange, onChange: this.handleFixedIPChange,
isMulti: false, isMulti: false,
@ -151,7 +154,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: canAssociateFloatingIPs, datas: canAssociateFloatingIPs,
hidden: !fixed_ip, isLoading: fipLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -104,6 +104,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.fipList, datas: this.fipList,
isLoading: this.floatingIpStore.list.isLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -101,6 +101,7 @@ export default class ConnectSubnet extends ModalAction {
}; };
get formItems() { get formItems() {
const { networkId } = this.state;
return [ return [
{ {
name: 'name', name: 'name',
@ -120,6 +121,7 @@ export default class ConnectSubnet extends ModalAction {
label: t('Subnet'), label: t('Subnet'),
type: 'select-table', type: 'select-table',
datas: this.subnets, datas: this.subnets,
isLoading: networkId && this.subnetStore.list.isLoading,
disabledFunc: this.disabledFuncSubnet, disabledFunc: this.disabledFuncSubnet,
required: true, required: true,
filterParams: [ filterParams: [

View File

@ -118,6 +118,7 @@ export default class Create extends ModalAction {
label: t('Availability Zone Hints'), label: t('Availability Zone Hints'),
type: 'select-table', type: 'select-table',
datas: this.aZones, datas: this.aZones,
isLoading: globalNeutronStore.zoneLoading,
isMulti: true, isMulti: true,
filterParams: [ filterParams: [
{ {

View File

@ -33,6 +33,7 @@ export default class DisconnectSubnet extends ModalAction {
this.subnetStore = globalSubnetStore; this.subnetStore = globalSubnetStore;
this.portStore = new PortStore(); this.portStore = new PortStore();
this.getSubnetList(); this.getSubnetList();
this.state.subnetLoading = true;
} }
static policy = 'remove_router_interface'; static policy = 'remove_router_interface';
@ -83,13 +84,14 @@ export default class DisconnectSubnet extends ModalAction {
}); });
this.setState({ this.setState({
subnets: subnets.map((it) => toJS(it)), subnets: subnets.map((it) => toJS(it)),
subnetLoading: false,
}); });
} }
static allowed = () => Promise.resolve(true); static allowed = () => Promise.resolve(true);
get formItems() { get formItems() {
const { subnets = [] } = this.state; const { subnets = [], subnetLoading } = this.state;
return [ return [
{ {
name: 'name', name: 'name',
@ -102,6 +104,7 @@ export default class DisconnectSubnet extends ModalAction {
label: t('Subnet'), label: t('Subnet'),
type: 'select-table', type: 'select-table',
datas: subnets, datas: subnets,
isLoading: subnetLoading,
required: true, required: true,
filterParams: [ filterParams: [
{ {

View File

@ -54,12 +54,16 @@ export default class Create extends ModalAction {
this.state = { this.state = {
subnets: [], subnets: [],
type: 'subnet', type: 'subnet',
subnetLoading: true,
}; };
this.getAllSubnets(); this.getAllSubnets();
} }
async getAllSubnets() { async getAllSubnets() {
this.allSubnets = await this.subnetStore.pureFetchList(); this.allSubnets = await this.subnetStore.pureFetchList();
this.setState({
subnetLoading: false,
});
} }
get defaultValue() { get defaultValue() {
@ -87,18 +91,22 @@ export default class Create extends ModalAction {
}; };
handleRouterChange = async (value) => { handleRouterChange = async (value) => {
this.setState({
subnetLoading: true,
});
const ports = await getPortsWithFixedIPs(); const ports = await getPortsWithFixedIPs();
const allSubnets = getSubnetToRouter(ports, value.selectedRows, false); const allSubnets = getSubnetToRouter(ports, value.selectedRows, false);
this.setState({ this.setState({
subnets: this.allSubnets.filter((item) => { subnets: this.allSubnets.filter((item) => {
return allSubnets.findIndex((i) => i.subnet_id === item.id) > -1; return allSubnets.findIndex((i) => i.subnet_id === item.id) > -1;
}), }),
subnetLoading: false,
}); });
this.formRef.current.resetFields(['subnet_id']); this.formRef.current.resetFields(['subnet_id']);
}; };
get formItems() { get formItems() {
const { subnets, type } = this.state; const { subnets, type, subnetLoading } = this.state;
const isLocal = type === 'subnet'; const isLocal = type === 'subnet';
return [ return [
@ -151,6 +159,7 @@ export default class Create extends ModalAction {
label: t('Subnet'), label: t('Subnet'),
type: 'select-table', type: 'select-table',
datas: subnets, datas: subnets,
isLoading: subnetLoading,
isMulti: true, isMulti: true,
columns: [ columns: [
{ {

View File

@ -38,6 +38,7 @@ export default class AssociateFip extends ModalAction {
fixed_ip: null, fixed_ip: null,
canAssociateFloatingIPs: [], canAssociateFloatingIPs: [],
canReachSubnetIdsWithRouterId: [], canReachSubnetIdsWithRouterId: [],
portLoading: true,
}; };
} }
@ -46,6 +47,7 @@ export default class AssociateFip extends ModalAction {
const interfaces = await getInterfaceWithReason(buildInterfaces); const interfaces = await getInterfaceWithReason(buildInterfaces);
this.setState({ this.setState({
interfaces, interfaces,
portLoading: false,
}); });
} }
@ -104,7 +106,7 @@ export default class AssociateFip extends ModalAction {
}; };
get formItems() { get formItems() {
const { fixed_ip, canAssociateFloatingIPs } = this.state; const { canAssociateFloatingIPs, portLoading, fipLoading } = this.state;
return [ return [
{ {
name: 'virtualAdapter', name: 'virtualAdapter',
@ -118,6 +120,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.ports, datas: this.ports,
isLoading: portLoading,
disabledFunc: (record) => !record.available, disabledFunc: (record) => !record.available,
onChange: this.handleFixedIPChange, onChange: this.handleFixedIPChange,
isMulti: false, isMulti: false,
@ -148,7 +151,7 @@ export default class AssociateFip extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: canAssociateFloatingIPs, datas: canAssociateFloatingIPs,
hidden: !fixed_ip, isLoading: fipLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -265,6 +265,7 @@ export default class CreateAction extends ModalAction {
'The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)' 'The security group is similar to the firewall function for setting up network access control, or you can go to the console and create a new security group. (Note: The security group you selected will work on all virtual LANS on the instances.)'
), ),
datas: this.securityGroups, datas: this.securityGroups,
isLoading: this.securityGroupStore.list.isLoading,
extraParams: { project_id: this.currentProjectId }, extraParams: { project_id: this.currentProjectId },
backendPageStore: this.securityGroupStore, backendPageStore: this.securityGroupStore,
isMulti: true, isMulti: true,

View File

@ -361,6 +361,7 @@ export default class Create extends FormAction {
label: t('Operating System'), label: t('Operating System'),
type: 'select-table', type: 'select-table',
datas: this.images, datas: this.images,
isLoading: this.imageStore.list.isLoading,
required: this.sourceTypeIsImage, required: this.sourceTypeIsImage,
isMulti: false, isMulti: false,
hidden: !this.sourceTypeIsImage, hidden: !this.sourceTypeIsImage,
@ -434,6 +435,7 @@ export default class Create extends FormAction {
), ),
...volumeTypeSelectProps, ...volumeTypeSelectProps,
datas: this.volumeTypes, datas: this.volumeTypes,
isLoading: this.volumeTypeStore.list.isLoading,
required: true, required: true,
extra: this.getVolumeTypeExtra(), extra: this.getVolumeTypeExtra(),
onChange: this.onVolumeTypeChange, onChange: this.onVolumeTypeChange,

View File

@ -30,7 +30,7 @@ export default class Migrate extends ModalAction {
return 'large'; return 'large';
} }
get modalSize() { getModalSize() {
return 'large'; return 'large';
} }
@ -89,6 +89,7 @@ export default class Migrate extends ModalAction {
type: 'select-table', type: 'select-table',
required: true, required: true,
datas: this.pools, datas: this.pools,
isLoading: this.poolStore.list.isLoading,
disabledFunc: this.disableFunc, disabledFunc: this.disableFunc,
rowKey: 'name', rowKey: 'name',
columns: poolColumns, columns: poolColumns,

View File

@ -148,6 +148,7 @@ export default class Create extends ModalAction {
isMulti: true, isMulti: true,
hidden: isPublic, hidden: isPublic,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
]; ];

View File

@ -113,6 +113,7 @@ export default class ManageAccess extends ModalAction {
isMulti: true, isMulti: true,
hidden: isPublic, hidden: isPublic,
datas: this.projects, datas: this.projects,
isLoading: this.projectStore.list.isLoading,
...projectTableOptions, ...projectTableOptions,
}, },
]; ];

View File

@ -79,6 +79,7 @@ export default class ManageQos extends ModalAction {
type: 'select-table', type: 'select-table',
required: false, required: false,
datas: this.QosMap, datas: this.QosMap,
isLoading: this.store.list.isLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {

View File

@ -258,7 +258,17 @@ export async function getFipsFromRouterId(router) {
} }
export async function handleFixedIPChange(e) { export async function handleFixedIPChange(e) {
this.setState({
fipLoading: true,
});
const { canReachSubnetIdsWithRouterId } = this.state; const { canReachSubnetIdsWithRouterId } = this.state;
if (!e.selectedRows.length) {
this.setState({
fixed_ip: null,
canAssociateFloatingIPs: [],
fipLoading: false,
});
}
const item = e.selectedRows[0]; const item = e.selectedRows[0];
const totalFips = []; const totalFips = [];
// 考虑单subnet连接多个路由并且路由开启了不同的公网网关。 // 考虑单subnet连接多个路由并且路由开启了不同的公网网关。
@ -280,5 +290,6 @@ export async function handleFixedIPChange(e) {
this.setState({ this.setState({
fixed_ip: item, fixed_ip: item,
canAssociateFloatingIPs: norepeatFips, canAssociateFloatingIPs: norepeatFips,
fipLoading: false,
}); });
} }

View File

@ -84,7 +84,7 @@ export function getPortsAndReasons(
} }
export function getPortFormItem(device_owner) { export function getPortFormItem(device_owner) {
const { portFixedIPs } = this.state; const { portFixedIPs, fixedIpLoading } = this.state;
return [ return [
{ {
name: 'virtual_adapter', name: 'virtual_adapter',
@ -151,6 +151,7 @@ export function getPortFormItem(device_owner) {
rowKey: 'fixed_ip_address', rowKey: 'fixed_ip_address',
required: true, required: true,
datas: portFixedIPs, datas: portFixedIPs,
isLoading: fixedIpLoading,
isMulti: false, isMulti: false,
filterParams: [ filterParams: [
{ {