mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes / refactoring
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
fbcb2fd281
commit
79e5d6eddc
@ -92,14 +92,14 @@ export class BaseStore<T = any> extends Singleton {
|
|||||||
|
|
||||||
protected onConfigChange(data: T, oldValue: Partial<T>) {
|
protected onConfigChange(data: T, oldValue: Partial<T>) {
|
||||||
if (!isEqual(this.toJSON(), data)) {
|
if (!isEqual(this.toJSON(), data)) {
|
||||||
logger.debug(`💿 Store received update from ${this.name}`, { data, oldValue });
|
logger.info(`💿 Store received update from ${this.name}`, { data, oldValue });
|
||||||
this.fromStore(data);
|
this.fromStore(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onModelChange(model: T) {
|
protected onModelChange(model: T) {
|
||||||
if (!isEqual(this.storeModel, model)) {
|
if (!isEqual(this.storeModel, model)) {
|
||||||
logger.debug(`💿 Store ${this.name} is saving updates from app runtime`, {
|
logger.info(`💿 Store ${this.name} is saving updates from app runtime`, {
|
||||||
data: model,
|
data: model,
|
||||||
oldValue: this.storeModel
|
oldValue: this.storeModel
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export type ClusterId = string;
|
|||||||
export interface ClusterModel {
|
export interface ClusterModel {
|
||||||
id: ClusterId;
|
id: ClusterId;
|
||||||
workspace?: string;
|
workspace?: string;
|
||||||
|
contextName?: string;
|
||||||
preferences?: ClusterPreferences;
|
preferences?: ClusterPreferences;
|
||||||
kubeConfigPath: string;
|
kubeConfigPath: string;
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export class Cluster implements ClusterModel {
|
|||||||
updateModel(model: ClusterModel) {
|
updateModel(model: ClusterModel) {
|
||||||
Object.assign(this, model);
|
Object.assign(this, model);
|
||||||
this.apiUrl = this.getKubeconfig().getCurrentCluster().server;
|
this.apiUrl = this.getKubeconfig().getCurrentCluster().server;
|
||||||
this.contextName = this.preferences.clusterName;
|
this.contextName = this.contextName || this.preferences.clusterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { RouteProps } from "react-router";
|
||||||
|
import { buildURL } from "../../navigation";
|
||||||
|
|
||||||
|
export const addClusterRoute: RouteProps = {
|
||||||
|
path: "/add-cluster"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addClusterURL = buildURL(addClusterRoute.path)
|
||||||
@ -1,10 +1,12 @@
|
|||||||
import "./add-cluster.scss"
|
import "./add-cluster.scss"
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { observable } from "mobx";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AddCluster extends React.Component {
|
@observable
|
||||||
|
export class AddCluster extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="AddCluster">
|
<div className="AddCluster">
|
||||||
|
|||||||
@ -1 +1,2 @@
|
|||||||
export * from "./add-cluster"
|
export * from "./add-cluster"
|
||||||
|
export * from "./add-cluster.route"
|
||||||
|
|||||||
@ -6,12 +6,10 @@
|
|||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&.interactive {
|
&.active, &.interactive:hover {
|
||||||
&:hover {
|
opacity: 1;
|
||||||
opacity: 1;
|
background-color: #fff;
|
||||||
background-color: #fff;
|
box-shadow: 0 0 0 $radius #fff;
|
||||||
box-shadow: 0 0 0 $radius #fff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> img {
|
> img {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ interface Props extends DOMAttributes<HTMLElement> {
|
|||||||
errorClass?: IClassName;
|
errorClass?: IClassName;
|
||||||
showErrors?: boolean;
|
showErrors?: boolean;
|
||||||
interactive?: boolean;
|
interactive?: boolean;
|
||||||
|
isActive?: boolean;
|
||||||
options?: HashiconParams;
|
options?: HashiconParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,11 +27,12 @@ export class ClusterIcon extends React.Component<Props> {
|
|||||||
static defaultProps = defaultProps as object;
|
static defaultProps = defaultProps as object;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className: cName, cluster, showErrors, errorClass, options, interactive, children, ...elemProps } = this.props;
|
const { className: cName, cluster, showErrors, errorClass, options, interactive, isActive, children, ...elemProps } = this.props;
|
||||||
const { isAdmin, eventCount, preferences } = cluster;
|
const { isAdmin, eventCount, preferences } = cluster;
|
||||||
const { clusterName, icon } = preferences;
|
const { clusterName, icon } = preferences;
|
||||||
const className = cssNames("ClusterIcon flex inline", cName, {
|
const className = cssNames("ClusterIcon flex inline", cName, {
|
||||||
interactive: interactive || !!this.props.onClick,
|
interactive: interactive || !!this.props.onClick,
|
||||||
|
active: isActive,
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div {...elemProps} className={className}>
|
<div {...elemProps} className={className}>
|
||||||
|
|||||||
@ -22,9 +22,9 @@ interface Props {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ClustersMenu extends React.Component<Props> {
|
export class ClustersMenu extends React.Component<Props> {
|
||||||
selectCluster = (cluster: Cluster) => {
|
showCluster = (cluster: Cluster) => {
|
||||||
clusterStore.activeClusterId = cluster.id;
|
clusterStore.activeClusterId = cluster.id;
|
||||||
console.log('load lens for cluster:', cluster)
|
console.log('load lens for cluster:', cluster.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCluster = () => {
|
addCluster = () => {
|
||||||
@ -59,14 +59,13 @@ export class ClustersMenu extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<div className={cssNames("ClustersMenu flex gaps column", className)}>
|
<div className={cssNames("ClustersMenu flex gaps column", className)}>
|
||||||
{clusters.map(cluster => {
|
{clusters.map(cluster => {
|
||||||
const isActive = cluster.id === clusterStore.activeClusterId;
|
|
||||||
return (
|
return (
|
||||||
<ClusterIcon
|
<ClusterIcon
|
||||||
key={cluster.id}
|
key={cluster.id}
|
||||||
showErrors={true}
|
showErrors={true}
|
||||||
cluster={cluster}
|
cluster={cluster}
|
||||||
className={cssNames({ active: isActive })}
|
isActive={cluster.id === clusterStore.activeClusterId}
|
||||||
onClick={() => this.selectCluster(cluster)}
|
onClick={() => this.showCluster(cluster)}
|
||||||
onContextMenu={() => this.showContextMenu(cluster)}
|
onContextMenu={() => this.showContextMenu(cluster)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user