import "./cluster-icon.scss" import React, { DOMAttributes } from "react"; import { observer } from "mobx-react"; import { Params as HashiconParams } from "@emeraldpay/hashicon"; import { Hashicon } from "@emeraldpay/hashicon-react"; import { Cluster } from "../../../main/cluster"; import { cssNames, IClassName } from "../../utils"; import { Badge } from "../badge"; import { Tooltip } from "../tooltip"; interface Props extends DOMAttributes { cluster: Cluster; className?: IClassName; errorClass?: IClassName; showErrors?: boolean; showTooltip?: boolean; interactive?: boolean; isActive?: boolean; options?: HashiconParams; } const defaultProps: Partial = { showErrors: true, showTooltip: true, }; @observer export class ClusterIcon extends React.Component { static defaultProps = defaultProps as object; render() { const { cluster, showErrors, showTooltip, errorClass, options, interactive, isActive, children, ...elemProps } = this.props; const { isAdmin, eventCount, preferences, id: clusterId } = cluster; const { clusterName, icon } = preferences; const clusterIconId = `cluster-icon-${clusterId}`; const className = cssNames("ClusterIcon flex inline", this.props.className, { interactive: interactive !== undefined ? interactive : !!this.props.onClick, active: isActive, }); return (
{showTooltip && ( {clusterName} )} {icon && {clusterName}/} {!icon && } {showErrors && isAdmin && eventCount > 0 && ( = 1000 ? Math.ceil(eventCount / 1000) + "k+" : eventCount} /> )} {children}
); } }