mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move visible to StatusBarRegistration
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
9eebb9f9fb
commit
b469ab5425
@ -100,8 +100,8 @@ describe("status-bar-items-originating-from-extensions", () => {
|
|||||||
components: {
|
components: {
|
||||||
Item: () => <div data-testid="some-testId">right4</div>,
|
Item: () => <div data-testid="some-testId">right4</div>,
|
||||||
position: "right" as const,
|
position: "right" as const,
|
||||||
visible: computed(() => false),
|
|
||||||
},
|
},
|
||||||
|
visible: computed(() => false),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
@ -39,7 +39,7 @@ const toItemInjectableFor = (extension: LensRendererExtension, getRandomId: () =
|
|||||||
const id = `${getRandomId()}-status-bar-item-for-extension-${extension.sanitizedExtensionId}`;
|
const id = `${getRandomId()}-status-bar-item-for-extension-${extension.sanitizedExtensionId}`;
|
||||||
let component: React.ComponentType;
|
let component: React.ComponentType;
|
||||||
let position: "left" | "right";
|
let position: "left" | "right";
|
||||||
let visible: IComputedValue<boolean> | undefined;
|
const visible: IComputedValue<boolean> | undefined = registration?.visible;
|
||||||
|
|
||||||
if (registration?.item) {
|
if (registration?.item) {
|
||||||
const { item } = registration;
|
const { item } = registration;
|
||||||
@ -56,7 +56,7 @@ const toItemInjectableFor = (extension: LensRendererExtension, getRandomId: () =
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (registration?.components) {
|
} else if (registration?.components) {
|
||||||
const { position: pos = "right", Item, visible: componentVisible } = registration.components;
|
const { position: pos = "right", Item } = registration.components;
|
||||||
|
|
||||||
if (pos !== "left" && pos !== "right") {
|
if (pos !== "left" && pos !== "right") {
|
||||||
throw new TypeError("StatusBarRegistration.components.position must be either 'right' or 'left'");
|
throw new TypeError("StatusBarRegistration.components.position must be either 'right' or 'left'");
|
||||||
@ -64,7 +64,6 @@ const toItemInjectableFor = (extension: LensRendererExtension, getRandomId: () =
|
|||||||
|
|
||||||
position = pos;
|
position = pos;
|
||||||
component = Item;
|
component = Item;
|
||||||
visible = componentVisible;
|
|
||||||
} else {
|
} else {
|
||||||
logger.warn("StatusBarRegistration must have valid item or components field");
|
logger.warn("StatusBarRegistration must have valid item or components field");
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,6 @@ export interface StatusBarComponents {
|
|||||||
* @default "right"
|
* @default "right"
|
||||||
*/
|
*/
|
||||||
position?: "left" | "right";
|
position?: "left" | "right";
|
||||||
|
|
||||||
/**
|
|
||||||
* If specified, controls item visibility
|
|
||||||
*/
|
|
||||||
visible?: IComputedValue<boolean>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,4 +40,9 @@ export interface StatusBarRegistration {
|
|||||||
* The newer API, allows for registering a component instead of a ReactNode
|
* The newer API, allows for registering a component instead of a ReactNode
|
||||||
*/
|
*/
|
||||||
components?: StatusBarComponents;
|
components?: StatusBarComponents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified, controls item visibility
|
||||||
|
*/
|
||||||
|
visible?: IComputedValue<boolean>;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user