From fab8cf703aeb50be7135f217c953f2a17fc3603b Mon Sep 17 00:00:00 2001 From: zhuyue Date: Thu, 2 Sep 2021 17:59:44 +0800 Subject: [PATCH] fix: Fix for magic input with boolean option show & etc. 1. fix for magic input with boolean option show 2. add filter params for security group rule Change-Id: Ibc278779487a3678193749b741f090d2b55e2be9 --- src/components/MagicInput/index.jsx | 7 +++++-- src/resources/security-group-rule.jsx | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/MagicInput/index.jsx b/src/components/MagicInput/index.jsx index a5824827..16bc5de0 100644 --- a/src/components/MagicInput/index.jsx +++ b/src/components/MagicInput/index.jsx @@ -17,7 +17,7 @@ import PropTypes from 'prop-types'; import { Input, Tag, Menu, Divider, Button, Checkbox } from 'antd'; import { CloseOutlined, SearchOutlined } from '@ant-design/icons'; import classnames from 'classnames'; -import { isEmpty } from 'lodash'; +import { isEmpty, isBoolean } from 'lodash'; import styles from './index.less'; const option = PropTypes.shape({ @@ -265,7 +265,10 @@ class MagicInput extends PureComponent { const { options } = filter; let label = value; if (options) { - const current = options.find((item) => item.key === value); + const current = options.find((item) => { + const key = isBoolean(item.key) ? item.key.toString() : item.key; + return key === (isBoolean(value) ? value.toString() : value); + }); label = current ? current.label : value; } return ( diff --git a/src/resources/security-group-rule.jsx b/src/resources/security-group-rule.jsx index f720ca1d..0d895ff8 100644 --- a/src/resources/security-group-rule.jsx +++ b/src/resources/security-group-rule.jsx @@ -113,6 +113,14 @@ export const getSelfColumns = (self) => [ ]; export const filterParams = [ + { + label: t('Remote IP Prefix'), + name: 'remote_ip_prefix', + filterFunc: (record, value) => { + const recordValue = record || '0.0.0.0/0'; + return recordValue.includes(value); + }, + }, { label: t('Direction'), name: 'direction',