mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: show loading-state when activating a cluster or adding new one
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
78a9fcde56
commit
4388558d2e
@ -77,6 +77,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
@observable removedClusters = observable.map<ClusterId, Cluster>();
|
@observable removedClusters = observable.map<ClusterId, Cluster>();
|
||||||
@observable clusters = observable.map<ClusterId, Cluster>();
|
@observable clusters = observable.map<ClusterId, Cluster>();
|
||||||
|
|
||||||
|
@computed get activeCluster(): Cluster | null {
|
||||||
|
return this.getById(this.activeClusterId);
|
||||||
|
}
|
||||||
|
|
||||||
@computed get clustersList(): Cluster[] {
|
@computed get clustersList(): Cluster[] {
|
||||||
return Array.from(this.clusters.values());
|
return Array.from(this.clusters.values());
|
||||||
}
|
}
|
||||||
@ -194,7 +198,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
|
|
||||||
export const clusterStore = ClusterStore.getInstance<ClusterStore>();
|
export const clusterStore = ClusterStore.getInstance<ClusterStore>();
|
||||||
|
|
||||||
export function getHostedCluster(): Cluster {
|
export function getHostedClusterId() {
|
||||||
const clusterId = location.hostname.split(".")[0];
|
return location.hostname.split(".")[0];
|
||||||
return clusterStore.getById(clusterId);
|
}
|
||||||
|
|
||||||
|
export function getHostedCluster(): Cluster {
|
||||||
|
return clusterStore.getById(getHostedClusterId());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,6 @@ import type { ClusterId } from "../common/cluster-store";
|
|||||||
import { clusterStore } from "../common/cluster-store";
|
import { clusterStore } from "../common/cluster-store";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
|
|
||||||
// fixme: remove switching view delay on first load
|
|
||||||
|
|
||||||
export class WindowManager {
|
export class WindowManager {
|
||||||
protected activeView: BrowserWindow;
|
protected activeView: BrowserWindow;
|
||||||
protected splashWindow: BrowserWindow;
|
protected splashWindow: BrowserWindow;
|
||||||
|
|||||||
@ -8,6 +8,13 @@
|
|||||||
#lens-view {
|
#lens-view {
|
||||||
position: relative;
|
position: relative;
|
||||||
grid-area: lens-view;
|
grid-area: lens-view;
|
||||||
|
|
||||||
|
&.inactive {
|
||||||
|
opacity: .85;
|
||||||
|
filter: grayscale(1);
|
||||||
|
user-select: none;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ClustersMenu {
|
.ClustersMenu {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import "./cluster-manager.scss"
|
import "./cluster-manager.scss"
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { computed } from "mobx";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
import { App } from "../app";
|
import { App } from "../app";
|
||||||
import { ClustersMenu } from "./clusters-menu";
|
import { ClustersMenu } from "./clusters-menu";
|
||||||
import { BottomBar } from "./bottom-bar";
|
import { BottomBar } from "./bottom-bar";
|
||||||
@ -7,12 +9,15 @@ import { cssNames, IClassName } from "../../utils";
|
|||||||
import { Terminal } from "../dock/terminal";
|
import { Terminal } from "../dock/terminal";
|
||||||
import { i18nStore } from "../../i18n";
|
import { i18nStore } from "../../i18n";
|
||||||
import { themeStore } from "../../theme.store";
|
import { themeStore } from "../../theme.store";
|
||||||
|
import { clusterStore, getHostedClusterId } from "../../../common/cluster-store";
|
||||||
|
import { CubeSpinner } from "../spinner";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: IClassName;
|
className?: IClassName;
|
||||||
contentClass?: IClassName;
|
contentClass?: IClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@observer
|
||||||
export class ClusterManager extends React.Component<Props> {
|
export class ClusterManager extends React.Component<Props> {
|
||||||
static async init() {
|
static async init() {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@ -22,16 +27,26 @@ export class ClusterManager extends React.Component<Props> {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get isInactive() {
|
||||||
|
const { activeCluster, activeClusterId } = clusterStore;
|
||||||
|
const isActivatedBefore = activeCluster?.initialized;
|
||||||
|
return !isActivatedBefore && activeClusterId !== getHostedClusterId();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, contentClass } = this.props;
|
const { className, contentClass } = this.props;
|
||||||
|
const lensViewClass = cssNames("flex column", contentClass, {
|
||||||
|
inactive: this.isInactive,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<div className={cssNames("ClusterManager", className)}>
|
<div className={cssNames("ClusterManager", className)}>
|
||||||
<div id="draggable-top"/>
|
<div id="draggable-top"/>
|
||||||
<div id="lens-view" className={cssNames("flex column", contentClass)}>
|
<div id="lens-view" className={lensViewClass}>
|
||||||
<App/>
|
<App/>
|
||||||
</div>
|
</div>
|
||||||
<ClustersMenu/>
|
<ClustersMenu/>
|
||||||
<BottomBar/>
|
<BottomBar/>
|
||||||
|
{this.isInactive && <CubeSpinner center/>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,13 @@
|
|||||||
.CubeSpinner {
|
.CubeSpinner {
|
||||||
--size: 70px;
|
--size: 70px;
|
||||||
|
|
||||||
|
&.center {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
.sk-cube-grid {
|
.sk-cube-grid {
|
||||||
$size: 70px;
|
$size: 70px;
|
||||||
width: $size;
|
width: $size;
|
||||||
|
|||||||
@ -4,13 +4,14 @@ import { cssNames } from "../../utils";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
center?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CubeSpinner extends React.PureComponent<Props> {
|
export class CubeSpinner extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { className } = this.props;
|
const { className, center } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className={cssNames("CubeSpinner ", className)}>
|
<div className={cssNames("CubeSpinner ", className, { center })}>
|
||||||
<div className="sk-cube-grid">
|
<div className="sk-cube-grid">
|
||||||
<div className="sk-cube sk-cube1"></div>
|
<div className="sk-cube sk-cube1"></div>
|
||||||
<div className="sk-cube sk-cube2"></div>
|
<div className="sk-cube sk-cube2"></div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user