mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
34 lines
832 B
TypeScript
34 lines
832 B
TypeScript
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()
|