Skip to content

Commit

Permalink
[change-enforced-layout] - Added a new feature to the ui-commands: ch…
Browse files Browse the repository at this point in the history
…ange the enforced layout, now one should be able to properly change from one layout to another seamlessly
  • Loading branch information
GuiLeme committed Dec 5, 2024
1 parent 92a1e8c commit 4d2cdc0
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
UiLayouts,
pluginLogger,
NotificationTypeUiCommand,
ChangeEnforcedLayoutTypeEnum,
} from 'bigbluebutton-html-plugin-sdk';
import * as ReactDOM from 'react-dom/client';
import { IsMeetingBreakoutGraphqlResponse, SampleActionButtonDropdownPluginProps } from './types';
Expand Down Expand Up @@ -41,6 +42,8 @@ function SampleActionButtonDropdownPlugin(
isOpen: true,
}]);

const [isCamerasOnly, setIsCamerasOnly] = useState(false);

const { data: isMeetingBreakoutFromGraphql } = pluginApi.useCustomSubscription<
IsMeetingBreakoutGraphqlResponse>(IS_MEETING_BREAKOUT);

Expand Down Expand Up @@ -135,9 +138,26 @@ function SampleActionButtonDropdownPlugin(
allowed: true,
onClick: handleChangePresentationAreaContent,
}),
new ActionButtonDropdownOption({
label: (!isCamerasOnly) ? 'Switch to cameras only layout' : 'Switch to custom layout',
icon: 'copy',
tooltip: 'this is a button injected by plugin',
allowed: true,
onClick: (!isCamerasOnly) ? () => {
pluginApi.uiCommands.layout.changeEnforcedLayout(
ChangeEnforcedLayoutTypeEnum.CAMERAS_ONLY,
);
setIsCamerasOnly(true);
} : () => {
pluginApi.uiCommands.layout.changeEnforcedLayout(
ChangeEnforcedLayoutTypeEnum.PARTICIPANTS_AND_CHAT_ONLY,
);
setIsCamerasOnly(false);
},
}),
]);
}
}, [currentPresentation, currentUser, showingGenericContentInPresentationArea]);
}, [currentPresentation, currentUser, showingGenericContentInPresentationArea, isCamerasOnly]);

return (
<ReactModal
Expand Down
2 changes: 2 additions & 0 deletions src/ui-commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { presentationArea } from './presentation-area/commands';
import { userStatus } from './user-status/commands';
import { conference } from './conference/commands';
import { notification } from './notification/commands';
import { layout } from './layout/commands';

export const uiCommands = {
chat,
Expand All @@ -14,4 +15,5 @@ export const uiCommands = {
userStatus,
conference,
notification,
layout,
};
1 change: 1 addition & 0 deletions src/ui-commands/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { NotificationTypeUiCommand } from './notification/enums';
export { ChangeEnforcedLayoutTypeEnum } from './layout/enums';
21 changes: 21 additions & 0 deletions src/ui-commands/layout/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ChangeEnforcedLayoutTypeEnum, LayoutEnum } from './enums';
import { ChangeEnforcedLayout, ChangeEnforcedLayoutCommandArguments } from './types';

export const layout = {
/**
* <description>
*
* @param
*/
changeEnforcedLayout: ((layoutType: ChangeEnforcedLayoutTypeEnum) => {
window.dispatchEvent(
new CustomEvent<
ChangeEnforcedLayoutCommandArguments
>(LayoutEnum.CHANGE_ENFORCED_LAYOUT, {
detail: {
layoutType,
},
}),
);
}) as ChangeEnforcedLayout,
};
14 changes: 14 additions & 0 deletions src/ui-commands/layout/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export enum LayoutEnum {
CHANGE_ENFORCED_LAYOUT = 'CHANGE_ENFORCED_LAYOUT',
}

export enum ChangeEnforcedLayoutTypeEnum {
CUSTOM_LAYOUT = 'CUSTOM_LAYOUT',
SMART_LAYOUT = 'SMART_LAYOUT',
PRESENTATION_FOCUS = 'PRESENTATION_FOCUS',
VIDEO_FOCUS = 'VIDEO_FOCUS',
CAMERAS_ONLY = 'CAMERAS_ONLY',
PRESENTATION_ONLY = 'PRESENTATION_ONLY',
PARTICIPANTS_AND_CHAT_ONLY = 'PARTICIPANTS_AND_CHAT_ONLY',
MEDIA_ONLY = 'MEDIA_ONLY',
}
11 changes: 11 additions & 0 deletions src/ui-commands/layout/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ChangeEnforcedLayoutTypeEnum } from './enums';

export interface ChangeEnforcedLayoutCommandArguments {
layoutType: ChangeEnforcedLayoutTypeEnum;
}

export type ChangeEnforcedLayout = (layoutType: ChangeEnforcedLayoutTypeEnum) => void;

export interface UiCommandsLayoutObject {
changeEnforcedLayout: ChangeEnforcedLayout;
}
2 changes: 2 additions & 0 deletions src/ui-commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { UiCommandsPresentationAreaObject } from './presentation-area/types';
import { UiCommandsUserStatusObject } from './user-status/types';
import { UiCommandsConferenceObject } from './conference/types';
import { UiCommandsNotificationObject } from './notification/types';
import { UiCommandsLayoutObject } from './layout/types';

export interface UiCommands {
layout: UiCommandsLayoutObject;
chat: UiCommandsChatObject;
externalVideo: UiCommandsExternalVideoObject;
sidekickOptionsContainer: UiCommandsSidekickOptionsContainerObject;
Expand Down

0 comments on commit 4d2cdc0

Please sign in to comment.