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

Technical requirements for behavioural unit tests (#5084)

* Implement a lot of technical requirements for behavioural unit tests

Note: the crux of this was to make routing env-agnostic, and not based on URLs as magic strings, but instead something type-enforced.

Note: extension-based routes comply to same exact interface by "late-registering" their routes when installed. Routes are just injectables.

Note: another chunk of global shared state is no more.

Note: a lot of explicit side effects have been cornered to injectables.

Note: a lot of stuff has become reactive as part if this.

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make a directory commonly available

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Require id for <Select /> to prevent non-deterministic renders

This was caused by global state in a 3rd party lib: "react-select".

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Specify id for all <Select /> to satisfy previous commit

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Prevent explicit side effect in component by using existing dependency instead

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Extract instantiation of "conf" as injectables for causing side effects

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Introduce a legacy-helper to make gradual refactoring of inheritors of Singleton easier

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Make legacy unit tests for hotbar green and more simple by using the new legacy helper

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Temporarily kludge all unit tests green with a disclaimer about allowing side-effects

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Remove kludge in previous commit by explicitly permitting specific side effects where old unit tests require it

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Prevent old unit test with side effects from accessing file system

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Migrate to actual typing for di.permitSideEffects

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Prevent unit tests from failing because of non-standard method of HTML-element not present in js-dom

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Adapt integration tests to recent changes

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Fix code style

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Fix artifact from bad rebase

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Add a deprecation from a review comment

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Remove change that is not required

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove redundant comment

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix code style

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove redundant file

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix bad merge

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Improve variable name

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Tweak logger interface to be more descriptive

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make injecting legacy singleton always provide new instance

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove conditional typing when not needed

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Improve naming of variable

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove unnecessary code style changes

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove flag for causing side effects from too broad scope

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Override side-effects in unit test using injectable instead of monkey patching

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Flag some side-effects and add general overrides

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Fix unit tests in CI by removing explicit side-effect

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Remove explicit side-effect from getting default shell

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Introduce abstraction for getting absolute paths

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Switch to using abstraction for getting absolute path to control explicit side effect

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Introduce abstraction for joining paths

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Switch to using abstraction for joining paths to control explicit side effect

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix fake implementation for join paths

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix test after removing explicit side effect

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove explicit side effects from kubeconfig-syncs

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix arguments after removing explicit side effect

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make registrators not async for not being needed anymore

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Make generalCatalogEntities non-observable, as there is no requirement

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Remove redundant code

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>

* Simplify logic for registering general catalog entity sources

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Add TODO

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Replace function for getting application menu items with reactive solution

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix typo in interface name

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove global shared state usages of hot bar store

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Remove redundant enum

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Iku-turso 2022-03-31 16:57:05 +03:00 committed by GitHub
parent ab2cd27a27
commit a277cfcf02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
583 changed files with 13073 additions and 6556 deletions

View File

@ -52,7 +52,7 @@ describe("preferences page tests", () => {
];
for (const { id, header } of pages) {
await window.click(`[data-testid=${id}-tab]`);
await window.click(`[data-testid=tab-link-for-${id}]`);
await window.waitForSelector(`[data-testid=${id}-header] >> text=${header}`);
}
}, 10*60*1000);

View File

