mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
use private static
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
28b0f618be
commit
f5bbf72576
@ -40,13 +40,30 @@ export interface ClusterStoreModel {
|
|||||||
export type ClusterId = string;
|
export type ClusterId = string;
|
||||||
|
|
||||||
export interface ClusterModel {
|
export interface ClusterModel {
|
||||||
|
/** Unique id for a cluster */
|
||||||
id: ClusterId;
|
id: ClusterId;
|
||||||
|
|
||||||
|
/** Path to cluster kubeconfig */
|
||||||
kubeConfigPath: string;
|
kubeConfigPath: string;
|
||||||
|
|
||||||
|
/** Workspace id */
|
||||||
workspace?: WorkspaceId;
|
workspace?: WorkspaceId;
|
||||||
|
|
||||||
|
/** User context in kubeconfig */
|
||||||
contextName?: string;
|
contextName?: string;
|
||||||
|
|
||||||
|
/** Preferences */
|
||||||
preferences?: ClusterPreferences;
|
preferences?: ClusterPreferences;
|
||||||
|
|
||||||
|
/** Metadata */
|
||||||
metadata?: ClusterMetadata;
|
metadata?: ClusterMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If extension sets ownerRef it has to explicitly mark a cluster as enabled during onActive (or when cluster is saved)
|
||||||
|
*/
|
||||||
ownerRef?: string;
|
ownerRef?: string;
|
||||||
|
|
||||||
|
/** List of accessible namespaces */
|
||||||
accessibleNamespaces?: string[];
|
accessibleNamespaces?: string[];
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
@ -89,7 +106,7 @@ 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>();
|
||||||
|
|
||||||
private stateRequestChannel = "cluster:states";
|
private static stateRequestChannel = "cluster:states";
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super({
|
super({
|
||||||
@ -112,7 +129,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
};
|
};
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
logger.info("[CLUSTER-STORE] requesting initial state sync");
|
logger.info("[CLUSTER-STORE] requesting initial state sync");
|
||||||
const clusterStates: clusterStateSync[] = await requestMain(this.stateRequestChannel);
|
const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel);
|
||||||
clusterStates.forEach((clusterState) => {
|
clusterStates.forEach((clusterState) => {
|
||||||
const cluster = this.getById(clusterState.id);
|
const cluster = this.getById(clusterState.id);
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
@ -120,7 +137,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
handleRequest(this.stateRequestChannel, (): clusterStateSync[] => {
|
handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => {
|
||||||
const states: clusterStateSync[] = [];
|
const states: clusterStateSync[] = [];
|
||||||
this.clustersList.forEach((cluster) => {
|
this.clustersList.forEach((cluster) => {
|
||||||
states.push({
|
states.push({
|
||||||
|
|||||||
@ -27,11 +27,45 @@ export interface WorkspaceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Workspace implements WorkspaceModel, WorkspaceState {
|
export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||||
|
/**
|
||||||
|
* Unique id for workspace
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable id: WorkspaceId;
|
@observable id: WorkspaceId;
|
||||||
|
/**
|
||||||
|
* Workspace name
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable name: string;
|
@observable name: string;
|
||||||
|
/**
|
||||||
|
* Workspace description
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable description?: string;
|
@observable description?: string;
|
||||||
|
/**
|
||||||
|
* Workspace owner reference
|
||||||
|
*
|
||||||
|
* If extension sets ownerRef then it needs to explicitly mark workspace as enabled onActivate (or when workspace is saved)
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable ownerRef?: string;
|
@observable ownerRef?: string;
|
||||||
|
/**
|
||||||
|
* Is workspace enabled
|
||||||
|
*
|
||||||
|
* Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace.
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable enabled: boolean;
|
@observable enabled: boolean;
|
||||||
|
/**
|
||||||
|
* Last active cluster id
|
||||||
|
*
|
||||||
|
* @observable
|
||||||
|
*/
|
||||||
@observable lastActiveClusterId?: ClusterId;
|
@observable lastActiveClusterId?: ClusterId;
|
||||||
|
|
||||||
constructor(data: WorkspaceModel) {
|
constructor(data: WorkspaceModel) {
|
||||||
@ -77,7 +111,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
|||||||
|
|
||||||
export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
||||||
static readonly defaultId: WorkspaceId = "default";
|
static readonly defaultId: WorkspaceId = "default";
|
||||||
private stateRequestChannel = "workspace:states";
|
private static stateRequestChannel = "workspace:states";
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super({
|
super({
|
||||||
@ -93,7 +127,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
};
|
};
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
logger.info("[WORKSPACE-STORE] requesting initial state sync");
|
logger.info("[WORKSPACE-STORE] requesting initial state sync");
|
||||||
const workspaceStates: workspaceStateSync[] = await requestMain(this.stateRequestChannel);
|
const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel);
|
||||||
workspaceStates.forEach((workspaceState) => {
|
workspaceStates.forEach((workspaceState) => {
|
||||||
const workspace = this.getById(workspaceState.id);
|
const workspace = this.getById(workspaceState.id);
|
||||||
if (workspace) {
|
if (workspace) {
|
||||||
@ -101,7 +135,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
handleRequest(this.stateRequestChannel, (): workspaceStateSync[] => {
|
handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => {
|
||||||
const states: workspaceStateSync[] = [];
|
const states: workspaceStateSync[] = [];
|
||||||
this.workspacesList.forEach((workspace) => {
|
this.workspacesList.forEach((workspace) => {
|
||||||
states.push({
|
states.push({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user