diff --git a/src/components/Popover/Popover.jsx b/src/components/Popover/Popover.jsx
new file mode 100644
index 00000000..b79368f1
--- /dev/null
+++ b/src/components/Popover/Popover.jsx
@@ -0,0 +1,63 @@
+// Copyright 2021 99cloud
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import React, { useEffect, useState } from 'react';
+import { Popover, Spin, Table } from 'antd';
+import { FileTextOutlined } from '@ant-design/icons';
+import PropTypes from 'prop-types';
+
+function PopupResources({ getRequests, columns }) {
+ 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);
+ };
+ fetchData();
+ }, []);
+ if (isLoading) {
+ return ;
+ }
+ return
;
+}
+
+const IPopoverProps = {
+ columns: PropTypes.array.isRequired,
+ getRequests: PropTypes.func.isRequired,
+ placement: PropTypes.string,
+};
+
+export default function IPopover(props) {
+ const { columns = [], getRequests, ...rest } = props;
+ const content = (
+
+ );
+ return (
+ <>
+
+
+
+ >
+ );
+}
+
+IPopover.propTypes = IPopoverProps;
diff --git a/src/components/Popover/PopoverSubnets.jsx b/src/components/Popover/PopoverSubnets.jsx
new file mode 100644
index 00000000..a3b1004a
--- /dev/null
+++ b/src/components/Popover/PopoverSubnets.jsx
@@ -0,0 +1,38 @@
+// Copyright 2021 99cloud
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import React from 'react';
+import { SubnetStore } from 'stores/neutron/subnet';
+import IPopover from './Popover';
+
+export default function PopOverSubnets(props) {
+ const { subnetIds = [] } = props;
+ if (!subnetIds.length) {
+ return null;
+ }
+ const getRequests = () => {
+ return subnetIds.map((i) => new SubnetStore().fetchDetail({ id: i }));
+ };
+ const columns = [
+ {
+ dataIndex: 'name',
+ title: t('Name'),
+ },
+ {
+ dataIndex: 'cidr',
+ title: t('CIDR'),
+ },
+ ];
+ return ;
+}
diff --git a/src/resources/network.jsx b/src/resources/network.jsx
index 117570b7..40c2aa32 100644
--- a/src/resources/network.jsx
+++ b/src/resources/network.jsx
@@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import React, { useEffect, useState } from 'react';
-import { Col, Empty, Popover, Row, Spin } from 'antd';
-import { FileTextOutlined } from '@ant-design/icons';
-import { SubnetStore } from 'stores/neutron/subnet';
+import React from 'react';
+import PopoverSubnets from 'components/Popover/PopoverSubnets';
export const networkStatus = {
ACTIVE: t('Active'),
@@ -63,14 +61,11 @@ export const networkColumns = (self) => [
title: t('Subnet Count'),
dataIndex: 'subnets',
render: (value, record) => {
- const content = ;
return (
<>
{(value && value.length) || 0}{' '}
{value && value.length !== 0 && (
-
-
-
+
)}
>
);
@@ -116,35 +111,6 @@ export const getAnchorData = (num, y) => {
export const isExternalNetwork = (network) => !!network['router:external'];
-function PopUpSubnet({ subnetIds }) {
- const [subnets, setSubnets] = useState(subnetIds);
- const [isLoading, setLoading] = useState(false);
- useEffect(() => {
- setLoading(true);
- (async function () {
- const promises = subnets.map((i) =>
- new SubnetStore().fetchDetail({ id: i })
- );
- const ret = await Promise.all(promises);
- setSubnets(ret);
- setLoading(false);
- })();
- }, []);
- if (isLoading) {
- return ;
- }
- return subnets.length === 0 ? (
-
- ) : (
- subnets.map((item, index) => (
-
- {item.name}
- {item.cidr}
-
- ))
- );
-}
-
export const subnetIpv6Tip = t(
'Default is slaac, for details, see https://docs.openstack.org/neutron/latest/admin/config-ipv6.html'
);