1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add computed name property to cluster (#1428)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-11-18 09:12:11 +02:00 committed by GitHub
parent b0b2a99372
commit 04517148c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -86,6 +86,10 @@ export class Cluster implements ClusterModel, ClusterState {
return this.accessible && !this.disconnected; return this.accessible && !this.disconnected;
} }
@computed get name() {
return this.preferences.clusterName || this.contextName
}
get version(): string { get version(): string {
return String(this.metadata?.version) || "" return String(this.metadata?.version) || ""
} }

View File

@ -89,7 +89,7 @@ export function createTrayMenu(windowManager: WindowManager): Menu {
label: workspace.name, label: workspace.name,
toolTip: workspace.description, toolTip: workspace.description,
submenu: clusters.map(cluster => { submenu: clusters.map(cluster => {
const { id: clusterId, preferences: { clusterName: label }, online, workspace } = cluster; const { id: clusterId, name: label, online, workspace } = cluster;
return { return {
label: `${online ? '✓' : '\x20'.repeat(3)/*offset*/}${label}`, label: `${online ? '✓' : '\x20'.repeat(3)/*offset*/}${label}`,
toolTip: clusterId, toolTip: clusterId,

View File

@ -34,8 +34,8 @@ export class ClusterIcon extends React.Component<Props> {
cluster, showErrors, showTooltip, errorClass, options, interactive, isActive, cluster, showErrors, showTooltip, errorClass, options, interactive, isActive,
children, ...elemProps children, ...elemProps
} = this.props; } = this.props;
const { isAdmin, eventCount, preferences, id: clusterId } = cluster; const { isAdmin, name, eventCount, preferences, id: clusterId } = cluster;
const { clusterName, icon } = preferences; const { icon } = preferences;
const clusterIconId = `cluster-icon-${clusterId}`; const clusterIconId = `cluster-icon-${clusterId}`;
const className = cssNames("ClusterIcon flex inline", this.props.className, { const className = cssNames("ClusterIcon flex inline", this.props.className, {
interactive: interactive !== undefined ? interactive : !!this.props.onClick, interactive: interactive !== undefined ? interactive : !!this.props.onClick,
@ -44,9 +44,9 @@ export class ClusterIcon extends React.Component<Props> {
return ( return (
<div {...elemProps} className={className} id={showTooltip ? clusterIconId : null}> <div {...elemProps} className={className} id={showTooltip ? clusterIconId : null}>
{showTooltip && ( {showTooltip && (
<Tooltip targetId={clusterIconId}>{clusterName}</Tooltip> <Tooltip targetId={clusterIconId}>{name}</Tooltip>
)} )}
{icon && <img src={icon} alt={clusterName}/>} {icon && <img src={icon} alt={name}/>}
{!icon && <Hashicon value={clusterId} options={options}/>} {!icon && <Hashicon value={clusterId} options={options}/>}
{showErrors && isAdmin && eventCount > 0 && ( {showErrors && isAdmin && eventCount > 0 && (
<Badge <Badge

View File

@ -65,7 +65,7 @@ export class MainLayout extends React.Component<MainLayoutProps> {
return ( return (
<div className={cssNames("MainLayout", className)} style={this.getSidebarSize() as any}> <div className={cssNames("MainLayout", className)} style={this.getSidebarSize() as any}>
<header className={cssNames("flex gaps align-center", headerClass)}> <header className={cssNames("flex gaps align-center", headerClass)}>
<span className="cluster">{cluster.preferences.clusterName || cluster.contextName}</span> <span className="cluster">{cluster.name}</span>
</header> </header>
<aside className={cssNames("flex column", { pinned: this.isPinned, accessible: this.isAccessible })}> <aside className={cssNames("flex column", { pinned: this.isPinned, accessible: this.isAccessible })}>