* feat: add language selection chore: update tests so we have less error message test: update test * test: update tests * chore: remove duplicate translation * chore: lint for console * chore: remove comments * chore: make sure the affect url frame refresh after the language selection change * chore: add whole_course_translation and language to courseware meta (#1305) * feat: Add feedback widget UI mock Add unit tests Fix snapshot Clean Sequence component logEvent calls Clean unit test Put feedback widget behind whole course translation flag Fix useFeedbackWidget test * chore: add src and dest translation * feat: first iteration of plugin translation chore: update plugin instruction * feat: Connect FeedbackWidget with backend services (#1325) Connect FeedbackWidget with backend services Move feedback widget to unit translation plugin * feat: Add authentication to WCT feedback endpoints (#1329) * chore: add fetch config and move feedback widget for the plugin chore: rewrite and test the api request chore: rebase chore: update translation feedback chore: test chore: add more tests * chore: rebase * chore: update requested change * chore: update package * chore: upgrade frontend-lib-special-exams and frontend-lib-learning-assistant * chore: update tests * chore: remove unneeded package * chore: update example config * chore: add source-map-loader * fix: feedback widget render error after submit feedback (#1335) * fix: feedback widget render error after submit feedback * fix: widget logic --------- Co-authored-by: Rodrigo Martin <rodrigom_94@hotmail.com>
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
import {
|
|
StandardModal,
|
|
ActionRow,
|
|
Button,
|
|
Icon,
|
|
ListBox,
|
|
ListBoxOption,
|
|
} from '@openedx/paragon';
|
|
import { Check } from '@openedx/paragon/icons';
|
|
|
|
import useTranslationModal from './useTranslationModal';
|
|
import messages from './messages';
|
|
|
|
import './TranslationModal.scss';
|
|
|
|
const TranslationModal = ({
|
|
isOpen,
|
|
close,
|
|
selectedLanguage,
|
|
setSelectedLanguage,
|
|
availableLanguages,
|
|
}) => {
|
|
const { formatMessage } = useIntl();
|
|
const { selectedIndex, setSelectedIndex, onSubmit } = useTranslationModal({
|
|
selectedLanguage,
|
|
setSelectedLanguage,
|
|
close,
|
|
availableLanguages,
|
|
});
|
|
|
|
return (
|
|
<StandardModal
|
|
title={formatMessage(messages.languageSelectionModalTitle)}
|
|
isOpen={isOpen}
|
|
onClose={close}
|
|
footerNode={(
|
|
<ActionRow>
|
|
<ActionRow.Spacer />
|
|
<Button variant="tertiary" onClick={close}>
|
|
{formatMessage(messages.cancelButtonText)}
|
|
</Button>
|
|
<Button onClick={onSubmit}>
|
|
{formatMessage(messages.submitButtonText)}
|
|
</Button>
|
|
</ActionRow>
|
|
)}
|
|
>
|
|
<ListBox className="listbox-container">
|
|
{availableLanguages.map(({ code, label }, index) => (
|
|
<ListBoxOption
|
|
className="d-flex justify-content-between"
|
|
key={code}
|
|
selectedOptionIndex={selectedIndex}
|
|
onSelect={() => setSelectedIndex(index)}
|
|
>
|
|
{label}
|
|
{selectedIndex === index && <Icon src={Check} />}
|
|
</ListBoxOption>
|
|
))}
|
|
</ListBox>
|
|
</StandardModal>
|
|
);
|
|
};
|
|
|
|
TranslationModal.propTypes = {
|
|
isOpen: PropTypes.bool.isRequired,
|
|
close: PropTypes.func.isRequired,
|
|
selectedLanguage: PropTypes.string.isRequired,
|
|
setSelectedLanguage: PropTypes.func.isRequired,
|
|
availableLanguages: PropTypes.arrayOf(
|
|
PropTypes.shape({
|
|
code: PropTypes.string.isRequired,
|
|
label: PropTypes.string.isRequired,
|
|
}),
|
|
).isRequired,
|
|
};
|
|
|
|
export default TranslationModal;
|