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

50 lines
1.7 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
2023-09-11 21:12:37 +08:00
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
2023-09-13 22:31:20 +08:00
uuid={pluginProvidedStateChildrenProps.uuid}
generateItemWithId={pluginProvidedStateChildrenProps.generateItemWithId}
pluginProvidedStateMap={pluginProvidedStateChildrenProps.pluginProvidedStateMap}
pluginApi={pluginProvidedStateChildrenProps.pluginApi}
/>
<UserListDropdownPluginStateContainer
2023-09-13 22:31:20 +08:00
uuid={pluginProvidedStateChildrenProps.uuid}
generateItemWithId={pluginProvidedStateChildrenProps.generateItemWithId}
pluginProvidedStateMap={pluginProvidedStateChildrenProps.pluginProvidedStateMap}
pluginApi={pluginProvidedStateChildrenProps.pluginApi}
/>
</>
);
};
export default PluginProvidedStateContainer;