mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Convert sidebarItemInjectionToken to use InjectWithMetadata instead of duplicating the IDs
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
72a1e2aaa0
commit
81293304a7
62 files changed
+145
-212
No files matched your search
+4
-4
@@ -37,7 +37,7 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
|
||||
clusterPageMenus: [
|
||||
{
|
||||
id: "some-sidebar-item",
|
||||
id: "sidebar-item-some",
|
||||
title: "Some sidebar item",
|
||||
|
||||
components: {
|
||||
@@ -60,7 +60,7 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
|
||||
it("does not show the sidebar item", () => {
|
||||
const actual = rendered.queryByTestId(
|
||||
"sidebar-item-some-extension-name-some-sidebar-item",
|
||||
"sidebar-item-sidebar-item-some-extension-name-some",
|
||||
);
|
||||
|
||||
expect(actual).not.toBeInTheDocument();
|
||||
@@ -78,7 +78,7 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
|
||||
it("does not show the sidebar item", () => {
|
||||
const actual = rendered.queryByTestId(
|
||||
"sidebar-item-some-extension-name-some-sidebar-item",
|
||||
"sidebar-item-sidebar-item-some-extension-name-some",
|
||||
);
|
||||
|
||||
expect(actual).not.toBeInTheDocument();
|
||||
@@ -96,7 +96,7 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
|
||||
it("shows the sidebar item", () => {
|
||||
const actual = rendered.getByTestId(
|
||||
"sidebar-item-test-extension-some-sidebar-item",
|
||||
"sidebar-item-sidebar-item-test-extension-some",
|
||||
);
|
||||
|
||||
expect(actual).toBeInTheDocument();
|
||||
|
||||
@@ -85,9 +85,8 @@ describe("cluster - order of sidebar items", () => {
|
||||
});
|
||||
|
||||
const someParentSidebarItemInjectable = getInjectable({
|
||||
id: "some-parent-sidebar-item",
|
||||
id: "sidebar-item-some-parent",
|
||||
instantiate: () => ({
|
||||
id: "some-parent-id",
|
||||
parentId: null,
|
||||
title: "Some parent",
|
||||
onClick: noop,
|
||||
@@ -97,9 +96,8 @@ const someParentSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someOtherParentSidebarItemInjectable = getInjectable({
|
||||
id: "some-other-parent-sidebar-item",
|
||||
id: "sidebar-item-some-other-parent",
|
||||
instantiate: () => ({
|
||||
id: "some-other-parent-id",
|
||||
parentId: null,
|
||||
title: "Some other parent",
|
||||
onClick: noop,
|
||||
@@ -109,9 +107,8 @@ const someOtherParentSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someAnotherParentSidebarItemInjectable = getInjectable({
|
||||
id: "some-another-parent-sidebar-item",
|
||||
id: "sidebar-item-some-another-parent",
|
||||
instantiate: () => ({
|
||||
id: "some-another-parent-id",
|
||||
parentId: null,
|
||||
title: "Some another parent",
|
||||
onClick: noop,
|
||||
@@ -121,10 +118,9 @@ const someAnotherParentSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someChildSidebarItemInjectable = getInjectable({
|
||||
id: "some-child-sidebar-item",
|
||||
instantiate: (di) => ({
|
||||
id: "some-child-id",
|
||||
parentId: di.inject(someParentSidebarItemInjectable).id,
|
||||
id: "sidebar-item-some-child",
|
||||
instantiate: () => ({
|
||||
parentId: someParentSidebarItemInjectable.id,
|
||||
title: "Some child",
|
||||
onClick: noop,
|
||||
orderNumber: 168,
|
||||
@@ -133,10 +129,9 @@ const someChildSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someOtherChildSidebarItemInjectable = getInjectable({
|
||||
id: "some-other-child-sidebar-item",
|
||||
instantiate: (di) => ({
|
||||
id: "some-other-child-id",
|
||||
parentId: di.inject(someParentSidebarItemInjectable).id,
|
||||
id: "sidebar-item-some-other-child",
|
||||
instantiate: () => ({
|
||||
parentId: someParentSidebarItemInjectable.id,
|
||||
title: "Some other child",
|
||||
onClick: noop,
|
||||
orderNumber: 252,
|
||||
@@ -145,10 +140,9 @@ const someOtherChildSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someAnotherChildSidebarItemInjectable = getInjectable({
|
||||
id: "some-another-child-sidebar-item",
|
||||
instantiate: (di) => ({
|
||||
id: "some-another-child-id",
|
||||
parentId: di.inject(someParentSidebarItemInjectable).id,
|
||||
id: "sidebar-item-some-another-child",
|
||||
instantiate: () => ({
|
||||
parentId: someParentSidebarItemInjectable.id,
|
||||
title: "Some another child",
|
||||
onClick: noop,
|
||||
orderNumber: 210,
|
||||
|
||||
@@ -295,9 +295,8 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
});
|
||||
|
||||
const someParentSidebarItemInjectable = getInjectable({
|
||||
id: "some-parent-sidebar-item",
|
||||
id: "sidebar-item-some-parent",
|
||||
instantiate: () => ({
|
||||
id: "some-parent-id",
|
||||
parentId: null,
|
||||
title: "Some parent",
|
||||
onClick: noop,
|
||||
@@ -308,15 +307,14 @@ const someParentSidebarItemInjectable = getInjectable({
|
||||
});
|
||||
|
||||
const someChildSidebarItemInjectable = getInjectable({
|
||||
id: "some-child-sidebar-item",
|
||||
id: "sidebar-item-some-child",
|
||||
instantiate: (di) => {
|
||||
const route = di.inject(testRouteInjectable);
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
const routeIsActive = di.inject(routeIsActiveInjectable, route);
|
||||
|
||||
return {
|
||||
id: "some-child-id",
|
||||
parentId: di.inject(someParentSidebarItemInjectable).id,
|
||||
parentId: someParentSidebarItemInjectable.id,
|
||||
title: "Some child",
|
||||
onClick: () => navigateToRoute(route),
|
||||
isActive: routeIsActive,
|
||||
|
||||
@@ -27,7 +27,7 @@ describe("cluster - visibility of sidebar items", () => {
|
||||
runInAction(() => {
|
||||
windowDi.register(testRouteInjectable);
|
||||
windowDi.register(testRouteComponentInjectable);
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
windowDi.register(testSidebarItemInjectable);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -94,15 +94,14 @@ const testRouteComponentInjectable = getInjectable({
|
||||
injectionToken: routeSpecificComponentInjectionToken,
|
||||
});
|
||||
|
||||
const testSidebarItemsInjectable = getInjectable({
|
||||
id: "some-sidebar-item-injectable",
|
||||
const testSidebarItemInjectable = getInjectable({
|
||||
id: "sidebar-item-test",
|
||||
|
||||
instantiate: (di) => {
|
||||
const testRoute = di.inject(testRouteInjectable);
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
|
||||
return {
|
||||
id: "some-item-id",
|
||||
parentId: null,
|
||||
title: "Some item",
|
||||
onClick: () => navigateToRoute(testRoute),
|
||||
|
||||
Reference in new issue
Block a user