1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Allow to define entity setting priority (#2596)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-04-23 15:27:42 +03:00 committed by GitHub
parent cb373befaf
commit fd36830865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,8 +15,9 @@ export interface EntitySettingRegistration {
kind: string;
apiVersions: string[];
source?: string;
id?: string;
components: EntitySettingComponents;
id?: string;
priority?: number;
}
export interface RegisteredEntitySetting extends EntitySettingRegistration {
@ -32,17 +33,21 @@ export class EntitySettingRegistry extends BaseRegistry<EntitySettingRegistratio
}
getItemsForKind(kind: string, apiVersion: string, source?: string) {
const items = this.getItems().filter((item) => {
let items = this.getItems().filter((item) => {
return item.kind === kind && item.apiVersions.includes(apiVersion);
}).map((item) => {
item.priority = item.priority ?? 50;
return item;
});
if (source) {
return items.filter((item) => {
items = items.filter((item) => {
return !item.source || item.source === source;
});
} else {
return items;
}
return items.sort((a, b) => b.priority - a.priority);
}
}