Skip to content

Commit 886951c

Browse files
committed
feat: ajust plugin to run on bbb 3.1.x
- Updates required sdk version in manifest.json - Updates SDK version to 0.1.10 - Replaces `ActionButtonDropdownItems` by `MediaAreaItems` - Adds proper padding in sidekick panel component - Uses hook to inject intl messages
1 parent 52801df commit 886951c

File tree

14 files changed

+180
-152
lines changed

14 files changed

+180
-152
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"requiredSdkVersion": "~0.0.59",
2+
"requiredSdkVersion": "0.1.x",
33
"name": "TypedCaptions",
44
"javascriptEntrypointUrl": "TypedCaptions.js",
55
"localesBaseUrl": "locales",

package-lock.json

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"@types/react": "^18.2.13",
1111
"@types/react-dom": "^18.2.6",
1212
"babel-plugin-syntax-dynamic-import": "^6.18.0",
13-
"bigbluebutton-html-plugin-sdk": "0.0.84",
13+
"bigbluebutton-html-plugin-sdk": "0.1.10",
1414
"path": "^0.12.7",
15-
"react-intl": "^6.6.8",
1615
"react": "^18.2.0",
1716
"react-chat-elements": "^12.0.14",
1817
"react-dom": "^18.2.0",
18+
"react-intl": "^6.6.8",
1919
"react-modal": "^3.16.1",
2020
"react-select": "^5.7.3",
2121
"react-textarea-autosize": "^8.5.3",
@@ -50,6 +50,7 @@
5050
"@types/react-dom": "^18.2.7",
5151
"@types/react-modal": "^3.16.0",
5252
"@types/styled-components": "^5.1.26",
53+
"@types/webpack-env": "^1.18.8",
5354
"@typescript-eslint/eslint-plugin": "^6.2.0",
5455
"@typescript-eslint/parser": "^6.2.0",
5556
"babel-loader": "^9.1.2",

src/components/main/component.tsx

Lines changed: 19 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,26 @@
11
import * as React from 'react';
22
import * as ReactDOM from 'react-dom/client';
3-
import { createIntl, defineMessages } from 'react-intl';
43

54
import {
6-
ActionButtonDropdownOption,
7-
ActionButtonDropdownSeparator,
8-
BbbPluginSdk,
5+
MediaAreaOption,
6+
MediaAreaSeparator,
97
DataChannelTypes,
108
GenericContentSidekickArea,
11-
PluginApi,
129
} from 'bigbluebutton-html-plugin-sdk';
1310

14-
import { TypedCaptionsProps } from './types';
1511
import { TypedCaptionsModal } from '../modal/component';
1612
import { CaptionMenu } from '../../common/types';
1713
import { TypedCaptionsSidekickArea } from '../typed-captions-sidekick-content/component';
14+
import { TypedCaptionsProps } from './types';
15+
import { intlMessages } from '../../intlMessages';
1816

