From 250c34433353643f0d3330bf6c1566a5a6f75462 Mon Sep 17 00:00:00 2001 From: yangao Date: Wed, 6 Apr 2022 16:47:30 +0800 Subject: [PATCH] fix: Fix source port/port range 1. When the direction of the security group rule is egress, the following prompt should be the destination port/port range Issue: 126898 Change-Id: I199fe1d9471c06eac1b00f2f0ec245d9dfb4177c --- .../Detail/Rule/actions/Create.jsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 35b416e1..320d67bb 100644 --- a/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx +++ b/src/pages/network/containers/SecurityGroup/Detail/Rule/actions/Create.jsx @@ -215,7 +215,15 @@ export default class Create extends ModalAction { label: t('Source Port/Port Range'), type: 'port-range', required: showSourcePort, - hidden: !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', }, { name: 'ipProtocol', @@ -284,6 +292,8 @@ export default class Create extends ModalAction { const { match: { params: { id } = {} } = {} } = containerProps; const { sourcePort, + destination_port, + direction, protocol, ipProtocol, icmpType, @@ -295,7 +305,10 @@ export default class Create extends ModalAction { const range = ['custom_udp', 'custom_tcp'].includes(protocol) && portOrRange === 'range'; - const ports = sourcePort.split(':'); + const ports = + values.direction === 'ingress' + ? sourcePort.split(':') + : destination_port.split(':'); const newProtocol = protocol !== 'custom_protocol' ? this.defaultRules[protocol].ip_protocol @@ -315,6 +328,7 @@ export default class Create extends ModalAction { ? parseInt(ports[1] || ports[0], 10) : null, protocol: newProtocol, + direction, ...rest, }; if (protocol.includes('all')) {