mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix build due to removal of old extended collections (#4779)
This commit is contained in:
parent
ac42a6565f
commit
0b1696fe16
@ -6,7 +6,7 @@
|
|||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import { getAppVersion, ObservableToggleSet } from "../utils";
|
import { getAppVersion } from "../utils";
|
||||||
import type { editor } from "monaco-editor";
|
import type { editor } from "monaco-editor";
|
||||||
import merge from "lodash/merge";
|
import merge from "lodash/merge";
|
||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
@ -236,10 +236,10 @@ const terminalCopyOnSelect: PreferenceDescription<boolean> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const hiddenTableColumns: PreferenceDescription<[string, string[]][], Map<string, ObservableToggleSet<string>>> = {
|
const hiddenTableColumns: PreferenceDescription<[string, string[]][], Map<string, Set<string>>> = {
|
||||||
fromStore(val) {
|
fromStore(val) {
|
||||||
return new Map(
|
return new Map(
|
||||||
(val ?? []).map(([tableId, columnIds]) => [tableId, new ObservableToggleSet(columnIds)]),
|
(val ?? []).map(([tableId, columnIds]) => [tableId, new Set(columnIds)]),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
toStore(val) {
|
toStore(val) {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import migrations, { fileNameMigration } from "../../migrations/user-store";
|
|||||||
import { getAppVersion } from "../utils/app-version";
|
import { getAppVersion } from "../utils/app-version";
|
||||||
import { kubeConfigDefaultPath } from "../kube-helpers";
|
import { kubeConfigDefaultPath } from "../kube-helpers";
|
||||||
import { appEventBus } from "../app-event-bus/event-bus";
|
import { appEventBus } from "../app-event-bus/event-bus";
|
||||||
import { ObservableToggleSet, toJS } from "../../renderer/utils";
|
import { getOrInsertSet, toggle, toJS } from "../../renderer/utils";
|
||||||
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel, TerminalConfig } from "./preferences-helpers";
|
import { DESCRIPTORS, EditorConfiguration, ExtensionRegistry, KubeconfigSyncValue, UserPreferencesModel, TerminalConfig } from "./preferences-helpers";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
* The column IDs under each configurable table ID that have been configured
|
* The column IDs under each configurable table ID that have been configured
|
||||||
* to not be shown
|
* to not be shown
|
||||||
*/
|
*/
|
||||||
hiddenTableColumns = observable.map<string, ObservableToggleSet<string>>();
|
hiddenTableColumns = observable.map<string, Set<string>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monaco editor configs
|
* Monaco editor configs
|
||||||
@ -133,16 +133,11 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
|||||||
return columnIds.some(columnId => config.has(columnId));
|
return columnIds.some(columnId => config.has(columnId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
/**
|
/**
|
||||||
* Toggles the hidden configuration of a table's column
|
* Toggles the hidden configuration of a table's column
|
||||||
*/
|
*/
|
||||||
toggleTableColumnVisibility(tableId: string, columnId: string) {
|
toggleTableColumnVisibility(tableId: string, columnId: string) {
|
||||||
if (!this.hiddenTableColumns.get(tableId)) {
|
toggle(getOrInsertSet(this.hiddenTableColumns, tableId), columnId);
|
||||||
this.hiddenTableColumns.set(tableId, new ObservableToggleSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hiddenTableColumns.get(tableId).toggle(columnId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { runInAction } from "mobx";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value behind `key`. If it was not present, first insert `value`
|
* Get the value behind `key`. If it was not present, first insert `value`
|
||||||
* @param map The map to interact with
|
* @param map The map to interact with
|
||||||
@ -26,6 +28,14 @@ export function getOrInsertMap<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map
|
|||||||
return getOrInsert(map, key, new Map<MK, MV>());
|
return getOrInsert(map, key, new Map<MK, MV>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like `getOrInsert` but specifically for when `V` is `Set<any>` so that
|
||||||
|
* the typings are inferred.
|
||||||
|
*/
|
||||||
|
export function getOrInsertSet<K, SK>(map: Map<K, Set<SK>>, key: K): Set<SK> {
|
||||||
|
return getOrInsert(map, key, new Set<SK>());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like `getOrInsert` but with delayed creation of the item
|
* Like `getOrInsert` but with delayed creation of the item
|
||||||
*/
|
*/
|
||||||
@ -36,3 +46,17 @@ export function getOrInsertWith<K, V>(map: Map<K, V>, key: K, value: () => V): V
|
|||||||
|
|
||||||
return map.get(key);
|
return map.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If `key` is in `set`, remove it otherwise add it.
|
||||||
|
* @param set The set to manipulate
|
||||||
|
* @param key The key to toggle the "is in"-ness of
|
||||||
|
*/
|
||||||
|
export function toggle<K>(set: Set<K>, key: K): void {
|
||||||
|
runInAction(() => {
|
||||||
|
// Returns true if value was already in Set; otherwise false.
|
||||||
|
if (!set.delete(key)) {
|
||||||
|
set.add(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ export * from "./singleton";
|
|||||||
export * from "./sort-compare";
|
export * from "./sort-compare";
|
||||||
export * from "./splitArray";
|
export * from "./splitArray";
|
||||||
export * from "./tar";
|
export * from "./tar";
|
||||||
export * from "./toggle-set";
|
|
||||||
export * from "./toJS";
|
export * from "./toJS";
|
||||||
export * from "./type-narrowing";
|
export * from "./type-narrowing";
|
||||||
export * from "./types";
|
export * from "./types";
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { ObservableSet } from "mobx";
|
|
||||||
|
|
||||||
export class ToggleSet<T> extends Set<T> {
|
|
||||||
public toggle(value: T): void {
|
|
||||||
if (!this.delete(value)) {
|
|
||||||
// Set.prototype.delete returns false if `value` was not in the set
|
|
||||||
this.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ObservableToggleSet<T> extends ObservableSet<T> {
|
|
||||||
public toggle(value: T): void {
|
|
||||||
if (!this.delete(value)) {
|
|
||||||
// Set.prototype.delete returns false if `value` was not in the set
|
|
||||||
this.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -12,7 +12,7 @@ import { DrawerItem, DrawerTitle } from "../drawer";
|
|||||||
import { Input } from "../input";
|
import { Input } from "../input";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { base64, ObservableToggleSet } from "../../utils";
|
import { base64, toggle } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { secretsStore } from "./secrets.store";
|
import { secretsStore } from "./secrets.store";
|
||||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||||
@ -27,7 +27,7 @@ interface Props extends KubeObjectDetailsProps<Secret> {
|
|||||||
export class SecretDetails extends React.Component<Props> {
|
export class SecretDetails extends React.Component<Props> {
|
||||||
@observable isSaving = false;
|
@observable isSaving = false;
|
||||||
@observable data: { [name: string]: string } = {};
|
@observable data: { [name: string]: string } = {};
|
||||||
revealSecret = new ObservableToggleSet<string>();
|
revealSecret = new Set<string>();
|
||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -99,7 +99,7 @@ export class SecretDetails extends React.Component<Props> {
|
|||||||
<Icon
|
<Icon
|
||||||
material={revealSecret ? "visibility" : "visibility_off"}
|
material={revealSecret ? "visibility" : "visibility_off"}
|
||||||
tooltip={revealSecret ? "Hide" : "Show"}
|
tooltip={revealSecret ? "Hide" : "Show"}
|
||||||
onClick={() => this.revealSecret.toggle(name)}
|
onClick={() => toggle(this.revealSecret, name)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { action, comparer, computed, IReactionDisposer, makeObservable, reaction } from "mobx";
|
import { action, comparer, computed, IReactionDisposer, makeObservable, reaction } from "mobx";
|
||||||
import { autoBind, noop, StorageHelper, ToggleSet } from "../../../utils";
|
import { autoBind, noop, StorageHelper, toggle } from "../../../utils";
|
||||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../../../common/k8s-api/kube-object.store";
|
||||||
import { Namespace, namespacesApi } from "../../../../common/k8s-api/endpoints/namespaces.api";
|
import { Namespace, namespacesApi } from "../../../../common/k8s-api/endpoints/namespaces.api";
|
||||||
|
|
||||||
@ -175,10 +175,10 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
*/
|
*/
|
||||||
@action
|
@action
|
||||||
toggleContext(namespaces: string | string[]) {
|
toggleContext(namespaces: string | string[]) {
|
||||||
const nextState = new ToggleSet(this.contextNamespaces);
|
const nextState = new Set(this.contextNamespaces);
|
||||||
|
|
||||||
for (const namespace of [namespaces].flat()) {
|
for (const namespace of [namespaces].flat()) {
|
||||||
nextState.toggle(namespace);
|
toggle(nextState, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dependencies.storage.set([...nextState]);
|
this.dependencies.storage.set([...nextState]);
|
||||||
@ -191,9 +191,9 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
* @param namespace The name of a namespace
|
* @param namespace The name of a namespace
|
||||||
*/
|
*/
|
||||||
toggleSingle(namespace: string) {
|
toggleSingle(namespace: string) {
|
||||||
const nextState = new ToggleSet(this.contextNamespaces);
|
const nextState = new Set(this.contextNamespaces);
|
||||||
|
|
||||||
nextState.toggle(namespace);
|
toggle(nextState, namespace);
|
||||||
this.dependencies.storage.set([...nextState]);
|
this.dependencies.storage.set([...nextState]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,31 +8,17 @@ import "./item-list-layout.scss";
|
|||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode } from "react";
|
||||||
import { computed, makeObservable, untracked } from "mobx";
|
import { computed, makeObservable, untracked } from "mobx";
|
||||||
import type { ConfirmDialogParams } from "../confirm-dialog";
|
import type { ConfirmDialogParams } from "../confirm-dialog";
|
||||||
import type {
|
import type { TableCellProps, TableProps, TableRowProps, TableSortCallbacks } from "../table";
|
||||||
TableCellProps,
|
import { boundMethod, cssNames, IClassName, noop, StorageHelper } from "../../utils";
|
||||||
TableProps,
|
|
||||||
TableRowProps,
|
|
||||||
TableSortCallbacks,
|
|
||||||
} from "../table";
|
|
||||||
import {
|
|
||||||
boundMethod,
|
|
||||||
cssNames,
|
|
||||||
IClassName,
|
|
||||||
noop,
|
|
||||||
ObservableToggleSet,
|
|
||||||
StorageHelper,
|
|
||||||
} from "../../utils";
|
|
||||||
import type { AddRemoveButtonsProps } from "../add-remove-buttons";
|
import type { AddRemoveButtonsProps } from "../add-remove-buttons";
|
||||||
import type { ItemObject, ItemStore } from "../../../common/item.store";
|
import type { ItemObject, ItemStore } from "../../../common/item.store";
|
||||||
import type { SearchInputUrlProps } from "../input";
|
import type { SearchInputUrlProps } from "../input";
|
||||||
import { Filter, FilterType, pageFilters } from "./page-filters.store";
|
import { Filter, FilterType, pageFilters } from "./page-filters.store";
|
||||||
import { PageFiltersList } from "./page-filters-list";
|
import { PageFiltersList } from "./page-filters-list";
|
||||||
import { UserStore } from "../../../common/user-store";
|
|
||||||
import type { NamespaceStore } from "../+namespaces/namespace-store/namespace.store";
|
import type { NamespaceStore } from "../+namespaces/namespace-store/namespace.store";
|
||||||
import namespaceStoreInjectable from "../+namespaces/namespace-store/namespace-store.injectable";
|
import namespaceStoreInjectable from "../+namespaces/namespace-store/namespace-store.injectable";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import itemListLayoutStorageInjectable
|
import itemListLayoutStorageInjectable from "./storage.injectable";
|
||||||
from "./storage.injectable";
|
|
||||||
import { ItemListLayoutContent } from "./content";
|
import { ItemListLayoutContent } from "./content";
|
||||||
import { ItemListLayoutHeader } from "./header";
|
import { ItemListLayoutHeader } from "./header";
|
||||||
import groupBy from "lodash/groupBy";
|
import groupBy from "lodash/groupBy";
|
||||||
@ -142,10 +128,6 @@ class NonInjectedItemListLayout<I extends ItemObject> extends React.Component<It
|
|||||||
throw new Error("[ItemListLayout]: configurable list require props.tableId to be specified");
|
throw new Error("[ItemListLayout]: configurable list require props.tableId to be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isConfigurable && !UserStore.getInstance().hiddenTableColumns.has(tableId)) {
|
|
||||||
UserStore.getInstance().hiddenTableColumns.set(tableId, new ObservableToggleSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preloadStores) {
|
if (preloadStores) {
|
||||||
this.loadStores();
|
this.loadStores();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user