mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix hotbar migration of workspaces (#3178)
This commit is contained in:
1 parent
b9dfd20a93
commit
51655884c7
39 files changed
+333
-446
No files matched your search
@@ -22,6 +22,14 @@
|
||||
import { UserStore } from "../../common/user-store";
|
||||
import { ContextHandler } from "../context-handler";
|
||||
import { PrometheusProvider, PrometheusProviderRegistry, PrometheusService } from "../prometheus";
|
||||
import mockFs from "mock-fs";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "tmp",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
enum ServiceResult {
|
||||
Success,
|
||||
@@ -70,6 +78,10 @@ function getHandler() {
|
||||
|
||||
describe("ContextHandler", () => {
|
||||
beforeEach(() => {
|
||||
mockFs({
|
||||
"tmp": {}
|
||||
});
|
||||
|
||||
PrometheusProviderRegistry.createInstance();
|
||||
UserStore.createInstance();
|
||||
});
|
||||
@@ -77,6 +89,7 @@ describe("ContextHandler", () => {
|
||||
afterEach(() => {
|
||||
PrometheusProviderRegistry.resetInstance();
|
||||
UserStore.resetInstance();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
describe("getPrometheusService", () => {
|
||||
|
||||
@@ -46,7 +46,8 @@ jest.mock("winston", () => ({
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "/foo",
|
||||
getPath: () => "tmp",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -77,8 +78,6 @@ const mockWaitUntilUsed = waitUntilUsed as jest.MockedFunction<typeof waitUntilU
|
||||
describe("kube auth proxy tests", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
UserStore.resetInstance();
|
||||
UserStore.createInstance();
|
||||
|
||||
const mockMinikubeConfig = {
|
||||
"minikube-config.yml": JSON.stringify({
|
||||
@@ -102,13 +101,16 @@ describe("kube auth proxy tests", () => {
|
||||
}],
|
||||
kind: "Config",
|
||||
preferences: {},
|
||||
})
|
||||
}),
|
||||
"tmp": {},
|
||||
};
|
||||
|
||||
mockFs(mockMinikubeConfig);
|
||||
UserStore.createInstance();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
UserStore.resetInstance();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -67,6 +67,6 @@ const generalEntities = observable([
|
||||
preferencesEntity
|
||||
]);
|
||||
|
||||
export function initializeGeneralEntities() {
|
||||
export function syncGeneralEntities() {
|
||||
catalogEntityRegistry.addObservableSource("lens:general", generalEntities);
|
||||
}
|
||||
@@ -19,6 +19,6 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export { initializeWeblinks } from "./weblinks";
|
||||
export { syncWeblinks } from "./weblinks";
|
||||
export { KubeconfigSyncManager } from "./kubeconfig-sync";
|
||||
export { initializeGeneralEntities } from "./general";
|
||||
export { syncGeneralEntities } from "./general";
|
||||
@@ -69,7 +69,7 @@ async function validateLink(link: WebLink) {
|
||||
}
|
||||
|
||||
|
||||
export function initializeWeblinks() {
|
||||
export function syncWeblinks() {
|
||||
const weblinkStore = WeblinkStore.getInstance();
|
||||
const weblinks = observable.array(defaultLinks);
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ export class FilesystemProvisionerStore extends BaseStore<FSProvisionModel> {
|
||||
accessPropertiesByDotNotation: false, // To make dots safe in cluster context names
|
||||
});
|
||||
makeObservable(this);
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+24
-4
@@ -48,11 +48,17 @@ import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||
import { pushCatalogToRenderer } from "./catalog-pusher";
|
||||
import { catalogEntityRegistry } from "./catalog";
|
||||
import { HelmRepoManager } from "./helm/helm-repo-manager";
|
||||
import { KubeconfigSyncManager } from "./catalog-sources";
|
||||
import { syncGeneralEntities, syncWeblinks, KubeconfigSyncManager } from "./catalog-sources";
|
||||
import { handleWsUpgrade } from "./proxy/ws-upgrade";
|
||||
import configurePackages from "../common/configure-packages";
|
||||
import { PrometheusProviderRegistry } from "./prometheus";
|
||||
import * as initializers from "./initializers";
|
||||
import { ClusterStore } from "../common/cluster-store";
|
||||
import { HotbarStore } from "../common/hotbar-store";
|
||||
import { UserStore } from "../common/user-store";
|
||||
import { WeblinkStore } from "../common/weblink-store";
|
||||
import { ExtensionsStore } from "../extensions/extensions-store";
|
||||
import { FilesystemProvisionerStore } from "./extension-filesystem";
|
||||
|
||||
const workingDir = path.join(app.getPath("appData"), appName);
|
||||
const cleanup = disposer();
|
||||
@@ -123,8 +129,23 @@ app.on("ready", async () => {
|
||||
PrometheusProviderRegistry.createInstance();
|
||||
initializers.initPrometheusProviderRegistry();
|
||||
|
||||
await initializers.initializeStores();
|
||||
initializers.initializeWeblinks();
|
||||
/**
|
||||
* The following sync MUST be done before HotbarStore creation, because that
|
||||
* store has migrations that will remove items that previous migrations add
|
||||
* if this is not presant
|
||||
*/
|
||||
syncGeneralEntities();
|
||||
|
||||
logger.info("💾 Loading stores");
|
||||
|
||||
UserStore.createInstance().startMainReactions();
|
||||
ClusterStore.createInstance().provideInitialFromMain();
|
||||
HotbarStore.createInstance();
|
||||
ExtensionsStore.createInstance();
|
||||
FilesystemProvisionerStore.createInstance();
|
||||
WeblinkStore.createInstance();
|
||||
|
||||
syncWeblinks();
|
||||
|
||||
HelmRepoManager.createInstance(); // create the instance
|
||||
|
||||
@@ -182,7 +203,6 @@ app.on("ready", async () => {
|
||||
ipcMainOn(IpcRendererNavigationEvents.LOADED, () => {
|
||||
cleanup.push(pushCatalogToRenderer(catalogEntityRegistry));
|
||||
KubeconfigSyncManager.getInstance().startSync();
|
||||
initializers.initializeGeneralEntities();
|
||||
startUpdateChecking();
|
||||
LensProtocolRouterMain.getInstance().rendererLoaded = true;
|
||||
});
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export { initializeGeneralEntities } from "../catalog-sources";
|
||||
@@ -22,6 +22,3 @@
|
||||
export * from "./registries";
|
||||
export * from "./metrics-providers";
|
||||
export * from "./ipc";
|
||||
export * from "./weblinks";
|
||||
export * from "./stores";
|
||||
export * from "./general-entities";
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { HotbarStore } from "../../common/hotbar-store";
|
||||
import { ClusterStore } from "../../common/cluster-store";
|
||||
import { UserStore } from "../../common/user-store";
|
||||
import { ExtensionsStore } from "../../extensions/extensions-store";
|
||||
import { FilesystemProvisionerStore } from "../extension-filesystem";
|
||||
import { WeblinkStore } from "../../common/weblink-store";
|
||||
import logger from "../logger";
|
||||
|
||||
export async function initializeStores() {
|
||||
const userStore = UserStore.createInstance();
|
||||
const clusterStore = ClusterStore.createInstance();
|
||||
const hotbarStore = HotbarStore.createInstance();
|
||||
const extensionsStore = ExtensionsStore.createInstance();
|
||||
const filesystemStore = FilesystemProvisionerStore.createInstance();
|
||||
const weblinkStore = WeblinkStore.createInstance();
|
||||
|
||||
logger.info("💾 Loading stores");
|
||||
// preload
|
||||
await Promise.all([
|
||||
userStore.load(),
|
||||
clusterStore.load(),
|
||||
hotbarStore.load(),
|
||||
extensionsStore.load(),
|
||||
filesystemStore.load(),
|
||||
weblinkStore.load()
|
||||
]);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export { initializeWeblinks } from "../catalog-sources";
|
||||
@@ -28,9 +28,17 @@ import { LensExtension } from "../../../extensions/main-api";
|
||||
import { ExtensionLoader } from "../../../extensions/extension-loader";
|
||||
import { ExtensionsStore } from "../../../extensions/extensions-store";
|
||||
import { LensProtocolRouterMain } from "../router";
|
||||
import mockFs from "mock-fs";
|
||||
|
||||
jest.mock("../../../common/ipc");
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "tmp",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
function throwIfDefined(val: any): void {
|
||||
if (val != null) {
|
||||
throw val;
|
||||
@@ -39,6 +47,9 @@ function throwIfDefined(val: any): void {
|
||||
|
||||
describe("protocol router tests", () => {
|
||||
beforeEach(() => {
|
||||
mockFs({
|
||||
"tmp": {}
|
||||
});
|
||||
ExtensionsStore.createInstance();
|
||||
ExtensionLoader.createInstance();
|
||||
|
||||
@@ -53,6 +64,7 @@ describe("protocol router tests", () => {
|
||||
ExtensionsStore.resetInstance();
|
||||
ExtensionLoader.resetInstance();
|
||||
LensProtocolRouterMain.resetInstance();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
it("should throw on non-lens URLS", () => {
|
||||
|
||||
Reference in new issue
Block a user