mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
master-merge fixes, upgrading packages: mobx-observable-history@2.0, mobx@6.3, mobx-react
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
04ea4120ed
commit
264af63fad
@ -202,9 +202,9 @@
|
||||
"mac-ca": "^1.0.4",
|
||||
"marked": "^2.0.3",
|
||||
"md5-file": "^5.0.0",
|
||||
"mobx": "^6.2.0",
|
||||
"mobx-observable-history": "^1.0.3",
|
||||
"mobx-react": "^6.2.2",
|
||||
"mobx": "^6.3.0",
|
||||
"mobx-observable-history": "^2.0.0",
|
||||
"mobx-react": "^7.1.0",
|
||||
"mock-fs": "^4.12.0",
|
||||
"moment": "^2.26.0",
|
||||
"moment-timezone": "^0.5.33",
|
||||
|
||||
@ -15,13 +15,13 @@ export class CatalogPusher {
|
||||
const disposers: Disposer[] = [];
|
||||
|
||||
disposers.push(reaction(() => this.catalog.items, (items) => {
|
||||
broadcastMessage("catalog:items", toJS(items, { recurseEverything: true }));
|
||||
broadcastMessage("catalog:items", toJS(items));
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
}));
|
||||
|
||||
const listener = subscribeToBroadcast("catalog:broadcast", () => {
|
||||
broadcastMessage("catalog:items", toJS(this.catalog.items, { recurseEverything: true }));
|
||||
broadcastMessage("catalog:items", toJS(this.catalog.items));
|
||||
});
|
||||
|
||||
disposers.push(() => unsubscribeFromBroadcast("catalog:broadcast", listener));
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { action, observable, IComputedValue, computed, ObservableMap, runInAction } from "mobx";
|
||||
import { action, computed, IComputedValue, observable, ObservableMap, runInAction } from "mobx";
|
||||
import { CatalogEntity, catalogEntityRegistry } from "../../common/catalog";
|
||||
import { watch } from "chokidar";
|
||||
import fs from "fs";
|
||||
@ -47,7 +47,7 @@ export class KubeconfigSyncManager extends Singleton {
|
||||
this.startNewSync(filePath, port);
|
||||
}
|
||||
|
||||
this.syncListDisposer = UserStore.getInstance().syncKubeconfigEntries.observe(change => {
|
||||
this.syncListDisposer = UserStore.getInstance().syncKubeconfigEntries.observe_(change => {
|
||||
switch (change.type) {
|
||||
case "add":
|
||||
this.startNewSync(change.name, port);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import "../common/cluster-ipc";
|
||||
import type http from "http";
|
||||
import { ipcMain } from "electron";
|
||||
import { action, autorun, observable, reaction, makeObservable } from "mobx";
|
||||
import { Singleton, toJS } from "../common/utils";
|
||||
import { action, autorun, makeObservable, observable, reaction } from "mobx";
|
||||
import { Singleton } from "../common/utils";
|
||||
import { ClusterStore, getClusterIdFromHost } from "../common/cluster-store";
|
||||
import { Cluster } from "./cluster";
|
||||
import logger from "./logger";
|
||||
@ -32,15 +32,14 @@ export class ClusterManager extends Singleton {
|
||||
|
||||
}, { fireImmediately: true });
|
||||
|
||||
reaction(() => toJS(ClusterStore.getInstance().enabledClustersList, { recurseEverything: true }), () => {
|
||||
this.updateCatalogSource(ClusterStore.getInstance().enabledClustersList);
|
||||
reaction(() => ClusterStore.getInstance().enabledClustersList, (enabledClusters) => {
|
||||
this.updateCatalogSource(enabledClusters);
|
||||
}, { fireImmediately: true });
|
||||
|
||||
reaction(() => catalogEntityRegistry.getItemsForApiKind<KubernetesCluster>("entity.k8slens.dev/v1alpha1", "KubernetesCluster"), (entities) => {
|
||||
this.syncClustersFromCatalog(entities);
|
||||
});
|
||||
|
||||
|
||||
// auto-stop removed clusters
|
||||
autorun(() => {
|
||||
const removedClusters = Array.from(ClusterStore.getInstance().removedClusters.values());
|
||||
@ -60,7 +59,8 @@ export class ClusterManager extends Singleton {
|
||||
ipcMain.on("network:online", () => { this.onNetworkOnline(); });
|
||||
}
|
||||
|
||||
@action protected updateCatalogSource(clusters: Cluster[]) {
|
||||
@action
|
||||
protected updateCatalogSource(clusters: Cluster[]) {
|
||||
this.catalogSource.replace(this.catalogSource.filter(entity => (
|
||||
clusters.find((cluster) => entity.metadata.uid === cluster.id)
|
||||
)));
|
||||
@ -175,9 +175,7 @@ export class ClusterManager extends Singleton {
|
||||
}
|
||||
|
||||
export function catalogEntityFromCluster(cluster: Cluster) {
|
||||
return new KubernetesCluster(toJS({
|
||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||
kind: "KubernetesCluster",
|
||||
return new KubernetesCluster({
|
||||
metadata: {
|
||||
uid: cluster.id,
|
||||
name: cluster.name,
|
||||
@ -196,5 +194,5 @@ export function catalogEntityFromCluster(cluster: Cluster) {
|
||||
message: "",
|
||||
active: !cluster.disconnected
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ export class Dialog extends React.PureComponent<DialogProps, DialogState> {
|
||||
};
|
||||
|
||||
@disposeOnUnmount
|
||||
closeOnNavigate = reaction(() => navigation.getPath(), () => this.close());
|
||||
closeOnNavigate = reaction(() => navigation.toString(), () => this.close());
|
||||
|
||||
public state: DialogState = {
|
||||
isOpen: this.props.isOpen,
|
||||
|
||||
@ -21,7 +21,7 @@ export class ErrorBoundary extends React.Component<Props, State> {
|
||||
|
||||
@disposeOnUnmount
|
||||
resetOnNavigate = reaction(
|
||||
() => navigation.getPath(),
|
||||
() => navigation.toString(),
|
||||
() => this.setState({ error: null, errorInfo: null })
|
||||
);
|
||||
|
||||
|
||||
@ -4,7 +4,14 @@ import { createObservableHistory } from "mobx-observable-history";
|
||||
import logger from "../../main/logger";
|
||||
|
||||
export const history = ipcRenderer ? createBrowserHistory() : createMemoryHistory();
|
||||
export const navigation = createObservableHistory(history);
|
||||
|
||||
export const navigation = createObservableHistory(history, {
|
||||
searchParams: {
|
||||
skipEmpty: true, // skip empty params, e.g. "?x=&y2=" will be "?y=2"
|
||||
joinArrays: false, // join multiple params with same name, e.g. "?x=1&x=2" => "?x=1,2"
|
||||
joinArraysWith: ",", // param values splitter, applicable only with {joinArrays:true}
|
||||
}
|
||||
});
|
||||
|
||||
navigation.listen((location, action) => {
|
||||
const isClusterView = !process.isMainFrame;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Manage observable URL-param from document.location.search
|
||||
import { IObservableHistory } from "mobx-observable-history";
|
||||
// TODO: refactor / streamline with mobx-observable-history@2.x
|
||||
import type { ObservableHistory } from "mobx-observable-history";
|
||||
|
||||
export interface PageParamInit<V = any> {
|
||||
name: string;
|
||||
@ -22,7 +23,7 @@ export class PageParam<V = any> {
|
||||
readonly name: string;
|
||||
readonly urlName: string;
|
||||
|
||||
constructor(readonly init: PageParamInit<V> | PageSystemParamInit<V>, protected history: IObservableHistory) {
|
||||
constructor(readonly init: PageParamInit<V> | PageSystemParamInit<V>, protected history: ObservableHistory<{}>) {
|
||||
const { isSystem, name } = init as PageSystemParamInit;
|
||||
|
||||
this.name = name;
|
||||
@ -93,9 +94,14 @@ export class PageParam<V = any> {
|
||||
|
||||
getRaw(): string[] {
|
||||
const { history, urlName } = this;
|
||||
const { multiValueSep } = this.init;
|
||||
const { multiValueSep, multiValues } = this.init;
|
||||
const values = history.searchParams.getAll(urlName);
|
||||
|
||||
return history.searchParams.getAsArray(urlName, multiValueSep);
|
||||
if (multiValues) {
|
||||
return values.flatMap(value => value.split(multiValueSep));
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
getDefaultValue() {
|
||||
|
||||
50
yarn.lock
50
yarn.lock
@ -1269,11 +1269,16 @@
|
||||
"@types/shot" "*"
|
||||
joi "^17.3.0"
|
||||
|
||||
"@types/history@*", "@types/history@^4.7.3":
|
||||
"@types/history@*":
|
||||
version "4.7.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.6.tgz#ed8fc802c45b8e8f54419c2d054e55c9ea344356"
|
||||
integrity sha512-GRTZLeLJ8ia00ZH8mxMO8t0aC9M1N9bN461Z2eaRurJo6Fpa+utgCwLzI4jQHcrdzuzp5WPN9jRwpsCQ1VhJ5w==
|
||||
|
||||
"@types/history@^4.7.8":
|
||||
version "4.7.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934"
|
||||
integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA==
|
||||
|
||||
"@types/hoist-non-react-statics@^3.3.0", "@types/hoist-non-react-statics@^3.3.1":
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
|
||||
@ -9458,36 +9463,31 @@ mkdirp@1.x, mkdirp@^1.0.3:
|
||||
dependencies:
|
||||
minimist "^1.2.5"
|
||||
|
||||
mobx-observable-history@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/mobx-observable-history/-/mobx-observable-history-1.0.3.tgz#7e34be76024dc09c71b17c3996b422f50a347c98"
|
||||
integrity sha512-3JNF00AWbAXBSFJ8y/+xiPEpyySEDsNiWoT5q1G7V2w5BUQ+umqPSrmoJJlSzSs5d6Ey8HHGyPm0aGK444+hcA==
|
||||
mobx-observable-history@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx-observable-history/-/mobx-observable-history-2.0.0.tgz#aec91929b8c0d363a19aac8dfd071a92c509caff"
|
||||
integrity sha512-xX8w4lM5mKAO0S3yJ2M8FQ2pQ7Ns7zOvq7+goEnhHizO8HeHfC7O5SCy+BL5LN3Ahr5p4AW08KAj3edLBK5h4Q==
|
||||
dependencies:
|
||||
"@types/history" "^4.7.3"
|
||||
"@types/history" "^4.7.8"
|
||||
history "^4.10.1"
|
||||
mobx "^5.15.4"
|
||||
mobx "^6.3.0"
|
||||
|
||||
mobx-react-lite@^2.2.0:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.yarnpkg.com/mobx-react-lite/-/mobx-react-lite-2.2.2.tgz#87c217dc72b4e47b22493daf155daf3759f868a6"
|
||||
integrity sha512-2SlXALHIkyUPDsV4VTKVR9DW7K3Ksh1aaIv3NrNJygTbhXe2A9GrcKHZ2ovIiOp/BXilOcTYemfHHZubP431dg==
|
||||
mobx-react-lite@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx-react-lite/-/mobx-react-lite-3.2.0.tgz#331d7365a6b053378dfe9c087315b4e41c5df69f"
|
||||
integrity sha512-q5+UHIqYCOpBoFm/PElDuOhbcatvTllgRp3M1s+Hp5j0Z6XNgDbgqxawJ0ZAUEyKM8X1zs70PCuhAIzX1f4Q/g==
|
||||
|
||||
mobx-react@^6.2.2:
|
||||
version "6.3.1"
|
||||
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-6.3.1.tgz#204f9756e42e19d91cb6598837063b7e7de87c52"
|
||||
integrity sha512-IOxdJGnRSNSJrL2uGpWO5w9JH5q5HoxEqwOF4gye1gmZYdjoYkkMzSGMDnRCUpN/BNzZcFoMdHXrjvkwO7KgaQ==
|
||||
mobx-react@^7.1.0:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx-react/-/mobx-react-7.1.0.tgz#d947cada3cfad294b4b6f692e969c242b9c16eaf"
|
||||
integrity sha512-DxvA6VXmnZ+N9f/UTtolWtdRnAAQY2iHWTSPLktfpj8NKlXUe4dabBAjuXrBcZUM8GjLWnxD1ZEjssXq1M0RAw==
|
||||
dependencies:
|
||||
mobx-react-lite "^2.2.0"
|
||||
mobx-react-lite "^3.2.0"
|
||||
|
||||
mobx@^5.15.4:
|
||||
version "5.15.4"
|
||||
resolved "https://registry.yarnpkg.com/mobx/-/mobx-5.15.4.tgz#9da1a84e97ba624622f4e55a0bf3300fb931c2ab"
|
||||
integrity sha512-xRFJxSU2Im3nrGCdjSuOTFmxVDGeqOHL+TyADCGbT0k4HHqGmx5u2yaHNryvoORpI4DfbzjJ5jPmuv+d7sioFw==
|
||||
|
||||
mobx@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.2.0.tgz#9a5afe3525a0302691c7805d0df6ef60834d79e5"
|
||||
integrity sha512-j5f16JIq2v4flvYCqaAB9tMtJt/y5efR2OO5Xy+w4/MBMeQ1WeGR0T8BtiNgmxM/OQzPFUKb5DTex9Y8a/yk+g==
|
||||
mobx@^6.3.0:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.3.0.tgz#a8fb693c3047bdfcb1eaff9aa48e36a7eb084f96"
|
||||
integrity sha512-Aa1+VXsg4WxqJMTQfWoYuJi5UD10VZhiobSmcs5kcmI3BIT0aVtn7DysvCeDADCzl7dnbX+0BTHUj/v7gLlZpQ==
|
||||
|
||||
mock-fs@^4.12.0:
|
||||
version "4.12.0"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user