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

Allow extensions to register kube-object menus + details #1108

Merged
merged 6 commits into from
Oct 22, 2020

Conversation

jakolehm
Copy link
Contributor

This is a quite big refactoring. Basically this PR replaces old apiManager.set/getViews with a registry pattern that is used in extension-api. PR also moves node/pod menus to extensions so that we actually eat our own dogfood.

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm added enhancement New feature or request area/extension Something to related to the extension api labels Oct 21, 2020
@jakolehm jakolehm added this to the 3.7.0 milestone Oct 21, 2020
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

export interface KubeObjectMenuRegistration {
kind: string;
apiVersions: string[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows extensions to have different components for different apiVersions (for example v1alpha1 vs v1). It also allows extension to register multiple versions for a component.

@@ -1,4 +0,0 @@
export * from "./certificates"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed everything related to certmanager because it's using old apiversion and this actually should be an extension.

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jim-docker
Copy link
Contributor

jim-docker commented Oct 21, 2020

I pulled the PR and did make clean and make dev. Are the extensions supposed to be built and loaded automatically? I don't see them...

After running make build-extensions they do appear in the app

Copy link
Contributor

@jim-docker jim-docker left a comment

Choose a reason for hiding this comment

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

I got about 2/3 through, will finish tomorrow

Comment on lines +15 to +21
"devDependencies": {
"ts-loader": "^8.0.4",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"mobx": "^5.15.5",
"react": "^16.13.1"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this (and maybe other things) will be necessary for all extensions, right? Are we going to template it or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should probably mark these as dependencies of @k8slens/extensions package (topic for another PR).

@@ -1,2 +1,4 @@
export type { DynamicPageType, PageRegistry } from "../page-registry"
export type { AppPreferenceRegistry } from "../app-preference-registry"
export type { KubeObjectMenuRegistry } from "../../renderer/api/kube-object-menu-registry"
export type { KubeObjectDetailRegistry } from "../../renderer/api/kube-object-details-registry"
Copy link
Contributor

Choose a reason for hiding this comment

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

naming should be consistent (KubeObjectDetailsRegistry?) (details <=> Detail)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed.

Comment on lines +16 to +18
registerKubeObjectMenus(registry: KubeObjectMenuRegistry) {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why these methods have to be defined by the subclasses. Can't it be something like

  registerKubeObjectMenus(kubeObjectMenus: KubeObjectMenuRegistration[]) {
      for (menu of kubeObjectMenus) {
        this.disposers.push(this.registry.add(menu))
      }
  }

(with registry being a class member)? I'm probably missing something... tsx versus ts?

Copy link
Contributor Author

@jakolehm jakolehm Oct 22, 2020

Choose a reason for hiding this comment

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

This is actually a very good point. I also hate the fact that disposers are now exposed and "mandatory" to use within extensions. We need to discuss about pros/cons (this is out of scope of this PR).

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
import { CrdResourceDetails, CrdResourceMenu } from "../+custom-resources";
import { CrdResourceDetails } from "../+custom-resources";
import { KubeObjectMenu } from "./kube-object-menu"
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";

export interface KubeObjectDetailsProps<T = KubeObject> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be KubeObjectDetailProps? Maybe 'details' is appropriate in some places, 'detail' in other?

apiVersions: ["v1"],
components: {
Details: (props) => <ConfigMapDetails {...props} />
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: some places (props: any) is used

@jakolehm jakolehm merged commit 99db7ac into extensions-api Oct 22, 2020
@jakolehm jakolehm deleted the refactor-apimanager-setviews-to-registry branch October 22, 2020 18:41
@nevalla nevalla modified the milestones: 3.7.0, 4.0.0 Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants