bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/plugins-engine/plugin-provided-state/container.tsx
2023-09-13 11:31:20 -03:00

50 lines
1.7 KiB
TypeScript

import * as React from 'react';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import { PluginProvidedStateContainerProps, PluginsProvidedStateMap, PluginProvidedState } from '../types';
import PresentationToolbarPluginStateContainer from './presentation-toolbar/container';
import UserListDropdownPluginStateContainer from './user-list-dropdown/container';
const pluginProvidedStateMap: PluginsProvidedStateMap = {};
function generateItemWithId<T extends PluginSdk.PluginProvidedUiItemDescriptor>(
item: T, index: number,
): T {
item.setItemId(`${index}`);
return item;
}
const PluginProvidedStateContainer = (props: PluginProvidedStateContainerProps) => {
const {
uuid,
} = props;
if (!pluginProvidedStateMap[uuid]) {
pluginProvidedStateMap[uuid] = {} as PluginProvidedState;
}
const pluginApi: PluginSdk.PluginApi = PluginSdk.getPluginApi(uuid);
const pluginProvidedStateChildrenProps = {
uuid,
generateItemWithId,
pluginProvidedStateMap,
pluginApi,
};
return (
<>
<PresentationToolbarPluginStateContainer
uuid={pluginProvidedStateChildrenProps.uuid}
generateItemWithId={pluginProvidedStateChildrenProps.generateItemWithId}
pluginProvidedStateMap={pluginProvidedStateChildrenProps.pluginProvidedStateMap}
pluginApi={pluginProvidedStateChildrenProps.pluginApi}
/>
<UserListDropdownPluginStateContainer
uuid={pluginProvidedStateChildrenProps.uuid}
generateItemWithId={pluginProvidedStateChildrenProps.generateItemWithId}
pluginProvidedStateMap={pluginProvidedStateChildrenProps.pluginProvidedStateMap}
pluginApi={pluginProvidedStateChildrenProps.pluginApi}
/>
</>
);
};
export default PluginProvidedStateContainer;