19-
const intlMessages = defineMessages({
20-
writeCC: {
21-
id: 'plugin.actionButtonDropdown.write',
22-
description: 'action button dropdown label to start writing',
23-
},
24-
stopCC: {
25-
id: 'plugin.actionButtonDropdown.remove',
26-
description: 'action button dropdown label to start writing',
27-
},
28-
sectionName: {
29-
id: 'plugin.actionButtonDropdown.sidekickComponent.sectionName',
30-
description: 'name of the sidekick component section',
31-
},
32-
menuTitle: {
33-
id: 'plugin.actionButtonDropdown.sidekickComponent.menuTitle',
34-
description: 'title of the sidekick component menu (internal part)',
35-
},
36-
});
37-
38-
function TypedCaptions(
39-
{ pluginUuid: uuid }: TypedCaptionsProps,
40-
): React.ReactElement {
41-
BbbPluginSdk.initialize(uuid);
42-
43-
const pluginApi: PluginApi = BbbPluginSdk.getPluginApi(uuid);
44-
17+
function TypedCaptions({ intl, pluginApi, uuid }: TypedCaptionsProps): React.ReactElement {
4518
const {
4619
data: captionMenusResponseFromDataChannel,
4720
pushEntry: pushCaptionMenuResponseFromDataChannel,
4821
deleteEntry: excludeCaptionMenuResponseFromDataChannel,
4922
} = pluginApi.useDataChannel<CaptionMenu>('typed-captions-data-channel', DataChannelTypes.ALL_ITEMS, 'caption-menus');
5023

51-
const {
52-
messages,
53-
currentLocale,
54-
loading: localeMessagesLoading,
55-
} = pluginApi.useLocaleMessages({
56-
headers: {
57-
'ngrok-skip-browser-warning': 'any',
58-
},
59-
});
60-
61-
const intl = (!localeMessagesLoading && messages) ? createIntl({
62-
locale: currentLocale,
63-
messages,
64-
fallbackOnEmptyString: true,
65-
}) : null;
66-
6724
const [captionLocale, setCaptionLocale] = React.useState('');
6825

6926
const currentUserResponse = pluginApi.useCurrentUser();
@@ -76,7 +33,7 @@ function TypedCaptions(
7633

7734
/// contentFunction, name, section, buttonIcon
7835
React.useEffect(() => {
79-
if (!localeMessagesLoading && captionMenusResponseFromDataChannel?.data && currentUserResponse?.data?.role === 'MODERATOR') {
36+
if (captionMenusResponseFromDataChannel?.data && currentUserResponse?.data?.role === 'MODERATOR') {
8037
const sectionName = intl.formatMessage(intlMessages.sectionName);
8138
const sidekickMenuComponentList = captionMenusResponseFromDataChannel?.data
8239
.map((menu) => new GenericContentSidekickArea({
@@ -102,7 +59,7 @@ function TypedCaptions(
10259
}));
10360
pluginApi.setGenericContentItems(sidekickMenuComponentList);
10461
}
105-
}, [captionMenusResponseFromDataChannel, localeMessagesLoading, messages]);
62+
}, [captionMenusResponseFromDataChannel]);
10663

10764
React.useEffect(() => {
10865
if (currentUserResponse?.data?.role === 'MODERATOR') {
@@ -131,23 +88,21 @@ function TypedCaptions(
13188
};
13289
} else actionButtonDropdownLabel = intl.formatMessage(intlMessages.stopCC);
13390
}
134-
if (!localeMessagesLoading) {
135-
pluginApi.setActionButtonDropdownItems([
136-
new ActionButtonDropdownSeparator(),
137-
new ActionButtonDropdownOption({
138-
icon: 'closed_caption',
139-
label: actionButtonDropdownLabel,
140-
tooltip: 'this is a button injected by plugin',
141-
allowed: true,
142-
onClick: actionButtonDropdownOnClick,
143-
}),
144-
]);
145-
}
91+
pluginApi.setMediaAreaItems([
92+
new MediaAreaSeparator({}),
93+
new MediaAreaOption({
94+
icon: 'closed_caption',
95+
label: actionButtonDropdownLabel,
96+
tooltip: 'this is a button injected by plugin',
97+
allowed: true,
98+
onClick: actionButtonDropdownOnClick,
99+
}),
100+
]);
146101
} else {
147-
pluginApi.setActionButtonDropdownItems([]);
102+
pluginApi.setMediaAreaItems([]);
148103
pluginApi.setGenericContentItems([]);
149104
}
150-
}, [currentUserResponse, captionMenusResponseFromDataChannel, localeMessagesLoading, messages]);
105+
}, [currentUserResponse, captionMenusResponseFromDataChannel]);
151106

