// 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, { Component } from 'react'; import PropTypes from 'prop-types'; import imageSvg from 'asset/image/image.svg'; import securityImg from 'asset/image/security-group.svg'; import lbImg from 'asset/image/load-balancer.png'; import { DesktopOutlined, BorderOuterOutlined, SecurityScanOutlined, InboxOutlined, GlobalOutlined, GatewayOutlined, UserOutlined, CameraOutlined, SaveOutlined, KeyOutlined, ClusterOutlined, TagOutlined, HddOutlined, CloudServerOutlined, LoadingOutlined, TeamOutlined, ProjectOutlined, AimOutlined, } from '@ant-design/icons'; import styles from './index.less'; const ImageIcon = ( image_icon ); const SecurityIcon = ( security_icon ); const LBIcon = lb_icon; const iconTypeMap = { instance: , router: , externalNetwork: , network: , firewall: , volume: , gateway: , user: , snapshot: , backup: , keypair: , image: ImageIcon, aggregate: , metadata: , flavor: , host: , security: SecurityIcon, lb: LBIcon, group: , project: , floatingIp: , }; export default class index extends Component { static propTypes = { content: PropTypes.any, value: PropTypes.any, icon: PropTypes.node, iconType: PropTypes.string, }; static defaultProps = { icon: null, iconType: '', content: '', value: null, }; renderIcon() { const { icon, iconType } = this.props; if (iconType) { const iconComp = iconTypeMap[iconType] || null; return {iconComp}; } return {icon || null}; } render() { const { content, value, iconType, showLoading, ...rest } = this.props; const failValues = [undefined, null, '']; if (content) { return content; } return ( {this.renderIcon()} {showLoading && failValues.includes(value) ? ( ) : ( value )} ); } }