mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove unnecessary code style changes
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
dd11bcd67e
commit
5113729e87
@ -6,11 +6,7 @@
|
||||
import { anyObject } from "jest-mock-extended";
|
||||
import mockFs from "mock-fs";
|
||||
import logger from "../../main/logger";
|
||||
import type {
|
||||
CatalogEntity,
|
||||
CatalogEntityData,
|
||||
CatalogEntityKindData,
|
||||
} from "../catalog";
|
||||
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
|
||||
import { HotbarStore } from "../hotbar-store";
|
||||
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
||||
import hotbarStoreInjectable from "../hotbar-store.injectable";
|
||||
@ -72,9 +68,7 @@ jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
function getMockCatalogEntity(
|
||||
data: Partial<CatalogEntityData> & CatalogEntityKindData,
|
||||
): CatalogEntity {
|
||||
function getMockCatalogEntity(data: Partial<CatalogEntityData> & CatalogEntityKindData): CatalogEntity {
|
||||
return {
|
||||
getName: jest.fn(() => data.metadata?.name),
|
||||
getId: jest.fn(() => data.metadata?.uid),
|
||||
@ -233,16 +227,9 @@ describe("HotbarStore", () => {
|
||||
// aws -> catalog
|
||||
hotbarStore.restackItems(3, 0);
|
||||
|
||||
const items = hotbarStore
|
||||
.getActive()
|
||||
.items.map((item) => item?.entity.uid || null);
|
||||
const items = hotbarStore.getActive().items.map(item => item?.entity.uid || null);
|
||||
|
||||
expect(items.slice(0, 4)).toEqual([
|
||||
"aws",
|
||||
"catalog-entity",
|
||||
"test",
|
||||
"minikube",
|
||||
]);
|
||||
expect(items.slice(0, 4)).toEqual(["aws", "catalog-entity", "test", "minikube"]);
|
||||
});
|
||||
|
||||
it("moves items up", () => {
|
||||
@ -255,16 +242,9 @@ describe("HotbarStore", () => {
|
||||
// test -> aws
|
||||
hotbarStore.restackItems(1, 3);
|
||||
|
||||
const items = hotbarStore
|
||||
.getActive()
|
||||
.items.map((item) => item?.entity.uid || null);
|
||||
const items = hotbarStore.getActive().items.map(item => item?.entity.uid || null);
|
||||
|
||||
expect(items.slice(0, 4)).toEqual([
|
||||
"catalog-entity",
|
||||
"minikube",
|
||||
"aws",
|
||||
"test",
|
||||
]);
|
||||
expect(items.slice(0, 4)).toEqual(["catalog-entity", "minikube", "aws", "test"]);
|
||||
});
|
||||
|
||||
it("logs an error if cellIndex is out of bounds", () => {
|
||||
@ -279,22 +259,13 @@ describe("HotbarStore", () => {
|
||||
logger.error = mocked;
|
||||
|
||||
hotbarStore.addToHotbar(testCluster, -1);
|
||||
expect(mocked).toBeCalledWith(
|
||||
"[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range",
|
||||
anyObject(),
|
||||
);
|
||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||
|
||||
hotbarStore.addToHotbar(testCluster, 12);
|
||||
expect(mocked).toBeCalledWith(
|
||||
"[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range",
|
||||
anyObject(),
|
||||
);
|
||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||
|
||||
hotbarStore.addToHotbar(testCluster, 13);
|
||||
expect(mocked).toBeCalledWith(
|
||||
"[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range",
|
||||
anyObject(),
|
||||
);
|
||||
expect(mocked).toBeCalledWith("[HOTBAR-STORE]: cannot pin entity to hotbar outside of index range", anyObject());
|
||||
|
||||
logger.error = error;
|
||||
});
|
||||
@ -302,23 +273,15 @@ 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);
|
||||
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);
|
||||
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", () => {
|
||||
@ -443,9 +406,7 @@ describe("HotbarStore", () => {
|
||||
});
|
||||
|
||||
it("allows to retrieve a hotbar", () => {
|
||||
const hotbar = HotbarStore.getInstance().getById(
|
||||
"3caac17f-aec2-4723-9694-ad204465d935",
|
||||
);
|
||||
const hotbar = HotbarStore.getInstance().getById("3caac17f-aec2-4723-9694-ad204465d935");
|
||||
|
||||
expect(hotbar.id).toBe("3caac17f-aec2-4723-9694-ad204465d935");
|
||||
});
|
||||
|
||||
@ -48,12 +48,9 @@ export abstract class BaseStore<T> extends Singleton {
|
||||
*/
|
||||
load() {
|
||||
if (!isTestEnv) {
|
||||
logger.info(
|
||||
`[${kebabCase(this.displayName).toUpperCase()}]: LOADING from ${
|
||||
this.path
|
||||
} ...`,
|
||||
);
|
||||
logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADING from ${this.path} ...`);
|
||||
}
|
||||
|
||||
const di = getLegacyGlobalDiForExtensionApi();
|
||||
|
||||
const getConfigurationFileModel = di.inject(getConfigurationFileModelInjectable);
|
||||
@ -67,23 +64,14 @@ export abstract class BaseStore<T> extends Singleton {
|
||||
|
||||
const res: any = this.fromStore(this.storeConfig.store);
|
||||
|
||||
if (
|
||||
res instanceof Promise ||
|
||||
(typeof res === "object" && res && typeof res.then === "function")
|
||||
) {
|
||||
console.error(
|
||||
`${this.displayName} extends BaseStore<T>'s fromStore method returns a Promise or promise-like object. This is an error and must be fixed.`,
|
||||
);
|
||||
if (res instanceof Promise || (typeof res === "object" && res && typeof res.then === "function")) {
|
||||
console.error(`${this.displayName} extends BaseStore<T>'s fromStore method returns a Promise or promise-like object. This is an error and must be fixed.`);
|
||||
}
|
||||
|
||||
this.enableSync();
|
||||
|
||||
if (!isTestEnv) {
|
||||
logger.info(
|
||||
`[${kebabCase(this.displayName).toUpperCase()}]: LOADED from ${
|
||||
this.path
|
||||
}`,
|
||||
);
|
||||
logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADED from ${this.path}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,27 +112,23 @@ export abstract class BaseStore<T> extends Singleton {
|
||||
this.syncDisposers.push(
|
||||
reaction(
|
||||
() => toJS(this.toJSON()), // unwrap possible observables and react to everything
|
||||
(model) => this.onModelChange(model),
|
||||
model => this.onModelChange(model),
|
||||
this.params.syncOptions,
|
||||
),
|
||||
);
|
||||
|
||||
if (ipcMain) {
|
||||
this.syncDisposers.push(
|
||||
ipcMainOn(this.syncMainChannel, (event, model: T) => {
|
||||
logger.silly(`[STORE]: SYNC ${this.name} from renderer`, { model });
|
||||
this.onSync(model);
|
||||
}),
|
||||
);
|
||||
this.syncDisposers.push(ipcMainOn(this.syncMainChannel, (event, model: T) => {
|
||||
logger.silly(`[STORE]: SYNC ${this.name} from renderer`, { model });
|
||||
this.onSync(model);
|
||||
}));
|
||||
}
|
||||
|
||||
if (ipcRenderer) {
|
||||
this.syncDisposers.push(
|
||||
ipcRendererOn(this.syncRendererChannel, (event, model: T) => {
|
||||
logger.silly(`[STORE]: SYNC ${this.name} from main`, { model });
|
||||
this.onSyncFromMain(model);
|
||||
}),
|
||||
);
|
||||
this.syncDisposers.push(ipcRendererOn(this.syncRendererChannel, (event, model: T) => {
|
||||
logger.silly(`[STORE]: SYNC ${this.name} from main`, { model });
|
||||
this.onSyncFromMain(model);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +144,7 @@ export abstract class BaseStore<T> extends Singleton {
|
||||
}
|
||||
|
||||
disableSync() {
|
||||
this.syncDisposers.forEach((dispose) => dispose());
|
||||
this.syncDisposers.forEach(dispose => dispose());
|
||||
this.syncDisposers.length = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -16,4 +16,7 @@ export const asLegacyGlobalObjectForExtensionApiWithModifications = <
|
||||
injectable: Injectable<InjectableInstance, InjectionTokenInstance, void>,
|
||||
modificationObject: ModificationObject,
|
||||
) =>
|
||||
Object.assign(asLegacyGlobalForExtensionApi(injectable), modificationObject);
|
||||
Object.assign(
|
||||
asLegacyGlobalForExtensionApi(injectable),
|
||||
modificationObject,
|
||||
);
|
||||
|
||||
@ -7,8 +7,7 @@ import { ExtensionLoader } from "./extension-loader";
|
||||
import updateExtensionsStateInjectable from "./update-extensions-state/update-extensions-state.injectable";
|
||||
import createExtensionInstanceInjectable from "./create-extension-instance/create-extension-instance.injectable";
|
||||
import { extensionRegistratorInjectionToken } from "./extension-registrator-injection-token";
|
||||
import extensionInstallationCounterInjectable
|
||||
from "./extension-installation-counter.injectable";
|
||||
import extensionInstallationCounterInjectable from "./extension-installation-counter.injectable";
|
||||
|
||||
const extensionLoaderInjectable = getInjectable({
|
||||
id: "extension-loader",
|
||||
|
||||
@ -13,16 +13,11 @@ import { ExtensionsStore } from "../../../extensions/extensions-store/extensions
|
||||
import type { LensProtocolRouterMain } from "../lens-protocol-router-main/lens-protocol-router-main";
|
||||
import mockFs from "mock-fs";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import extensionLoaderInjectable
|
||||
from "../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import lensProtocolRouterMainInjectable
|
||||
from "../lens-protocol-router-main/lens-protocol-router-main.injectable";
|
||||
import extensionsStoreInjectable
|
||||
from "../../../extensions/extensions-store/extensions-store.injectable";
|
||||
import getConfigurationFileModelInjectable
|
||||
from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable
|
||||
from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import lensProtocolRouterMainInjectable from "../lens-protocol-router-main/lens-protocol-router-main.injectable";
|
||||
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
|
||||
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
|
||||
jest.mock("../../../common/ipc");
|
||||
|
||||
|
||||
@ -8,8 +8,7 @@ import fse from "fs-extra";
|
||||
import type { ClusterModel } from "../../common/cluster-types";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
import directoryForUserDataInjectable
|
||||
from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
interface Pre500WorkspaceStoreModel {
|
||||
workspaces: {
|
||||
|
||||
@ -13,7 +13,6 @@ import { observer } from "mobx-react";
|
||||
import path from "path";
|
||||
import React from "react";
|
||||
import * as uuid from "uuid";
|
||||
|
||||
import { appEventBus } from "../../../common/app-event-bus/event-bus";
|
||||
import { loadConfigFromString, splitConfig } from "../../../common/kube-helpers";
|
||||
import { docsUrl } from "../../../common/vars";
|
||||
@ -24,9 +23,7 @@ import { SettingLayout } from "../layout/setting-layout";
|
||||
import { MonacoEditor } from "../monaco-editor";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import getCustomKubeConfigDirectoryInjectable from "../../../common/app-paths/get-custom-kube-config-directory/get-custom-kube-config-directory.injectable";
|
||||
import navigateToCatalogInjectable, {
|
||||
NavigateToCatalog,
|
||||
} from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import navigateToCatalogInjectable, { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
|
||||
interface Option {
|
||||
config: KubeConfig;
|
||||
|
||||
@ -15,19 +15,15 @@ import type { CatalogEntityStore } from "./catalog-entity-store/catalog-entity.s
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import catalogEntityStoreInjectable from "./catalog-entity-store/catalog-entity-store.injectable";
|
||||
import catalogEntityRegistryInjectable
|
||||
from "../../api/catalog-entity-registry/catalog-entity-registry.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../api/catalog-entity-registry/catalog-entity-registry.injectable";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
import { ThemeStore } from "../../theme.store";
|
||||
import { UserStore } from "../../../common/user-store";
|
||||
import mockFs from "mock-fs";
|
||||
import directoryForUserDataInjectable
|
||||
from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import getConfigurationFileModelInjectable
|
||||
from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable
|
||||
from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import type { AppEvent } from "../../../common/app-event-bus/event-bus";
|
||||
import appEventBusInjectable from "../../../common/app-event-bus/app-event-bus.injectable";
|
||||
|
||||
|
||||
@ -8,16 +8,7 @@ import styles from "./catalog.module.scss";
|
||||
import React from "react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { ItemListLayout } from "../item-object-list";
|
||||
import {
|
||||
action,
|
||||
computed,
|
||||
IComputedValue,
|
||||
makeObservable,
|
||||
observable,
|
||||
reaction,
|
||||
runInAction,
|
||||
when,
|
||||
} from "mobx";
|
||||
import { action, computed, IComputedValue, makeObservable, observable, reaction, runInAction, when } from "mobx";
|
||||
import type { CatalogEntityStore } from "./catalog-entity-store/catalog-entity.store";
|
||||
import { navigate } from "../../navigation";
|
||||
import { MenuItem, MenuActions } from "../menu";
|
||||
@ -43,9 +34,7 @@ import getCategoryColumnsInjectable from "./get-category-columns.injectable";
|
||||
import type { RegisteredCustomCategoryViewDecl } from "./custom-views.injectable";
|
||||
import customCategoryViewsInjectable from "./custom-views.injectable";
|
||||
import type { CustomCategoryViewComponents } from "./custom-views";
|
||||
import navigateToCatalogInjectable, {
|
||||
NavigateToCatalog,
|
||||
} from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import navigateToCatalogInjectable, { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import catalogRouteParametersInjectable from "./catalog-route-parameters.injectable";
|
||||
import { browseCatalogTab } from "./catalog-browse-tab";
|
||||
import type { AppEvent } from "../../../common/app-event-bus/event-bus";
|
||||
|
||||
@ -56,11 +56,7 @@ class NonInjectedEntitySettings extends React.Component<Dependencies> {
|
||||
get menuItems() {
|
||||
if (!this.entity) return [];
|
||||
|
||||
return EntitySettingRegistry.getInstance().getItemsForKind(
|
||||
this.entity.kind,
|
||||
this.entity.apiVersion,
|
||||
this.entity.metadata.source,
|
||||
);
|
||||
return EntitySettingRegistry.getInstance().getItemsForKind(this.entity.kind, this.entity.apiVersion, this.entity.metadata.source);
|
||||
}
|
||||
|
||||
get activeSetting() {
|
||||
@ -74,9 +70,7 @@ class NonInjectedEntitySettings extends React.Component<Dependencies> {
|
||||
};
|
||||
|
||||
renderNavigation() {
|
||||
const groups = Object.entries(
|
||||
groupBy(this.menuItems, (item) => item.group || "Extensions"),
|
||||
);
|
||||
const groups = Object.entries(groupBy(this.menuItems, (item) => item.group || "Extensions"));
|
||||
|
||||
groups.sort((a, b) => {
|
||||
if (a[0] === "Settings") return -1;
|
||||
@ -90,26 +84,21 @@ class NonInjectedEntitySettings extends React.Component<Dependencies> {
|
||||
<div className="flex items-center pb-8">
|
||||
<Avatar
|
||||
title={this.entity.getName()}
|
||||
colorHash={`${this.entity.getName()}-${
|
||||
this.entity.metadata.source
|
||||
}`}
|
||||
colorHash={`${this.entity.getName()}-${this.entity.metadata.source}`}
|
||||
src={this.entity.spec.icon?.src}
|
||||
className={styles.settingsAvatar}
|
||||
size={40}
|
||||
/>
|
||||
<div className={styles.entityName}>{this.entity.getName()}</div>
|
||||
<div className={styles.entityName}>
|
||||
{this.entity.getName()}
|
||||
</div>
|
||||
</div>
|
||||
<Tabs
|
||||
className="flex column"
|
||||
scrollable={false}
|
||||
onChange={this.onTabChange}
|
||||
value={this.activeTab}
|
||||
>
|
||||
{groups.map((group, groupIndex) => (
|
||||
<Tabs className="flex column" scrollable={false} onChange={this.onTabChange} value={this.activeTab}>
|
||||
{ groups.map((group, groupIndex) => (
|
||||
<React.Fragment key={`group-${groupIndex}`}>
|
||||
<hr />
|
||||
<hr/>
|
||||
<div className="header">{group[0]}</div>
|
||||
{group[1].map((setting, index) => (
|
||||
{ group[1].map((setting, index) => (
|
||||
<Tab
|
||||
key={index}
|
||||
value={setting.id}
|
||||
@ -134,20 +123,20 @@ class NonInjectedEntitySettings extends React.Component<Dependencies> {
|
||||
const { activeSetting } = this;
|
||||
|
||||
return (
|
||||
<SettingLayout navigation={this.renderNavigation()} contentGaps={false}>
|
||||
{activeSetting && (
|
||||
<section>
|
||||
<h2 data-testid={`${activeSetting.id}-header`}>
|
||||
{activeSetting.title}
|
||||
</h2>
|
||||
<SettingLayout
|
||||
navigation={this.renderNavigation()}
|
||||
contentGaps={false}
|
||||
>
|
||||
{
|
||||
activeSetting && (
|
||||
<section>
|
||||
<activeSetting.components.View
|
||||
entity={this.entity}
|
||||
key={activeSetting.title}
|
||||
/>
|
||||
<h2 data-testid={`${activeSetting.id}-header`}>{activeSetting.title}</h2>
|
||||
<section>
|
||||
<activeSetting.components.View entity={this.entity} key={activeSetting.title} />
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
)}
|
||||
)
|
||||
}
|
||||
</SettingLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ import { PortForwardDetails } from "./port-forward-details";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import portForwardStoreInjectable from "../../port-forward/port-forward-store/port-forward-store.injectable";
|
||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||
|
||||
import { computed, IComputedValue, makeObservable } from "mobx";
|
||||
import portForwardsRouteParametersInjectable from "./port-forwards-route-parameters.injectable";
|
||||
import navigateToPortForwardsInjectable, { NavigateToPortForwards } from "../../../common/front-end-routing/routes/cluster/network/port-forwards/navigate-to-port-forwards.injectable";
|
||||
|
||||
@ -18,8 +18,7 @@ import { IComputedValue, reaction } from "mobx";
|
||||
import currentRouteComponentInjectable from "../../routes/current-route-component.injectable";
|
||||
import { setEntityOnRouteMatch } from "../../api/helpers/general-active-sync";
|
||||
import { navigation } from "../../navigation";
|
||||
import welcomeRouteInjectable
|
||||
from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable";
|
||||
import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable";
|
||||
import { buildURL } from "../../../common/utils/buildUrl";
|
||||
|
||||
interface Dependencies {
|
||||
|
||||
@ -14,9 +14,7 @@ import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
import { requestClusterActivation } from "../../ipc";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import navigateToCatalogInjectable, {
|
||||
NavigateToCatalog,
|
||||
} from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import navigateToCatalogInjectable, { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import clusterViewRouteParametersInjectable from "./cluster-view-route-parameters.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
|
||||
@ -6,11 +6,7 @@
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Select } from "../select";
|
||||
|
||||
import hotbarStoreInjectable, {
|
||||
HotbarStore,
|
||||
} from "../../../common/hotbar-store.injectable";
|
||||
|
||||
import hotbarStoreInjectable, { HotbarStore } from "../../../common/hotbar-store.injectable";
|
||||
import type { CommandOverlay } from "../command-palette";
|
||||
import { HotbarAddCommand } from "./hotbar-add-command";
|
||||
import { HotbarRemoveCommand } from "./hotbar-remove-command";
|
||||
|
||||
@ -24,13 +24,9 @@ import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-f
|
||||
import kubeWatchApiInjectable from "../../kube-watch-api/kube-watch-api.injectable";
|
||||
import type { KubeWatchSubscribeStoreOptions } from "../../kube-watch-api/kube-watch-api";
|
||||
|
||||
type ItemListLayoutPropsWithoutGetItems<K extends KubeObject> = Omit<
|
||||
ItemListLayoutProps<K>,
|
||||
"getItems"
|
||||
>;
|
||||
type ItemListLayoutPropsWithoutGetItems<K extends KubeObject> = Omit<ItemListLayoutProps<K>, "getItems">;
|
||||
|
||||
export interface KubeObjectListLayoutProps<K extends KubeObject>
|
||||
extends ItemListLayoutPropsWithoutGetItems<K> {
|
||||
export interface KubeObjectListLayoutProps<K extends KubeObject> extends ItemListLayoutPropsWithoutGetItems<K> {
|
||||
items?: K[];
|
||||
getItems?: () => K[];
|
||||
store: KubeObjectStore<K>;
|
||||
@ -45,10 +41,7 @@ const defaultProps: Partial<KubeObjectListLayoutProps<KubeObject>> = {
|
||||
|
||||
interface Dependencies {
|
||||
clusterFrameContext: ClusterFrameContext;
|
||||
subscribeToStores: (
|
||||
stores: KubeObjectStore<KubeObject>[],
|
||||
options: KubeWatchSubscribeStoreOptions
|
||||
) => Disposer;
|
||||
subscribeToStores: (stores: KubeObjectStore<KubeObject>[], options: KubeWatchSubscribeStoreOptions) => Disposer;
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -70,12 +63,10 @@ class NonInjectedKubeObjectListLayout<K extends KubeObject> extends React.Compon
|
||||
const { store, dependentStores = [], subscribeStores } = this.props;
|
||||
const stores = Array.from(new Set([store, ...dependentStores]));
|
||||
const reactions: Disposer[] = [
|
||||
reaction(
|
||||
() => this.props.clusterFrameContext.contextNamespaces.slice(),
|
||||
() => {
|
||||
// clear load errors
|
||||
this.loadErrors.length = 0;
|
||||
}),
|
||||
reaction(() => this.props.clusterFrameContext.contextNamespaces.slice(), () => {
|
||||
// clear load errors
|
||||
this.loadErrors.length = 0;
|
||||
}),
|
||||
];
|
||||
|
||||
if (subscribeStores) {
|
||||
@ -111,10 +102,8 @@ class NonInjectedKubeObjectListLayout<K extends KubeObject> extends React.Compon
|
||||
}
|
||||
|
||||
render() {
|
||||
const { className, customizeHeader, store, items, ...layoutProps } =
|
||||
this.props;
|
||||
const placeholderString =
|
||||
ResourceNames[ResourceKindMap[store.api.kind]] || store.api.kind;
|
||||
const { className, customizeHeader, store, items, ...layoutProps } = this.props;
|
||||
const placeholderString = ResourceNames[ResourceKindMap[store.api.kind]] || store.api.kind;
|
||||
|
||||
return (
|
||||
<ItemListLayout
|
||||
@ -152,10 +141,7 @@ class NonInjectedKubeObjectListLayout<K extends KubeObject> extends React.Compon
|
||||
}
|
||||
}
|
||||
|
||||
const InjectedKubeObjectListLayout = withInjectables<
|
||||
Dependencies,
|
||||
KubeObjectListLayoutProps<KubeObject>
|
||||
>(NonInjectedKubeObjectListLayout, {
|
||||
const InjectedKubeObjectListLayout = withInjectables<Dependencies, KubeObjectListLayoutProps<KubeObject>>(NonInjectedKubeObjectListLayout, {
|
||||
getProps: (di, props) => ({
|
||||
clusterFrameContext: di.inject(clusterFrameContextInjectable),
|
||||
subscribeToStores: di.inject(kubeWatchApiInjectable).subscribeStores,
|
||||
|
||||
@ -11,15 +11,12 @@ import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { DiRender, renderFor } from "../test-utils/renderFor";
|
||||
import mockFs from "mock-fs";
|
||||
import directoryForUserDataInjectable
|
||||
from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import rendererExtensionsInjectable from "../../../extensions/renderer-extensions.injectable";
|
||||
import { computed } from "mobx";
|
||||
import type { LensRendererExtension } from "../../../extensions/lens-renderer-extension";
|
||||
import getConfigurationFileModelInjectable
|
||||
from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable
|
||||
from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
ipcRenderer: {
|
||||
|
||||
@ -30,9 +30,7 @@ export interface SelectOption<T = any> {
|
||||
label?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface SelectProps<T = any>
|
||||
extends ReactSelectProps<T, boolean>,
|
||||
CreatableProps<T, boolean> {
|
||||
export interface SelectProps<T = any> extends ReactSelectProps<T, boolean>, CreatableProps<T, boolean> {
|
||||
id: string;
|
||||
value?: T;
|
||||
themeName?: "dark" | "light" | "outlined" | "lens";
|
||||
|
||||
@ -25,6 +25,7 @@ import { StorageClassDetails } from "../components/+storage-classes";
|
||||
import { PersistentVolumeClaimDetails } from "../components/+storage-volume-claims";
|
||||
import { PersistentVolumeDetails } from "../components/+storage-volumes";
|
||||
import { ClusterRoleDetails } from "../components/+user-management/+cluster-roles";
|
||||
import { ClusterRoleBindingDetails } from "../components/+user-management/+cluster-role-bindings";
|
||||
import { RoleDetails } from "../components/+user-management/+roles";
|
||||
import { RoleBindingDetails } from "../components/+user-management/+role-bindings";
|
||||
import { ServiceAccountsDetails } from "../components/+user-management/+service-accounts";
|
||||
@ -36,7 +37,6 @@ import { PodDetails } from "../components/+workloads-pods";
|
||||
import { ReplicaSetDetails } from "../components/+workloads-replicasets";
|
||||
import { StatefulSetDetails } from "../components/+workloads-statefulsets";
|
||||
import type { KubeObjectDetailsProps } from "../components/kube-object-details";
|
||||
import { ClusterRoleBindingDetails } from "../components/+user-management/+cluster-role-bindings";
|
||||
|
||||
export function initKubeObjectDetailRegistry() {
|
||||
KubeObjectDetailRegistry.getInstance()
|
||||
|
||||
@ -7,8 +7,8 @@ import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting";
|
||||
import { overrideIpcBridge } from "./override-ipc-bridge";
|
||||
|
||||
export const getDisForUnitTesting = ({ doGeneralOverrides } = { doGeneralOverrides: false }) => {
|
||||
const mainDi = getMainDi({ doGeneralOverrides });
|
||||
const rendererDi = getRendererDi({ doGeneralOverrides });
|
||||
const mainDi = getMainDi({ doGeneralOverrides });
|
||||
|
||||
overrideIpcBridge({ rendererDi, mainDi });
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user