From 6ac1a90106aa441843d098748f1829ee1111e470 Mon Sep 17 00:00:00 2001 From: Guilherme Leme Date: Mon, 9 Dec 2024 16:52:12 -0300 Subject: [PATCH] [set-display-navbar] - created new ui-command to allow hide or display the navigation bar --- .../component.tsx | 12 ++++++++++ src/ui-commands/commands.ts | 2 ++ src/ui-commands/nav-bar/commands.ts | 23 +++++++++++++++++++ src/ui-commands/nav-bar/enums.ts | 3 +++ src/ui-commands/nav-bar/types.ts | 7 ++++++ src/ui-commands/types.ts | 2 ++ 6 files changed, 49 insertions(+) create mode 100644 src/ui-commands/nav-bar/commands.ts create mode 100644 src/ui-commands/nav-bar/enums.ts create mode 100644 src/ui-commands/nav-bar/types.ts diff --git a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx index 26f3ca1..6eb4ef6 100644 --- a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx +++ b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx @@ -128,6 +128,18 @@ function SampleActionButtonDropdownPlugin( handleFetchPresentationData(currentPresentation); }, }), + new ActionButtonDropdownOption({ + label: 'Hide nav-bar', + icon: 'copy', + tooltip: 'this is a button injected by plugin', + allowed: true, + onClick: () => { + pluginApi.uiCommands.navBar.setDisplayNavBar({ displayNavBar: false }); + setTimeout(() => { + pluginApi.uiCommands.navBar.setDisplayNavBar({ displayNavBar: true }); + }, 5000); + }, + }), new ActionButtonDropdownOption({ label: showingGenericContentInPresentationArea ? 'Return previous presentation content' : 'Set different content in presentation area', icon: 'copy', diff --git a/src/ui-commands/commands.ts b/src/ui-commands/commands.ts index 4c493ec..b57f27f 100644 --- a/src/ui-commands/commands.ts +++ b/src/ui-commands/commands.ts @@ -5,11 +5,13 @@ import { presentationArea } from './presentation-area/commands'; import { userStatus } from './user-status/commands'; import { conference } from './conference/commands'; import { notification } from './notification/commands'; +import { navBar } from './nav-bar/commands'; export const uiCommands = { chat, externalVideo, sidekickOptionsContainer, + navBar, presentationArea, userStatus, conference, diff --git a/src/ui-commands/nav-bar/commands.ts b/src/ui-commands/nav-bar/commands.ts new file mode 100644 index 0000000..fb0f4e5 --- /dev/null +++ b/src/ui-commands/nav-bar/commands.ts @@ -0,0 +1,23 @@ +import { NavBarEnum } from './enums'; +import { SetDisplayNavBarCommandArguments } from './types'; + +export const navBar = { + /** + * Sets the displayNavBar to true (show it) or false (hide it). + * + * @param setDisplayNavBarCommandArguments: object with a boolean that tells whether to display + * the navbar + */ + setDisplayNavBar: (setDisplayNavBarCommandArguments: SetDisplayNavBarCommandArguments) => { + const { displayNavBar } = setDisplayNavBarCommandArguments; + window.dispatchEvent( + new CustomEvent< + SetDisplayNavBarCommandArguments + >(NavBarEnum.SET_DISPLAY_NAV_BAR, { + detail: { + displayNavBar, + }, + }), + ); + }, +}; diff --git a/src/ui-commands/nav-bar/enums.ts b/src/ui-commands/nav-bar/enums.ts new file mode 100644 index 0000000..ec5a986 --- /dev/null +++ b/src/ui-commands/nav-bar/enums.ts @@ -0,0 +1,3 @@ +export enum NavBarEnum { + SET_DISPLAY_NAV_BAR = 'SET_DISPLAY_NAV_BAR_COMMAND', +} diff --git a/src/ui-commands/nav-bar/types.ts b/src/ui-commands/nav-bar/types.ts new file mode 100644 index 0000000..c226106 --- /dev/null +++ b/src/ui-commands/nav-bar/types.ts @@ -0,0 +1,7 @@ +export interface SetDisplayNavBarCommandArguments { + displayNavBar: boolean; +} + +export interface UiCommandsNavBarObject { + setDisplayNavBar: (setDisplayNavBarCommandArguments: SetDisplayNavBarCommandArguments) => void; +} diff --git a/src/ui-commands/types.ts b/src/ui-commands/types.ts index e2ea18a..2568add 100644 --- a/src/ui-commands/types.ts +++ b/src/ui-commands/types.ts @@ -5,11 +5,13 @@ import { UiCommandsPresentationAreaObject } from './presentation-area/types'; import { UiCommandsUserStatusObject } from './user-status/types'; import { UiCommandsConferenceObject } from './conference/types'; import { UiCommandsNotificationObject } from './notification/types'; +import { UiCommandsNavBarObject } from './nav-bar/types'; export interface UiCommands { chat: UiCommandsChatObject; externalVideo: UiCommandsExternalVideoObject; sidekickOptionsContainer: UiCommandsSidekickOptionsContainerObject; + navBar: UiCommandsNavBarObject; presentationArea: UiCommandsPresentationAreaObject; userStatus: UiCommandsUserStatusObject; conference: UiCommandsConferenceObject;