2024-06-11 05:16:11 +08:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
|
|
|
|
import { GenericContentType } from 'bigbluebutton-html-plugin-sdk/dist/cjs/extensible-areas/generic-content/enums';
|
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
|
|
|
import { PANELS } from '/imports/ui/components/layout/enums';
|
|
|
|
import GenericSidekickContent from './component';
|
|
|
|
import { GenericSidekickContentContainerProps } from '../types';
|
|
|
|
import logger from '/imports/startup/client/logger';
|
|
|
|
|
|
|
|
|
|
|
|
const GenericSidekickContentContainer: React.FC<GenericSidekickContentContainerProps> = (props: GenericSidekickContentContainerProps) => {
|
|
|
|
const { genericSidekickContentId } = props;
|
2024-06-14 06:30:37 +08:00
|
|
|
const genericSidekickContentIdIsolated = genericSidekickContentId.replace(PANELS.GENERIC_CONTENT_SIDEKICK, "");
|
2024-06-11 05:16:11 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
pluginsExtensibleAreasAggregatedState,
|
|
|
|
} = useContext(PluginsContext);
|
2024-06-14 06:30:37 +08:00
|
|
|
let genericSidekickContentExtensibleArea = [] as PluginSdk.GenericContentSidekickArea[];
|
2024-06-11 05:16:11 +08:00
|
|
|
|
|
|
|
if (pluginsExtensibleAreasAggregatedState.genericContents) {
|
2024-06-14 06:30:37 +08:00
|
|
|
.filter((g) => g.type === GenericContentType.SIDEKICK_AREA) as PluginSdk.GenericContentSidekickArea[];
|
2024-06-11 05:16:11 +08:00
|
|
|
genericSidekickContentExtensibleArea = [...genericMainContent];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (genericSidekickContentExtensibleArea.length === 0) return null;
|
|
|
|
const pickedGenericSidekickContent = genericSidekickContentExtensibleArea.filter((gsc) => gsc.id === genericSidekickContentIdIsolated)[0];
|
|
|
|
|
|
|
|
if (!pickedGenericSidekickContent) {
|
|
|
|
logger.error({
|
|
|
|
logCode: 'generic_sidekick_content_not_found',
|
|
|
|
extraInfo: {
|
|
|
|
genericSidekickContentId,
|
|
|
|
genericSidekickContentIdIsolated,
|
|
|
|
},
|
|
|
|
}, `Generic sidekick content with id ${genericSidekickContentIdIsolated} not found`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GenericSidekickContent
|
|
|
|
genericContentId={pickedGenericSidekickContent.id}
|
|
|
|
renderFunction={pickedGenericSidekickContent.contentFunction}
|
|
|
|
genericContentLabel={pickedGenericSidekickContent.name}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GenericSidekickContentContainer;
|