diff --git a/.env b/.env index 5183e318c7..9c900c37fb 100644 --- a/.env +++ b/.env @@ -41,3 +41,4 @@ HOTJAR_APP_ID='' HOTJAR_VERSION=6 HOTJAR_DEBUG=false INVITE_STUDENTS_EMAIL_TO='' +AI_TRANSLATIONS_BASE_URL='' diff --git a/.env.development b/.env.development index 4b98461d45..cc50a024fb 100644 --- a/.env.development +++ b/.env.development @@ -43,3 +43,4 @@ HOTJAR_APP_ID='' HOTJAR_VERSION=6 HOTJAR_DEBUG=true INVITE_STUDENTS_EMAIL_TO="someone@domain.com" +AI_TRANSLATIONS_BASE_URL='http://localhost:18760' diff --git a/package-lock.json b/package-lock.json index a0dd6e388b..1593f5447f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "AGPL-3.0", "dependencies": { "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", + "@edx/frontend-component-ai-translations-edx": "^1.3.0", "@edx/frontend-component-footer": "^12.3.0", "@edx/frontend-component-header": "^4.7.0", "@edx/frontend-enterprise-hotjar": "^2.0.0", @@ -2540,6 +2541,42 @@ "node": ">=8" } }, + "node_modules/@edx/frontend-component-ai-translations-edx": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@edx/frontend-component-ai-translations-edx/-/frontend-component-ai-translations-edx-1.3.0.tgz", + "integrity": "sha512-QMq8k3+EErv/29G8EJuMdpG1+uj9K5unoRP2VrjPoOOrDsK2lCdC8de7hKz2/2lmHzkdF5IOBbKtCQuC+VwxpA==", + "dependencies": { + "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", + "@edx/frontend-platform": "5.6.1", + "@edx/paragon": "21.5.6", + "babel-polyfill": "6.26.0", + "prop-types": "^15.5.10", + "react-responsive": "8.2.0" + }, + "peerDependencies": { + "@edx/frontend-platform": "^4.0.0 || ^5.0.0 || ^6.0.0", + "prop-types": "^15.5.10", + "react": "^16.14.0 || ^17.0.0", + "react-dom": "^16.14.0 || ^17.0.0" + } + }, + "node_modules/@edx/frontend-component-ai-translations-edx/node_modules/react-responsive": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-8.2.0.tgz", + "integrity": "sha512-iagCqVrw4QSjhxKp3I/YK6+ODkWY6G+YPElvdYKiUUbywwh9Ds0M7r26Fj2/7dWFFbOpcGnJE6uE7aMck8j5Qg==", + "dependencies": { + "hyphenate-style-name": "^1.0.0", + "matchmediaquery": "^0.3.0", + "prop-types": "^15.6.1", + "shallow-equal": "^1.1.0" + }, + "engines": { + "node": ">= 0.10" + }, + "peerDependencies": { + "react": ">=16.8.0" + } + }, "node_modules/@edx/frontend-component-footer": { "version": "12.5.1", "resolved": "https://registry.npmjs.org/@edx/frontend-component-footer/-/frontend-component-footer-12.5.1.tgz", diff --git a/package.json b/package.json index 17471fd2d5..4264dd7f4c 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ }, "dependencies": { "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", + "@edx/frontend-component-ai-translations-edx": "^1.3.0", "@edx/frontend-component-footer": "^12.3.0", "@edx/frontend-component-header": "^4.7.0", "@edx/frontend-enterprise-hotjar": "^2.0.0", diff --git a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.jsx b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.jsx index 0c94ee0a03..85ddf7b523 100644 --- a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.jsx +++ b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.jsx @@ -11,6 +11,7 @@ import { TransitionReplace, } from '@edx/paragon'; import { ChevronLeft, ChevronRight, Close } from '@edx/paragon/icons'; +import AITranslationsComponent from '@edx/frontend-component-ai-translations-edx'; import OrderTranscriptForm from './OrderTranscriptForm'; import messages from './messages'; import { @@ -31,9 +32,11 @@ const TranscriptSettings = ({ activeTranscriptPreferences, transcriptCredentials, videoTranscriptSettings, + isAiTranslationsEnabled, } = pageSettings; const { transcriptionPlans } = videoTranscriptSettings || {}; const [transcriptType, setTranscriptType] = useState(activeTranscriptPreferences?.provider); + const [isAiTranslations, setIsAiTranslations] = useState(false); const handleOrderTranscripts = (data, provider) => { const noCredentials = isEmpty(transcriptCredentials) || data.apiKey; @@ -54,59 +57,73 @@ const TranscriptSettings = ({ show={isTranscriptSettingsOpen} onClose={closeTranscriptSettings} > -
- +
+ {!isAiTranslations && ( + <> + + + {transcriptType ? ( + setTranscriptType(null)} + alt="back button to main transcript settings view" + /> + ) : ( +
+ +
+ )} +
+ + +
+ + {transcriptType ? ( +
+ +
+ ) : ( +
+ setTranscriptType('order')} + > + + + + + +
+ )} +
+ + )} + {(!transcriptType && isAiTranslationsEnabled) && ( - {transcriptType ? ( - setTranscriptType(null)} - alt="back button to main transcript settings view" - /> - ) : ( -
- -
- )} +
- - - - - {transcriptType ? ( -
- -
- ) : ( -
- setTranscriptType('order')} - > - - - - - -
- )} -
+ )}
); diff --git a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.scss b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.scss index 465d640e2b..db33fc0adc 100644 --- a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.scss +++ b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.scss @@ -2,3 +2,7 @@ .pgn__selectable_box[disabled] { opacity: .5; } + +.pgn__sheet-component.right { + min-width: 352px; +} diff --git a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.test.jsx b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.test.jsx index 4af40670fd..d1069e8baf 100644 --- a/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.test.jsx +++ b/src/files-and-videos/videos-page/transcript-settings/TranscriptSettings.test.jsx @@ -657,4 +657,64 @@ describe('TranscriptSettings', () => { }); }); }); + + describe('Ai translations component fails', () => { + beforeEach(async () => { + initializeMockApp({ + authenticatedUser: { + userId: 3, + username: 'abc123', + administrator: false, + roles: [], + }, + }); + store = initializeStore({ + ...initialState, + videos: { + ...initialState.videos, + pageSettings: { + ...initialState.videos.pageSettings, + }, + }, + }); + axiosMock = new MockAdapter(getAuthenticatedHttpClient()); + + renderComponent(defaultProps); + }); + + it('doesn\'t display AI translations component if not enabled', () => { + expect(screen.queryByText('/Get free translations/')).not.toBeInTheDocument(); + }); + }); + + describe('Ai translations component success', () => { + beforeEach(async () => { + initializeMockApp({ + authenticatedUser: { + userId: 3, + username: 'abc123', + administrator: false, + roles: [], + }, + }); + store = initializeStore({ + ...initialState, + videos: { + ...initialState.videos, + pageSettings: { + ...initialState.videos.pageSettings, + isAiTranslationsEnabled: true, + }, + }, + }); + axiosMock = new MockAdapter(getAuthenticatedHttpClient()); + + renderComponent(defaultProps); + }); + + it('displays AI translations component if enabled', () => { + const component = screen.getByText(/Get free translations/); + expect(component).toBeVisible(); + }); + }); });