feat: replace ai-translations component with a plugin slot (#1186)
* feat: replace ai-translations component with a plugin slot * feat: move ai-translations enabled check to plugin
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
TransitionReplace,
|
||||
} from '@openedx/paragon';
|
||||
import { ChevronLeft, ChevronRight, Close } from '@openedx/paragon/icons';
|
||||
import AITranslationsComponent from '@edx/frontend-component-ai-translations';
|
||||
import { PluginSlot } from '@openedx/frontend-plugin-framework';
|
||||
import OrderTranscriptForm from './OrderTranscriptForm';
|
||||
import messages from './messages';
|
||||
import {
|
||||
@@ -114,18 +114,19 @@ const TranscriptSettings = ({
|
||||
</TransitionReplace>
|
||||
</>
|
||||
)}
|
||||
{(!transcriptType && isAiTranslationsEnabled) && (
|
||||
<TransitionReplace>
|
||||
<div data-testid="ai-translations-component">
|
||||
<AITranslationsComponent
|
||||
setIsAiTranslations={setIsAiTranslations}
|
||||
closeTranscriptSettings={closeTranscriptSettings}
|
||||
courseId={courseId}
|
||||
key="ai-component"
|
||||
/>
|
||||
</div>
|
||||
</TransitionReplace>
|
||||
)}
|
||||
<TransitionReplace>
|
||||
<div data-testid="translations-component">
|
||||
<PluginSlot
|
||||
id="additonal_translations_component_slot"
|
||||
pluginProps={{
|
||||
setIsAiTranslations,
|
||||
closeTranscriptSettings,
|
||||
courseId,
|
||||
additionalProps: { transcriptType, isAiTranslationsEnabled },
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</TransitionReplace>
|
||||
</div>
|
||||
</Sheet>
|
||||
);
|
||||
|
||||
@@ -616,36 +616,7 @@ 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.queryByTestId('ai-translations-component')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ai translations component success', () => {
|
||||
describe('Translations component success', () => {
|
||||
beforeEach(async () => {
|
||||
initializeMockApp({
|
||||
authenticatedUser: {
|
||||
@@ -671,7 +642,7 @@ describe('TranscriptSettings', () => {
|
||||
});
|
||||
|
||||
it('displays AI translations component if enabled', () => {
|
||||
const component = screen.getByTestId('ai-translations-component');
|
||||
const component = screen.getByTestId('translations-component');
|
||||
expect(component).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user