mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Bump mobx from 6.5.0 to 6.6.0 (#5570)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
e13183f60e
commit
0dfd03e6df
@ -242,7 +242,7 @@
|
||||
"mac-ca": "^1.0.6",
|
||||
"marked": "^4.0.17",
|
||||
"md5-file": "^5.0.0",
|
||||
"mobx": "^6.5.0",
|
||||
"mobx": "^6.6.0",
|
||||
"mobx-observable-history": "^2.0.3",
|
||||
"mobx-react": "^7.5.0",
|
||||
"mobx-utils": "^6.0.4",
|
||||
|
||||
@ -7,7 +7,7 @@ import type { ClusterContext } from "./cluster-context";
|
||||
|
||||
import { action, computed, makeObservable, observable, reaction, when } from "mobx";
|
||||
import type { Disposer } from "../utils";
|
||||
import { autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils";
|
||||
import { waitUntilDefined, autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils";
|
||||
import type { KubeJsonApiDataFor, KubeObject } from "./kube-object";
|
||||
import { KubeStatus } from "./kube-object";
|
||||
import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||
@ -114,7 +114,7 @@ export abstract class KubeObjectStore<
|
||||
this.bindWatchEventsUpdater();
|
||||
}
|
||||
|
||||
get context(): ClusterContext {
|
||||
get context(): ClusterContext | undefined {
|
||||
return KubeObjectStore.defaultContext.get();
|
||||
}
|
||||
|
||||
@ -259,8 +259,9 @@ export abstract class KubeObjectStore<
|
||||
|
||||
@action
|
||||
async loadAll({ namespaces, merge = true, reqInit, onLoadFailure }: KubeObjectStoreLoadAllParams = {}): Promise<undefined | K[]> {
|
||||
await this.contextReady;
|
||||
namespaces ??= this.context.contextNamespaces;
|
||||
const context = await waitUntilDefined(() => this.context);
|
||||
|
||||
namespaces ??= context.contextNamespaces;
|
||||
this.isLoading = true;
|
||||
|
||||
try {
|
||||
@ -427,11 +428,17 @@ export abstract class KubeObjectStore<
|
||||
|
||||
subscribe({ onLoadFailure, abortController = new AbortController() }: KubeObjectStoreSubscribeParams = {}): Disposer {
|
||||
if (this.api.isNamespaced) {
|
||||
Promise.race([rejectPromiseBy(abortController.signal), Promise.all([this.contextReady, this.namespacesReady])])
|
||||
.then(() => {
|
||||
Promise.race([
|
||||
rejectPromiseBy(abortController.signal),
|
||||
Promise.all([
|
||||
waitUntilDefined(() => this.context),
|
||||
this.namespacesReady,
|
||||
] as const),
|
||||
])
|
||||
.then(([context]) => {
|
||||
assert(this.loadedNamespaces);
|
||||
|
||||
if (this.context.cluster?.isGlobalWatchEnabled && this.loadedNamespaces.length === 0) {
|
||||
if (context.cluster?.isGlobalWatchEnabled && this.loadedNamespaces.length === 0) {
|
||||
return this.watchNamespace("", abortController, { onLoadFailure });
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import type { AbortSignal } from "abort-controller";
|
||||
* Useful for `Promise.race()` applications.
|
||||
* @param signal The AbortController's signal to reject with
|
||||
*/
|
||||
export function rejectPromiseBy(signal: AbortSignal): Promise<void> {
|
||||
export function rejectPromiseBy(signal: AbortSignal): Promise<never> {
|
||||
return new Promise((_, reject) => {
|
||||
signal.addEventListener("abort", reject);
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { IObservableValue } from "mobx";
|
||||
import { computed } from "mobx";
|
||||
import syncBoxChannelInjectable from "./sync-box-channel.injectable";
|
||||
import { messageToChannelInjectionToken } from "../channel/message-to-channel-injection-token";
|
||||
@ -17,8 +18,8 @@ const createSyncBoxInjectable = getInjectable({
|
||||
const messageToChannel = di.inject(messageToChannelInjectionToken);
|
||||
const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id);
|
||||
|
||||
return <TData>(id: string, initialValue: TData): SyncBox<TData> => {
|
||||
const state = getSyncBoxState(id);
|
||||
return <Value>(id: string, initialValue: Value): SyncBox<Value> => {
|
||||
const state = getSyncBoxState(id) as IObservableValue<Value>;
|
||||
|
||||
state.set(initialValue);
|
||||
|
||||
|
||||
@ -4,21 +4,10 @@
|
||||
*/
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
|
||||
type AsJson<T> = T extends string | number | boolean | null
|
||||
? T
|
||||
: T extends Function
|
||||
? never
|
||||
: T extends Array<infer V>
|
||||
? AsJson<V>[]
|
||||
: T extends object
|
||||
? { [K in keyof T]: AsJson<T[K]> }
|
||||
: never;
|
||||
|
||||
export interface SyncBox<TValue> {
|
||||
export interface SyncBox<Value> {
|
||||
id: string;
|
||||
value: IComputedValue<AsJson<TValue>>;
|
||||
set: (value: AsJson<TValue>) => void;
|
||||
value: IComputedValue<Value>;
|
||||
set: (value: Value) => void;
|
||||
}
|
||||
|
||||
export const syncBoxInjectionToken = getInjectionToken<SyncBox<any>>({
|
||||
|
||||
@ -17,6 +17,10 @@ const currentClusterFrameInjectable = getInjectable({
|
||||
return computed(() => {
|
||||
const clusterId = currentClusterFrameState.get();
|
||||
|
||||
if (!clusterId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return clusterFrames.get(clusterId);
|
||||
});
|
||||
},
|
||||
|
||||
@ -114,7 +114,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
|
||||
* if user has given static list of namespaces let's not start watches
|
||||
* because watch adds stuff that's not wanted or will just fail
|
||||
*/
|
||||
if (this.context.cluster.accessibleNamespaces.length > 0) {
|
||||
if ((this.context?.cluster.accessibleNamespaces.length ?? 0) > 0) {
|
||||
return noop;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { beforeFrameStartsInjectionToken } from "../../before-frame-starts/before-frame-starts-injection-token";
|
||||
import syncBoxInitialValueChannelInjectable from "../../../common/utils/sync-box/sync-box-initial-value-channel.injectable";
|
||||
import syncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
|
||||
import createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
|
||||
const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||
@ -14,7 +14,7 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable);
|
||||
const setSyncBoxState = (id: string, state: any) => di.inject(syncBoxStateInjectable, id).set(state);
|
||||
const setSyncBoxState = (id: string, state: any) => di.inject(createSyncBoxStateInjectable, id).set(state);
|
||||
|
||||
return {
|
||||
run: async () => {
|
||||
|
||||
@ -9090,10 +9090,10 @@ mobx-utils@^6.0.4:
|
||||
resolved "https://registry.yarnpkg.com/mobx-utils/-/mobx-utils-6.0.5.tgz#0cce9afb07fbba1fb559f959f8cea1f44baa7252"
|
||||
integrity sha512-QOduwicYedD4mwYZRl8+c3BalljFDcubg+PUGqBkn8tOuBoj2q7GhjXBP6JXM9J+Zh+2mePK8IoToeLfqr3Z/w==
|
||||
|
||||
mobx@^6.3.0, mobx@^6.5.0:
|
||||
version "6.5.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.5.0.tgz#dc2d028b1882737f6e813fc92454381e438b7ad3"
|
||||
integrity sha512-pHZ/cySF00FVENDWIDzJyoObFahK6Eg4d0papqm6d7yMkxWTZ/S/csqJX1A3PsYy4t5k3z2QnlwuCfMW5lSEwA==
|
||||
mobx@^6.3.0, mobx@^6.6.0:
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.6.0.tgz#617ca1f3b745a781fa89c5eb94a773e3cbeff8ae"
|
||||
integrity sha512-MNTKevLH/6DShLZcmSL351+JgiJPO56A4GUpoiDQ3/yZ0mAtclNLdHK9q4BcQhibx8/JSDupfTpbX2NZPemlRg==
|
||||
|
||||
mock-fs@^5.1.2:
|
||||
version "5.1.2"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user