@ -12,295 +12,11 @@
import * as utils from "../helpers/utils";
import { minikubeReady } from "../helpers/minikube";
import type { Frame, Page } from "playwright";
import { groupBy, toPairs } from "lodash/fp";
import { pipeline } from "@ogre-tools/fp";
const TEST_NAMESPACE = "integration-tests";
function getSidebarSelectors(itemId: string) {
const root = `.SidebarItem[data-test-id="${itemId}"]`;
return {
expandSubMenu: `${root} .nav-item`,
subMenuLink: (href: string) => `[data-testid=cluster-sidebar] .sub-menu a[href^="${href}"]`,
};
}
function getLoadedSelector(page: CommonPage): string {
if (page.expectedText) {
return `${page.expectedSelector} >> text='${page.expectedText}'`;
}
return page.expectedSelector;
}
interface CommonPage {
name: string;
href: string;
expectedSelector: string;
expectedText?: string;
}
interface TopPageTest {
page: CommonPage;
}
interface SubPageTest {
drawerId: string;
pages: CommonPage[];
}
type CommonPageTest = TopPageTest | SubPageTest;
function isTopPageTest(test: CommonPageTest): test is TopPageTest {
return typeof (test as any).page === "object";
}
const commonPageTests: CommonPageTest[] = [{
page: {
name: "Cluster",
href: "/overview",
expectedSelector: "div[data-testid='cluster-overview-page'] div.label",
expectedText: "CPU",
},
},
{
page: {
name: "Nodes",
href: "/nodes",
expectedSelector: "h5.title",
expectedText: "Nodes",
},
},
{
drawerId: "workloads",
pages: [
{
name: "Overview",
href: "/workloads",
expectedSelector: "h5.box",
expectedText: "Overview",
},
{
name: "Pods",
href: "/pods",
expectedSelector: "h5.title",
expectedText: "Pods",
},
{
name: "Deployments",
href: "/deployments",
expectedSelector: "h5.title",
expectedText: "Deployments",
},
{
name: "DaemonSets",
href: "/daemonsets",
expectedSelector: "h5.title",
expectedText: "Daemon Sets",
},
{
name: "StatefulSets",
href: "/statefulsets",
expectedSelector: "h5.title",
expectedText: "Stateful Sets",
},
{
name: "ReplicaSets",
href: "/replicasets",
expectedSelector: "h5.title",
expectedText: "Replica Sets",
},
{
name: "Jobs",
href: "/jobs",
expectedSelector: "h5.title",
expectedText: "Jobs",
},
{
name: "CronJobs",
href: "/cronjobs",
expectedSelector: "h5.title",
expectedText: "Cron Jobs",
},
],
},
{
drawerId: "config",
pages: [
{
name: "ConfigMaps",
href: "/configmaps",
expectedSelector: "h5.title",
expectedText: "Config Maps",
},
{
name: "Secrets",
href: "/secrets",
expectedSelector: "h5.title",
expectedText: "Secrets",
},
{
name: "Resource Quotas",
href: "/resourcequotas",
expectedSelector: "h5.title",
expectedText: "Resource Quotas",
},
{
name: "Limit Ranges",
href: "/limitranges",
expectedSelector: "h5.title",
expectedText: "Limit Ranges",
},
{
name: "HPA",
href: "/hpa",
expectedSelector: "h5.title",
expectedText: "Horizontal Pod Autoscalers",
},
{
name: "Pod Disruption Budgets",
href: "/poddisruptionbudgets",
expectedSelector: "h5.title",
expectedText: "Pod Disruption Budgets",
},
],
},
{
drawerId: "networks",
pages: [
{
name: "Services",
href: "/services",
expectedSelector: "h5.title",
expectedText: "Services",
},
{
name: "Endpoints",
href: "/endpoints",
expectedSelector: "h5.title",
expectedText: "Endpoints",
},
{
name: "Ingresses",
href: "/ingresses",
expectedSelector: "h5.title",
expectedText: "Ingresses",
},
{
name: "Network Policies",
href: "/network-policies",
expectedSelector: "h5.title",
expectedText: "Network Policies",
},
],
},
{
drawerId: "storage",
pages: [
{
name: "Persistent Volume Claims",
href: "/persistent-volume-claims",
expectedSelector: "h5.title",
expectedText: "Persistent Volume Claims",
},
{
name: "Persistent Volumes",
href: "/persistent-volumes",
expectedSelector: "h5.title",
expectedText: "Persistent Volumes",
},
{
name: "Storage Classes",
href: "/storage-classes",
expectedSelector: "h5.title",
expectedText: "Storage Classes",
},
],
},
{
page: {
name: "Namespaces",
href: "/namespaces",
expectedSelector: "h5.title",
expectedText: "Namespaces",
},
},
{
page: {
name: "Events",
href: "/events",
expectedSelector: "h5.title",
expectedText: "Events",
},
},
{
drawerId: "helm",
pages: [
{
name: "Charts",
href: "/helm/charts",
expectedSelector: "div.HelmCharts input",
},
{
name: "Releases",
href: "/helm/releases",
expectedSelector: "h5.title",
expectedText: "Releases",
},
],
},
{
drawerId: "users",
pages: [
{
name: "Service Accounts",
href: "/service-accounts",
expectedSelector: "h5.title",
expectedText: "Service Accounts",
},
{
name: "Roles",
href: "/roles",
expectedSelector: "h5.title",
expectedText: "Roles",
},
{
name: "Cluster Roles",
href: "/cluster-roles",
expectedSelector: "h5.title",
expectedText: "Cluster Roles",
},
{
name: "Role Bindings",
href: "/role-bindings",
expectedSelector: "h5.title",
expectedText: "Role Bindings",
},
{
name: "Cluster Role Bindings",
href: "/cluster-role-bindings",
expectedSelector: "h5.title",
expectedText: "Cluster Role Bindings",
},
{
name: "Pod Security Policies",
href: "/pod-security-policies",
expectedSelector: "h5.title",
expectedText: "Pod Security Policies",
},
],
},
{
drawerId: "custom-resources",
pages: [
{
name: "Definitions",
href: "/crd/definitions",
expectedSelector: "h5.title",
expectedText: "Custom Resources",
},
],
}];
utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
let window: Page, cleanup: () => Promise<void>, frame: Frame;
@ -323,54 +39,59 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
await frame.waitForSelector(`.Menu >> text="Remove"`);
});
it("should navigate around common cluster pages", async () => {
for (const test of commonPageTests) {
if (isTopPageTest(test)) {
const { href, expectedText, expectedSelector } = test.page;
const menuButton = await frame.waitForSelector(`a[href^="${href}"]`);
it(
"should navigate around common cluster pages",
await menuButton.click();
await frame.waitForSelector(`${expectedSelector} >> text='${expectedText}'`);
async () => {
const scenariosByParent = pipeline(
scenarios,
groupBy("parentSidebarItemTestId"),
toPairs,
);
continue;
for (const [parentSidebarItemTestId, scenarios] of scenariosByParent) {
if (parentSidebarItemTestId !== "null") {
await frame.click(`[data-testid="${parentSidebarItemTestId}"]`);
}
const { drawerId, pages } = test;
const selectors = getSidebarSelectors(drawerId);
const mainPageSelector = `${selectors.subMenuLink(pages[0].href)} >> text='${pages[0].name}'`;
for (const scenario of scenarios) {
await frame.click(`[data-testid="${scenario.sidebarItemTestId}"]`);
await frame.click(selectors.expandSubMenu);
await frame.waitForSelector(mainPageSelector);
for (const page of pages) {
const subPageButton = await frame.waitForSelector(selectors.subMenuLink(page.href));
await subPageButton.click();
await frame.waitForSelector(getLoadedSelector(page));
await frame.waitForSelector(
scenario.expectedSelector,
selectorTimeout,
);
}
await frame.click(selectors.expandSubMenu);
await frame.waitForSelector(mainPageSelector, { state: "hidden" });
}
}, 10*60*1000);
},
it("show logs and highlight the log search entries", async () => {
await frame.click(`a[href="/workloads"]`);
await frame.click(`a[href="/pods"]`);
10 * 60 * 1000,
);
const namespacesSelector = await frame.waitForSelector(".NamespaceSelect");
it(
"show logs and highlight the log search entries",
async () => {
await navigateToPods(frame);
const namespacesSelector = await frame.waitForSelector(
".NamespaceSelect",
);
await namespacesSelector.click();
await namespacesSelector.type("kube-system");
await namespacesSelector.press("Enter");
await namespacesSelector.click();
const kubeApiServerRow = await frame.waitForSelector("div.TableCell >> text=kube-apiserver");
const kubeApiServerRow = await frame.waitForSelector(
"div.TableCell >> text=kube-apiserver",
);
await kubeApiServerRow.click();
await frame.waitForSelector(".Drawer", { state: "visible" });
const showPodLogsIcon = await frame.waitForSelector(".Drawer .drawer-title .Icon >> text=subject");
const showPodLogsIcon = await frame.waitForSelector(
".Drawer .drawer-title .Icon >> text=subject",
);
showPodLogsIcon.click();
@ -379,45 +100,61 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
await frame.waitForSelector(".LogList .VirtualList");
await frame.waitForSelector(".LogResourceSelector");
const logSearchInput = await frame.waitForSelector(".LogSearch .SearchInput input");
const logSearchInput = await frame.waitForSelector(
".LogSearch .SearchInput input",
);
await logSearchInput.type(":");
await frame.waitForSelector(".LogList .list span.active");
const showTimestampsButton = await frame.waitForSelector(".LogControls .show-timestamps");
const showTimestampsButton = await frame.waitForSelector(
".LogControls .show-timestamps",
);
await showTimestampsButton.click();
const showPreviousButton = await frame.waitForSelector(".LogControls .show-previous");
const showPreviousButton = await frame.waitForSelector(
".LogControls .show-previous",
);
await showPreviousButton.click();
}, 10*60*1000);
},
10 * 60 * 1000,
);
it("should show the default namespaces", async () => {
await frame.click('a[href="/namespaces"]');
it(
"should show the default namespaces",
async () => {
await navigateToNamespaces(frame);
await frame.waitForSelector("div.TableCell >> text='default'");
await frame.waitForSelector("div.TableCell >> text='kube-system'");
}, 10*60*1000);
},
10 * 60 * 1000,
);
it(`should create the ${TEST_NAMESPACE} and a pod in the namespace`, async () => {
await frame.click('a[href="/namespaces"]');
it(
`should create the ${TEST_NAMESPACE} and a pod in the namespace`,
async () => {
await navigateToNamespaces(frame);
await frame.click("button.add-button");
await frame.waitForSelector("div.AddNamespaceDialog >> text='Create Namespace'");
await frame.waitForSelector(
"div.AddNamespaceDialog >> text='Create Namespace'",
);
const namespaceNameInput = await frame.waitForSelector(".AddNamespaceDialog input");
const namespaceNameInput = await frame.waitForSelector(
".AddNamespaceDialog input",
);
await namespaceNameInput.type(TEST_NAMESPACE);
await namespaceNameInput.press("Enter");
await frame.waitForSelector(`div.TableCell >> text=${TEST_NAMESPACE}`);
if ((await frame.innerText(`a[href^="/workloads"] .expand-icon`)) === "keyboard_arrow_down") {
await frame.click(`a[href^="/workloads"]`);
}
await navigateToPods(frame);
await frame.click(`a[href^="/pods"]`);
const namespacesSelector = await frame.waitForSelector(".NamespaceSelect");
const namespacesSelector = await frame.waitForSelector(
".NamespaceSelect",
);
await namespacesSelector.click();
await namespacesSelector.type(TEST_NAMESPACE);
@ -441,7 +178,9 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
}
const testPodName = "nginx-create-pod-test";
const monacoEditor = await frame.waitForSelector(`.Dock.isOpen [data-test-component="monaco-editor"]`);
const monacoEditor = await frame.waitForSelector(
`.Dock.isOpen [data-test-component="monaco-editor"]`,
);
await monacoEditor.click();
await monacoEditor.type("apiVersion: v1", { delay: 10 });
@ -466,5 +205,224 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
await frame.click(".Dock .Button >> text='Create'");
await frame.waitForSelector(`.TableCell >> text=${testPodName}`);
}, 10*60*1000);
},
10 * 60 * 1000,
);
});
const selectorTimeout = { timeout: 30000 };
const scenarios = [
{
expectedSelector: "div[data-testid='cluster-overview-page'] div.label",
parentSidebarItemTestId: null,
sidebarItemTestId: "sidebar-item-link-for-cluster-overview",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: null,
sidebarItemTestId: "sidebar-item-link-for-nodes",
},
{
expectedSelector: 'h5 >> text="Overview"',
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-overview",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-pods",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-deployments",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-daemon-sets",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-stateful-sets",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-replica-sets",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-jobs",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-workloads",
sidebarItemTestId: "sidebar-item-link-for-cron-jobs",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-config-maps",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-secrets",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-resource-quotas",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-limit-ranges",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-horizontal-pod-auto-scalers",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-config",
sidebarItemTestId: "sidebar-item-link-for-pod-disruption-budgets",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-network",
sidebarItemTestId: "sidebar-item-link-for-services",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-network",
sidebarItemTestId: "sidebar-item-link-for-endpoints",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-network",
sidebarItemTestId: "sidebar-item-link-for-ingresses",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-network",
sidebarItemTestId: "sidebar-item-link-for-network-policies",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-storage",
sidebarItemTestId: "sidebar-item-link-for-persistent-volume-claims",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-storage",
sidebarItemTestId: "sidebar-item-link-for-persistent-volumes",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-storage",
sidebarItemTestId: "sidebar-item-link-for-storage-classes",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: null,
sidebarItemTestId: "sidebar-item-link-for-namespaces",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: null,
sidebarItemTestId: "sidebar-item-link-for-events",
},
{
expectedSelector: "div.HelmCharts input",
parentSidebarItemTestId: "sidebar-item-link-for-helm",
sidebarItemTestId: "sidebar-item-link-for-charts",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-helm",
sidebarItemTestId: "sidebar-item-link-for-releases",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-service-accounts",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-roles",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-cluster-roles",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-role-bindings",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-cluster-role-bindings",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: "sidebar-item-link-for-user-management",
sidebarItemTestId: "sidebar-item-link-for-pod-security-policies",
},
{
expectedSelector: "h5.title",
parentSidebarItemTestId: null,
sidebarItemTestId: "sidebar-item-link-for-custom-resources",
},
];
const navigateToPods = async (frame: Frame) => {
await frame.click(`[data-testid="sidebar-item-link-for-workloads"]`);
await frame.click(`[data-testid="sidebar-item-link-for-pods"]`);
};
const navigateToNamespaces = async (frame: Frame) => {
await frame.click(`[data-testid="sidebar-item-link-for-namespaces"]`);
};

