mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Passing id to status-bar-items
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4e02ccb1c7
commit
3f42f73994
@ -7,6 +7,7 @@ import type { IComputedValue } from "mobx";
|
|||||||
import type React from "react";
|
import type React from "react";
|
||||||
|
|
||||||
export interface StatusBarItem {
|
export interface StatusBarItem {
|
||||||
|
id?: string;
|
||||||
component: React.ComponentType<any>;
|
component: React.ComponentType<any>;
|
||||||
position: "left" | "right";
|
position: "left" | "right";
|
||||||
visible: IComputedValue<boolean>;
|
visible: IComputedValue<boolean>;
|
||||||
|
|||||||
@ -74,6 +74,7 @@ const toItemInjectableFor = (extension: LensRendererExtension, getRandomId: () =
|
|||||||
id,
|
id,
|
||||||
|
|
||||||
instantiate: () => ({
|
instantiate: () => ({
|
||||||
|
id: extension.sanitizedExtensionId,
|
||||||
component,
|
component,
|
||||||
position,
|
position,
|
||||||
visible: visible ?? computed(() => true),
|
visible: visible ?? computed(() => true),
|
||||||
|
|||||||
@ -10,9 +10,14 @@ import type { StatusBarItem } from "./status-bar-item-injection-token";
|
|||||||
import { statusBarItemInjectionToken } from "./status-bar-item-injection-token";
|
import { statusBarItemInjectionToken } from "./status-bar-item-injection-token";
|
||||||
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
|
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
|
|
||||||
|
interface StatusItem {
|
||||||
|
id?: string,
|
||||||
|
component: React.ComponentType<StatusBarItemProps>
|
||||||
|
}
|
||||||
|
|
||||||
export interface StatusBarItems {
|
export interface StatusBarItems {
|
||||||
right: React.ComponentType<StatusBarItemProps>[];
|
right: StatusItem[];
|
||||||
left: React.ComponentType<StatusBarItemProps>[];
|
left: StatusItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
@ -27,13 +32,16 @@ function getStatusBarItems({ registrations }: Dependencies): IComputedValue<Stat
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const registration of registrations.get()) {
|
for (const registration of registrations.get()) {
|
||||||
const { position = "right", component, visible } = registration;
|
const { position = "right", component, visible, id } = registration;
|
||||||
|
|
||||||
if (!visible.get()) {
|
if (!visible.get()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
res[position].push(component);
|
res[position].push({
|
||||||
|
id,
|
||||||
|
component
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is done so that the first ones registered are closest to the corner
|
// This is done so that the first ones registered are closest to the corner
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user