Made welcome page configurable (#6232)

Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Jim EhrismannandSebastian Malton authored and GitHub committed 2022-09-14 09:07:44 -04:00
1 parent 2555643749
commit a2d52fa6b8
11 files changed
+211 -23

No files matched your search

@@ -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 welcomeRouteConfigInjectable from "./welcome-route-config.injectable";
import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token";
const defaultWelcomeRouteInjectable = getInjectable({
id: "default-welcome-route",
instantiate: (di) => {
const welcomeRoute = di.inject(welcomeRouteConfigInjectable);
return {
path: "/welcome",
clusterFrame: false,
isEnabled: computed(() => welcomeRoute === "/welcome"),
};
},
injectionToken: frontEndRouteInjectionToken,
});
export default defaultWelcomeRouteInjectable;
@@ -0,0 +1,8 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getGlobalOverride } from "../../../test-utils/get-global-override";
import welcomeRouteConfig from "./welcome-route-config.injectable";
export default getGlobalOverride(welcomeRouteConfig, () => "/welcome");
@@ -0,0 +1,18 @@
/**
* 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 packageJsonInjectable from "../../../vars/package-json.injectable";
const welcomeRouteConfigInjectable = getInjectable({
id: "welcome-route-config",
instantiate: (di) => {
const packageJson = di.inject(packageJsonInjectable);
return packageJson.config.welcomeRoute;
},
});
export default welcomeRouteConfigInjectable;
@@ -4,16 +4,21 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import welcomeRouteConfigInjectable from "./welcome-route-config.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 welcomeRoute = di.inject(welcomeRouteConfigInjectable);
return {
path: welcomeRoute,
clusterFrame: false,
isEnabled: computed(() => true),
};
},
injectionToken: frontEndRouteInjectionToken,
});
@@ -5,7 +5,7 @@
import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
import { frontEndRouteInjectionToken } from "./front-end-route-injection-token";
import { filter, map, matches } from "lodash/fp";
import { filter, map } from "lodash/fp";
import clusterStoreInjectable from "../cluster-store/cluster-store.injectable";
import type { ClusterStore } from "../cluster-store/cluster-store";
import { pipeline } from "@ogre-tools/fp";
@@ -27,9 +27,11 @@ describe("verify-that-all-routes-have-component", () => {
routes,
map(
(route) => ({
path: route.path,
routeComponent: routeComponents.find(matches({ route })),
(currentRoute) => ({
path: currentRoute.path,
routeComponent: routeComponents.find(({ route }) => (
route.path === currentRoute.path
&& route.clusterFrame === currentRoute.clusterFrame)),
}),
),