fix: Fix the search filters

1. Add search filters of baremetal node list
2. Use public function getOptions to format some select options

Change-Id: I2952878ab21656364031db0216a32879ce87862c
This commit is contained in:
xusongfu 2022-02-21 14:40:37 +08:00
parent 4f7dec52bd
commit 438772f6f3
12 changed files with 41 additions and 58 deletions

View File

@ -17,6 +17,7 @@ import Base from 'containers/List';
import globalIronicStore from 'stores/ironic/ironic'; import globalIronicStore from 'stores/ironic/ironic';
import { powerState, provisioningState } from 'resources/ironic'; import { powerState, provisioningState } from 'resources/ironic';
import { ironicOriginEndpoint } from 'client/client/constants'; import { ironicOriginEndpoint } from 'client/client/constants';
import { getOptions } from 'utils';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -99,7 +100,22 @@ export default class BareMetalNode extends Base {
]; ];
get searchFilters() { get searchFilters() {
return []; return [
{
label: t('Name'),
name: 'name',
},
{
label: t('Power State'),
name: 'power_state',
options: getOptions(powerState),
},
{
label: t('Provision State'),
name: 'provision_state',
options: getOptions(provisioningState),
},
];
} }
updateFetchParams = (params) => { updateFetchParams = (params) => {

View File

@ -17,6 +17,7 @@ import Base from 'containers/List';
import { serviceStatus, serviceState } from 'resources/service'; import { serviceStatus, serviceState } from 'resources/service';
import globalComputeHostStore from 'stores/nova/compute-host'; import globalComputeHostStore from 'stores/nova/compute-host';
import { onlyAdminCanReadPolicy } from 'resources/policy'; import { onlyAdminCanReadPolicy } from 'resources/policy';
import { getOptions } from 'utils';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -94,18 +95,12 @@ export default class ComputeHost extends Base {
{ {
label: t('Service Status'), label: t('Service Status'),
name: 'status', name: 'status',
options: Object.keys(serviceStatus).map((key) => ({ options: getOptions(serviceStatus),
key,
label: serviceStatus[key],
})),
}, },
{ {
label: t('Service State'), label: t('Service State'),
name: 'state', name: 'state',
options: Object.keys(serviceState).map((key) => ({ options: getOptions(serviceState),
key,
label: serviceState[key],
})),
}, },
]; ];
} }

View File

@ -189,10 +189,7 @@ export class Image extends Base {
{ {
label: t('Status'), label: t('Status'),
name: 'status', name: 'status',
options: Object.keys(imageStatus).map((key) => ({ options: getOptions(imageStatus),
key,
label: imageStatus[key],
})),
}, },
]; ];
const values = ['public', 'shared']; const values = ['public', 'shared'];

View File

@ -22,6 +22,7 @@ import Base from 'components/Form';
import { getPasswordOtherRule, asciiValidator } from 'utils/validate'; import { getPasswordOtherRule, asciiValidator } from 'utils/validate';
import { hypervisorColumns, hypervisorFilters } from 'resources/hypervisor'; import { hypervisorColumns, hypervisorFilters } from 'resources/hypervisor';
import { physicalNodeTypes } from 'resources/instance'; import { physicalNodeTypes } from 'resources/instance';
import { getOptions } from 'utils';
export class SystemStep extends Base { export class SystemStep extends Base {
init() { init() {
@ -319,10 +320,7 @@ export class SystemStep extends Base {
{ {
label: t('Policy'), label: t('Policy'),
name: 'policy', name: 'policy',
options: Object.keys(policyType).map((key) => ({ options: getOptions(policyType),
key,
label: policyType[key],
})),
}, },
], ],
}, },

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import globalServerGroupStore from 'stores/nova/server-group'; import globalServerGroupStore from 'stores/nova/server-group';
import policyType from 'resources/server-group'; import policyType from 'resources/server-group';
import { getOptions } from 'utils';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -80,10 +81,7 @@ export default class ServerGroup extends Base {
{ {
label: t('Policy'), label: t('Policy'),
name: 'policy', name: 'policy',
options: Object.keys(policyType).map((key) => ({ options: getOptions(policyType),
key,
label: policyType[key],
})),
}, },
]; ];
} }

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { serviceStatus, serviceState } from 'resources/service'; import { serviceStatus, serviceState } from 'resources/service';
import globalServiceStore from 'stores/cinder/service'; import globalServiceStore from 'stores/cinder/service';
import { getOptions } from 'utils';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -93,18 +94,12 @@ export default class CinderService extends Base {
{ {
label: t('Service Status'), label: t('Service Status'),
name: 'status', name: 'status',
options: Object.keys(serviceStatus).map((key) => ({ options: getOptions(serviceStatus),
label: serviceStatus[key],
key,
})),
}, },
{ {
label: t('Service State'), label: t('Service State'),
name: 'state', name: 'state',
options: Object.keys(serviceState).map((key) => ({ options: getOptions(serviceState),
label: serviceState[key],
key,
})),
}, },
]; ];
} }

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { serviceStatus, serviceState } from 'resources/service'; import { serviceStatus, serviceState } from 'resources/service';
import { ComputeHostStore } from 'stores/nova/compute-host'; import { ComputeHostStore } from 'stores/nova/compute-host';
import { getOptions } from 'utils';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -94,18 +95,12 @@ export default class ComputeService extends Base {
{ {
label: t('Service Status'), label: t('Service Status'),
name: 'status', name: 'status',
options: Object.keys(serviceStatus).map((key) => ({ options: getOptions(serviceStatus),
label: serviceStatus[key],
key,
})),
}, },
{ {
label: t('Service State'), label: t('Service State'),
name: 'state', name: 'state',
options: Object.keys(serviceState).map((key) => ({ options: getOptions(serviceState),
label: serviceState[key],
key,
})),
}, },
]; ];
} }

