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

auto-select contexts up to 10, main-layout small fix

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-08-27 13:10:13 +03:00
parent b698b7f22a
commit 17185cd04b
2 changed files with 11 additions and 2 deletions

View File

@ -71,7 +71,7 @@ export class AddCluster extends React.Component {
} }
@action @action
refreshContexts() { refreshContexts(autoSelect = true) {
this.selectedContexts.clear(); this.selectedContexts.clear();
this.kubeContexts.clear(); this.kubeContexts.clear();
@ -91,6 +91,12 @@ export class AddCluster extends React.Component {
} }
break; break;
} }
if (autoSelect) {
const allContexts = Array.from(this.kubeContexts.keys());
if (allContexts.length <= 10) {
this.selectedContexts.replace(allContexts);
}
}
} }
getContexts(config: KubeConfig): Map<string, KubeConfig> { getContexts(config: KubeConfig): Map<string, KubeConfig> {

View File

@ -48,11 +48,14 @@ export class MainLayout extends React.Component<Props> {
const { className, contentClass, headerClass, tabs, footer, footerClass, children } = this.props; const { className, contentClass, headerClass, tabs, footer, footerClass, children } = this.props;
const routePath = navigation.location.pathname; const routePath = navigation.location.pathname;
const cluster = getHostedCluster(); const cluster = getHostedCluster();
if (!cluster) {
return null; // fix: skip render when removing active (visible) cluster
}
return ( return (
<div className={cssNames("MainLayout", className)}> <div className={cssNames("MainLayout", className)}>
<header className={cssNames("flex gaps align-center", headerClass)}> <header className={cssNames("flex gaps align-center", headerClass)}>
<span className="cluster"> <span className="cluster">
{cluster.preferences?.clusterName || cluster.contextName} {cluster.preferences.clusterName || cluster.contextName}
</span> </span>
</header> </header>