Hello from Example extension!
+File: {__filename}
++ Are you sure you want to drain {nodeName}? +
+ ), + }) + } + + return ( + <> ++ Ask a question, see what's being discussed, join the conversation here +
+ ++ Review existing issues or open a new one here +
+ + {/*{ + params?: P; + query?: Q; +} + +export function buildURL
(path: string | any) { + const pathBuilder = compile(String(path)); + return function ({ params, query }: IURLParams
= {}) {
+ const queryParams = query ? new URLSearchParams(Object.entries(query)).toString() : ""
+ return pathBuilder(params) + (queryParams ? `?${queryParams}` : "")
+ }
+}
diff --git a/src/common/vars.ts b/src/common/vars.ts
index ca28a2f99a..206aa59ce2 100644
--- a/src/common/vars.ts
+++ b/src/common/vars.ts
@@ -5,7 +5,9 @@ import { defineGlobal } from "./utils/defineGlobal";
export const isMac = process.platform === "darwin"
export const isWindows = process.platform === "win32"
+export const isLinux = process.platform === "linux"
export const isDebugging = process.env.DEBUG === "true";
+export const isSnap = !!process.env["SNAP"]
export const isProduction = process.env.NODE_ENV === "production"
export const isTestEnv = !!process.env.JEST_WORKER_ID;
export const isDevelopment = !isTestEnv && !isProduction;
diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts
index 752a53f41b..97611a01d3 100644
--- a/src/common/workspace-store.ts
+++ b/src/common/workspace-store.ts
@@ -1,20 +1,77 @@
-import { action, computed, observable, toJS } from "mobx";
+import { ipcRenderer } from "electron";
+import { action, computed, observable, toJS, reaction } from "mobx";
import { BaseStore } from "./base-store";
import { clusterStore } from "./cluster-store"
-import { landingURL } from "../renderer/components/+landing-page/landing-page.route";
-import { navigate } from "../renderer/navigation";
+import { appEventBus } from "./event-bus";
+import { broadcastIpc } from "../common/ipc";
+import logger from "../main/logger";
export type WorkspaceId = string;
export interface WorkspaceStoreModel {
currentWorkspace?: WorkspaceId;
- workspaces: Workspace[]
+ workspaces: WorkspaceModel[]
}
-export interface Workspace {
+export interface WorkspaceModel {
id: WorkspaceId;
name: string;
description?: string;
+ ownerRef?: string;
+}
+
+export interface WorkspaceState {
+ enabled: boolean;
+}
+
+export class Workspace implements WorkspaceModel, WorkspaceState {
+ @observable id: WorkspaceId
+ @observable name: string
+ @observable description?: string
+ @observable ownerRef?: string
+ @observable enabled: boolean
+
+ constructor(data: WorkspaceModel) {
+ Object.assign(this, data)
+
+ if (!ipcRenderer) {
+ reaction(() => this.getState(), () => {
+ this.pushState()
+ })
+ }
+ }
+
+ get isManaged(): boolean {
+ return !!this.ownerRef
+ }
+
+ getState(): WorkspaceState {
+ return {
+ enabled: this.enabled
+ }
+ }
+
+ pushState(state = this.getState()) {
+ logger.silly("[WORKSPACE] pushing state", {...state, id: this.id})
+ broadcastIpc({
+ channel: "workspace:state",
+ args: [this.id, toJS(state)],
+ });
+ }
+
+ @action
+ setState(state: WorkspaceState) {
+ Object.assign(this, state)
+ }
+
+ toJSON(): WorkspaceModel {
+ return toJS({
+ id: this.id,
+ name: this.name,
+ description: this.description,
+ ownerRef: this.ownerRef
+ })
+ }
}
export class WorkspaceStore extends BaseStore Prometheus service address.{cluster.preferences.clusterName}
-