mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* A bit of cleaning in Add Cluster page Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Adding head-col to WizardLayout Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Cluster Settings general layout bugs Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Cluster Status view refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Install Metrics component refactoring Using notifications for error, removed picking button icon method, simplified button generation. Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Remove icons / checks from RemoveClusterButton Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing colorError in Input styles Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Preventing Input's spellchecking Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterNameSettings refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterWorkspaceSettings refactoring/fixing Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterProxySetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterPrometheusSetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Clean up Removal section Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Glued InstallMetrics & InstallUserMode into 1 component Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Removing unused styles in Cluster Settings Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Cluster Settings styling Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Adding close button to settings header Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterHomeDirSetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * FilePicker restyling Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Prometheus selector Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Hashicon Passing cluster name instead of cluster id to prevent icon changing while typing new cluster name Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Minor ClusterSettings fixes Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Increasing opacity for non-interactive icons Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Keep feature install loading state Waiting for props to change before disabling loading state (gray button width spinner) Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Remove arrays in disposeOnUnmount() Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fix Cluster select behavior Now clicking cluster icon in sidebar always leads to / dashboard. And 'Settings' submenu switches active cluster at first and only the showing Cluster Settings Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Using structuralComparator in feature installer Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Saving input fields on blur Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Setting Select color same as Input color Signed-off-by: alexfront <alex.andreev.email@gmail.com>
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
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<HTMLElement> {
|
|
cluster: Cluster;
|
|
className?: IClassName;
|
|
errorClass?: IClassName;
|
|
showErrors?: boolean;
|
|
showTooltip?: boolean;
|
|
interactive?: boolean;
|
|
isActive?: boolean;
|
|
options?: HashiconParams;
|
|
}
|
|
|
|
const defaultProps: Partial<Props> = {
|
|
showErrors: true,
|
|
showTooltip: true,
|
|
};
|
|
|
|
@observer
|
|
export class ClusterIcon extends React.Component<Props> {
|
|
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 (
|
|
<div {...elemProps} className={className} id={showTooltip ? clusterIconId : null}>
|
|
{showTooltip && (
|
|
<Tooltip targetId={clusterIconId}>{clusterName}</Tooltip>
|
|
)}
|
|
{icon && <img src={icon} alt={clusterName}/>}
|
|
{!icon && <Hashicon value={clusterId} options={options}/>}
|
|
{showErrors && isAdmin && eventCount > 0 && (
|
|
<Badge
|
|
className={cssNames("events-count", errorClass)}
|
|
label={eventCount >= 1000 ? Math.ceil(eventCount / 1000) + "k+" : eventCount}
|
|
/>
|
|
)}
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
}
|