2024-06-11 05:16:11 +08:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
|
2024-06-14 06:30:59 +08:00
|
|
|
import { GenericContentType } from 'bigbluebutton-html-plugin-sdk/dist/cjs/extensible-areas/generic-content-item/enums';
|
2024-06-11 05:16:11 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2024-06-18 20:20:35 +08:00
|
|
|
import { PANELS, ACTIONS } from '/imports/ui/components/layout/enums';
|
2024-06-11 05:16:11 +08:00
|
|
|
import GenericSidekickContent from './component';
|
2024-06-15 02:32:55 +08:00
|
|
|
import { GenericContentSidekickContainerProps } from '../types';
|
2024-06-11 05:16:11 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2024-06-18 20:20:35 +08:00
|
|
|
import { layoutDispatch } from '../../layout/context';
|
2024-06-11 05:16:11 +08:00
|
|
|
|
2024-06-15 02:32:55 +08:00
|
|
|
const GenericContentSidekickContainer: React.FC<GenericContentSidekickContainerProps> = (
|
|
|
|
props: GenericContentSidekickContainerProps,
|
2024-06-14 06:30:59 +08:00
|
|
|
) => {
|
2024-06-11 05:16:11 +08:00
|
|
|
const { genericSidekickContentId } = props;
|
2024-06-14 06:30:59 +08:00
|
|
|
const genericSidekickContentIdIsolated = genericSidekickContentId.replace(PANELS.GENERIC_CONTENT_SIDEKICK, '');
|
2024-06-18 20:20:35 +08:00
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2024-06-11 05:16:11 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
pluginsExtensibleAreasAggregatedState,
|
|
|
|
} = useContext(PluginsContext);
|
2024-06-18 20:20:35 +08:00
|
|
|
let genericContentSidekickAreaExtensibleArea = [] as PluginSdk.GenericContentSidekickArea[];
|
2024-06-11 05:16:11 +08:00
|
|
|
|
2024-06-15 00:48:25 +08:00
|
|
|
if (pluginsExtensibleAreasAggregatedState.genericContentItems) {
|
2024-06-18 20:20:35 +08:00
|
|
|
const genericContentSidekickArea = pluginsExtensibleAreasAggregatedState.genericContentItems
|
2024-06-14 06:30:37 +08:00
|
|
|
.filter((g) => g.type === GenericContentType.SIDEKICK_AREA) as PluginSdk.GenericContentSidekickArea[];
|
2024-06-18 20:20:35 +08:00
|
|
|
genericContentSidekickAreaExtensibleArea = [...genericContentSidekickArea];
|
2024-06-11 05:16:11 +08:00
|
|
|
}
|
|
|
|
|
2024-06-18 20:20:35 +08:00
|
|
|
const pickedGenericSidekickContent = genericContentSidekickAreaExtensibleArea
|
2024-06-14 06:30:59 +08:00
|
|
|
.filter((gsc) => gsc.id === genericSidekickContentIdIsolated)[0];
|
2024-06-11 05:16:11 +08:00
|
|
|
|
2024-06-24 19:56:27 +08:00
|
|
|
if (genericContentSidekickAreaExtensibleArea.length === 0 || !pickedGenericSidekickContent) {
|
2024-06-11 05:16:11 +08:00
|
|
|
logger.error({
|
|
|
|
logCode: 'generic_sidekick_content_not_found',
|
|
|
|
extraInfo: {
|
|
|
|
genericSidekickContentId,
|
|
|
|
genericSidekickContentIdIsolated,
|
|
|
|
},
|
|
|
|
}, `Generic sidekick content with id ${genericSidekickContentIdIsolated} not found`);
|
2024-06-24 19:56:27 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: false,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.NONE,
|
|
|
|
});
|
|
|
|
return null;
|
2024-06-11 05:16:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GenericSidekickContent
|
2024-06-18 20:20:35 +08:00
|
|
|
layoutContextDispatch={layoutContextDispatch}
|
2024-06-11 05:16:11 +08:00
|
|
|
genericContentId={pickedGenericSidekickContent.id}
|
|
|
|
renderFunction={pickedGenericSidekickContent.contentFunction}
|
|
|
|
genericContentLabel={pickedGenericSidekickContent.name}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-06-15 02:32:55 +08:00
|
|
|
export default GenericContentSidekickContainer;
|