Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ One other thing is that the type of the return is precisely the same type requir
- panel:
- open: this function will open the sidekick options panel automatically;
- close: this function will close the sidekick options panel automatically (and also the sidebar content if open, to avoid inconsistencies in ui);
- panel:
- open: this function will open a panel in the sidekick area. It takes the ID of a generic content sidekick area (as returned by `setGenericContentItems`) as its first argument, or one of the `SidekickAreaCorePanelEnum` core panels as its second. Core panels the user could not open from the sidebar navigation themselves, such as Polls for a viewer, are ignored;
- close: this function will close a panel in the sidekick area. It takes the same arguments as `open`, and then only closes the panel if it is one of those on display, so a plugin does not close a panel it does not own. Passing neither closes the sidekick area altogether;
- sidekick-options-container:
- open: this function will open the sidekick options panel automatically;
- close: this function will close the sidekick options panel automatically (and also the sidebar content if open, to avoid inconsistencies in ui);
Expand Down Expand Up @@ -837,6 +840,18 @@ One other thing is that the type of the return is precisely the same type requir
'New Section Name'
);

// Open the plugin's own sidekick panel
pluginApi.uiCommands.sidekickArea.panel.open('my-content-id');

// Open a core panel
pluginApi.uiCommands.sidekickArea.panel.open(
undefined,
SidekickAreaCorePanelEnum.POLL
);

// Close it again, but only if it is still the one on display
pluginApi.uiCommands.sidekickArea.panel.close('my-content-id');

// Camera commands
pluginApi.uiCommands.camera.setSelfViewDisableAllDevices(true);
pluginApi.uiCommands.camera.setSelfViewDisable('camera-stream-id', false);
Expand Down
1 change: 1 addition & 0 deletions src/ui-commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { ChangeEnforcedLayoutTypeEnum, EnforcedLayoutTypeEnum } from './layout/e
export { CaptionsLanguageEnum } from './captions/enums';
export { ChatUiCommandsEnum } from './chat/enums';
export { ScreenshareCommandsEnum } from './screenshare/enums';
export { SidekickAreaCorePanelEnum } from './sidekick-area/panel/enums';
2 changes: 2 additions & 0 deletions src/ui-commands/sidekick-area/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { sidekickAreaOptions } from './options/commands';
import { sidekickAreaPanel } from './panel/commands';
import { UiCommandsSidekickArea } from './types';

export const sidekickArea: UiCommandsSidekickArea = {
options: sidekickAreaOptions,
panel: sidekickAreaPanel,
};
47 changes: 47 additions & 0 deletions src/ui-commands/sidekick-area/panel/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { SidekickAreaCorePanelEnum, SidekickAreaPanelEnum } from './enums';
import {
SidekickAreaPanelCommandArguments,
UiCommandsSidekickAreaPanelObject,
} from './types';

const dispatch = (
command: SidekickAreaPanelEnum,
id?: string,
panel?: SidekickAreaCorePanelEnum,
) => {
window.dispatchEvent(new CustomEvent<SidekickAreaPanelCommandArguments>(
command,
{
detail: {
id,
panel,
},
},
));
};

export const sidekickAreaPanel: UiCommandsSidekickAreaPanelObject = {
/**
* Opens a panel in the sidekick area.
*
* @param id Id of a generic content sidekick area, as returned by
* `pluginApi.setGenericContentItems`.
* @param panel Core panel to open instead, read only when no id is given. Core
* panels the user could not open themselves, such as Polls for a viewer, are ignored.
*/
open: (id?: string, panel?: SidekickAreaCorePanelEnum) => {
dispatch(SidekickAreaPanelEnum.OPEN, id, panel);
},

/**
* Closes a panel in the sidekick area, but only if it is on display, so a plugin
* does not close a panel it does not own. Passing neither argument closes the
* sidekick area altogether.
*
* @param id Id of a generic content sidekick area.
* @param panel Core panel to close instead, read only when no id is given.
*/
close: (id?: string, panel?: SidekickAreaCorePanelEnum) => {
dispatch(SidekickAreaPanelEnum.CLOSE, id, panel);
},
};
18 changes: 18 additions & 0 deletions src/ui-commands/sidekick-area/panel/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export enum SidekickAreaPanelEnum {
OPEN = 'OPEN_SIDEKICK_AREA_PANEL_COMMAND',
CLOSE = 'CLOSE_SIDEKICK_AREA_PANEL_COMMAND',
}

/**
* Core panels a plugin is allowed to open. Polls, Timer and Breakout only open when
* the user could already open them from the sidebar navigation.
*/
export enum SidekickAreaCorePanelEnum {
CHAT = 'chat',
USER_LIST = 'userlist',
SHARED_NOTES = 'shared-notes',
APPS_GALLERY = 'apps-gallery',
POLL = 'poll',
TIMER = 'timer',
BREAKOUT = 'breakoutroom',
}
11 changes: 11 additions & 0 deletions src/ui-commands/sidekick-area/panel/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SidekickAreaCorePanelEnum } from './enums';

export interface UiCommandsSidekickAreaPanelObject {
open: (id?: string, panel?: SidekickAreaCorePanelEnum) => void;
close: (id?: string, panel?: SidekickAreaCorePanelEnum) => void;
}

export interface SidekickAreaPanelCommandArguments {
id?: string;
panel?: SidekickAreaCorePanelEnum;
}
2 changes: 2 additions & 0 deletions src/ui-commands/sidekick-area/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { UiCommandsSidekickAreaOptionsObject } from './options/types';
import { UiCommandsSidekickAreaPanelObject } from './panel/types';

export interface UiCommandsSidekickArea {
options: UiCommandsSidekickAreaOptionsObject;
panel: UiCommandsSidekickAreaPanelObject;
}
Loading