Skip to content

Commit

Permalink
Replace KubeObjectDetailRegistry with injectable version
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Jan 5, 2022
1 parent 4f75acf commit f82e53f
Show file tree
Hide file tree
Showing 23 changed files with 684 additions and 618 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ module.exports = {
react: {
version: packageJson.devDependencies.react || "detect",
},
// the package eslint-import-resolver-typescript is required for this line which fixes errors when using .d.ts files
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
},
},
},
overrides: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

export { KubeObjectDetailRegistry } from "../../extensions/registries/kube-object-detail-registry";
module.exports = {
languages: {
register: jest.fn(),
setMonarchTokensProvider: jest.fn(),
registerCompletionItemProvider: jest.fn(),
},
editor: {
defineTheme: jest.fn(),
getModel: jest.fn(),
createModel: jest.fn(),
},
Uri: {
file: jest.fn(),
},
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
},
"moduleNameMapper": {
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.ts",
"\\.(svg)$": "<rootDir>/__mocks__/imageMock.ts"
"\\.(svg)$": "<rootDir>/__mocks__/imageMock.ts",
"^monaco-editor": "<rootDir>/node_modules/monaco-editor"
},
"modulePathIgnorePatterns": [
"<rootDir>/dist",
Expand Down Expand Up @@ -340,6 +341,7 @@
"esbuild": "^0.13.15",
"esbuild-loader": "^2.16.0",
"eslint": "^7.32.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-react": "^7.27.1",
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/common-api/registrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

export type { AppPreferenceRegistration, AppPreferenceComponents } from "../registries/app-preference-registry";
export type { KubeObjectDetailRegistration, KubeObjectDetailComponents } from "../registries/kube-object-detail-registry";
export type { KubeObjectDetailRegistration, KubeObjectDetailComponents } from "../../renderer/components/kube-object-details/kube-details-items/kube-detail-items";
export type { KubeObjectMenuRegistration, KubeObjectMenuComponents } from "../registries/kube-object-menu-registry";
export type { KubeObjectStatusRegistration } from "../registries/kube-object-status-registry";
export type { PageRegistration, RegisteredPage, PageParams, PageComponentProps, PageComponents, PageTarget } from "../registries/page-registry";
Expand Down
1 change: 0 additions & 1 deletion src/extensions/extension-loader/extension-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ export class ExtensionLoader {
registries.ClusterPageRegistry.getInstance().add(extension.clusterPages, extension),
registries.ClusterPageMenuRegistry.getInstance().add(extension.clusterPageMenus, extension),
registries.KubeObjectMenuRegistry.getInstance().add(extension.kubeObjectMenuItems),
registries.KubeObjectDetailRegistry.getInstance().add(extension.kubeObjectDetailItems),
registries.KubeObjectStatusRegistry.getInstance().add(extension.kubeObjectStatusTexts),
registries.WorkloadsOverviewDetailRegistry.getInstance().add(extension.kubeWorkloadsOverviewItems),
registries.CommandRegistry.getInstance().add(extension.commands),
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/lens-renderer-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { TopBarRegistration } from "../renderer/components/layout/top-bar/t
import type { KubernetesCluster } from "../common/catalog-entities";
import type { WelcomeMenuRegistration } from "../renderer/components/+welcome/welcome-menu-items/welcome-menu-registration";
import type { WelcomeBannerRegistration } from "../renderer/components/+welcome/welcome-banner-items/welcome-banner-registration";
import type { KubeObjectDetailRegistration } from "../renderer/components/kube-object-details/kube-details-items/kube-detail-items";

export class LensRendererExtension extends LensExtension {
globalPages: registries.PageRegistration[] = [];
Expand All @@ -39,7 +40,7 @@ export class LensRendererExtension extends LensExtension {
appPreferences: registries.AppPreferenceRegistration[] = [];
entitySettings: registries.EntitySettingRegistration[] = [];
statusBarItems: registries.StatusBarRegistration[] = [];
kubeObjectDetailItems: registries.KubeObjectDetailRegistration[] = [];
kubeObjectDetailItems: KubeObjectDetailRegistration[] = [];
kubeObjectMenuItems: registries.KubeObjectMenuRegistration[] = [];
kubeWorkloadsOverviewItems: registries.WorkloadsOverviewDetailRegistration[] = [];
commands: registries.CommandRegistration[] = [];
Expand Down
1 change: 0 additions & 1 deletion src/extensions/registries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export * from "./page-registry";
export * from "./page-menu-registry";
export * from "./app-preference-registry";
export * from "./status-bar-registry";
export * from "./kube-object-detail-registry";
export * from "./kube-object-menu-registry";
export * from "./kube-object-status-registry";
export * from "./command-registry";
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ export async function bootstrap(comp: () => Promise<AppComponent>, di: Dependenc
logger.info(`${logPrefix} initializing KubeObjectMenuRegistry`);
initializers.initKubeObjectMenuRegistry();

logger.info(`${logPrefix} initializing KubeObjectDetailRegistry`);
initializers.initKubeObjectDetailRegistry();

logger.info(`${logPrefix} initializing WorkloadsOverviewDetailRegistry`);
initializers.initWorkloadsOverviewDetailRegistry();

Expand Down
31 changes: 12 additions & 19 deletions src/renderer/components/+custom-resources/crd-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ export class CRDDetails extends React.Component<Props> {
</DrawerItem>
<DrawerItem name="Conditions" className="conditions" labelsOnly>
{
crd.getConditions().map(condition => {
const { type, message, lastTransitionTime, status } = condition;

return (
crd.getConditions()
.map(({ type, message, lastTransitionTime, status }) => (
<Badge
key={type}
label={type}
Expand All @@ -104,8 +102,7 @@ export class CRDDetails extends React.Component<Props> {
</>
)}
/>
);
})
))
}
</DrawerItem>
<DrawerTitle title="Names"/>
Expand Down Expand Up @@ -133,19 +130,15 @@ export class CRDDetails extends React.Component<Props> {
<TableCell className="json-path">JSON Path</TableCell>
</TableHead>
{
printerColumns.map((column, index) => {
const { name, type, jsonPath } = column;

return (
<TableRow key={index}>
<TableCell className="name">{name}</TableCell>
<TableCell className="type">{type}</TableCell>
<TableCell className="json-path">
<Badge label={jsonPath}/>
</TableCell>
</TableRow>
);
})
printerColumns.map(({ name, type, jsonPath }, index) => (
<TableRow key={index}>
<TableCell className="name">{name}</TableCell>
<TableCell className="type">{type}</TableCell>
<TableCell className="json-path">
<Badge label={jsonPath}/>
</TableCell>
</TableRow>
))
}
</Table>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { mockWindow } from "../../../../../__mocks__/windowMock";
import { AppPaths } from "../../../../common/app-paths";
import extensionLoaderInjectable
from "../../../../extensions/extension-loader/extension-loader.injectable";
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
import { DiRender, renderFor } from "../../test-utils/renderFor";

mockWindow();
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/+welcome/__test__/welcome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { screen } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import { defaultWidth, Welcome } from "../welcome";
import { computed } from "mobx";
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
import type { DiRender } from "../../test-utils/renderFor";
import { renderFor } from "../../test-utils/renderFor";
import type { ConfigurableDependencyInjectionContainer } from "@ogre-tools/injectable";
Expand Down
Loading

0 comments on commit f82e53f

Please sign in to comment.