Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace KubeObjectDetailRegistry with injectable version #4631

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mock is required so that jest won't complain about trying to load it.

},
"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 @@ -289,7 +289,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),
];
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 @@ -31,6 +31,7 @@ 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 { CommandRegistration } from "../renderer/components/command-palette/registered-commands/commands";
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 @@ -40,7 +41,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: 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 "./entity-setting-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 @@ -109,9 +109,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
Loading