mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove ExtenedMap, ToggleSet, and observable versions (#3310)
- Switch to helper functions instead. They don't impact the prototype tree and it means that we don't need to introduce versions that are both observable and "normal" - Tidy <ItemListLayout> and hiddenTableColumns to not need pre-initialization Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ed91ef2d03
commit
8088d3b5c2
10 files changed
+58
-105
No files matched your search
@@ -10,7 +10,7 @@ import { FSWatcher, watch } from "chokidar";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import type stream from "stream";
|
||||
import { bytesToUnits, Disposer, ExtendedObservableMap, iter, noop } from "../../../common/utils";
|
||||
import { bytesToUnits, Disposer, getOrInsertWith, iter, noop } from "../../../common/utils";
|
||||
import logger from "../../logger";
|
||||
import type { KubeConfig } from "@kubernetes/client-node";
|
||||
import { loadConfigFromString, splitConfig } from "../../../common/kube-helpers";
|
||||
@@ -294,7 +294,7 @@ const diffChangedConfigFor = (dependencies: Dependencies) => ({ filePath, source
|
||||
};
|
||||
|
||||
const watchFileChanges = (filePath: string, dependencies: Dependencies): [IComputedValue<CatalogEntity[]>, Disposer] => {
|
||||
const rootSource = new ExtendedObservableMap<string, ObservableMap<string, RootSourceValue>>();
|
||||
const rootSource = observable.map<string, ObservableMap<string, RootSourceValue>>();
|
||||
const derivedSource = computed(() => Array.from(iter.flatMap(rootSource.values(), from => iter.map(from.values(), child => child[1]))));
|
||||
|
||||
let watcher: FSWatcher;
|
||||
@@ -335,7 +335,7 @@ const watchFileChanges = (filePath: string, dependencies: Dependencies): [ICompu
|
||||
cleanup();
|
||||
cleanupFns.set(childFilePath, diffChangedConfig({
|
||||
filePath: childFilePath,
|
||||
source: rootSource.getOrInsert(childFilePath, observable.map),
|
||||
source: getOrInsertWith(rootSource, childFilePath, observable.map),
|
||||
stats,
|
||||
maxAllowedFileReadSize,
|
||||
}));
|
||||
@@ -353,7 +353,7 @@ const watchFileChanges = (filePath: string, dependencies: Dependencies): [ICompu
|
||||
|
||||
cleanupFns.set(childFilePath, diffChangedConfig({
|
||||
filePath: childFilePath,
|
||||
source: rootSource.getOrInsert(childFilePath, observable.map),
|
||||
source: getOrInsertWith(rootSource, childFilePath, observable.map),
|
||||
stats,
|
||||
maxAllowedFileReadSize,
|
||||
}));
|
||||
|
||||
+4
-5
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { ExtendedMap } from "../../../../common/utils";
|
||||
import { getOrInsertMap } from "../../../../common/utils";
|
||||
import type { ClusterId } from "../../../../common/cluster-types";
|
||||
import { ipcMainHandle } from "../../../../common/ipc";
|
||||
import crypto from "crypto";
|
||||
@@ -11,15 +11,14 @@ import { promisify } from "util";
|
||||
const randomBytes = promisify(crypto.randomBytes);
|
||||
|
||||
export class ShellRequestAuthenticator {
|
||||
private tokens = new ExtendedMap<ClusterId, Map<string, Uint8Array>>();
|
||||
private tokens = new Map<ClusterId, Map<string, Uint8Array>>();
|
||||
|
||||
init() {
|
||||
ipcMainHandle("cluster:shell-api", async (event, clusterId, tabId) => {
|
||||
const authToken = Uint8Array.from(await randomBytes(128));
|
||||
const forCluster = getOrInsertMap(this.tokens, clusterId);
|
||||
|
||||
this.tokens
|
||||
.getOrInsert(clusterId, () => new Map())
|
||||
.set(tabId, authToken);
|
||||
forCluster.set(tabId, authToken);
|
||||
|
||||
return authToken;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user