152107
return (
153108
<TypedCaptionsModal

src/components/main/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import { IntlShape } from 'react-intl';
2+
import { PluginApi } from 'bigbluebutton-html-plugin-sdk';
3+
14
interface TypedCaptionsProps {
2-
pluginName: string,
3-
pluginUuid: string,
5+
intl: IntlShape;
6+
pluginApi: PluginApi;
7+
uuid: string;
48
}
59

610
interface ExternalVideoMeetingSubscription {

src/components/modal/component.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as BbbPluginSdk from 'bigbluebutton-html-plugin-sdk';
2-
import { defineMessages, IntlShape } from 'react-intl';
2+
import { IntlShape } from 'react-intl';
33
import * as React from 'react';
44
import Styled from './styles';
55
import LocalesDropdown from './locales-dropdown/component';
66
import './styles.css';
77
import { AVAILABLE_LOCALES, CAPTIONS_CONFIG_LANGUAGES } from './constants';
88
import { AvailableLocaleObject, CaptionMenu } from '../../common/types';
9+
import { intlMessages } from '../../intlMessages';
910

1011
interface TypedCaptionsModalProps {
1112
isOpen: boolean;
@@ -21,21 +22,6 @@ interface TypedCaptionsModalProps {
2122

2223
const TIMEOUT_RENDER_ERROR = 3000;
2324

24-
const intlMessages = defineMessages({
25-
selectorLabel: {
26-
id: 'plugin.actionButtonDropdown.modal.selectorLabel',
27-
description: 'action button dropdown label to start writing',
28-
},
29-
selectPlaceholder: {
30-
id: 'plugin.actionButtonDropdown.modal.selectPlaceHolder',
31-
description: 'placeholder of the selector',
32-
},
33-
startButtonLabel: {
34-
id: 'plugin.actionButtonDropdown.modal.start',
35-
description: 'start button label',
36-
},
37-
});
38-
3925
function TypedCaptionsModal(props: TypedCaptionsModalProps) {
4026
const {
4127
isOpen,

src/components/modal/locales-dropdown/component.tsx

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
2-
import { defineMessages, IntlShape } from 'react-intl';
2+
import { IntlShape } from 'react-intl';
33
import { AvailableLocaleObject, WindowWithSettings } from '../../../common/types';
4+
import { intlMessages } from '../../../intlMessages';
45

56
const DEFAULT_VALUE = 'select';
67
const DEFAULT_KEY = -1;
@@ -14,49 +15,6 @@ interface LocalesDropdownProps {
1415
selectMessage: string;
1516
}
1617

17-
const intlMessages = defineMessages({
18-
'en-US': {
19-
id: 'plugin.actionButtonDropdown.modal.dropdown.en-US',
20-
description: 'English language',
21-
},
22-
'de-DE': {
23-
id: 'plugin.actionButtonDropdown.modal.dropdown.de-DE',
24-
description: 'English language',
25-
},
26-
'es-ES': {
27-
id: 'plugin.actionButtonDropdown.modal.dropdown.es-ES',
28-
description: 'English language',
29-
},
30-
'fr-FR': {
31-
id: 'plugin.actionButtonDropdown.modal.dropdown.fr-FR',
32-
description: 'English language',
33-
},
34-
'hi-ID': {
35-
id: 'plugin.actionButtonDropdown.modal.dropdown.hi-ID',
36-
description: 'English language',
37-
},
38-
'it-IT': {
39-
id: 'plugin.actionButtonDropdown.modal.dropdown.it-IT',
40-
description: 'English language',
41-
},
42-
'ja-JP': {
43-
id: 'plugin.actionButtonDropdown.modal.dropdown.ja-JP',
44-
description: 'English language',
45-
},
46-
'pt-BR': {
47-
id: 'plugin.actionButtonDropdown.modal.dropdown.pt-BR',
48-
description: 'English language',
49-
},
50-
'ru-RU': {
51-
id: 'plugin.actionButtonDropdown.modal.dropdown.ru-RU',
52-
description: 'English language',
53-
},
54-
'zh-CN': {
55-
id: 'plugin.actionButtonDropdown.modal.dropdown.zh-CN',
56-
description: 'English language',
57-
},
58-
});
59-
6018
declare const window: WindowWithSettings;
6119

6220
function LocalesDropdown(props: LocalesDropdownProps) {

src/components/modal/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const Content = styled.div`
131131
align-items: center;
132132
display: flex;
133133
flex-direction: column;
134-
padding: .3rem 0 0.5rem 0;
134+
gap: 1rem;
135135
`;
136136

137137
const CloseButton = styled.button`

src/components/typed-captions-sidekick-content/component.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
import { BbbPluginSdk, DataChannelTypes, PluginApi } from 'bigbluebutton-html-plugin-sdk';
2-
import { defineMessages, IntlShape } from 'react-intl';
2+
import { IntlShape } from 'react-intl';
33
import * as React from 'react';
44

55
import Styled from './styles';
66
import { TypedCaptionsInput } from './input-captions/component';
77
import { CaptionMessage } from '../../common/types';
88
import { CaptionMessagesList } from './caption-messages-list/component';
9+
import { intlMessages } from '../../intlMessages';
910

1011
interface GenericContentExampleProps {
1112
uuid: string;
1213
intl: IntlShape;
1314
captionLocale: string;
1415
}
1516

16-
const intlMessages = defineMessages({
17-
inputPlaceholder: {
18-
id: 'plugin.actionButtonDropdown.sidekickComponent.inputPlaceholder',
19-
description: 'Placeholder of the sidekick component input',
20-
},
21-
});
22-
2317
export function TypedCaptionsSidekickArea(props: GenericContentExampleProps) {
2418
const {
2519
uuid,

src/components/typed-captions-sidekick-content/styles.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
import styled from 'styled-components';
3-
import { mdPaddingY } from '../modal/styles';
3+
import { mdPaddingX, mdPaddingY, smallOnly } from '../modal/styles';
44

55
const CaptionsWrapper = styled.div`
6-
height: 100%;
7-
width: 100%;
86
display: flex;
7+
flex-grow: 1;
98
flex-direction: column;
10-
justify-content: space-between;
9+
overflow-x: hidden;
10+
overflow-y: auto;
11+
height: 100%;
12+
box-sizing: border-box;
13+
padding: ${mdPaddingX};
14+
15+
@media ${smallOnly} {
16+
transform: none !important;
17+
}
1118
`;
1219

1320
const HeaderWrapper = styled.div`

0 commit comments

Comments
 (0)