@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,130 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
-
4
- import brightcoveEmbedCode from '@brightcove/player-embed-code';
5
- import {
6
- Flex,
7
- FlexItem,
8
- CopyField,
9
- PlainTextArea,
10
- } from '@brightcove/studio-components';
11
-
12
- import { EmbedCodeProps } from 'js/types/EmbedCodeProps';
13
- import { getUrlBase, getBrightcove, decodeHtmlEntities } from 'js/utils/util';
14
-
15
- import css from 'styles/EmbedCode.sass';
16
- import {
17
- EmbedCodeAspectRatio,
18
- EmbedCodeUnits,
19
- } from 'js/types/EmbedCodeModalProps';
20
-
21
- interface EmbedCodeConfig {
22
- accountId: string;
23
- responsive: boolean;
24
- width: number;
25
- height: number;
26
- iframe: boolean;
27
- videoId?: string;
28
- interactivityProjectId?: string;
29
- playerId: string;
30
- urlBase: string;
31
- playlistIsHorizontal: boolean;
32
- units: EmbedCodeUnits;
33
- aspectRatio?: EmbedCodeAspectRatio;
34
- }
35
-
36
- const DEFAULT_HEIGHT = 540;
37
- const DEFAULT_WIDTH = 960;
38
- const defaultConfig = {
39
- responsive: false,
40
- width: DEFAULT_WIDTH,
41
- height: DEFAULT_HEIGHT,
42
- urlBase: getUrlBase(),
43
- playlistIsHorizontal: true,
44
- units: EmbedCodeUnits.PX,
45
- aspectRatio: EmbedCodeAspectRatio.FLUID,
46
- };
47
-
48
- const createEmbedConfigObject = ({
49
- embedCodeProperties,
50
- accountId,
51
- iframe,
52
- videoId,
53
- playerId,
54
- interactivityProjectId,
55
- livePlaybackToken,
56
- adConfigId,
57
- }: EmbedCodeProps): EmbedCodeConfig => {
58
- const config = {
59
- accountId,
60
- iframe,
61
- videoId,
62
- playerId,
63
- livePlaybackToken,
64
- adConfigId,
65
- interactivityProjectId,
66
- };
67
- return Object.assign(
68
- {},
69
- { ...defaultConfig, ...config, ...embedCodeProperties },
70
- );
71
- };
72
-
73
- export const EmbedCode = (config: EmbedCodeProps) => {
74
- const { t } = useTranslation();
75
- const [embedCode, setEmbedCode] = useState('');
76
-
77
- useEffect(() => {
78
- const embedConfigObj = createEmbedConfigObject(config);
79
-
80
- if (embedConfigObj.aspectRatio) {
81
- embedConfigObj.aspectRatio =
82
- embedConfigObj.aspectRatio === EmbedCodeAspectRatio.CUSTOM
83
- ? EmbedCodeAspectRatio.FLUID
84
- : embedConfigObj.aspectRatio;
85
- }
86
-
87
- const embedCode = decodeHtmlEntities(brightcoveEmbedCode(embedConfigObj));
88
- setEmbedCode(embedCode);
89
- }, [config]);
90
-
91
- const HelperTextNodeNew = (
92
- <Flex>
93
- <FlexItem flexGrow='1' className={css.helperText}>
94
- {t('tabs.helperText')}
95
- </FlexItem>
96
- </Flex>
97
- );
98
-
99
- return (
100
- <>
101
- <CopyField
102
- className={css.copyInput}
103
- helperNode={HelperTextNodeNew}
104
- Component={PlainTextArea}
105
- componentProps={{
106
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
107
- // @ts-ignore
108
- disabled: true,
109
- disableResizing: true,
110
- className: css.textAreaDimensions,
111
- onChange: () => void 0,
112
- }}
113
- onCopy={() => {
114
- getBrightcove().Toaster.success({
115
- title: t('toasterTitle'),
116
- message: t('toasterMessage'),
117
- });
118
- }}
119
- onError={() => {
120
- getBrightcove().Toaster.error({
121
- message: t('toasterErrorMessage'),
122
- });
123
- }}
124
- value={embedCode}
125
- hideButton={true}
126
- testName='embed-copy-section'
127
- />
128
- </>
129
- );
130
- };
@@ -1,367 +0,0 @@
1
- import React, { useState, useCallback, useEffect, useMemo } from 'react';
2
-
3
- import { useTranslation } from 'react-i18next';
4
- import useGetPlayers from 'js/hooks/useGetPlayers';
5
- import { Modal, Flex, Button } from '@brightcove/studio-components';
6
-
7
- import {
8
- EmbedCodeModalTypes,
9
- PlayerPayload,
10
- NoInteractivityPlayerModalTypes,
11
- EmbedCodeProperties,
12
- LivePayload,
13
- } from 'js/types/EmbedCodeModalProps';
14
- import { EmbedCodeModalProps } from 'js/EmbedCodeModal';
15
- import { addPluginsDataToPlayers } from 'js/utils/addPluginsDataToPlayers';
16
- import { PlayerSelectItem, PlayersObject } from 'js/types/players';
17
- import { createPlayer } from 'js/services/players-api';
18
- import { getStudioModule, getBrightcove, ROLES } from 'js/utils/util';
19
- import { DEFAULT_INTERACTIVITY_PLAYER } from 'js/constants/player';
20
-
21
- import css from 'styles/EmbedCodeModal.sass';
22
- import { VideoPlayer } from './VideoPlayer';
23
- import { PlayerPreview } from './PlayerPreview';
24
- import { getAccountId } from '../utils/call';
25
- import { NoPlayerModal } from './NoPlayerModal';
26
- import { PrismLiveModal } from './prism';
27
-
28
- interface ModalContainerProps extends EmbedCodeModalProps {
29
- handleSetComponentKey: () => void;
30
- handleSetHasCreatedPlayer: (value: boolean) => void;
31
- hasCreatedPlayer: boolean;
32
- embedCodeProperties?: EmbedCodeProperties;
33
- isOutstreamPlayer?: boolean;
34
- onDVRClick?: (newValue: boolean) => void;
35
- dvrTime?: number;
36
- showLowLatency?: boolean;
37
- onLowLatencyClick?: (newValue: boolean) => void;
38
- ssai?: boolean;
39
- adConfigOptions?: Array<{ label: string; value: string }>;
40
- onAdConfigChange?: (value: string) => void;
41
- theme?: 'blueSteel' | 'prism';
42
- }
43
-
44
- export const ModalContainer = ({
45
- handleSetComponentKey,
46
- data,
47
- embedCodeModalType = EmbedCodeModalTypes.VIDEO,
48
- handleSetHasCreatedPlayer,
49
- hasCreatedPlayer,
50
- embedCodeProperties,
51
- isOutstreamPlayer,
52
- showDVR,
53
- onDVRClick,
54
- dvrTime,
55
- showLowLatency,
56
- onLowLatencyClick,
57
- ssai,
58
- adConfigOptions = [],
59
- onAdConfigChange,
60
- theme,
61
- }: ModalContainerProps) => {
62
- const { t } = useTranslation();
63
- const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
64
- const { isFetching, data: playersData } = useGetPlayers(
65
- embedCodeModalType !== EmbedCodeModalTypes.PLAYER,
66
- );
67
- const [players, setPlayers] = useState<PlayersObject>({});
68
- const [playerListForSelection, setPlayerListForSelection] = useState<
69
- PlayerSelectItem[]
70
- >([]);
71
- const [hasPublishingRole, setHasPublishingRole] = useState(false);
72
- const [buttonSpinner, setButtonSpinner] = useState(false);
73
- const [adConfigValue, setAdConfigValue] = useState('');
74
- const [hasInitialized, setHasInitialized] = useState(false);
75
-
76
- const handleAdConfigChange = (value: string) => {
77
- setAdConfigValue(value);
78
- if (onAdConfigChange) {
79
- onAdConfigChange(value);
80
- }
81
- };
82
-
83
- useEffect(() => {
84
- if (adConfigOptions.length > 0) {
85
- const initialValue = adConfigOptions[0].value;
86
-
87
- // Only initialize if we haven't initialized yet, or if the current value is not in the new options
88
- if (
89
- !hasInitialized ||
90
- !adConfigOptions.some((option) => option.value === adConfigValue)
91
- ) {
92
- setAdConfigValue(initialValue);
93
- setHasInitialized(true);
94
-
95
- if (onAdConfigChange) {
96
- onAdConfigChange(initialValue);
97
- }
98
- }
99
- }
100
- }, [adConfigOptions, hasInitialized, onAdConfigChange, adConfigValue]);
101
-
102
- useEffect(() => {
103
- const { roles } = getStudioModule().getCurrentUserAccount();
104
- if (roles.length && roles.includes(ROLES.PUBLISHING)) {
105
- setHasPublishingRole(true);
106
- }
107
- }, []);
108
-
109
- useEffect(() => {
110
- if (embedCodeModalType === EmbedCodeModalTypes.PLAYER) {
111
- return;
112
- }
113
- if (!isFetching && playersData && (playersData?.items.length ?? 0) > 0) {
114
- const { playerListForSelection, players = {} } =
115
- addPluginsDataToPlayers(playersData);
116
- let filteredPlayerListForSelection = playerListForSelection;
117
-
118
- if (embedCodeModalType === EmbedCodeModalTypes.PROJECT) {
119
- filteredPlayerListForSelection = playerListForSelection.filter(
120
- (player) => players[player.value].hasInteractivityPlugin,
121
- );
122
- }
123
-
124
- setPlayers(players);
125
- setPlayerListForSelection(filteredPlayerListForSelection);
126
- }
127
- }, [isFetching, playersData, embedCodeModalType]);
128
-
129
- const hasInteractivityEnabledPlayer = useMemo(
130
- () =>
131
- Object.values(players).some((player) => player.hasInteractivityPlugin),
132
- [players],
133
- );
134
-
135
- useEffect(() => {
136
- if (data) {
137
- setIsModalOpen(true);
138
- }
139
- }, [data]);
140
-
141
- const closeModal = useCallback(() => {
142
- setIsModalOpen(false);
143
- handleSetHasCreatedPlayer(false);
144
- }, [handleSetHasCreatedPlayer]);
145
-
146
- const createInteractivityPlayer = () => {
147
- const { name, registry_id, version, options } =
148
- DEFAULT_INTERACTIVITY_PLAYER;
149
-
150
- setButtonSpinner(true);
151
-
152
- const payload = {
153
- data: {
154
- name,
155
- configuration: {
156
- plugins: [
157
- {
158
- registry_id,
159
- version,
160
- options,
161
- },
162
- ],
163
- },
164
- },
165
- };
166
-
167
- createPlayer(payload)
168
- .then((res) => {
169
- if (res && res.id) {
170
- handleSetHasCreatedPlayer(true);
171
- handleSetComponentKey();
172
- }
173
- })
174
- .catch((reason) => {
175
- console.error(reason);
176
- getBrightcove().Toaster.error({
177
- title: t('createPlayerFailedTitle'),
178
- message: t('createPlayerFailedMessage'),
179
- });
180
- })
181
- .finally(() => {
182
- setButtonSpinner(false);
183
- });
184
- };
185
-
186
- let content: JSX.Element | null = null;
187
- let modalTitle = t('modalHeader');
188
- let isLargeModal = true;
189
- let buttons = [
190
- <Button
191
- key={'close-button'}
192
- text={t('done')}
193
- onClick={closeModal}
194
- testName={'close-modal-btn'}
195
- />,
196
- ];
197
-
198
- if (
199
- embedCodeModalType === EmbedCodeModalTypes.LIVE &&
200
- theme === 'prism' &&
201
- 'videoId' in data
202
- ) {
203
- return (
204
- <PrismLiveModal
205
- isOpen={isModalOpen}
206
- onClose={closeModal}
207
- video={data as LivePayload}
208
- players={players}
209
- playerListForSelection={playerListForSelection}
210
- showDVR={showDVR}
211
- onDVRClick={onDVRClick}
212
- dvrTime={dvrTime}
213
- showLowLatency={showLowLatency}
214
- onLowLatencyClick={onLowLatencyClick}
215
- adConfigValue={adConfigValue}
216
- onAdConfigChange={handleAdConfigChange}
217
- ssai={ssai}
218
- adConfigOptions={adConfigOptions}
219
- />
220
- );
221
- }
222
-
223
- switch (embedCodeModalType) {
224
- case EmbedCodeModalTypes.LIVE:
225
- content =
226
- 'videoId' in data ? (
227
- <VideoPlayer
228
- video={data}
229
- embedCodeModalType={embedCodeModalType}
230
- players={players}
231
- playerListForSelection={playerListForSelection}
232
- showDVR={showDVR}
233
- onDVRClick={onDVRClick}
234
- dvrTime={dvrTime}
235
- showLowLatency={showLowLatency}
236
- onLowLatencyClick={onLowLatencyClick}
237
- adConfigValue={adConfigValue}
238
- onAdConfigChange={handleAdConfigChange}
239
- ssai={ssai}
240
- adConfigOptions={adConfigOptions}
241
- />
242
- ) : null;
243
- break;
244
- case EmbedCodeModalTypes.VIDEO:
245
- content =
246
- 'videoId' in data ? (
247
- <VideoPlayer
248
- video={data}
249
- embedCodeModalType={embedCodeModalType}
250
- players={players}
251
- playerListForSelection={playerListForSelection}
252
- showDVR={showDVR}
253
- onDVRClick={onDVRClick}
254
- dvrTime={dvrTime}
255
- showLowLatency={showLowLatency}
256
- onLowLatencyClick={onLowLatencyClick}
257
- />
258
- ) : null;
259
- break;
260
- case EmbedCodeModalTypes.PLAYER:
261
- {
262
- const accountId = data.accountId || getAccountId();
263
- content =
264
- 'id' in data && accountId ? (
265
- <PlayerPreview
266
- {...(data as PlayerPayload)}
267
- accountId={accountId}
268
- embedCodeProperties={embedCodeProperties}
269
- isOutstreamPlayer={isOutstreamPlayer}
270
- />
271
- ) : null;
272
- }
273
- break;
274
- case EmbedCodeModalTypes.PROJECT:
275
- if (!isFetching) {
276
- if (!hasInteractivityEnabledPlayer && !hasPublishingRole) {
277
- modalTitle = t('activateModal');
278
- isLargeModal = false;
279
- buttons = [
280
- <Button
281
- key={'close-button'}
282
- text={t('close')}
283
- onClick={closeModal}
284
- testName={'close-modal-done-btn'}
285
- />,
286
- ];
287
- content = (
288
- <NoPlayerModal
289
- modalType={NoInteractivityPlayerModalTypes.NO_PERMISSION}
290
- />
291
- );
292
- } else if (!hasInteractivityEnabledPlayer) {
293
- modalTitle = t('noPlayerModalHeader');
294
- isLargeModal = false;
295
- buttons = [
296
- <Button
297
- key={'cancel-button'}
298
- text={t('cancel')}
299
- onClick={closeModal}
300
- testName={'cancel-button'}
301
- look='tertiary'
302
- />,
303
- <Button
304
- key={'create-player-button'}
305
- text={t('createPlayerNow')}
306
- spinner={buttonSpinner}
307
- onClick={createInteractivityPlayer}
308
- testName={'create-player-button'}
309
- />,
310
- ];
311
- content = (
312
- <NoPlayerModal
313
- modalType={NoInteractivityPlayerModalTypes.NO_PLAYER}
314
- />
315
- );
316
- } else {
317
- content =
318
- 'videoId' in data && 'interactivityProjectId' in data ? (
319
- <VideoPlayer
320
- video={data}
321
- embedCodeModalType={embedCodeModalType}
322
- playerListForSelection={playerListForSelection}
323
- players={players}
324
- hasCreatedPlayer={hasCreatedPlayer}
325
- />
326
- ) : null;
327
- }
328
- } else {
329
- content =
330
- 'videoId' in data && 'interactivityProjectId' in data ? (
331
- <VideoPlayer
332
- video={data}
333
- embedCodeModalType={embedCodeModalType}
334
- playerListForSelection={playerListForSelection}
335
- players={players}
336
- hasCreatedPlayer={hasCreatedPlayer}
337
- />
338
- ) : null;
339
- }
340
- break;
341
- default: {
342
- console.warn(`EmbedModal with ${embedCodeModalType} is not supported`);
343
- content = null;
344
- break;
345
- }
346
- }
347
-
348
- if (!content) {
349
- console.warn(
350
- `EmbedModal called with wrong props for type: ${embedCodeModalType}`,
351
- );
352
- return null;
353
- }
354
-
355
- return (
356
- <Modal
357
- testName='embed-modal'
358
- title={modalTitle}
359
- isOpen={isModalOpen}
360
- large={isLargeModal}
361
- onClose={closeModal}
362
- buttons={buttons}
363
- >
364
- <Flex className={css.videoDetailsContainer}>{content}</Flex>
365
- </Modal>
366
- );
367
- };
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Flex } from '@brightcove/studio-components';
4
- import { getPlayerManagerModuleUrl } from 'js/utils/util';
5
- import { NoInteractivityPlayerModalTypes } from 'js/types/EmbedCodeModalProps';
6
-
7
- interface NoPlayerProps {
8
- modalType: NoInteractivityPlayerModalTypes;
9
- }
10
-
11
- export const NoPlayerModal = ({ modalType }: NoPlayerProps) => {
12
- const { t } = useTranslation();
13
-
14
- const createPlayersModuleLink = (text: string) => {
15
- return <a href={getPlayerManagerModuleUrl()}>{text}</a>;
16
- };
17
-
18
- return (
19
- <Flex flexDirection='column'>
20
- <p>
21
- {modalType === NoInteractivityPlayerModalTypes.NO_PLAYER ? (
22
- t('noPlayerModalContent1')
23
- ) : (
24
- <>
25
- {t('activateModalContent1')}
26
- {createPlayersModuleLink(t('activateModalContent2'))}.
27
- </>
28
- )}
29
- <br />
30
- {modalType === NoInteractivityPlayerModalTypes.NO_PLAYER
31
- ? t('noPlayerModalContent2')
32
- : null}
33
- </p>
34
-
35
- <>
36
- {modalType === NoInteractivityPlayerModalTypes.NO_PLAYER ? (
37
- <p>{createPlayersModuleLink(t('toPlayersModuleLink'))}</p>
38
- ) : null}
39
- </>
40
- </Flex>
41
- );
42
- };
@@ -1,116 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import cx from 'classnames';
4
- import { Hideable } from '@brightcove/studio-components';
5
- import ReactPlayerLoader from '@brightcove/react-player-loader';
6
-
7
- import {
8
- getPreviewPlayerUrl,
9
- getUrlBase,
10
- getVideoPreviewLink,
11
- } from 'js/utils/util';
12
- import {
13
- bcHostedPlugins,
14
- CAMPAIGN_PLUGIN_NAME,
15
- VIEWER_ID_KEY_NAME,
16
- BC_MAP_TRACKING_NAME,
17
- } from 'js/constants/pluginsRegistry';
18
- import { PlayerPayload } from '../types/EmbedCodeModalProps';
19
-
20
- import { TabsSection, VideoLinks } from 'js/components';
21
-
22
- import css from 'styles/EmbedCodeModal.sass';
23
-
24
- interface Plugin {
25
- name: string;
26
- options?: Record<string, unknown>;
27
- }
28
-
29
- export const PlayerPreview = ({
30
- id,
31
- configuration,
32
- accountId = '',
33
- embedCodeProperties,
34
- isOutstreamPlayer,
35
- }: PlayerPayload) => {
36
- const { t } = useTranslation();
37
- const previewPlayerUrl = getPreviewPlayerUrl(accountId, id);
38
- const playerUrl = getVideoPreviewLink({ accountId, playerId: id });
39
-
40
- const {
41
- hasCustomPlugins,
42
- isCampaignPlayer,
43
- isViewerIdSource,
44
- isBcMapTracking,
45
- } = useMemo((): {
46
- isCampaignPlayer: boolean;
47
- hasCustomPlugins: boolean;
48
- isViewerIdSource: boolean;
49
- isBcMapTracking: boolean;
50
- } => {
51
- let hasBCHostedPlugin = false;
52
- let isCampaignPlayer = false;
53
- let isViewerIdSource = false;
54
- let isBcMapTracking = false;
55
- let plugins: Plugin[] = [];
56
-
57
- // TODO: refactor with addPluginsDataToPlayers function to reuse code
58
- if (configuration) {
59
- plugins = (configuration.plugins as Plugin[]) ?? plugins;
60
- for (const plugin of plugins) {
61
- const { name } = plugin;
62
- hasBCHostedPlugin = bcHostedPlugins.includes(name);
63
- isCampaignPlayer =
64
- isCampaignPlayer || plugin.name === CAMPAIGN_PLUGIN_NAME;
65
- isBcMapTracking =
66
- isBcMapTracking || plugin.name === BC_MAP_TRACKING_NAME;
67
- }
68
- isViewerIdSource =
69
- (configuration[VIEWER_ID_KEY_NAME] as boolean) || false;
70
- }
71
-
72
- return {
73
- hasCustomPlugins: !hasBCHostedPlugin && plugins.length > 0,
74
- isCampaignPlayer,
75
- isViewerIdSource,
76
- isBcMapTracking,
77
- };
78
- }, [configuration]);
79
-
80
- return (
81
- <>
82
- <div className={css.leftContent}>
83
- <ReactPlayerLoader
84
- accountId={accountId}
85
- baseUrl={getUrlBase()}
86
- attrs={{ className: css.playerLoader }}
87
- embedType='iframe'
88
- refNode='player-container'
89
- playerUrl={previewPlayerUrl}
90
- />
91
- <Hideable show={hasCustomPlugins}>
92
- <span className={css.customPluginNotice}>
93
- {t('customPluginNotice')}
94
- </span>
95
- </Hideable>
96
- {isOutstreamPlayer ? null : (
97
- <VideoLinks previewUrl={previewPlayerUrl} playerUrl={playerUrl} />
98
- )}
99
- </div>
100
- <div
101
- className={cx(css.rightContent, {
102
- [css.rightContentFullWidth]: !!isOutstreamPlayer,
103
- })}
104
- >
105
- <TabsSection
106
- isCampaign={isCampaignPlayer}
107
- isViewerIdSource={isViewerIdSource}
108
- isBcMapTracking={isBcMapTracking}
109
- playerId={id}
110
- accountId={accountId}
111
- embedCodeProperties={embedCodeProperties}
112
- />
113
- </div>
114
- </>
115
- );
116
- };
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { Flex, Tabs, TabList, Tab } from '@brightcove/studio-components';
3
- import { TabsSelectedId } from 'js/types/players';
4
-
5
- interface TabsHeaderProps {
6
- currentTab: TabsSelectedId;
7
- handleTabChange: () => void;
8
- iframeLabel: string;
9
- jsLabel: string;
10
- }
11
- export const TabsHeader = ({
12
- currentTab,
13
- handleTabChange,
14
- iframeLabel,
15
- jsLabel,
16
- }: TabsHeaderProps) => {
17
- return (
18
- <Flex justifyContent='space-between' alignItems='baseline'>
19
- <Tabs selectedId={currentTab} onSelect={handleTabChange}>
20
- <TabList>
21
- <Tab tabId='iframe' testName={'iframe-tab'}>
22
- {iframeLabel}
23
- </Tab>
24
- <Tab tabId='javascript' testName={'js-tab'}>
25
- {jsLabel}
26
- </Tab>
27
- </TabList>
28
- </Tabs>
29
- </Flex>
30
- );
31
- };