1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

modified welcome page injectables to allow for the page component to come from an extension

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2022-09-12 20:16:36 -04:00
parent 23cb231c8f
commit a7121d2cbe
5 changed files with 71 additions and 11 deletions

View File

@ -56,7 +56,8 @@
"bundledKubectlVersion": "1.23.3",
"bundledHelmVersion": "3.7.2",
"sentryDsn": "",
"contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:"
"contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
"welcomeRoute": "/welcome"
},
"engines": {
"node": ">=16 <17"

View File

@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import packageJsonInjectable from "../../../vars/package-json.injectable";
import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token";
const defaultWelcomeRouteInjectable = getInjectable({
id: "default-welcome-route",
instantiate: (di) => {
const packageJson = di.inject(packageJsonInjectable);
return {
path: "/welcome",
clusterFrame: false,
isEnabled: computed(() => packageJson.config.welcomeRoute === "/welcome"),
};
},
injectionToken: frontEndRouteInjectionToken,
});
export default defaultWelcomeRouteInjectable;

View File

@ -4,16 +4,21 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import packageJsonInjectable from "../../../vars/package-json.injectable";
import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token";
const welcomeRouteInjectable = getInjectable({
id: "welcome-route",
instantiate: () => ({
path: "/welcome",
clusterFrame: false,
isEnabled: computed(() => true),
}),
instantiate: (di) => {
const packageJson = di.inject(packageJsonInjectable);
return {
path: packageJson.config.welcomeRoute,
clusterFrame: false,
isEnabled: computed(() => true),
};
},
injectionToken: frontEndRouteInjectionToken,
});

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export {};
describe("setting the welcome page", () => {
describe("given no extension sets the welcome page", () => {
it("sets the default welcome page", () => {
});
it("navigates to the default welcome page", () => {
});
});
describe("given an extension sets a custom welcome page", () => {
it("sets the custom welcome page", () => {
});
it("navigates to the custom welcome page", () => {
});
});
});

View File

@ -4,18 +4,18 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { Welcome } from "./welcome";
import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable";
import defaultWelcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/default-welcome-route.injectable";
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
const welcomeRouteComponentInjectable = getInjectable({
id: "welcome-route-component",
const defaultWelcomeRouteComponentInjectable = getInjectable({
id: "default-welcome-route-component",
instantiate: (di) => ({
route: di.inject(welcomeRouteInjectable),
route: di.inject(defaultWelcomeRouteInjectable),
Component: Welcome,
}),
injectionToken: routeSpecificComponentInjectionToken,
});
export default welcomeRouteComponentInjectable;
export default defaultWelcomeRouteComponentInjectable;