Skip to content

Commit 8f655d2

Browse files
authored
Merge pull request #135 from GuiLeme/change-enforced-layout
feat(CORE): Change enforced layout
2 parents df533e8 + 7868923 commit 8f655d2

File tree

7 files changed

+72
-1
lines changed

7 files changed

+72
-1
lines changed

samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
UiLayouts,
1515
pluginLogger,
1616
NotificationTypeUiCommand,
17+
ChangeEnforcedLayoutTypeEnum,
1718
} from 'bigbluebutton-html-plugin-sdk';
1819
import * as ReactDOM from 'react-dom/client';
1920
import { IsMeetingBreakoutGraphqlResponse, SampleActionButtonDropdownPluginProps } from './types';
@@ -41,6 +42,8 @@ function SampleActionButtonDropdownPlugin(
4142
isOpen: true,
4243
}]);
4344

45+
const [isCamerasOnly, setIsCamerasOnly] = useState(false);
46+
4447
const { data: isMeetingBreakoutFromGraphql } = pluginApi.useCustomSubscription<
4548
IsMeetingBreakoutGraphqlResponse>(IS_MEETING_BREAKOUT);
4649

@@ -147,9 +150,26 @@ function SampleActionButtonDropdownPlugin(
147150
allowed: true,
148151
onClick: handleChangePresentationAreaContent,
149152
}),
153+
new ActionButtonDropdownOption({
154+
label: (!isCamerasOnly) ? 'Switch to cameras only layout' : 'Switch to custom layout',
155+
icon: 'copy',
156+
tooltip: 'this is a button injected by plugin',
157+
allowed: true,
158+
onClick: (!isCamerasOnly) ? () => {
159+
pluginApi.uiCommands.layout.changeEnforcedLayout(
160+
ChangeEnforcedLayoutTypeEnum.CAMERAS_ONLY,
161+
);
162+
setIsCamerasOnly(true);
163+
} : () => {
164+
pluginApi.uiCommands.layout.changeEnforcedLayout(
165+
ChangeEnforcedLayoutTypeEnum.CUSTOM_LAYOUT,
166+
);
167+
setIsCamerasOnly(false);
168+
},
169+
}),
150170
]);
151171
}
152-
}, [currentPresentation, currentUser, showingGenericContentInPresentationArea]);
172+
}, [currentPresentation, currentUser, showingGenericContentInPresentationArea, isCamerasOnly]);
153173

154174
return (
155175
<ReactModal

src/ui-commands/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { userStatus } from './user-status/commands';
66
import { conference } from './conference/commands';
77
import { notification } from './notification/commands';
88
import { actionsBar } from './actions-bar/commands';
9+
import { layout } from './layout/commands';
910

1011
export const uiCommands = {
1112
actionsBar,
@@ -16,4 +17,5 @@ export const uiCommands = {
1617
userStatus,
1718
conference,
1819
notification,
20+
layout,
1921
};

src/ui-commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { NotificationTypeUiCommand } from './notification/enums';
2+
export { ChangeEnforcedLayoutTypeEnum } from './layout/enums';

src/ui-commands/layout/commands.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ChangeEnforcedLayoutTypeEnum, LayoutEnum } from './enums';
2+
import { ChangeEnforcedLayout, ChangeEnforcedLayoutCommandArguments } from './types';
3+
4+
export const layout = {
5+
/**
6+
* <description>
7+
*
8+
* @param
9+
*/
10+
changeEnforcedLayout: ((layoutType: ChangeEnforcedLayoutTypeEnum) => {
11+
window.dispatchEvent(
12+
new CustomEvent<
13+
ChangeEnforcedLayoutCommandArguments
14+
>(LayoutEnum.CHANGE_ENFORCED_LAYOUT, {
15+
detail: {
16+
layoutType,
17+
},
18+
}),
19+
);
20+
}) as ChangeEnforcedLayout,
21+
};

src/ui-commands/layout/enums.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export enum LayoutEnum {
2+
CHANGE_ENFORCED_LAYOUT = 'CHANGE_ENFORCED_LAYOUT',
3+
}
4+
5+
export enum ChangeEnforcedLayoutTypeEnum {
6+
CUSTOM_LAYOUT = 'CUSTOM_LAYOUT',
7+
SMART_LAYOUT = 'SMART_LAYOUT',
8+
PRESENTATION_FOCUS = 'PRESENTATION_FOCUS',
9+
VIDEO_FOCUS = 'VIDEO_FOCUS',
10+
CAMERAS_ONLY = 'CAMERAS_ONLY',
11+
PRESENTATION_ONLY = 'PRESENTATION_ONLY',
12+
PARTICIPANTS_AND_CHAT_ONLY = 'PARTICIPANTS_AND_CHAT_ONLY',
13+
MEDIA_ONLY = 'MEDIA_ONLY',
14+
}

src/ui-commands/layout/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ChangeEnforcedLayoutTypeEnum } from './enums';
2+
3+
export interface ChangeEnforcedLayoutCommandArguments {
4+
layoutType: ChangeEnforcedLayoutTypeEnum;
5+
}
6+
7+
export type ChangeEnforcedLayout = (layoutType: ChangeEnforcedLayoutTypeEnum) => void;
8+
9+
export interface UiCommandsLayoutObject {
10+
changeEnforcedLayout: ChangeEnforcedLayout;
11+
}

src/ui-commands/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { UiCommandsUserStatusObject } from './user-status/types';
66
import { UiCommandsConferenceObject } from './conference/types';
77
import { UiCommandsNotificationObject } from './notification/types';
88
import { UiCommandsActionsBarObject } from './actions-bar/types';
9+
import { UiCommandsLayoutObject } from './layout/types';
910

1011
export interface UiCommands {
12+
layout: UiCommandsLayoutObject;
1113
actionsBar: UiCommandsActionsBarObject;
1214
chat: UiCommandsChatObject;
1315
externalVideo: UiCommandsExternalVideoObject;

0 commit comments

Comments
 (0)