@brightcove/components-embed-code-modal 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/__tests__/PrismPlayerControls.test.d.ts +2 -0
  2. package/__tests__/PrismPlayerControls.test.d.ts.map +1 -0
  3. package/{build/index.js → index.js} +1 -1
  4. package/index.js.map +1 -0
  5. package/package.json +5 -15
  6. package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts.map +1 -1
  7. package/.eslintignore +0 -7
  8. package/.eslintrc +0 -23
  9. package/.github/workflows/ci.yml +0 -23
  10. package/.husky/pre-commit +0 -4
  11. package/.nvmrc +0 -1
  12. package/.prettierignore +0 -7
  13. package/.prettierrc +0 -5
  14. package/.release-it.json +0 -40
  15. package/.whitesource +0 -3
  16. package/CHANGELOG.md +0 -398
  17. package/CODEOWNERS +0 -37
  18. package/PULL_REQUEST_TEMPLATE.md +0 -17
  19. package/__tests__/EmbedCode.test.tsx +0 -51
  20. package/__tests__/InteractivityProject.test.tsx +0 -50
  21. package/__tests__/PlayerPreview.test.tsx +0 -23
  22. package/__tests__/PrismPlayerPreview.test.tsx +0 -168
  23. package/__tests__/TabsHeader.test.tsx +0 -19
  24. package/__tests__/TabsSection.test.tsx +0 -46
  25. package/__tests__/TitleWithTooltip.test.tsx +0 -45
  26. package/__tests__/VideoPlayer.test.tsx +0 -38
  27. package/__tests__/embedCodeGenerator.test.ts +0 -111
  28. package/__tests__/util.test.ts +0 -89
  29. package/babel.config.json +0 -17
  30. package/build/README.md +0 -109
  31. package/build/index.js.map +0 -1
  32. package/build/package.json +0 -100
  33. package/etc/wildcard.brightcove.com.key +0 -27
  34. package/etc/wildcard.brightcove.com.pem +0 -96
  35. package/jest/jest.setup.js +0 -90
  36. package/jest/jest.stub.js +0 -4
  37. package/jest.config.js +0 -24
  38. package/scripts/create-dist-pkg-prod.js +0 -18
  39. package/src/index.ts +0 -17
  40. package/src/js/EmbedCodeModal.tsx +0 -105
  41. package/src/js/components/CustomSettingsDropdown.tsx +0 -184
  42. package/src/js/components/EmbedCopySection.tsx +0 -130
  43. package/src/js/components/ModalContainer.tsx +0 -367
  44. package/src/js/components/NoPlayerModal.tsx +0 -42
  45. package/src/js/components/PlayerPreview.tsx +0 -116
  46. package/src/js/components/TabsHeader.tsx +0 -31
  47. package/src/js/components/TabsSection.tsx +0 -74
  48. package/src/js/components/TitleWithTooltip.tsx +0 -39
  49. package/src/js/components/VideoLinks.tsx +0 -83
  50. package/src/js/components/VideoPlayer.tsx +0 -324
  51. package/src/js/components/index.ts +0 -9
  52. package/src/js/components/prism/PrismLiveModal.tsx +0 -162
  53. package/src/js/components/prism/PrismPlayerControls.tsx +0 -343
  54. package/src/js/components/prism/PrismPlayerPreview.tsx +0 -188
  55. package/src/js/components/prism/index.ts +0 -3
  56. package/src/js/constants/baseUrls.ts +0 -4
  57. package/src/js/constants/embed.ts +0 -12
  58. package/src/js/constants/player.ts +0 -32
  59. package/src/js/constants/pluginsRegistry.ts +0 -30
  60. package/src/js/hooks/useGetPlayers.ts +0 -12
  61. package/src/js/i18n.ts +0 -43
  62. package/src/js/services/players-api.ts +0 -26
  63. package/src/js/services/url-shortener.ts +0 -10
  64. package/src/js/types/EmbedCodeModalProps.ts +0 -72
  65. package/src/js/types/EmbedCodeProps.ts +0 -13
  66. package/src/js/types/brightcoveEmbedCode.d.ts +0 -18
  67. package/src/js/types/players.ts +0 -64
  68. package/src/js/types/react-i18next.d.ts +0 -8
  69. package/src/js/types/studioModule.ts +0 -7
  70. package/src/js/utils/addPluginsDataToPlayers.ts +0 -59
  71. package/src/js/utils/call.ts +0 -31
  72. package/src/js/utils/dimensions.ts +0 -53
  73. package/src/js/utils/embedCodeGenerator.ts +0 -120
  74. package/src/js/utils/featureSwitches.ts +0 -16
  75. package/src/js/utils/util.ts +0 -153
  76. package/src/module.tsx +0 -280
  77. package/src/styles/CustomSettingsDropdown.sass +0 -42
  78. package/src/styles/EmbedCode.sass +0 -30
  79. package/src/styles/EmbedCodeModal.sass +0 -76
  80. package/src/styles/base.sass +0 -1
  81. package/src/styles/prism/PrismLiveModal.sass +0 -155
  82. package/src/styles/theme.sass +0 -11
  83. package/src/styles/typings.td.ts +0 -9
  84. package/src/translations/en.json +0 -65
  85. package/src/translations/es.json +0 -65
  86. package/src/translations/fr.json +0 -65
  87. package/src/translations/ja.json +0 -65
  88. package/src/translations/ko.json +0 -65
  89. package/src/translations/zh.json +0 -65
  90. package/src/types/studio.ts +0 -197
  91. package/tsconfig.json +0 -34
  92. package/webpack.config.js +0 -117
  93. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts +0 -0
  94. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts.map +0 -0
  95. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts +0 -0
  96. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts.map +0 -0
  97. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts +0 -0
  98. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts.map +0 -0
  99. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts +0 -0
  100. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts.map +0 -0
  101. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts +0 -0
  102. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts.map +0 -0
  103. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts +0 -0
  104. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts.map +0 -0
  105. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts +0 -0
  106. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts.map +0 -0
  107. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts +0 -0
  108. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts.map +0 -0
  109. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts +0 -0
  110. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts.map +0 -0
  111. /package/{build/__tests__ → __tests__}/util.test.d.ts +0 -0
  112. /package/{build/__tests__ → __tests__}/util.test.d.ts.map +0 -0
  113. /package/{build/src → src}/index.d.ts +0 -0
  114. /package/{build/src → src}/index.d.ts.map +0 -0
  115. /package/{build/src → src}/js/EmbedCodeModal.d.ts +0 -0
  116. /package/{build/src → src}/js/EmbedCodeModal.d.ts.map +0 -0
  117. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts +0 -0
  118. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts.map +0 -0
  119. /package/{build/src → src}/js/components/EmbedCopySection.d.ts +0 -0
  120. /package/{build/src → src}/js/components/EmbedCopySection.d.ts.map +0 -0
  121. /package/{build/src → src}/js/components/ModalContainer.d.ts +0 -0
  122. /package/{build/src → src}/js/components/ModalContainer.d.ts.map +0 -0
  123. /package/{build/src → src}/js/components/NoPlayerModal.d.ts +0 -0
  124. /package/{build/src → src}/js/components/NoPlayerModal.d.ts.map +0 -0
  125. /package/{build/src → src}/js/components/PlayerPreview.d.ts +0 -0
  126. /package/{build/src → src}/js/components/PlayerPreview.d.ts.map +0 -0
  127. /package/{build/src → src}/js/components/TabsHeader.d.ts +0 -0
  128. /package/{build/src → src}/js/components/TabsHeader.d.ts.map +0 -0
  129. /package/{build/src → src}/js/components/TabsSection.d.ts +0 -0
  130. /package/{build/src → src}/js/components/TabsSection.d.ts.map +0 -0
  131. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts +0 -0
  132. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts.map +0 -0
  133. /package/{build/src → src}/js/components/VideoLinks.d.ts +0 -0
  134. /package/{build/src → src}/js/components/VideoLinks.d.ts.map +0 -0
  135. /package/{build/src → src}/js/components/VideoPlayer.d.ts +0 -0
  136. /package/{build/src → src}/js/components/VideoPlayer.d.ts.map +0 -0
  137. /package/{build/src → src}/js/components/index.d.ts +0 -0
  138. /package/{build/src → src}/js/components/index.d.ts.map +0 -0
  139. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts +0 -0
  140. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts.map +0 -0
  141. /package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts +0 -0
  142. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts +0 -0
  143. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts.map +0 -0
  144. /package/{build/src → src}/js/components/prism/index.d.ts +0 -0
  145. /package/{build/src → src}/js/components/prism/index.d.ts.map +0 -0
  146. /package/{build/src → src}/js/constants/baseUrls.d.ts +0 -0
  147. /package/{build/src → src}/js/constants/baseUrls.d.ts.map +0 -0
  148. /package/{build/src → src}/js/constants/embed.d.ts +0 -0
  149. /package/{build/src → src}/js/constants/embed.d.ts.map +0 -0
  150. /package/{build/src → src}/js/constants/player.d.ts +0 -0
  151. /package/{build/src → src}/js/constants/player.d.ts.map +0 -0
  152. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts +0 -0
  153. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts.map +0 -0
  154. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts +0 -0
  155. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts.map +0 -0
  156. /package/{build/src → src}/js/i18n.d.ts +0 -0
  157. /package/{build/src → src}/js/i18n.d.ts.map +0 -0
  158. /package/{build/src → src}/js/services/players-api.d.ts +0 -0
  159. /package/{build/src → src}/js/services/players-api.d.ts.map +0 -0
  160. /package/{build/src → src}/js/services/url-shortener.d.ts +0 -0
  161. /package/{build/src → src}/js/services/url-shortener.d.ts.map +0 -0
  162. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts +0 -0
  163. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts.map +0 -0
  164. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts +0 -0
  165. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts.map +0 -0
  166. /package/{build/src → src}/js/types/players.d.ts +0 -0
  167. /package/{build/src → src}/js/types/players.d.ts.map +0 -0
  168. /package/{build/src → src}/js/types/studioModule.d.ts +0 -0
  169. /package/{build/src → src}/js/types/studioModule.d.ts.map +0 -0
  170. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts +0 -0
  171. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts.map +0 -0
  172. /package/{build/src → src}/js/utils/call.d.ts +0 -0
  173. /package/{build/src → src}/js/utils/call.d.ts.map +0 -0
  174. /package/{build/src → src}/js/utils/dimensions.d.ts +0 -0
  175. /package/{build/src → src}/js/utils/dimensions.d.ts.map +0 -0
  176. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts +0 -0
  177. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts.map +0 -0
  178. /package/{build/src → src}/js/utils/featureSwitches.d.ts +0 -0
  179. /package/{build/src → src}/js/utils/featureSwitches.d.ts.map +0 -0
  180. /package/{build/src → src}/js/utils/util.d.ts +0 -0
  181. /package/{build/src → src}/js/utils/util.d.ts.map +0 -0
  182. /package/{build/src → src}/module.d.ts +0 -0
  183. /package/{build/src → src}/module.d.ts.map +0 -0
  184. /package/{build/src → src}/styles/typings.td.d.ts +0 -0
  185. /package/{build/src → src}/styles/typings.td.d.ts.map +0 -0
  186. /package/{build/src → src}/types/studio.d.ts +0 -0
  187. /package/{build/src → src}/types/studio.d.ts.map +0 -0
