bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/plugins-engine/plugin-provided-state/container.tsx

57 lines
2.2 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';
import PresentationDropdownPluginStateContainer from './presentation-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}
/>
<PresentationDropdownPluginStateContainer
uuid={pluginProvidedStateChildrenProps.uuid}
generateItemWithId={pluginProvidedStateChildrenProps.generateItemWithId}
pluginProvidedStateMap={pluginProvidedStateChildrenProps.pluginProvidedStateMap}
pluginApi={pluginProvidedStateChildrenProps.pluginApi}
/>
</>
);
};
export default PluginProvidedStateContainer;