From f91454fdcb21be89e806bc13f7a108f0b7415078 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Fri, 15 Apr 2022 15:42:09 +0800 Subject: [PATCH] fix: Fix role list and monitor data and others 1. Fix the role list fetch in user manger and system role 2. Fix the state to get the right data of up and down 3. Add rest attribute for better extension functionality in select component 4. Fix create rule error A recent git update broke our jobs, diskimage-builder was updated to fix 1. This issue but the grenade job doesn't use dib from master (our other jobs do) 2. This commit ensure that our grenade job pulls dib from the git repo Change-Id: I2de592a337e769d1604d72b117fd8a44d5777f58 --- .zuul.yaml | 1 + src/components/FormItem/PortRange/index.jsx | 4 +-- src/components/FormItem/index.jsx | 2 ++ src/locales/en.json | 2 ++ src/locales/zh.json | 2 ++ .../Project/actions/UserGroupManager.jsx | 10 ++++-- .../Project/actions/UserManager.jsx | 6 ++-- .../containers/User/actions/SystemRole.jsx | 6 ++-- .../monitor/containers/Overview/config.jsx | 2 +- .../Detail/Rule/actions/Create.jsx | 35 +++++++++---------- test/e2e/config/config-other.yaml | 4 +-- 11 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index e85a198a..7156d30b 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -212,6 +212,7 @@ - openstack/requirements - openstack/skyline-apiserver - openstack/skyline-console + - opendev.org/openstack/diskimage-builder timeout: 10800 vars: devstack_services: diff --git a/src/components/FormItem/PortRange/index.jsx b/src/components/FormItem/PortRange/index.jsx index cb1cd24b..39bf2e03 100644 --- a/src/components/FormItem/PortRange/index.jsx +++ b/src/components/FormItem/PortRange/index.jsx @@ -33,12 +33,12 @@ export default class index extends Component { placeholder, ...componentProps, }; - const { rules, ...rest } = formItemProps; + const { rules, extra, ...rest } = formItemProps; const newRules = this.getRules(rules); const newFormItemProps = { ...rest, rules: newRules, - extra: portRangeMessage, + extra: extra || portRangeMessage, }; return ( diff --git a/src/components/FormItem/index.jsx b/src/components/FormItem/index.jsx index 33bfa1eb..f3ec7ef1 100644 --- a/src/components/FormItem/index.jsx +++ b/src/components/FormItem/index.jsx @@ -157,6 +157,7 @@ export default class FormItem extends React.Component { checkOptions, checkBoxInfo, allowClear, + ...rest } = this.props; return { options, @@ -171,6 +172,7 @@ export default class FormItem extends React.Component { checkOptions, checkBoxInfo, allowClear, + ...rest, }; } default: { diff --git a/src/locales/en.json b/src/locales/en.json index c3d086df..8b7d57d6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -689,6 +689,7 @@ "Effective mode after configuration changes": "Effective mode after configuration changes", "Egress": "Egress", "Egypt": "Egypt", + "Eject": "Eject", "El Salvador": "El Salvador", "Email": "Email", "Enable": "Enable", @@ -1546,6 +1547,7 @@ "Project User": "Project User", "Project User Group": "Project User Group", "Projects": "Projects", + "Promote": "Promote", "Properties": "Properties", "Protected": "Protected", "Protocol": "Protocol", diff --git a/src/locales/zh.json b/src/locales/zh.json index 79e95cef..687d6115 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -689,6 +689,7 @@ "Effective mode after configuration changes": "配置变更后的生效模式", "Egress": "出口", "Egypt": "埃及", + "Eject": "删除", "El Salvador": "萨尔瓦多", "Email": "邮箱", "Enable": "启用", @@ -1546,6 +1547,7 @@ "Project User": "项目用户", "Project User Group": "项目用户组", "Projects": "项目", + "Promote": "推动", "Properties": "属性", "Protected": "受保护的", "Protocol": "协议", diff --git a/src/pages/identity/containers/Project/actions/UserGroupManager.jsx b/src/pages/identity/containers/Project/actions/UserGroupManager.jsx index b615eb4a..1e4f157b 100644 --- a/src/pages/identity/containers/Project/actions/UserGroupManager.jsx +++ b/src/pages/identity/containers/Project/actions/UserGroupManager.jsx @@ -25,14 +25,14 @@ export class UserGroupManager extends ModalAction { static title = t('Manage User Group'); - init() { + async init() { const roles = JSON.stringify(this.item.groups); this.state.domainDefault = this.item.domain_id; this.state.groupRoles = JSON.parse(roles); this.userGroupStore = new GroupStore(); this.store = globalRoleStore; + await this.getRoleList(); this.getUserGroup(); - this.getRoleList(); } get name() { @@ -48,7 +48,11 @@ export class UserGroupManager extends ModalAction { } getRoleList() { - this.store.fetchList(); + return new Promise((resolve) => { + this.store.fetchList().finally(() => { + resolve(); + }); + }); } static get modalSize() { diff --git a/src/pages/identity/containers/Project/actions/UserManager.jsx b/src/pages/identity/containers/Project/actions/UserManager.jsx index 3785e342..56dbb275 100644 --- a/src/pages/identity/containers/Project/actions/UserManager.jsx +++ b/src/pages/identity/containers/Project/actions/UserManager.jsx @@ -30,20 +30,20 @@ export class UserManager extends ModalAction { return t('Manager user'); } - init() { + async init() { const projectRole = JSON.stringify(this.item.userMapProjectRoles); this.state.domainDefault = this.item.domain_id; this.state.userRoles = JSON.parse(projectRole); this.store = new RoleStore(); this.domainStore = globalDomainStore; this.userStore = new UserStore(); - this.getRoleList(); + await this.getRoleList(); this.getDomains(); this.getUser(); } getRoleList() { - this.store.fetchList(); + return this.store.fetchList(); } getDomains() { diff --git a/src/pages/identity/containers/User/actions/SystemRole.jsx b/src/pages/identity/containers/User/actions/SystemRole.jsx index 6fefb841..55e6a51d 100644 --- a/src/pages/identity/containers/User/actions/SystemRole.jsx +++ b/src/pages/identity/containers/User/actions/SystemRole.jsx @@ -30,20 +30,20 @@ export class SystemRole extends ModalAction { return t('edit system permission'); } - init() { + async init() { const systemRole = JSON.stringify(this.item.projectMapSystemRole); this.state.domainDefault = this.item.domain_id; this.state.projectRoles = JSON.parse(systemRole); this.store = new RoleStore(); this.domainStore = globalDomainStore; this.userStore = globalUserStore; - this.getRoleList(); + await this.getRoleList(); this.getDomains(); this.getUser(); } getRoleList() { - this.store.fetchList(); + return this.store.fetchList(); } getDomains() { diff --git a/src/pages/monitor/containers/Overview/config.jsx b/src/pages/monitor/containers/Overview/config.jsx index 2664a2e6..95efb16c 100644 --- a/src/pages/monitor/containers/Overview/config.jsx +++ b/src/pages/monitor/containers/Overview/config.jsx @@ -169,7 +169,7 @@ export const physicalNodeRightTopCardList = [ ]; const result = get(responses[0], 'data.result', []); result.forEach((r) => { - const idx = r.metric.adminState === 'enabled' ? 0 : 1; + const idx = r.metric.services_state === 'up' ? 0 : 1; status[idx].value += parseInt(r.value[1], 10); }); return status; diff --git a/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx b/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx index 320d67bb..ffbf8989 100644 --- a/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx +++ b/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx @@ -159,8 +159,14 @@ export default class Create extends ModalAction { }); }; + handleDirectionChange = (direction) => { + this.setState({ + direction, + }); + }; + get formItems() { - const { protocol, portOrRange, remoteType } = this.state; + const { protocol, portOrRange, remoteType, direction } = this.state; const isCustomProtocol = protocol === 'custom_protocol'; const isCustomIcmp = protocol === 'custom_icmp'; const showPortType = ['custom_udp', 'custom_tcp'].includes(protocol); @@ -188,6 +194,7 @@ export default class Create extends ModalAction { { value: 'ingress', label: t('Ingress') }, { value: 'egress', label: t('Egress') }, ], + onChange: this.handleDirectionChange, }, { name: 'ethertype', @@ -212,18 +219,16 @@ export default class Create extends ModalAction { }, { name: 'sourcePort', - label: t('Source Port/Port Range'), + label: + direction === 'egress' + ? t('Destination Port/Port Range') + : t('Source Port/Port Range'), type: 'port-range', required: showSourcePort, - hidden: !showSourcePort || this.state.direction === 'egress', - }, - { - name: 'destination_port', - label: t('Destination Port/Port Range'), - type: 'input', - required: showSourcePort, - help: t('Input destination port or port range(example: 80 or 80:160)'), - hidden: !showSourcePort || this.state.direction === 'ingress', + hidden: !showSourcePort, + extra: + direction === 'egress' && + t('Input destination port or port range(example: 80 or 80:160)'), }, { name: 'ipProtocol', @@ -292,8 +297,6 @@ export default class Create extends ModalAction { const { match: { params: { id } = {} } = {} } = containerProps; const { sourcePort, - destination_port, - direction, protocol, ipProtocol, icmpType, @@ -305,10 +308,7 @@ export default class Create extends ModalAction { const range = ['custom_udp', 'custom_tcp'].includes(protocol) && portOrRange === 'range'; - const ports = - values.direction === 'ingress' - ? sourcePort.split(':') - : destination_port.split(':'); + const ports = sourcePort.split(':'); const newProtocol = protocol !== 'custom_protocol' ? this.defaultRules[protocol].ip_protocol @@ -328,7 +328,6 @@ export default class Create extends ModalAction { ? parseInt(ports[1] || ports[0], 10) : null, protocol: newProtocol, - direction, ...rest, }; if (protocol.includes('all')) { diff --git a/test/e2e/config/config-other.yaml b/test/e2e/config/config-other.yaml index df17b908..2d0c528a 100644 --- a/test/e2e/config/config-other.yaml +++ b/test/e2e/config/config-other.yaml @@ -20,8 +20,8 @@ testFiles: # identity - pages/identity/role.spec.js - pages/identity/domain.spec.js - # - pages/identity/user.spec.js - # - pages/identity/project.spec.js + - pages/identity/user.spec.js + - pages/identity/project.spec.js - pages/identity/user-group.spec.js # configuration - pages/configuration/metadata.spec.js