diff --git a/src/components/Popover/Popover.jsx b/src/components/Popover/Popover.jsx index d236e4af..5cb12480 100644 --- a/src/components/Popover/Popover.jsx +++ b/src/components/Popover/Popover.jsx @@ -27,15 +27,21 @@ const getColumn = (column) => { }; }; -function PopupResources({ getRequests, columns }) { +function PopupResources({ getRequests, getData, columns, pagination }) { const [data, setData] = useState([]); const [isLoading, setLoading] = useState(true); useEffect(() => { const fetchData = async () => { - const requests = getRequests(); - const ret = await Promise.all(requests); - setData(ret); - setLoading(false); + if (getData) { + const ret = await getData(); + setData(ret); + setLoading(false); + } else if (getRequests) { + const requests = getRequests(); + const ret = await Promise.all(requests); + setData(ret); + setLoading(false); + } }; fetchData(); }, []); @@ -44,20 +50,37 @@ function PopupResources({ getRequests, columns }) { } const currentColumns = columns.map((c) => getColumn(c)); return ( - +
); } const IPopoverProps = { columns: PropTypes.array.isRequired, - getRequests: PropTypes.func.isRequired, + getRequests: PropTypes.func, + getData: PropTypes.func, + title: PropTypes.any, placement: PropTypes.string, + pagination: PropTypes.any, + icon: PropTypes.any, }; export default function IPopover(props) { - const { columns = [], getRequests, ...rest } = props; + const { + columns = [], + getRequests, + getData, + title, + pagination = false, + icon = , + ...rest + } = props; const content = ( - + ); return ( <> @@ -67,7 +90,7 @@ export default function IPopover(props) { mouseEnterDelay={0.5} {...rest} > - + {title} {icon} ); diff --git a/src/components/Popover/PopoverSubnets.jsx b/src/components/Popover/PopoverSubnets.jsx index b11ebb88..702cf59e 100644 --- a/src/components/Popover/PopoverSubnets.jsx +++ b/src/components/Popover/PopoverSubnets.jsx @@ -17,7 +17,7 @@ import { SubnetStore } from 'stores/neutron/subnet'; import IPopover from './Popover'; export default function PopoverSubnets(props) { - const { subnetIds = [] } = props; + const { subnetIds = [], title = '' } = props; if (!subnetIds.length) { return null; } @@ -34,5 +34,5 @@ export default function PopoverSubnets(props) { title: t('CIDR'), }, ]; - return ; + return ; } diff --git a/src/resources/neutron/network.jsx b/src/resources/neutron/network.jsx index 40c2aa32..21ff1756 100644 --- a/src/resources/neutron/network.jsx +++ b/src/resources/neutron/network.jsx @@ -61,14 +61,11 @@ export const networkColumns = (self) => [ title: t('Subnet Count'), dataIndex: 'subnets', render: (value, record) => { - return ( - <> - {(value && value.length) || 0}{' '} - {value && value.length !== 0 && ( - - )} - - ); + const count = (value || []).length; + if (count === 0) { + return count; + } + return ; }, stringify: (subnets) => `${subnets.length}(${subnets.join(',')})`, sorter: false,