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:
parent
cb373befaf
commit
fd36830865
@ -15,8 +15,9 @@ export interface EntitySettingRegistration {
|
|||||||
kind: string;
|
kind: string;
|
||||||
apiVersions: string[];
|
apiVersions: string[];
|
||||||
source?: string;
|
source?: string;
|
||||||
id?: string;
|
|
||||||
components: EntitySettingComponents;
|
components: EntitySettingComponents;
|
||||||
|
id?: string;
|
||||||
|
priority?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegisteredEntitySetting extends EntitySettingRegistration {
|
export interface RegisteredEntitySetting extends EntitySettingRegistration {
|
||||||
@ -32,17 +33,21 @@ export class EntitySettingRegistry extends BaseRegistry<EntitySettingRegistratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemsForKind(kind: string, apiVersion: string, source?: string) {
|
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);
|
return item.kind === kind && item.apiVersions.includes(apiVersion);
|
||||||
|
}).map((item) => {
|
||||||
|
item.priority = item.priority ?? 50;
|
||||||
|
|
||||||
|
return item;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
return items.filter((item) => {
|
items = items.filter((item) => {
|
||||||
return !item.source || item.source === source;
|
return !item.source || item.source === source;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return items.sort((a, b) => b.priority - a.priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user