mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow extensions to register kube-object menus + details (#1108)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
91bef77997
commit
99db7aca19
101 files changed
+7858
-1604
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { observable } from "mobx"
|
||||
import React from "react"
|
||||
|
||||
export interface KubeObjectDetailComponents {
|
||||
Details: React.ComponentType<any>;
|
||||
}
|
||||
|
||||
export interface KubeObjectDetailRegistration {
|
||||
kind: string;
|
||||
apiVersions: string[];
|
||||
components: KubeObjectDetailComponents;
|
||||
}
|
||||
|
||||
export class KubeObjectDetailRegistry {
|
||||
items = observable.array<KubeObjectDetailRegistration>([], { deep: false });
|
||||
|
||||
add(item: KubeObjectDetailRegistration) {
|
||||
this.items.push(item)
|
||||
return () => {
|
||||
this.items.replace(
|
||||
this.items.filter(c => c !== item)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
getItemsForKind(kind: string, apiVersion: string) {
|
||||
return this.items.filter((item) => {
|
||||
return item.kind === kind && item.apiVersions.includes(apiVersion)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const kubeObjectDetailRegistry = new KubeObjectDetailRegistry()
|
||||
Reference in new issue
Block a user