@@ -1,74 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { TabPanel } from '@brightcove/studio-components';
4
- import { TabsSelectedId } from 'js/types/players';
5
- import css from 'styles/EmbedCodeModal.sass';
6
- import { TabsHeader, EmbedCode } from 'js/components';
7
- import { EmbedCodeProperties } from 'js/types/EmbedCodeModalProps';
8
-
9
- export const TabsSection = ({
10
- isCampaign,
11
- isViewerIdSource,
12
- isBcMapTracking,
13
- ...rest
14
- }: {
15
- playerId: string;
16
- isCampaign: boolean;
17
- isViewerIdSource: boolean;
18
- isBcMapTracking: boolean;
19
- videoId?: string;
20
- accountId: string;
21
- interactivityProjectId?: string;
22
- livePlaybackToken?: string;
23
- adConfigId?: string;
24
- embedCodeProperties?: EmbedCodeProperties;
25
- }) => {
26
- const { t } = useTranslation();
27
- const [currentTab, setCurrentTab] = useState<TabsSelectedId>('iframe');
28
-
29
- const isIframe = currentTab === 'iframe';
30
-
31
- const handleTabChange = (id?: string | number) => setCurrentTab(id);
32
-
33
- return (
34
- <>
35
- <TabsHeader
36
- currentTab={currentTab}
37
- handleTabChange={handleTabChange}
38
- jsLabel={t('tabs.labels.javascript')}
39
- iframeLabel={t('tabs.labels.iframe')}
40
- />
41
- <TabPanel
42
- testName='embed-tab-content'
43
- className={css.tabPanelContent}
44
- render={() => {
45
- if (isIframe) {
46
- if (isCampaign) {
47
- return (
48
- <span className={css.redHelperText}>
49
- {t('tabs.helperTextWarning')}
50
- </span>
51
- );
52
- } else if (isViewerIdSource) {
53
- return (
54
- <span className={css.redHelperText}>
55
- {t('tabs.viewerIdTextWarning')}
56
- </span>
57
- );
58
- } else if (isBcMapTracking) {
59
- return (
60
- <span className={css.redHelperText}>
61
- {t('tabs.bcMapTrackingTextWarning')}
62
- </span>
63
- );
64
- } else {
65
- return <EmbedCode iframe={isIframe} {...rest} />;
66
- }
67
- } else {
68
- return <EmbedCode iframe={isIframe} {...rest} />;
69
- }
70
- }}
71
- />
72
- </>
73
- );
74
- };
@@ -1,39 +0,0 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
2
- import { Flex, ToolTip } from '@brightcove/studio-components';
3
- import css from 'styles/EmbedCodeModal.sass';
4
- import { truncateVideoTitle } from '../utils/util';
5
-
6
- interface TitleWithTooltipProps {
7
- name: string;
8
- id: string;
9
- }
10
- export const TitleWithTooltip = ({ name, id }: TitleWithTooltipProps) => {
11
- const [isOverflowing, setIsOverflowing] = useState(false);
12
-
13
- const titleMemo = useMemo(
14
- () => (name ? truncateVideoTitle(name) : ''),
15
- [name],
16
- );
17
-
18
- useEffect(() => {
19
- if (name) {
20
- setIsOverflowing(titleMemo !== name);
21
- }
22
- }, [titleMemo, name]);
23
-
24
- return (
25
- <Flex flexDirection='column' className={css.mediaData}>
26
- <ToolTip
27
- placement='top'
28
- portal
29
- block
30
- content={name}
31
- active={isOverflowing}
32
- testName='embed-video-tooltip'
33
- >
34
- <div className={css.mediaTitle}>{titleMemo}</div>
35
- </ToolTip>
36
- <div className={css.mediaId}>{id}</div>
37
- </Flex>
38
- );
39
- };
@@ -1,83 +0,0 @@
1
- import React, { useCallback, useState } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Button, Loader } from '@brightcove/studio-components';
4
- import css from 'styles/EmbedCodeModal.sass';
5
- import { shortenUrl } from '../services/url-shortener';
6
- import { getBrightcove } from 'js/utils/util';
7
-
8
- interface VideoLinksProps {
9
- previewUrl: string;
10
- playerUrl: string;
11
- }
12
-
13
- export const VideoLinks = ({ previewUrl, playerUrl }: VideoLinksProps) => {
14
- const { t } = useTranslation();
15
- const [isGetUrlLoading, setIsGetUrlLoading] = useState<boolean>(false);
16
-
17
- const copyPreviewURL = useCallback(
18
- async (link: string) => {
19
- setIsGetUrlLoading(true);
20
- getUrlAndAddItToClipboard(link)
21
- .then(() => {
22
- getBrightcove().Toaster.success({
23
- title: t('toasterTitle'),
24
- message: t('toasterGetURLSuccess'),
25
- });
26
- })
27
- .catch(() => {
28
- getBrightcove().Toaster.error({
29
- message: t('toasterGetURLError'),
30
- });
31
- })
32
- .finally(() => setIsGetUrlLoading(false));
33
- },
34
- [t],
35
- );
36
- return (
37
- <div>
38
- <div className={css.getURLBtnContainer}>
39
- <Button
40
- look='tertiary'
41
- text={t('getURL')}
42
- testName='get-url-btn'
43
- icon={isGetUrlLoading ? '' : 'link'}
44
- iconRight
45
- onClick={() => copyPreviewURL(playerUrl)}
46
- />
47
- {isGetUrlLoading && (
48
- <Loader className={css.getURLBtnSpinner} size='inline' color='navy' />
49
- )}
50
- </div>
51
- <Button
52
- look='tertiary'
53
- text={t('previewButton')}
54
- testName='preview-player-btn'
55
- icon='external_link'
56
- iconRight
57
- onClick={() => {
58
- window.open(previewUrl, '_blank');
59
- }}
60
- />
61
- </div>
62
- );
63
- };
64
-
65
- export const getUrlAndAddItToClipboard = async (url: string) => {
66
- const escapedLongUrl = encodeURI(url);
67
- // safari
68
- try {
69
- return navigator.clipboard.write([
70
- new ClipboardItem({
71
- // eslint-disable-next-line no-async-promise-executor
72
- 'text/plain': new Promise(async (resolve) => {
73
- const shortUrl = await shortenUrl({ longUrl: escapedLongUrl });
74
- resolve(new Blob([shortUrl], { type: 'text/plain' }));
75
- }),
76
- }),
77
- ]);
78
- } catch {
79
- // chrome and firefox
80
- const shortUrl = await shortenUrl({ longUrl: escapedLongUrl });
81
- return navigator.clipboard.writeText(shortUrl);
82
- }
83
- };
@@ -1,324 +0,0 @@
1
- import React, { useEffect, useState, useMemo, useCallback } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import ReactPlayerLoader from '@brightcove/react-player-loader';
4
- import {
5
- Checkbox,
6
- Hideable,
7
- Input,
8
- PlayerSelect,
9
- Select,
10
- } from '@brightcove/studio-components';
11
- import {
12
- VideoPayload,
13
- ProjectPayload,
14
- EmbedCodeModalTypes,
15
- EmbedCodeProperties,
16
- LivePayload,
17
- } from 'js/types/EmbedCodeModalProps';
18
- import {
19
- PlayerSelectItem,
20
- PlayersObject,
21
- PlayersObjectItem,
22
- } from 'js/types/players';
23
- import css from 'styles/EmbedCodeModal.sass';
24
- import {
25
- getUrlBase,
26
- getVideoPreviewLink,
27
- PREVIEW_URL_BASE,
28
- VideoPreviewLinkOptions,
29
- } from 'js/utils/util';
30
- import {
31
- VideoLinks,
32
- TitleWithTooltip,
33
- TabsSection,
34
- CustomSettingsDropdown,
35
- } from 'js/components';
36
- import { DEFAULT_PLAYER_ID, PLAYERS } from 'js/constants/player';
37
- import { EMBED_DEFAULT } from 'js/constants/embed';
38
- import { getFavoritePlayer } from 'js/utils/featureSwitches';
39
- import cx from 'classnames';
40
-
41
- export const VideoPlayer = ({
42
- video,
43
- embedCodeModalType,
44
- playerListForSelection,
45
- players,
46
- hasCreatedPlayer,
47
- embedCodeProperties,
48
- showDVR,
49
- onDVRClick,
50
- dvrTime,
51
- showLowLatency,
52
- onLowLatencyClick,
53
- adConfigValue,
54
- onAdConfigChange,
55
- ssai = false,
56
- adConfigOptions = [],
57
- }: {
58
- video: VideoPayload | ProjectPayload | LivePayload;
59
- embedCodeModalType: EmbedCodeModalTypes;
60
- playerListForSelection: PlayerSelectItem[];
61
- players: PlayersObject;
62
- hasCreatedPlayer?: boolean;
63
- embedCodeProperties?: EmbedCodeProperties;
64
- showDVR?: boolean;
65
- onDVRClick?: (newValue: boolean) => void;
66
- dvrTime?: number;
67
- showLowLatency?: boolean;
68
- onLowLatencyClick?: (newValue: boolean) => void;
69
- adConfigValue?: string;
70
- onAdConfigChange?: (value: string) => void;
71
- ssai?: boolean;
72
- adConfigOptions?: Array<{ label: string; value: string }>;
73
- }) => {
74
- const { t } = useTranslation();
75
- const [player, setPlayer] = useState<PlayersObjectItem>(PLAYERS.default);
76
- const [previewUrl, setPreviewUrl] = useState<string>('');
77
- const [embedProperties, setEmbedProperties] = useState<EmbedCodeProperties>(
78
- embedCodeProperties ? embedCodeProperties : EMBED_DEFAULT,
79
- );
80
- const [allowLowLatency, setAllowLowLatency] = useState(true);
81
- const [allowDVR, setAllowDVR] = useState(!showLowLatency);
82
- const [time, setTime] = useState<number>(dvrTime || 0);
83
-
84
- useEffect(() => {
85
- setTime(dvrTime || 0);
86
- }, [dvrTime]);
87
-
88
- useEffect(() => {
89
- if (playerListForSelection.length === 0) return;
90
- const favoritePlayer = getFavoritePlayer();
91
- const player = players[favoritePlayer];
92
-
93
- if (
94
- playerListForSelection.find((selection) => selection.value === player?.id)
95
- ) {
96
- setPlayer(player);
97
- } else {
98
- setPlayer(players[playerListForSelection[0].value]);
99
- }
100
- // eslint-disable-next-line react-hooks/exhaustive-deps
101
- }, [playerListForSelection]);
102
-
103
- const onPlayerSelectChange = (id: string) => {
104
- const player = players[id];
105
- setPlayer(player);
106
- };
107
-
108
- const interactivityProjectId = useMemo(() => {
109
- return embedCodeModalType === EmbedCodeModalTypes.PROJECT
110
- ? (video as ProjectPayload).interactivityProjectId
111
- : null;
112
- }, [video, embedCodeModalType]);
113
-
114
- const onEmbedCreated = useCallback(
115
- (el: HTMLElement) => {
116
- if (interactivityProjectId) {
117
- el.setAttribute(
118
- 'data-interactivity-project-id',
119
- interactivityProjectId,
120
- );
121
- }
122
- },
123
- [interactivityProjectId],
124
- );
125
-
126
- const sharedProps: {
127
- accountId: string;
128
- playerId: string;
129
- isCampaign: boolean;
130
- isViewerIdSource: boolean;
131
- isBcMapTracking: boolean;
132
- videoId?: string;
133
- interactivityProjectId?: string;
134
- livePlaybackToken?: string;
135
- adConfigId?: string;
136
- } = {
137
- accountId: video.accountId,
138
- playerId:
139
- player?.id ||
140
- (playerListForSelection.length > 0
141
- ? playerListForSelection[0].value
142
- : DEFAULT_PLAYER_ID),
143
- isCampaign: player?.hasCampaignPlugin || false,
144
- isViewerIdSource: player?.hasViewerIDSource || false,
145
- isBcMapTracking: player?.hasBcMapTracking || false,
146
- videoId: video.videoId,
147
- };
148
-
149
- const name = interactivityProjectId
150
- ? (video as ProjectPayload).interactivityProjectName
151
- : (video as VideoPayload).videoName;
152
- const id = interactivityProjectId || video.videoId;
153
-
154
- if (interactivityProjectId) {
155
- sharedProps.interactivityProjectId = interactivityProjectId;
156
- }
157
-
158
- const { livePlaybackToken, adConfigId } = video as LivePayload;
159
-
160
- if (livePlaybackToken) {
161
- sharedProps.livePlaybackToken = livePlaybackToken;
162
- }
163
-
164
- if (adConfigId) {
165
- sharedProps.adConfigId = adConfigId;
166
- }
167
-
168
- const {
169
- adConfigId: sharedAdConfigId,
170
- livePlaybackToken: sharedLivePlaybackToken,
171
- ...restSharedProps
172
- } = sharedProps;
173
-
174
- const playerProps = {
175
- ...restSharedProps,
176
- ...(sharedAdConfigId ? {} : { adConfigId: sharedAdConfigId }),
177
- ...(sharedLivePlaybackToken
178
- ? {}
179
- : { livePlaybackToken: sharedLivePlaybackToken }),
180
- };
181
-
182
- useEffect(() => {
183
- if (player?.id) {
184
- const options: VideoPreviewLinkOptions = {
185
- accountId: video.accountId,
186
- playerId: player.id,
187
- videoId: video.videoId,
188
- };
189
- if (interactivityProjectId) {
190
- options.interactivityProjectId = interactivityProjectId;
191
- }
192
-
193
- if (adConfigId) {
194
- options.adConfigId = adConfigId;
195
- }
196
-
197
- if (livePlaybackToken) {
198
- options.livePlaybackToken = livePlaybackToken;
199
- }
200
-
201
- setPreviewUrl(getVideoPreviewLink(options));
202
- }
203
- }, [player, video, interactivityProjectId, adConfigId, livePlaybackToken]);
204
-
205
- return (
206
- <>
207
- <div className={css.leftContent}>
208
- <PlayerSelect
209
- label={t('player')}
210
- tooltip={
211
- <>
212
- <div>{t('tooltipTextNew')}</div>
213
- <a href={t('learnmore')} target='_blank' rel='noreferrer'>
214
- {t('tooltipLink')}
215
- </a>
216
- </>
217
- }
218
- selectedPlayer={player?.id || DEFAULT_PLAYER_ID}
219
- players={playerListForSelection}
220
- onChange={onPlayerSelectChange}
221
- inputClassName={css.playerSelect}
222
- testName='embed-player-select'
223
- />
224
- {embedCodeModalType === EmbedCodeModalTypes.LIVE &&
225
- ssai &&
226
- adConfigOptions.length > 0 &&
227
- onAdConfigChange && (
228
- <Select
229
- label={t('adConfiguration')}
230
- value={adConfigValue || adConfigOptions[0]?.value || ''}
231
- options={adConfigOptions}
232
- onChange={onAdConfigChange}
233
- testName='ad-config-dropdown'
234
- />
235
- )}
236
- {hasCreatedPlayer ? (
237
- <iframe
238
- src={`${PREVIEW_URL_BASE()}/${sharedProps.accountId}/players/${
239
- sharedProps.playerId
240
- }/preview/embeds/default/master/index.html?interactivityProjectId=${
241
- sharedProps.interactivityProjectId
242
- }&videoId=${sharedProps.videoId}`}
243
- allowFullScreen
244
- allow='autoplay;encrypted-media;fullscreen'
245
- width='539'
246
- height='303.2'
247
- data-interactivity-project-id={interactivityProjectId}
248
- ></iframe>
249
- ) : (
250
- <ReactPlayerLoader
251
- {...playerProps}
252
- baseUrl={getUrlBase()}
253
- attrs={{ className: css.playerLoader }}
254
- embedType='iframe'
255
- refNode='player-container'
256
- onEmbedCreated={onEmbedCreated}
257
- />
258
- )}
259
- <Hideable show={player?.hasCustomPlugins}>
260
- <span className={css.customPluginNotice}>
261
- {t('customPluginNotice')}
262
- </span>
263
- </Hideable>
264
- <VideoLinks previewUrl={previewUrl} playerUrl={previewUrl} />
265
- </div>
266
- <div
267
- className={cx(css.rightContent, {
268
- [css.expandRightContent]: showDVR,
269
- })}
270
- >
271
- <TitleWithTooltip name={name} id={id} />
272
- {(embedCodeModalType === EmbedCodeModalTypes.VIDEO ||
273
- embedCodeModalType === EmbedCodeModalTypes.PROJECT ||
274
- embedCodeModalType === EmbedCodeModalTypes.LIVE) && (
275
- <CustomSettingsDropdown
276
- setEmbedProperties={setEmbedProperties}
277
- embedProperties={embedProperties}
278
- />
279
- )}
280
- <TabsSection {...sharedProps} embedCodeProperties={embedProperties} />
281
- {showLowLatency ? (
282
- <Checkbox
283
- disabled={showDVR && allowDVR}
284
- checked={allowLowLatency}
285
- onChange={() => {
286
- onLowLatencyClick?.(!allowLowLatency);
287
- setAllowLowLatency(!allowLowLatency);
288
- }}
289
- className={css.dvrCheckbox}
290
- testName='low-latency-checkbox'
291
- >
292
- {t('lowLatency')}
293
- </Checkbox>
294
- ) : null}
295
- {showDVR && (
296
- <div>
297
- <Checkbox
298
- disabled={showLowLatency && allowLowLatency}
299
- checked={allowDVR}
300
- onChange={() => {
301
- onDVRClick?.(!allowDVR);
302
- setAllowDVR(!allowDVR);
303
- }}
304
- className={css.dvrCheckbox}
305
- testName='dvr-checkbox'
306
- >
307
- {t('dvr.allowDVR')}
308
- </Checkbox>
309
- {allowDVR && (
310
- <Input
311
- className={css.timeInput}
312
- label={t('dvr.inputLabel')}
313
- value={time}
314
- description={t('dvr.inputDescription')}
315
- disabled
316
- testName='dvr-time-input'
317
- />
318
- )}
319
- </div>
320
- )}
321
- </div>
322
- </>
323
- );
324
- };
@@ -1,9 +0,0 @@
1
- export * from './EmbedCopySection';
2
- export * from './ModalContainer';
3
- export * from './TitleWithTooltip';
4
- export * from './TabsHeader';
5
- export * from './TabsSection';
6
- export * from './VideoLinks';
7
- export * from './VideoPlayer';
8
- export * from './PlayerPreview';
9
- export * from './CustomSettingsDropdown';
@@ -1,162 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { PrismModal } from '@brightcove/prism-core';
3
- import { useTranslation } from 'react-i18next';
4
- import { PlayerSelectItem, PlayersObject } from 'js/types/players';
5
- import {
6
- LivePayload,
7
- EmbedCodeProperties,
8
- EmbedCodeAspectRatio,
9
- EmbedCodeUnits,
10
- } from 'js/types/EmbedCodeModalProps';
11
- import { getVideoPreviewLink, VideoPreviewLinkOptions } from 'js/utils/util';
12
- import { getFavoritePlayer } from 'js/utils/featureSwitches';
13
- import { PrismPlayerControls } from './PrismPlayerControls';
14
- import { PrismPlayerPreview } from './PrismPlayerPreview';
15
-
16
- import css from 'styles/prism/PrismLiveModal.sass';
17
-
18
- interface PrismLiveModalProps {
19
- isOpen: boolean;
20
- onClose: () => void;
21
- video: LivePayload;
22
- players: PlayersObject;
23
- playerListForSelection: PlayerSelectItem[];
24
- showDVR?: boolean;
25
- onDVRClick?: (newValue: boolean) => void;
26
- dvrTime?: number;
27
- showLowLatency?: boolean;
28
- onLowLatencyClick?: (newValue: boolean) => void;
29
- adConfigValue?: string;
30
- onAdConfigChange?: (value: string) => void;
31
- ssai?: boolean;
32
- adConfigOptions?: Array<{ label: string; value: string }>;
33
- }
34
-
35
- const DEFAULT_PLAYER_ID = 'default';
36
- const DEFAULT_EMBED_PROPERTIES: EmbedCodeProperties = {
37
- width: 960,
38
- height: 540,
39
- units: EmbedCodeUnits.PX,
40
- responsive: false,
41
- aspectRatio: EmbedCodeAspectRatio.SIXTEEN_NINE,
42
- };
43
-
44
- export const PrismLiveModal = ({
45
- isOpen,
46
- onClose,
47
- video,
48
- players,
49
- playerListForSelection,
50
- showDVR,
51
- onDVRClick,
52
- dvrTime,
53
- showLowLatency,
54
- onLowLatencyClick,
55
- adConfigValue,
56
- onAdConfigChange,
57
- ssai,
58
- adConfigOptions,
59
- }: PrismLiveModalProps) => {
60
- const { t } = useTranslation();
61
- const [selectedPlayer, setSelectedPlayer] =
62
- useState<string>(DEFAULT_PLAYER_ID);
63
- const [embedProperties, setEmbedProperties] = useState<EmbedCodeProperties>(
64
- DEFAULT_EMBED_PROPERTIES,
65
- );
66
- const [previewUrl, setPreviewUrl] = useState<string>('');
67
-
68
- // Initialize selected player
69
- useEffect(() => {
70
- if (playerListForSelection.length === 0) {
71
- return;
72
- }
73
-
74
- const favoritePlayer = getFavoritePlayer();
75
- const player = players[favoritePlayer];
76
-
77
- if (
78
- playerListForSelection.find((selection) => selection.value === player?.id)
79
- ) {
80
- setSelectedPlayer(player.id);
81
- } else {
82
- setSelectedPlayer(playerListForSelection[0].value);
83
- }
84
- }, [playerListForSelection, players]);
85
-
86
- // Update preview URL when player or video changes
87
- useEffect(() => {
88
- if (!selectedPlayer) {
89
- setPreviewUrl('');
90
- return;
91
- }
92
-
93
- const options: VideoPreviewLinkOptions = {
94
- accountId: video.accountId,
95
- playerId: selectedPlayer,
96
- videoId: video.videoId,
97
- };
98
-
99
- // Use the selected adConfigValue from dropdown, fallback to video.adConfigId
100
- if (adConfigValue) {
101
- options.adConfigId = adConfigValue;
102
- } else if (video.adConfigId) {
103
- options.adConfigId = video.adConfigId;
104
- }
105
-
106
- if (video.livePlaybackToken) {
107
- options.livePlaybackToken = video.livePlaybackToken;
108
- }
109
-
110
- setPreviewUrl(getVideoPreviewLink(options));
111
- }, [selectedPlayer, video, adConfigValue]);
112
-
113
- const handlePlayerChange = (playerId: string) => {
114
- setSelectedPlayer(playerId);
115
- };
116
-
117
- return (
118
- <PrismModal
119
- isOpen={isOpen}
120
- onClose={onClose}
121
- title={(t('modalHeader') as string) || 'Publish Video'}
122
- onPrimaryAction={onClose}
123
- primaryButtonText={t('done') as string}
124
- cancelButtonText={t('cancel') as string}
125
- className={css.prismLiveModal}
126
- >
127
- <div className={css.prismLiveModalContent}>
128
- {/* Left Column: Player Controls */}
129
- <PrismPlayerControls
130
- video={video}
131
- players={players}
132
- playerListForSelection={playerListForSelection}
133
- selectedPlayer={selectedPlayer}
134
- onPlayerChange={handlePlayerChange}
135
- embedProperties={embedProperties}
136
- setEmbedProperties={setEmbedProperties}
137
- showDVR={showDVR}
138
- onDVRClick={onDVRClick}
139
- dvrTime={dvrTime}
140
- showLowLatency={showLowLatency}
141
- onLowLatencyClick={onLowLatencyClick}
142
- adConfigValue={adConfigValue}
143
- onAdConfigChange={onAdConfigChange}
144
- ssai={ssai}
145
- adConfigOptions={adConfigOptions}
146
- />
147
-
148
- {/* Right Column: Player Preview */}
149
- <div className={css.prismRightColumn}>
150
- <PrismPlayerPreview
151
- accountId={video.accountId}
152
- playerId={selectedPlayer}
153
- videoId={video.videoId}
154
- previewUrl={previewUrl}
155
- livePlaybackToken={video.livePlaybackToken}
156
- adConfigId={adConfigValue || video.adConfigId}
157
- />
158
- </div>
159
- </div>
160
- </PrismModal>
161
- );
162
- };