Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): Refactor enums and filenames #19418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bigbluebutton-html5/imports/ui/components/app/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import LayoutEngine from '../layout/layout-manager/layoutEngine';
import NavBarContainer from '../nav-bar/container';
import SidebarNavigationContainer from '../sidebar-navigation/container';
import SidebarContentContainer from '../sidebar-content/container';
import PluginsEngineContainer from '../plugins-engine/container';
import PluginsEngineManager from '../plugins-engine/manager';
import Settings from '/imports/ui/services/settings';
import { registerTitleView } from '/imports/utils/dom-utils';
import Notifications from '../notifications/container';
Expand Down Expand Up @@ -606,7 +606,7 @@ class App extends Component {
} = this.state;
return (
<>
<PluginsEngineContainer />
<PluginsEngineManager />
<FloatingWindowContainer />
<TimeSync />
<Notifications />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createChannelIdentifier } from 'bigbluebutton-html-plugin-sdk/dist/cjs/
import {
DispatcherFunction, ObjectTo, ToRole, ToUserId,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-channel/types';
import { Hooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataChannelHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-channel/enums';

import { PLUGIN_DATA_CHANNEL_DISPATCH_QUERY, PLUGIN_DATA_CHANNEL_FETCH_QUERY } from '../queries';

Expand Down Expand Up @@ -84,7 +84,7 @@ export const DataChannelItemManager: React.ElementType<DataChannelItemManagerPro
useEffect(() => {
window.dispatchEvent(
new CustomEvent(dataChannelIdentifier, {
detail: { hook: Hooks.DATA_CHANNEL, data },
detail: { hook: DataChannelHooks.DATA_CHANNEL, data },
}),
);
}, [data]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
HookEventWrapper, UnsubscribedEventDetails, SubscribedEventDetails,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataChannelHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-channel/enums';

import { PluginDataChannelManagerContainerProps } from './types';
import { PluginDataChannelManagerProps } from './types';
import { DataChannelItemManager } from './channel-manager/manager';

const PluginDataChannelManagerContainer: React.ElementType<PluginDataChannelManagerContainerProps> = ((
props: PluginDataChannelManagerContainerProps,
const PluginDataChannelManager: React.ElementType<PluginDataChannelManagerProps> = ((
props: PluginDataChannelManagerProps,
) => {
const {
pluginApi,
Expand All @@ -38,11 +39,10 @@ const PluginDataChannelManagerContainer: React.ElementType<PluginDataChannelMana
});
};

// Alterar aqui
useEffect(() => {
const subscribeHandler: EventListener = (
(event: HookEventWrapper<void>) => {
if (event.detail.hook === Hooks.DATA_CHANNEL) {
if (event.detail.hook === DataChannelHooks.DATA_CHANNEL) {
const eventDetails = event.detail as SubscribedEventDetails;
const hookArguments = eventDetails?.hookArguments as DataChannelArguments | undefined;
if (hookArguments?.channelName && hookArguments?.pluginName) {
Expand All @@ -52,7 +52,7 @@ const PluginDataChannelManagerContainer: React.ElementType<PluginDataChannelMana
}) as EventListener;
const unsubscribeHandler: EventListener = (
(event: HookEventWrapper<void>) => {
if (event.detail.hook === Hooks.DATA_CHANNEL) {
if (event.detail.hook === DataChannelHooks.DATA_CHANNEL) {
const eventDetails = event.detail as UnsubscribedEventDetails;
const hookArguments = eventDetails?.hookArguments as DataChannelArguments | undefined;
if (hookArguments?.channelName && hookArguments?.pluginName) {
Expand Down Expand Up @@ -88,6 +88,6 @@ const PluginDataChannelManagerContainer: React.ElementType<PluginDataChannelMana
}
</>
);
}) as React.ElementType<PluginDataChannelManagerContainerProps>;
}) as React.ElementType<PluginDataChannelManagerProps>;

export default PluginDataChannelManagerContainer;
export default PluginDataChannelManager;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';

export interface PluginDataChannelManagerContainerProps {
export interface PluginDataChannelManagerProps {
pluginApi: PluginSdk.PluginApi;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
LoadedChatMessage,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/domain/chat/loaded-chat-messages/types';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataConsumptionHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';
import { UpdatedEventDetails } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import useLoadedChatMessages from '/imports/ui/core/hooks/useLoadedChatMessages';
import { GraphqlDataHookSubscriptionResponse } from '/imports/ui/Types/hook';
Expand All @@ -29,7 +30,7 @@ const LoadedChatMessagesHookContainer = () => {
>(HookEvents.UPDATED, {
detail: {
data: formatLoadedChatMessagesDataFromGraphql(chatMessagesData),
hook: Hooks.LOADED_CHAT_MESSAGES,
hook: DataConsumptionHooks.LOADED_CHAT_MESSAGES,
},
}));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useEffect, useState } from 'react';
import useCurrentPresentation from '/imports/ui/core/hooks/useCurrentPresentation';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataConsumptionHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';

import { CurrentPresentation } from '/imports/ui/Types/presentation';
import formatCurrentPresentation from './utils';
Expand All @@ -27,7 +28,7 @@ const CurrentPresentationHookContainer = () => {
{
detail: {
data: formattedCurrentPresentation,
hook: Hooks.CURRENT_PRESENTATION,
hook: DataConsumptionHooks.CURRENT_PRESENTATION,
},
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import logger from '/imports/startup/client/logger';
import { CustomSubscriptionArguments } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/domain/shared/custom-subscription/types';
import { UpdatedEventDetails } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataConsumptionHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';

import { HookWithArgumentsContainerProps } from './types';

Expand Down Expand Up @@ -36,7 +37,7 @@ const CustomSubscriptionHookContainer = (props: HookWithArgumentsContainerProps)
{
detail: {
data: customSubscriptionData,
hook: Hooks.CUSTOM_SUBSCRIPTION,
hook: DataConsumptionHooks.CUSTOM_SUBSCRIPTION,
hookArguments: {
query: queryFromPlugin,
variables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import { User } from '/imports/ui/Types/user';
import { UpdatedEventDetails } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataConsumptionHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';

import formatCurrentUserResponseFromGraphql from './utils';

Expand All @@ -32,7 +33,7 @@ const CurrentUserHookContainer = () => {
{
detail: {
data: currentUserProjection,
hook: Hooks.CURRENT_USER,
hook: DataConsumptionHooks.CURRENT_USER,
},
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useEffect, useState } from 'react';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import { User } from '/imports/ui/Types/user';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import { DataConsumptionHooks } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';
import { UpdatedEventDetails } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import formatLoadedUserListDataFromGraphql from './utils';
import useLoadedUserList from '/imports/ui/core/hooks/useLoadedUserList';
Expand All @@ -23,7 +24,7 @@ const LoadedUserListHookContainer = () => {
>(HookEvents.UPDATED, {
detail: {
data: formatLoadedUserListDataFromGraphql(usersData),
hook: Hooks.LOADED_USER_LIST,
hook: DataConsumptionHooks.LOADED_USER_LIST,
},
}));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,36 @@ import React, { useEffect, useState } from 'react';
import { CustomSubscriptionArguments } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/domain/shared/custom-subscription/types';
import { makeCustomHookIdentifierFromArgs } from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/utils';
import {
Hooks, HookEvents,
HookEvents,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/enum';
import {
DataConsumptionHooks,
} from 'bigbluebutton-html-plugin-sdk/dist/cjs/data-consumption/enums';
import { HookEventWrapper, SubscribedEventDetails } from 'bigbluebutton-html-plugin-sdk/dist/cjs/core/types';
import LoadedUserListHookContainer from '../domain/users/loaded-user-list/hook-manager';
import CurrentUserHookContainer from '../domain/users/current-user/hook-manager';
import CustomSubscriptionHookContainer from '../domain/shared/custom-subscription/hook-manager';
import LoadedUserListHookContainer from './domain/users/loaded-user-list/hook-manager';
import CurrentUserHookContainer from './domain/users/current-user/hook-manager';
import CustomSubscriptionHookContainer from './domain/shared/custom-subscription/hook-manager';

import { ObjectToCustomHookContainerMap, HookWithArgumentsContainerProps, HookWithArgumentContainerToRender } from '../domain/shared/custom-subscription/types';
import CurrentPresentationHookContainer from '../domain/presentations/current-presentation/hook-manager';
import LoadedChatMessagesHookContainer from '../domain/chat/loaded-chat-messages/hook-manager';
import { ObjectToCustomHookContainerMap, HookWithArgumentsContainerProps, HookWithArgumentContainerToRender } from './domain/shared/custom-subscription/types';
import CurrentPresentationHookContainer from './domain/presentations/current-presentation/hook-manager';
import LoadedChatMessagesHookContainer from './domain/chat/loaded-chat-messages/hook-manager';

const hooksMap:{
[key: string]: React.FunctionComponent
} = {
[Hooks.LOADED_CHAT_MESSAGES]: LoadedChatMessagesHookContainer,
[Hooks.LOADED_USER_LIST]: LoadedUserListHookContainer,
[Hooks.CURRENT_USER]: CurrentUserHookContainer,
[Hooks.CURRENT_PRESENTATION]: CurrentPresentationHookContainer,
[DataConsumptionHooks.LOADED_CHAT_MESSAGES]: LoadedChatMessagesHookContainer,
[DataConsumptionHooks.LOADED_USER_LIST]: LoadedUserListHookContainer,
[DataConsumptionHooks.CURRENT_USER]: CurrentUserHookContainer,
[DataConsumptionHooks.CURRENT_PRESENTATION]: CurrentPresentationHookContainer,
};

const HooksMapWithArguments:{
[key: string]: React.FunctionComponent<HookWithArgumentsContainerProps>
} = {
[Hooks.CUSTOM_SUBSCRIPTION]: CustomSubscriptionHookContainer,
[DataConsumptionHooks.CUSTOM_SUBSCRIPTION]: CustomSubscriptionHookContainer,
};

const PluginHooksHandlerContainer: React.FC = () => {
const PluginDataConsumptionManager: React.FC = () => {
const [
hookUtilizationCount,
setHookUtilizationCount,
Expand All @@ -45,7 +48,7 @@ const PluginHooksHandlerContainer: React.FC = () => {
const updateHookUsage = (
hookName: string, delta: number, hookArguments?: CustomSubscriptionArguments,
): void => {
if (hookName !== Hooks.CUSTOM_SUBSCRIPTION) {
if (hookName !== DataConsumptionHooks.CUSTOM_SUBSCRIPTION) {
setHookUtilizationCount((mapObj) => {
const newMap = new Map<string, number>(mapObj.entries());
newMap.set(hookName, (mapObj.get(hookName) || 0) + delta);
Expand Down Expand Up @@ -74,7 +77,7 @@ const PluginHooksHandlerContainer: React.FC = () => {
const subscribeHandler: EventListener = (
(event: HookEventWrapper<void>) => {
let hookArguments: CustomSubscriptionArguments | undefined;
if (event.detail.hook === Hooks.CUSTOM_SUBSCRIPTION) {
if (event.detail.hook === DataConsumptionHooks.CUSTOM_SUBSCRIPTION) {
const detail = event.detail as SubscribedEventDetails;
hookArguments = detail.hookArguments as CustomSubscriptionArguments;
}
Expand All @@ -83,7 +86,7 @@ const PluginHooksHandlerContainer: React.FC = () => {
const unsubscribeHandler: EventListener = (
(event: HookEventWrapper<void>) => {
let hookArguments: CustomSubscriptionArguments | undefined;
if (event.detail.hook === Hooks.CUSTOM_SUBSCRIPTION) {
if (event.detail.hook === DataConsumptionHooks.CUSTOM_SUBSCRIPTION) {
const detail = event.detail as SubscribedEventDetails;
hookArguments = detail.hookArguments as CustomSubscriptionArguments;
}
Expand Down Expand Up @@ -138,4 +141,4 @@ const PluginHooksHandlerContainer: React.FC = () => {
);
};

export default PluginHooksHandlerContainer;
export default PluginDataConsumptionManager;
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as React from 'react';
import { PluginProvidedUiItemDescriptor } from 'bigbluebutton-html-plugin-sdk/dist/cjs/extensible-areas/base';

import PresentationToolbarPluginStateContainer from '../components/presentation-toolbar/manager';
import UserListDropdownPluginStateContainer from '../components/user-list-dropdown/manager';
import ActionButtonDropdownPluginStateContainer from '../components/action-button-dropdown/manager';
import AudioSettingsDropdownPluginStateContainer from '../components/audio-settings-dropdown/manager';
import ActionBarPluginStateContainer from '../components/action-bar/manager';
import PresentationDropdownPluginStateContainer from '../components/presentation-dropdown/manager';
import NavBarPluginStateContainer from '../components/nav-bar/manager';
import OptionsDropdownPluginStateContainer from '../components/options-dropdown/manager';
import CameraSettingsDropdownPluginStateContainer from '../components/camera-settings-dropdown/manager';
import UserCameraDropdownPluginStateContainer from '../components/user-camera-dropdown/manager';
import UserListItemAdditionalInformationPluginStateContainer from '../components/user-list-item-additional-information/manager';
import PresentationToolbarPluginStateContainer from './components/presentation-toolbar/manager';
import UserListDropdownPluginStateContainer from './components/user-list-dropdown/manager';
import ActionButtonDropdownPluginStateContainer from './components/action-button-dropdown/manager';
import AudioSettingsDropdownPluginStateContainer from './components/audio-settings-dropdown/manager';
import ActionBarPluginStateContainer from './components/action-bar/manager';
import PresentationDropdownPluginStateContainer from './components/presentation-dropdown/manager';
import NavBarPluginStateContainer from './components/nav-bar/manager';
import OptionsDropdownPluginStateContainer from './components/options-dropdown/manager';
import CameraSettingsDropdownPluginStateContainer from './components/camera-settings-dropdown/manager';
import UserCameraDropdownPluginStateContainer from './components/user-camera-dropdown/manager';
import UserListItemAdditionalInformationPluginStateContainer from './components/user-list-item-additional-information/manager';
import {
ExtensibleArea, ExtensibleAreaStateManagerProps,
ExtensibleAreaComponentManager, ExtensibleAreaMap,
} from '../types';
import FloatingWindowPluginStateContainer from '../components/floating-window/manager';
} from './types';
import FloatingWindowPluginStateContainer from './components/floating-window/manager';

const extensibleAreaMap: ExtensibleAreaMap = {};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PluginLoaderContainerProps } from './types';
import { PluginLoaderManagerProps } from './types';
import { useEffect } from 'react';
import logger from '/imports/startup/client/logger';

const PluginLoaderContainer = (props: PluginLoaderContainerProps) => {
const PluginLoaderManager = (props: PluginLoaderManagerProps) => {
const {
uuid,
containerRef,
Expand Down Expand Up @@ -37,4 +37,4 @@ const PluginLoaderContainer = (props: PluginLoaderContainerProps) => {
return null;
};

export default PluginLoaderContainer;
export default PluginLoaderManager;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PluginConfig } from '../types';

export interface PluginLoaderContainerProps {
export interface PluginLoaderManagerProps {
uuid: string;
containerRef: React.RefObject<HTMLDivElement>;
loadedPlugins: React.MutableRefObject<number>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import {
} from 'bigbluebutton-html-plugin-sdk';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import * as uuidLib from 'uuid';
import PluginHooksHandlerContainer from './data-consumption/state-manager/manager';
import PluginDataConsumptionManager from './data-consumption/manager';
import PluginsEngineComponent from './component';
import { PluginConfig, EffectivePluginConfig } from './types';
import PluginLoaderContainer from './loader/manager';
import ExtensibleAreaStateManager from './extensible-areas/state-manager/manager';
import PluginDataChannelManagerContainer from './data-channel/manager';
import PluginLoaderManager from './loader/manager';
import ExtensibleAreaStateManager from './extensible-areas/manager';
import PluginDataChannelManager from './data-channel/manager';
import PluginUiCommandsHandler from './ui-commands/handler';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - temporary, while meteor exists in the project
const PLUGINS_CONFIG = Meteor.settings.public.plugins;

const PluginsEngineContainer = () => {
const PluginsEngineManager = () => {
// If there is no plugin to load, the engine simply returns null
if (!PLUGINS_CONFIG) return null;

Expand Down Expand Up @@ -51,14 +51,15 @@ const PluginsEngineContainer = () => {
containerRef,
}}
/>
<PluginDataConsumptionManager />
<PluginUiCommandsHandler />
{
effectivePluginsConfig.map((effectivePluginConfig: EffectivePluginConfig) => {
const { uuid, name: pluginName } = effectivePluginConfig;
const pluginApi: PluginSdk.PluginApi = BbbPluginSdk.getPluginApi(uuid, pluginName);
return (
<div key={uuid}>
<PluginLoaderContainer
<PluginLoaderManager
{...{
uuid,
containerRef,
Expand All @@ -67,7 +68,7 @@ const PluginsEngineContainer = () => {
pluginConfig: effectivePluginConfig,
}}
/>
<PluginDataChannelManagerContainer
<PluginDataChannelManager
{...{
pluginApi,
}}
Expand All @@ -82,9 +83,8 @@ const PluginsEngineContainer = () => {
);
})
}
<PluginHooksHandlerContainer />
</>
);
};

export default PluginsEngineContainer;
export default PluginsEngineManager;