View File

@ -15,7 +15,7 @@
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { serviceState } from 'resources/service'; import { serviceState } from 'resources/service';
import { getOptions } from 'utils';
import globalHeatServiceStore from 'stores/heat/service'; import globalHeatServiceStore from 'stores/heat/service';
@inject('rootStore') @inject('rootStore')
@ -74,10 +74,7 @@ export default class HeatService extends Base {
{ {
label: t('Status'), label: t('Status'),
name: 'status', name: 'status',
options: Object.keys(serviceState).map((key) => ({ options: getOptions(serviceState),
label: serviceState[key],
key,
})),
}, },
]; ];
} }

View File

@ -22,6 +22,7 @@ import { Col, Popover, Row } from 'antd';
import { FileTextOutlined } from '@ant-design/icons'; import { FileTextOutlined } from '@ant-design/icons';
import { qosEndpoint } from 'client/client/constants'; import { qosEndpoint } from 'client/client/constants';
import { enablePFW } from 'resources/neutron'; import { enablePFW } from 'resources/neutron';
import { getOptions } from 'utils';
import styles from './styles.less'; import styles from './styles.less';
import actionConfigs from './actions'; import actionConfigs from './actions';
@ -222,10 +223,7 @@ export class FloatingIps extends Base {
{ {
label: t('Status'), label: t('Status'),
name: 'status', name: 'status',
options: Object.keys(floatingIpStatus).map((key) => ({ options: getOptions(floatingIpStatus),
label: floatingIpStatus[key],
key,
})),
}, },
]; ];
return filters; return filters;

View File

@ -17,6 +17,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { portStatus } from 'resources/port'; import { portStatus } from 'resources/port';
import { PortStore } from 'stores/neutron/port'; import { PortStore } from 'stores/neutron/port';
import { getOptions } from 'utils';
@inject('rootStore') @inject('rootStore')
@observer @observer
@ -109,10 +110,7 @@ export default class Ports extends Base {
{ {
label: t('Status'), label: t('Status'),
name: 'status', name: 'status',
options: Object.keys(portStatus).map((key) => ({ options: getOptions(portStatus),
label: portStatus[key],
key,
})),
}, },
]; ];
} }

View File

@ -15,6 +15,7 @@
import React from 'react'; import React from 'react';
import globalRouterStore from 'stores/neutron/router'; import globalRouterStore from 'stores/neutron/router';
import { getPortsWithFixedIPs, getSubnetToRouter } from 'resources/floatingip'; import { getPortsWithFixedIPs, getSubnetToRouter } from 'resources/floatingip';
import { getOptions } from 'utils';
export const routerStatus = { export const routerStatus = {
ACTIVE: t('Active'), ACTIVE: t('Active'),
@ -87,10 +88,7 @@ export const routerFilters = [
{ {
label: t('Status'), label: t('Status'),
name: 'status', name: 'status',
options: Object.keys(routerStatus).map((key) => ({ options: getOptions(routerStatus),
label: routerStatus[key],
key,
})),
}, },
]; ];

View File

@ -14,6 +14,7 @@
import React from 'react'; import React from 'react';
import { isNumber } from 'lodash'; import { isNumber } from 'lodash';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { getOptions } from 'utils';
export const ipProtocols = [ export const ipProtocols = [
{ value: 'ah', label: t('AH') }, { value: 'ah', label: t('AH') },
@ -114,10 +115,7 @@ export const filterParams = [
{ {
label: t('Direction'), label: t('Direction'),
name: 'direction', name: 'direction',
options: Object.keys(directions).map((key) => ({ options: getOptions(directions),
label: directions[key],
key,
})),
}, },
{ {
label: t('Ether Type'), label: t('Ether Type'),