// 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 { observer, inject } from 'mobx-react';
import { VirtualAdapterStore } from 'stores/neutron/virtual-adapter';
import { Button, Table, Collapse, Divider, Col, Row, Spin, Empty } from 'antd';
import ManageSecurityGroup from 'pages/network/containers/VirtualAdapter/actions/ManageSecurityGroup';
import { Link } from 'react-router-dom';
import classnames from 'classnames';
import { toJS } from 'mobx';
import { CaretRightOutlined } from '@ant-design/icons';
import PrimaryActionButtons from 'components/Tables/Base/PrimaryActionButtons';
import ItemActionButtons from 'components/Tables/Base/ItemActionButtons';
import { getSelfColumns } from 'resources/security-group-rule';
import { isAdminPage } from 'utils/index';
import { getPath } from 'utils/route-map';
import Detach from './actions/Detach';
import styles from './index.less';
const { Panel } = Collapse;
export class SecurityGroup extends React.Component {
constructor(props) {
super(props);
this.store = new VirtualAdapterStore();
}
componentDidMount() {
this.refreshSecurityGroup();
}
getDetailUrl(id) {
const key = this.isAdminPage
? 'securityGroupDetailAdmin'
: 'securityGroupDetail';
return getPath({ key, params: { id } });
}
get portId() {
const {
detail: { id },
} = this.props;
return id;
}
get isAdminPage() {
const { pathname } = this.props.location;
return isAdminPage(pathname);
}
refreshSecurityGroup = () => {
this.store.fetchSecurityGroupsDetail(this.portId);
};
renderPanelTitle(item) {
const {
security_groups: { data },
} = this.store;
const detailUrl = this.getDetailUrl(item);
return (