View File

@ -202,8 +202,9 @@
"@hapi/call": "^8.0.1",
"@hapi/subtext": "^7.0.3",
"@kubernetes/client-node": "^0.16.3",
"@ogre-tools/injectable": "5.1.2",
"@ogre-tools/injectable-react": "5.1.2",
"@ogre-tools/injectable": "5.2.0",
"@ogre-tools/injectable-react": "5.2.0",
"@ogre-tools/fp": "5.2.0",
"@sentry/electron": "^2.5.4",
"@sentry/integrations": "^6.19.2",
"@types/circular-dependency-plugin": "5.0.5",

View File

@ -7,10 +7,14 @@ import mockFs from "mock-fs";
import { BaseStore } from "../base-store";
import { action, comparer, makeObservable, observable, toJS } from "mobx";
import { readFileSync } from "fs";
import { getDisForUnitTesting } from "../../test-utils/get-dis-for-unit-testing";
import directoryForUserDataInjectable
from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import getConfigurationFileModelInjectable
from "../get-configuration-file-model/get-configuration-file-model.injectable";
import appVersionInjectable
from "../get-configuration-file-model/app-version/app-version.injectable";
jest.mock("electron", () => ({
ipcMain: {
@ -78,11 +82,13 @@ describe("BaseStore", () => {
let store: TestStore;
beforeEach(async () => {
const dis = getDisForUnitTesting({ doGeneralOverrides: true });
const mainDi = getDiForUnitTesting({ doGeneralOverrides: true });
dis.mainDi.override(directoryForUserDataInjectable, () => "some-user-data-directory");
mainDi.override(directoryForUserDataInjectable, () => "some-user-data-directory");
mainDi.permitSideEffects(getConfigurationFileModelInjectable);
mainDi.permitSideEffects(appVersionInjectable);
await dis.runSetups();
await mainDi.runSetups();
store = undefined;
TestStore.resetInstance();
@ -99,9 +105,9 @@ describe("BaseStore", () => {
});
afterEach(() => {
mockFs.restore();
store.disableSync();
TestStore.resetInstance();
mockFs.restore();
});
describe("persistence", () => {

View File

@ -18,12 +18,12 @@ import type {
DiContainer,
} from "@ogre-tools/injectable";
import { getDisForUnitTesting } from "../../test-utils/get-dis-for-unit-testing";
import { createClusterInjectionToken } from "../cluster/create-cluster-injection-token";
import directoryForUserDataInjectable
from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import getConfigurationFileModelInjectable from "../get-configuration-file-model/get-configuration-file-model.injectable";
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
console = new Console(stdout, stderr);
@ -80,15 +80,17 @@ describe("cluster-store", () => {
let createCluster: (model: ClusterModel) => Cluster;
beforeEach(async () => {
const dis = getDisForUnitTesting({ doGeneralOverrides: true });
mainDi = getDiForUnitTesting({ doGeneralOverrides: true });
mockFs();
mainDi = dis.mainDi;
mainDi.override(clusterStoreInjectable, (di) => ClusterStore.createInstance({ createCluster: di.inject(createClusterInjectionToken) }));
mainDi.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
await dis.runSetups();
mainDi.permitSideEffects(getConfigurationFileModelInjectable);
mainDi.permitSideEffects(appVersionInjectable);
await mainDi.runSetups();
createCluster = mainDi.inject(createClusterInjectionToken);
});

View File

@ -7,10 +7,13 @@ import { anyObject } from "jest-mock-extended";
import mockFs from "mock-fs";
import logger from "../../main/logger";
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
import { HotbarStore } from "../hotbar-store";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import writeFileInjectable from "../fs/write-file.injectable";
import getConfigurationFileModelInjectable from "../get-configuration-file-model/get-configuration-file-model.injectable";
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
import type { DiContainer } from "@ogre-tools/injectable";
import hotbarStoreInjectable from "../hotbar-store.injectable";
import { HotbarStore } from "../hotbar-store";
import catalogCatalogEntityInjectable from "../catalog-entities/general-catalog-entities/implementations/catalog-catalog-entity.injectable";
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
catalogEntityRegistry: {
@ -18,9 +21,11 @@ jest.mock("../../main/catalog/catalog-entity-registry", () => ({
getMockCatalogEntity({
apiVersion: "v1",
kind: "Cluster",
status: {
phase: "Running",
},
metadata: {
uid: "1dfa26e2ebab15780a3547e9c7fa785c",
name: "mycluster",
@ -28,12 +33,15 @@ jest.mock("../../main/catalog/catalog-entity-registry", () => ({
labels: {},
},
}),
getMockCatalogEntity({
apiVersion: "v1",
kind: "Cluster",
status: {
phase: "Running",
},
metadata: {
uid: "55b42c3c7ba3b04193416cda405269a5",
name: "my_shiny_cluster",
@ -41,12 +49,15 @@ jest.mock("../../main/catalog/catalog-entity-registry", () => ({
labels: {},
},
}),
getMockCatalogEntity({
apiVersion: "v1",
kind: "Cluster",
status: {
phase: "Running",
},
metadata: {
uid: "catalog-entity",
name: "Catalog",
@ -113,38 +124,45 @@ const awsCluster = getMockCatalogEntity({
});
describe("HotbarStore", () => {
let di: DiContainer;
let hotbarStore: HotbarStore;
beforeEach(async () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting({ doGeneralOverrides: true });
di.override(writeFileInjectable, () => () => undefined);
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
di.permitSideEffects(getConfigurationFileModelInjectable);
di.permitSideEffects(appVersionInjectable);
await di.runSetups();
di.override(hotbarStoreInjectable, () => {
HotbarStore.resetInstance();
mockFs({
"some-directory-for-user-data": {
"lens-hotbar-store.json": JSON.stringify({}),
},
return HotbarStore.createInstance({
catalogCatalogEntity: di.inject(catalogCatalogEntityInjectable),
});
});
HotbarStore.createInstance();
});
afterEach(() => {
HotbarStore.resetInstance();
mockFs.restore();
});
describe("given no migrations", () => {
beforeEach(async () => {
mockFs();
await di.runSetups();
hotbarStore = di.inject(hotbarStoreInjectable);
});
describe("load", () => {
it("loads one hotbar by default", () => {
expect(HotbarStore.getInstance().hotbars.length).toEqual(1);
expect(hotbarStore.hotbars.length).toEqual(1);
});
});
describe("add", () => {
it("adds a hotbar", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.add({ name: "hottest" });
expect(hotbarStore.hotbars.length).toEqual(2);
});
@ -152,20 +170,14 @@ describe("HotbarStore", () => {
describe("hotbar items", () => {
it("initially creates 12 empty cells", () => {
const hotbarStore = HotbarStore.getInstance();
expect(hotbarStore.getActive().items.length).toEqual(12);
});
it("initially adds catalog entity as first item", () => {
const hotbarStore = HotbarStore.getInstance();
expect(hotbarStore.getActive().items[0].entity.name).toEqual("Catalog");
});
it("adds items", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
const items = hotbarStore.getActive().items.filter(Boolean);
@ -173,8 +185,6 @@ describe("HotbarStore", () => {
});
it("removes items", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.removeFromHotbar("test");
hotbarStore.removeFromHotbar("catalog-entity");
@ -184,8 +194,6 @@ describe("HotbarStore", () => {
});
it("does nothing if removing with invalid uid", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.removeFromHotbar("invalid uid");
const items = hotbarStore.getActive().items.filter(Boolean);
@ -194,8 +202,6 @@ describe("HotbarStore", () => {
});
it("moves item to empty cell", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.addToHotbar(minikubeCluster);
hotbarStore.addToHotbar(awsCluster);
@ -209,8 +215,6 @@ describe("HotbarStore", () => {
});
it("moves items down", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.addToHotbar(minikubeCluster);
hotbarStore.addToHotbar(awsCluster);
@ -224,8 +228,6 @@ describe("HotbarStore", () => {
});
it("moves items up", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.addToHotbar(minikubeCluster);
hotbarStore.addToHotbar(awsCluster);
@ -239,8 +241,6 @@ describe("HotbarStore", () => {
});
it("logs an error if cellIndex is out of bounds", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.add({ name: "hottest", id: "hottest" });
hotbarStore.setActiveHotbar("hottest");
@ -262,22 +262,16 @@ describe("HotbarStore", () => {
});
it("throws an error if getId is invalid or returns not a string", () => {
const hotbarStore = HotbarStore.getInstance();
expect(() => hotbarStore.addToHotbar({} as any)).toThrowError(TypeError);
expect(() => hotbarStore.addToHotbar({ getId: () => true } as any)).toThrowError(TypeError);
});
it("throws an error if getName is invalid or returns not a string", () => {
const hotbarStore = HotbarStore.getInstance();
expect(() => hotbarStore.addToHotbar({ getId: () => "" } as any)).toThrowError(TypeError);
expect(() => hotbarStore.addToHotbar({ getId: () => "", getName: () => 4 } as any)).toThrowError(TypeError);
});
it("does nothing when item moved to same cell", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.restackItems(1, 1);
@ -285,8 +279,6 @@ describe("HotbarStore", () => {
});
it("new items takes first empty cell", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
hotbarStore.addToHotbar(awsCluster);
hotbarStore.restackItems(0, 3);
@ -302,8 +294,6 @@ describe("HotbarStore", () => {
console.error = jest.fn();
console.warn = jest.fn();
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
expect(() => hotbarStore.restackItems(-5, 0)).toThrow();
@ -317,66 +307,64 @@ describe("HotbarStore", () => {
});
it("checks if entity already pinned to hotbar", () => {
const hotbarStore = HotbarStore.getInstance();
hotbarStore.addToHotbar(testCluster);
expect(hotbarStore.isAddedToActive(testCluster)).toBeTruthy();
expect(hotbarStore.isAddedToActive(awsCluster)).toBeFalsy();
});
});
});
describe("pre beta-5 migrations", () => {
beforeEach(() => {
HotbarStore.resetInstance();
const mockOpts = {
"some-directory-for-user-data": {
describe("given pre beta-5 configurations", () => {
beforeEach(async () => {
const configurationToBeMigrated = {
"some-electron-app-path-for-user-data": {
"lens-hotbar-store.json": JSON.stringify({
__internal__: {
migrations: {
version: "5.0.0-beta.3",
},
},
"hotbars": [
hotbars: [
{
"id": "3caac17f-aec2-4723-9694-ad204465d935",
"name": "myhotbar",
"items": [
id: "3caac17f-aec2-4723-9694-ad204465d935",
name: "myhotbar",
items: [
{
"entity": {
"uid": "1dfa26e2ebab15780a3547e9c7fa785c",
entity: {
uid: "1dfa26e2ebab15780a3547e9c7fa785c",
},
},
{
"entity": {
"uid": "55b42c3c7ba3b04193416cda405269a5",
entity: {
uid: "55b42c3c7ba3b04193416cda405269a5",
},
},
{
"entity": {
"uid": "176fd331968660832f62283219d7eb6e",
entity: {
uid: "176fd331968660832f62283219d7eb6e",
},
},
{
"entity": {
"uid": "61c4fb45528840ebad1badc25da41d14",
"name": "user1-context",
"source": "local",
entity: {
uid: "61c4fb45528840ebad1badc25da41d14",
name: "user1-context",
source: "local",
},
},
{
"entity": {
"uid": "27d6f99fe9e7548a6e306760bfe19969",
"name": "foo2",
"source": "local",
entity: {
uid: "27d6f99fe9e7548a6e306760bfe19969",
name: "foo2",
source: "local",
},
},
null,
{
"entity": {
"uid": "c0b20040646849bb4dcf773e43a0bf27",
"name": "multinode-demo",
"source": "local",
entity: {
uid: "c0b20040646849bb4dcf773e43a0bf27",
name: "multinode-demo",
source: "local",
},
},
null,
@ -391,29 +379,27 @@ describe("HotbarStore", () => {
},
};
mockFs(mockOpts);
mockFs(configurationToBeMigrated);
HotbarStore.createInstance();
});
await di.runSetups();
afterEach(() => {
mockFs.restore();
hotbarStore = di.inject(hotbarStoreInjectable);
});
it("allows to retrieve a hotbar", () => {
const hotbar = HotbarStore.getInstance().getById("3caac17f-aec2-4723-9694-ad204465d935");
const hotbar = hotbarStore.getById("3caac17f-aec2-4723-9694-ad204465d935");
expect(hotbar.id).toBe("3caac17f-aec2-4723-9694-ad204465d935");
});
it("clears cells without entity", () => {
const items = HotbarStore.getInstance().hotbars[0].items;
const items = hotbarStore.hotbars[0].items;
expect(items[2]).toBeNull();
});
it("adds extra data to cells with according entity", () => {
const items = HotbarStore.getInstance().hotbars[0].items;
const items = hotbarStore.hotbars[0].items;
expect(items[0]).toEqual({
entity: {

View File

@ -26,34 +26,41 @@ import { Console } from "console";
import { SemVer } from "semver";
import electron from "electron";
import { stdout, stderr } from "process";
import { getDisForUnitTesting } from "../../test-utils/get-dis-for-unit-testing";
import userStoreInjectable from "../user-store/user-store.injectable";
import type { DiContainer } from "@ogre-tools/injectable";
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import type { ClusterStoreModel } from "../cluster-store/cluster-store";
import { defaultTheme } from "../vars";
import writeFileInjectable from "../fs/write-file.injectable";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import getConfigurationFileModelInjectable
from "../get-configuration-file-model/get-configuration-file-model.injectable";
import appVersionInjectable
from "../get-configuration-file-model/app-version/app-version.injectable";
console = new Console(stdout, stderr);
describe("user store tests", () => {
let userStore: UserStore;
let mainDi: DiContainer;
let di: DiContainer;
beforeEach(async () => {
const dis = getDisForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting({ doGeneralOverrides: true });
mockFs();
mainDi = dis.mainDi;
di.override(writeFileInjectable, () => () => undefined);
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
di.override(userStoreInjectable, () => UserStore.createInstance());
mainDi.override(writeFileInjectable, () => () => undefined);
mainDi.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
di.permitSideEffects(getConfigurationFileModelInjectable);
di.permitSideEffects(appVersionInjectable);
await dis.runSetups();
await di.runSetups();
});
afterEach(() => {
UserStore.resetInstance();
mockFs.restore();
});
@ -61,12 +68,7 @@ describe("user store tests", () => {
beforeEach(() => {
mockFs({ "some-directory-for-user-data": { "config.json": "{}", "kube_config": "{}" }});
userStore = mainDi.inject(userStoreInjectable);
});
afterEach(() => {
mockFs.restore();
UserStore.resetInstance();
userStore = di.inject(userStoreInjectable);
});
it("allows setting and retrieving lastSeenAppVersion", () => {
@ -128,12 +130,7 @@ describe("user store tests", () => {
},
});
userStore = mainDi.inject(userStoreInjectable);
});
afterEach(() => {
UserStore.resetInstance();
mockFs.restore();
userStore = di.inject(userStoreInjectable);
});
it("sets last seen app version to 0.0.0", () => {

View File

@ -10,7 +10,6 @@ import type { PathName } from "./app-path-names";
import setElectronAppPathInjectable from "../../main/app-paths/set-electron-app-path/set-electron-app-path.injectable";
import appNameInjectable from "../../main/app-paths/app-name/app-name.injectable";
import directoryForIntegrationTestingInjectable from "../../main/app-paths/directory-for-integration-testing/directory-for-integration-testing.injectable";
import path from "path";
describe("app-paths", () => {
let mainDi: DiContainer;
@ -85,7 +84,7 @@ describe("app-paths", () => {
recent: "some-recent",
temp: "some-temp",
videos: "some-videos",
userData: `some-app-data${path.sep}some-app-name`,
userData: "some-app-data/some-app-name",
});
});
@ -108,7 +107,7 @@ describe("app-paths", () => {
recent: "some-recent",
temp: "some-temp",
videos: "some-videos",
userData: `some-app-data${path.sep}some-app-name`,
userData: "some-app-data/some-app-name",
});
});
});
@ -128,7 +127,7 @@ describe("app-paths", () => {
expect({ appData, userData }).toEqual({
appData: "some-integration-testing-app-data",
userData: `some-integration-testing-app-data${path.sep}some-app-name`,
userData: `some-integration-testing-app-data/some-app-name`,
});
});
@ -137,7 +136,7 @@ describe("app-paths", () => {
expect({ appData, userData }).toEqual({
appData: "some-integration-testing-app-data",
userData: `some-integration-testing-app-data${path.sep}some-app-name`,
userData: "some-integration-testing-app-data/some-app-name",
});
});
});

View File

@ -3,14 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";
import getAbsolutePathInjectable from "../../path/get-absolute-path.injectable";
const directoryForBinariesInjectable = getInjectable({
id: "directory-for-binaries",
instantiate: (di) =>
path.join(di.inject(directoryForUserDataInjectable), "binaries"),
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const directoryForUserData = di.inject(directoryForUserDataInjectable);
return getAbsolutePath(directoryForUserData, "binaries");
},
});
export default directoryForBinariesInjectable;

View File

@ -4,13 +4,20 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";
import path from "path";
import getAbsolutePathInjectable from "../../path/get-absolute-path.injectable";
const directoryForKubeConfigsInjectable = getInjectable({
id: "directory-for-kube-configs",
instantiate: (di) =>
path.resolve(di.inject(directoryForUserDataInjectable), "kubeconfigs"),
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const directoryForUserData = di.inject(directoryForUserDataInjectable);
return getAbsolutePath(
directoryForUserData,
"kubeconfigs",
);
},
});
export default directoryForKubeConfigsInjectable;

View File

@ -0,0 +1,21 @@
/**
* 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 directoryForBinariesInjectable from "../directory-for-binaries/directory-for-binaries.injectable";
import getAbsolutePathInjectable from "../../path/get-absolute-path.injectable";
const directoryForKubectlBinariesInjectable = getInjectable({
id: "directory-for-kubectl-binaries",
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const directoryForBinaries = di.inject(directoryForBinariesInjectable);
return getAbsolutePath(directoryForBinaries, "kubectl");
},
});
export default directoryForKubectlBinariesInjectable;

View File

@ -3,19 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForKubeConfigsInjectable from "../directory-for-kube-configs/directory-for-kube-configs.injectable";
import getAbsolutePathInjectable from "../../path/get-absolute-path.injectable";
const getCustomKubeConfigDirectoryInjectable = getInjectable({
id: "get-custom-kube-config-directory",
instantiate: (di) => (directoryName: string) => {
instantiate: (di) => {
const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable);
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
return path.resolve(
directoryForKubeConfigs,
directoryName,
);
return (directoryName: string) =>
getAbsolutePath(directoryForKubeConfigs, directoryName);
},
});

View File

@ -4,7 +4,7 @@
*/
import path from "path";
import Config from "conf";
import type Config from "conf";
import type { Options as ConfOptions } from "conf/dist/source/types";
import { ipcMain, ipcRenderer } from "electron";
import { IEqualsComparer, makeObservable, reaction, runInAction } from "mobx";
@ -15,8 +15,8 @@ import isEqual from "lodash/isEqual";
import { isTestEnv } from "./vars";
import { kebabCase } from "lodash";
import { getLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import directoryForUserDataInjectable
from "./app-paths/directory-for-user-data/directory-for-user-data.injectable";
import directoryForUserDataInjectable from "./app-paths/directory-for-user-data/directory-for-user-data.injectable";
import getConfigurationFileModelInjectable from "./get-configuration-file-model/get-configuration-file-model.injectable";
export interface BaseStoreParams<T> extends ConfOptions<T> {
syncOptions?: {
@ -51,7 +51,11 @@ export abstract class BaseStore<T> extends Singleton {
logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADING from ${this.path} ...`);
}
this.storeConfig = new Config({
const di = getLegacyGlobalDiForExtensionApi();
const getConfigurationFileModel = di.inject(getConfigurationFileModelInjectable);
this.storeConfig = getConfigurationFileModel({
...this.params,
projectName: "lens",
projectVersion: getAppVersion(),

View File

@ -0,0 +1,10 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
import type { GeneralEntity } from "../index";
export const generalCatalogEntityInjectionToken = getInjectionToken<GeneralEntity>({
id: "general-catalog-entity-injection-token",
});

View File

@ -0,0 +1,41 @@
/**
* 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 { generalCatalogEntityInjectionToken } from "../general-catalog-entity-injection-token";
import { GeneralEntity } from "../../index";
import { buildURL } from "../../../utils/buildUrl";
import catalogRouteInjectable from "../../../front-end-routing/routes/catalog/catalog-route.injectable";
const catalogCatalogEntityInjectable = getInjectable({
id: "general-catalog-entity-for-catalog",
instantiate: (di) => {
const route = di.inject(catalogRouteInjectable);
const url = buildURL(route.path);
return new GeneralEntity({
metadata: {
uid: "catalog-entity",
name: "Catalog",
source: "app",
labels: {},
},
spec: {
path: url,
icon: {
material: "view_list",
background: "#3d90ce",
},
},
status: {
phase: "active",
},
});
},
injectionToken: generalCatalogEntityInjectionToken,
});
export default catalogCatalogEntityInjectable;

View File

@ -0,0 +1,41 @@
/**
* 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 { generalCatalogEntityInjectionToken } from "../general-catalog-entity-injection-token";
import { GeneralEntity } from "../../index";
import { buildURL } from "../../../utils/buildUrl";
import appPreferencesRouteInjectable from "../../../front-end-routing/routes/preferences/app/app-preferences-route.injectable";
const preferencesCatalogEntityInjectable = getInjectable({
id: "general-catalog-entity-for-preferences",
instantiate: (di) => {
const route = di.inject(appPreferencesRouteInjectable);
const url = buildURL(route.path);
return new GeneralEntity({
metadata: {
uid: "preferences-entity",
name: "Preferences",
source: "app",
labels: {},
},
spec: {
path: url,
icon: {
material: "settings",
background: "#3d90ce",
},
},
status: {
phase: "active",
},
});
},
injectionToken: generalCatalogEntityInjectionToken,
});
export default preferencesCatalogEntityInjectable;

View File

@ -0,0 +1,41 @@
/**
* 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 { generalCatalogEntityInjectionToken } from "../general-catalog-entity-injection-token";
import { GeneralEntity } from "../../index";
import { buildURL } from "../../../utils/buildUrl";
import welcomeRouteInjectable from "../../../front-end-routing/routes/welcome/welcome-route.injectable";
const welcomeCatalogEntityInjectable = getInjectable({
id: "general-catalog-entity-for-welcome",
instantiate: (di) => {
const route = di.inject(welcomeRouteInjectable);
const url = buildURL(route.path);
return new GeneralEntity({
metadata: {
uid: "welcome-page-entity",
name: "Welcome Page",
source: "app",
labels: {},
},
spec: {
path: url,
icon: {
material: "meeting_room",
background: "#3d90ce",
},
},
status: {
phase: "active",
},
});
},
injectionToken: generalCatalogEntityInjectionToken,
});
export default welcomeCatalogEntityInjectable;

View File

@ -13,6 +13,8 @@ const clusterStoreInjectable = getInjectable({
ClusterStore.createInstance({
createCluster: di.inject(createClusterInjectionToken),
}),
causesSideEffects: true,
});
export default clusterStoreInjectable;

View File

@ -3,17 +3,21 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
import getAbsolutePathInjectable from "../path/get-absolute-path.injectable";
const directoryForLensLocalStorageInjectable = getInjectable({
id: "directory-for-lens-local-storage",
instantiate: (di) =>
path.resolve(
di.inject(directoryForUserDataInjectable),
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const directoryForUserData = di.inject(directoryForUserDataInjectable);
return getAbsolutePath(
directoryForUserData,
"lens-local-storage",
),
);
},
});
export default directoryForLensLocalStorageInjectable;

View File

@ -0,0 +1,13 @@
/**
* 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 navigateToCatalogInjectable from "./routes/catalog/navigate-to-catalog.injectable";
const navigateToFrontPageInjectable = getInjectable({
id: "navigate-to-front-page",
instantiate: (di) => di.inject(navigateToCatalogInjectable),
});
export default navigateToFrontPageInjectable;

View File

@ -0,0 +1,52 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
import type { Route } from "./route-injection-token";
type InferParametersFrom<TRoute> = TRoute extends Route<infer TParameters>
? TParameters
: never;
type RequiredKeys<T> = Exclude<
{
[K in keyof T]: T extends Record<K, T[K]> ? K : never;
}[keyof T],
undefined
>;
type ObjectContainingNoRequired<T> = T extends void
? never
: RequiredKeys<T> extends []
? any
: never;
type ObjectContainsNoRequired<T> = T extends ObjectContainingNoRequired<T>
? true
: false;
// TODO: Missing types for:
// - Navigating to route without parameters, with parameters
// - Navigating to route with required parameters, without parameters
type Parameters<TParameters> = TParameters extends void
? {}
: ObjectContainsNoRequired<TParameters> extends true
? { parameters?: TParameters }
: { parameters: TParameters };
export type NavigateToRouteOptions<TRoute> = Parameters<
InferParametersFrom<TRoute>
> & {
query?: Record<string, string>;
fragment?: string;
withoutAffectingBackButton?: boolean;
};
export type NavigateToRoute = <TRoute extends Route<unknown>>(
route: TRoute,
options?: NavigateToRouteOptions<TRoute>) => void;
export const navigateToRouteInjectionToken = getInjectionToken<NavigateToRoute>(
{ id: "navigate-to-route-injection-token" },
);

View File

@ -0,0 +1,16 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
export interface NavigateToUrlOptions {
withoutAffectingBackButton?: boolean;
forceRootFrame?: boolean;
}
export type NavigateToUrl = (url: string, options?: NavigateToUrlOptions) => void;
export const navigateToUrlInjectionToken = getInjectionToken<NavigateToUrl>(
{ id: "navigate-to-url-injection-token" },
);

View File

@ -0,0 +1,9 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { createChannel } from "../ipc-channel/create-channel/create-channel";
import { IpcRendererNavigationEvents } from "../../renderer/navigation/events";
export const appNavigationIpcChannel = createChannel<string>(IpcRendererNavigationEvents.NAVIGATE_IN_APP);
export const clusterFrameNavigationIpcChannel = createChannel<string>(IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER);

View File

@ -0,0 +1,20 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx";
import type { LensRendererExtension } from "../../extensions/lens-renderer-extension";
export const routeInjectionToken = getInjectionToken<Route<unknown>>({
id: "route-injection-token",
});
export interface Route<TParameter = void> {
path: string;
clusterFrame: boolean;
isEnabled: IComputedValue<boolean>;
extension?: LensRendererExtension;
readonly parameterSignature?: TParameter;
}

View File

@ -0,0 +1,21 @@
/**
* 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 { routeInjectionToken } from "../../route-injection-token";
const addClusterRouteInjectable = getInjectable({
id: "add-cluster-route",
instantiate: () => ({
path: "/add-cluster",
clusterFrame: false,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default addClusterRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 addClusterRouteInjectable from "./add-cluster-route.injectable";
import { navigateToRouteInjectionToken } from "../../navigate-to-route-injection-token";
const navigateToAddClusterInjectable = getInjectable({
id: "navigate-to-add-cluster",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(addClusterRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToAddClusterInjectable;

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 { Route, routeInjectionToken } from "../../route-injection-token";
export interface CatalogPathParameters {
group?: string;
kind?: string;
}
const catalogRouteInjectable = getInjectable({
id: "catalog-route",
instantiate: (): Route<CatalogPathParameters> => ({
path: "/catalog/:group?/:kind?",
clusterFrame: false,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default catalogRouteInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 catalogRouteInjectable, { CatalogPathParameters } from "./catalog-route.injectable";
import { navigateToRouteInjectionToken } from "../../navigate-to-route-injection-token";
export type NavigateToCatalog = (parameters?: CatalogPathParameters) => void;
const navigateToCatalogInjectable = getInjectable({
id: "navigate-to-catalog",
instantiate: (di): NavigateToCatalog => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const catalogRoute = di.inject(catalogRouteInjectable);
return (parameters) =>
navigateToRoute(catalogRoute, {
parameters,
});
},
});
export default navigateToCatalogInjectable;

View File

@ -0,0 +1,21 @@
/**
* 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 { routeInjectionToken } from "../../route-injection-token";
const clusterViewRouteInjectable = getInjectable({
id: "cluster-view-route",
instantiate: () => ({
path: "/cluster/:clusterId",
clusterFrame: false,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default clusterViewRouteInjectable;

View File

@ -0,0 +1,23 @@
/**
* 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 { navigateToRouteInjectionToken } from "../../navigate-to-route-injection-token";
import clusterViewRouteInjectable from "./cluster-view-route.injectable";
export type NavigateToClusterView = (clusterId: string) => void;
const navigateToClusterViewInjectable = getInjectable({
id: "navigate-to-cluster-view",
instantiate: (di): NavigateToClusterView => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(clusterViewRouteInjectable);
return (clusterId) =>
navigateToRoute(route, { parameters: { clusterId }});
},
});
export default navigateToClusterViewInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const configMapsRouteInjectable = getInjectable({
id: "config-maps-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "configmaps");
return {
path: "/configmaps",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default configMapsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 configMapsRouteInjectable from "./config-maps-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToConfigMapsInjectable = getInjectable({
id: "navigate-to-config-maps",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(configMapsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToConfigMapsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const horizontalPodAutoscalersRouteInjectable = getInjectable({
id: "horizontal-pod-autoscalers-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "horizontalpodautoscalers");
return {
path: "/hpa",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default horizontalPodAutoscalersRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 horizontalPodAutoscalersRouteInjectable from "./horizontal-pod-autoscalers-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToHorizontalPodAutoscalersInjectable = getInjectable({
id: "navigate-to-horizontal-pod-autoscalers",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(horizontalPodAutoscalersRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToHorizontalPodAutoscalersInjectable;

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.
*/
import { getInjectable } from "@ogre-tools/injectable";
import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const limitRangesRouteInjectable = getInjectable({
id: "limit-ranges-route",
instantiate: (di) => {
const limitRangesIsAllowed = di.inject(
isAllowedResourceInjectable,
"limitranges",
);
return {
path: "/limitranges",
clusterFrame: true,
isEnabled: limitRangesIsAllowed,
};
},
injectionToken: routeInjectionToken,
});
export default limitRangesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 limitRangesRouteInjectable from "./limit-ranges-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToLimitRangesInjectable = getInjectable({
id: "navigate-to-limit-ranges",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(limitRangesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToLimitRangesInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 podDisruptionBudgetsRouteInjectable from "./pod-disruption-budgets-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToPodDisruptionBudgetsInjectable = getInjectable({
id: "navigate-to-pod-disruption-budgets",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(podDisruptionBudgetsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToPodDisruptionBudgetsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const podDisruptionBudgetsRouteInjectable = getInjectable({
id: "pod-disruption-budgets-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "poddisruptionbudgets");
return {
path: "/poddisruptionbudgets",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default podDisruptionBudgetsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 resourceQuotasRouteInjectable from "./resource-quotas-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToResourceQuotasInjectable = getInjectable({
id: "navigate-to-resource-quotas",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(resourceQuotasRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToResourceQuotasInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const resourceQuotasRouteInjectable = getInjectable({
id: "resource-quotas-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "resourcequotas");
return {
path: "/resourcequotas",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default resourceQuotasRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 secretsRouteInjectable from "./secrets-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToSecretsInjectable = getInjectable({
id: "navigate-to-secrets",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(secretsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToSecretsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const secretsRouteInjectable = getInjectable({
id: "secrets-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "secrets");
return {
path: "/secrets",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default secretsRouteInjectable;

View File

@ -0,0 +1,21 @@
/**
* 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 { routeInjectionToken } from "../../../../route-injection-token";
const crdListRouteInjectable = getInjectable({
id: "crd-list-route",
instantiate: () => ({
path: "/crd/definitions",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default crdListRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 crdListRouteInjectable from "./crd-list-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToCrdListInjectable = getInjectable({
id: "navigate-to-crd-list",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(crdListRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToCrdListInjectable;

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 { Route, routeInjectionToken } from "../../../../route-injection-token";
export interface CustomResourcesPathParameters {
group?: string;
name?: string;
}
const customResourcesRouteInjectable = getInjectable({
id: "custom-resources-route",
instantiate: (): Route<CustomResourcesPathParameters> => ({
path: "/crd/:group?/:name?",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default customResourcesRouteInjectable;

View File

@ -0,0 +1,21 @@
/**
* 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 customResourcesRouteInjectable, { CustomResourcesPathParameters } from "./custom-resources-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToCustomResourcesInjectable = getInjectable({
id: "navigate-to-custom-resources",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(customResourcesRouteInjectable);
return (parameters?: CustomResourcesPathParameters) =>
navigateToRoute(route, { parameters });
},
});
export default navigateToCustomResourcesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../route-injection-token";
const eventsRouteInjectable = getInjectable({
id: "events-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "events");
return {
path: "/events",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default eventsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 eventsRouteInjectable from "./events-route.injectable";
import { navigateToRouteInjectionToken } from "../../../navigate-to-route-injection-token";
const navigateToEventsInjectable = getInjectable({
id: "navigate-to-events",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(eventsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToEventsInjectable;

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 { Route, routeInjectionToken } from "../../../../route-injection-token";
export interface HelmChartsPathParameters {
repo?: string;
chartName?: string;
}
const helmChartsRouteInjectable = getInjectable({
id: "helm-charts-route",
instantiate: (): Route<HelmChartsPathParameters> => ({
path: "/helm/charts/:repo?/:chartName?",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default helmChartsRouteInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 helmChartsRouteInjectable, { HelmChartsPathParameters } from "./helm-charts-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
export type NavigateToHelmCharts = (parameters?: HelmChartsPathParameters) => void;
const navigateToHelmChartsInjectable = getInjectable({
id: "navigate-to-helm-charts",
instantiate: (di): NavigateToHelmCharts => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(helmChartsRouteInjectable);
return (parameters) =>
navigateToRoute(route, {
parameters,
});
},
});
export default navigateToHelmChartsInjectable;

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 { Route, routeInjectionToken } from "../../../../route-injection-token";
export interface HelmReleasesPathParameters {
namespace?: string;
name?: string;
}
const helmReleasesRouteInjectable = getInjectable({
id: "helm-releases-route",
instantiate: (): Route<HelmReleasesPathParameters> => ({
path: "/helm/releases/:namespace?/:name?",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default helmReleasesRouteInjectable;

View File

@ -0,0 +1,23 @@
/**
* 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 helmReleasesRouteInjectable, { HelmReleasesPathParameters } from "./helm-releases-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
export type NavigateToHelmReleases = (parameters?: HelmReleasesPathParameters) => void;
const navigateToHelmReleasesInjectable = getInjectable({
id: "navigate-to-helm-releases",
instantiate: (di): NavigateToHelmReleases => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(helmReleasesRouteInjectable);
return (parameters) =>
navigateToRoute(route, { parameters });
},
});
export default navigateToHelmReleasesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../route-injection-token";
const namespacesRouteInjectable = getInjectable({
id: "namespaces-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "namespaces");
return {
path: "/namespaces",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default namespacesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 namespacesRouteInjectable from "./namespaces-route.injectable";
import { navigateToRouteInjectionToken } from "../../../navigate-to-route-injection-token";
const navigateToNamespacesInjectable = getInjectable({
id: "navigate-to-namespaces",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(namespacesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToNamespacesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const endpointsRouteInjectable = getInjectable({
id: "endpoints-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "endpoints");
return {
path: "/endpoints",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default endpointsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 endpointsRouteInjectable from "./endpoints-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToEndpointsInjectable = getInjectable({
id: "navigate-to-endpoints",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(endpointsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToEndpointsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const ingressesRouteInjectable = getInjectable({
id: "ingresses-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "ingresses");
return {
path: "/ingresses",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default ingressesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 ingressesRouteInjectable from "./ingresses-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToIngressesInjectable = getInjectable({
id: "navigate-to-ingresses",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(ingressesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToIngressesInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 networkPoliciesRouteInjectable from "./network-policies-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToNetworkPoliciesInjectable = getInjectable({
id: "navigate-to-network-policies",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(networkPoliciesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToNetworkPoliciesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const networkPoliciesRouteInjectable = getInjectable({
id: "network-policies-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "networkpolicies");
return {
path: "/network-policies",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default networkPoliciesRouteInjectable;

View File

@ -0,0 +1,23 @@
/**
* 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 portForwardsRouteInjectable, { PortForwardsPathParameters } from "./port-forwards-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
export type NavigateToPortForwards = (parameters?: PortForwardsPathParameters) => void;
const navigateToPortForwardsInjectable = getInjectable({
id: "navigate-to-port-forwards",
instantiate: (di): NavigateToPortForwards => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(portForwardsRouteInjectable);
return (parameters) =>
navigateToRoute(route, { parameters });
},
});
export default navigateToPortForwardsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 { Route, routeInjectionToken } from "../../../../route-injection-token";
export interface PortForwardsPathParameters {
forwardport?: string;
}
const portForwardsRouteInjectable = getInjectable({
id: "port-forwards-route",
instantiate: (): Route<PortForwardsPathParameters> => ({
path: "/port-forwards/:forwardport?",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default portForwardsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 servicesRouteInjectable from "./services-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToServicesInjectable = getInjectable({
id: "navigate-to-services",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(servicesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToServicesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const servicesRouteInjectable = getInjectable({
id: "services-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "services");
return {
path: "/services",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default servicesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 nodesRouteInjectable from "./nodes-route.injectable";
import { navigateToRouteInjectionToken } from "../../../navigate-to-route-injection-token";
const navigateToNodesInjectable = getInjectable({
id: "navigate-to-nodes",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(nodesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToNodesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../route-injection-token";
const nodesRouteInjectable = getInjectable({
id: "nodes-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "nodes");
return {
path: "/nodes",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default nodesRouteInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../route-injection-token";
const clusterOverviewRouteInjectable = getInjectable({
id: "cluster-overview-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "nodes");
return {
path: "/overview",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default clusterOverviewRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 clusterOverviewRouteInjectable from "./cluster-overview-route.injectable";
import { navigateToRouteInjectionToken } from "../../../navigate-to-route-injection-token";
const navigateToClusterOverviewInjectable = getInjectable({
id: "navigate-to-cluster-overview",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(clusterOverviewRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToClusterOverviewInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 persistentVolumeClaimsRouteInjectable from "./persistent-volume-claims-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToPersistentVolumeClaimsInjectable = getInjectable({
id: "navigate-to-persistent-volume-claims",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(persistentVolumeClaimsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToPersistentVolumeClaimsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const persistentVolumeClaimsRouteInjectable = getInjectable({
id: "persistent-volume-claims-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "persistentvolumeclaims");
return {
path: "/persistent-volume-claims",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default persistentVolumeClaimsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 persistentVolumesRouteInjectable from "./persistent-volumes-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToPersistentVolumesInjectable = getInjectable({
id: "navigate-to-persistent-volumes",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(persistentVolumesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToPersistentVolumesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const persistentVolumesRouteInjectable = getInjectable({
id: "persistent-volumes-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "persistentvolumes");
return {
path: "/persistent-volumes",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default persistentVolumesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 storageClassesRouteInjectable from "./storage-classes-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToStorageClassesInjectable = getInjectable({
id: "navigate-to-storage-classes",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(storageClassesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToStorageClassesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const storageClassesRouteInjectable = getInjectable({
id: "storage-classes-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "storageclasses");
return {
path: "/storage-classes",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default storageClassesRouteInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const clusterRoleBindingsRouteInjectable = getInjectable({
id: "cluster-role-bindings-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "clusterrolebindings");
return {
path: "/cluster-role-bindings",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default clusterRoleBindingsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 clusterRoleBindingsRouteInjectable from "./cluster-role-bindings-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToClusterRoleBindingsInjectable = getInjectable({
id: "navigate-to-cluster-role-bindings",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(clusterRoleBindingsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToClusterRoleBindingsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const clusterRolesRouteInjectable = getInjectable({
id: "cluster-roles-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "clusterroles");
return {
path: "/cluster-roles",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default clusterRolesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 clusterRolesRouteInjectable from "./cluster-roles-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToClusterRolesInjectable = getInjectable({
id: "navigate-to-cluster-roles",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(clusterRolesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToClusterRolesInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 podSecurityPoliciesRouteInjectable from "./pod-security-policies-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToPodSecurityPoliciesInjectable = getInjectable({
id: "navigate-to-pod-security-policies",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(podSecurityPoliciesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToPodSecurityPoliciesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const podSecurityPoliciesRouteInjectable = getInjectable({
id: "pod-security-policies-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "podsecuritypolicies");
return {
path: "/pod-security-policies",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default podSecurityPoliciesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 roleBindingsRouteInjectable from "./role-bindings-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToRoleBindingsInjectable = getInjectable({
id: "navigate-to-role-bindings",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(roleBindingsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToRoleBindingsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const roleBindingsRouteInjectable = getInjectable({
id: "role-bindings-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "rolebindings");
return {
path: "/role-bindings",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default roleBindingsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 rolesRouteInjectable from "./roles-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToRolesInjectable = getInjectable({
id: "navigate-to-roles",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(rolesRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToRolesInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const rolesRouteInjectable = getInjectable({
id: "roles-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "roles");
return {
path: "/roles",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default rolesRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 serviceAccountsRouteInjectable from "./service-accounts-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToServiceAccountsInjectable = getInjectable({
id: "navigate-to-service-accounts",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(serviceAccountsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToServiceAccountsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const serviceAccountsRouteInjectable = getInjectable({
id: "service-accounts-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "serviceaccounts");
return {
path: "/service-accounts",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default serviceAccountsRouteInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const cronJobsRouteInjectable = getInjectable({
id: "cron-jobs-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "cronjobs");
return {
path: "/cronjobs",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default cronJobsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 cronJobsRouteInjectable from "./cron-jobs-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToCronJobsInjectable = getInjectable({
id: "navigate-to-cron-jobs",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(cronJobsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToCronJobsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const daemonsetsRouteInjectable = getInjectable({
id: "daemonsets-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "daemonsets");
return {
path: "/daemonsets",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default daemonsetsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 daemonsetsRouteInjectable from "./daemonsets-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToDaemonsetsInjectable = getInjectable({
id: "navigate-to-daemonsets",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(daemonsetsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToDaemonsetsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const deploymentsRouteInjectable = getInjectable({
id: "deployments-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "deployments");
return {
path: "/deployments",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default deploymentsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 deploymentsRouteInjectable from "./deployments-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToDeploymentsInjectable = getInjectable({
id: "navigate-to-deployments",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(deploymentsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToDeploymentsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const jobsRouteInjectable = getInjectable({
id: "jobs-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "jobs");
return {
path: "/jobs",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default jobsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 jobsRouteInjectable from "./jobs-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToJobsInjectable = getInjectable({
id: "navigate-to-jobs",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(jobsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToJobsInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 workloadsOverviewRouteInjectable from "./workloads-overview-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToWorkloadsOverviewInjectable = getInjectable({
id: "navigate-to-workloads-overview",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(workloadsOverviewRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToWorkloadsOverviewInjectable;

View File

@ -0,0 +1,21 @@
/**
* 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 { routeInjectionToken } from "../../../../route-injection-token";
const workloadsOverviewRouteInjectable = getInjectable({
id: "workloads-overview-route",
instantiate: () => ({
path: "/workloads",
clusterFrame: true,
isEnabled: computed(() => true),
}),
injectionToken: routeInjectionToken,
});
export default workloadsOverviewRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 podsRouteInjectable from "./pods-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToPodsInjectable = getInjectable({
id: "navigate-to-pods",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(podsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToPodsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const podsRouteInjectable = getInjectable({
id: "pods-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "pods");
return {
path: "/pods",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default podsRouteInjectable;

View File

@ -0,0 +1,20 @@
/**
* 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 replicasetsRouteInjectable from "./replicasets-route.injectable";
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
const navigateToReplicasetsInjectable = getInjectable({
id: "navigate-to-replicasets",
instantiate: (di) => {
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
const route = di.inject(replicasetsRouteInjectable);
return () => navigateToRoute(route);
},
});
export default navigateToReplicasetsInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
import { routeInjectionToken } from "../../../../route-injection-token";
const replicasetsRouteInjectable = getInjectable({
id: "replicasets-route",
instantiate: (di) => {
const isAllowedResource = di.inject(isAllowedResourceInjectable, "replicasets");
return {
path: "/replicasets",
clusterFrame: true,
isEnabled: isAllowedResource,
};
},
injectionToken: routeInjectionToken,
});
export default replicasetsRouteInjectable;

Some files were not shown because too many files have changed in this diff Show More