import React from 'react' import { List, Icon, Tooltip, Popconfirm, Tag } from 'antd' import { IViewVariable } from 'containers/View/types' import { ViewVariableTypes } from '../constants' import Styles from '../View.less' export interface IViewVariableListProps { variables: IViewVariable[] className?: string onAdd?: () => void onDelete?: (key: string) => void onEdit?: (variable: IViewVariable) => void } export class ViewVariableList extends React.PureComponent { private editItem = (variable: IViewVariable) => () => { this.props.onEdit({ ...variable }) } private deleteItem = (key: string) => () => { this.props.onDelete(key) } private renderItem = (item: IViewVariable) => { const icons = [ ( ), ( ) ] const { name, alias, type } = item const text = alias ? `${name}[${alias}]` : `${name}` const color = type === ViewVariableTypes.Query ? 'green' : 'volcano' const category = type === ViewVariableTypes.Query ? 'QUERY' : 'AUTH' return ( {category}
{text}
) } public render () { const { variables, className, onAdd } = this.props return (

变量

} locale={{ emptyText: '暂无变量' }} dataSource={variables} renderItem={this.renderItem} /> ) } } export default ViewVariableList