Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
import { Card } from '@openedx/paragon';
import PropTypes from 'prop-types';
import { thunkActions } from '@src/editors/data/redux';
Expand All @@ -15,6 +15,7 @@ const SwitchEditorCard = ({
editorType,
problemType,
}) => {
const intl = useIntl();
const [isConfirmOpen, setConfirmOpen] = React.useState(false);
const dispatch = useDispatch();
const { editorRef } = useProblemEditorContext();
Expand All @@ -27,7 +28,7 @@ const SwitchEditorCard = ({
close={() => {
setConfirmOpen(false);
}}
title={<FormattedMessage {...messages[`ConfirmSwitchMessageTitle-${editorType}`]} />}
title={intl.formatMessage(messages[`ConfirmSwitchMessageTitle-${editorType}`])}
confirmAction={
<Button
/* istanbul ignore next */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import {
ActionRow,
Expand All @@ -10,20 +9,35 @@ import { FormattedMessage } from '@edx/frontend-platform/i18n';

import messages from './messages';

interface BaseModalProps {
isOpen: boolean;
close: () => void;
title: string;
children: React.ReactNode;
confirmAction: React.ReactNode;
footerAction?: React.ReactNode;
headerComponent?: React.ReactNode;
size?: 'sm' | 'md' | 'lg' | 'xl' | 'fullscreen';
isFullscreenScroll?: boolean;
bodyStyle?: React.CSSProperties;
className?: string;
hideCancelButton?: boolean;
}

const BaseModal = ({
isOpen,
close,
title,
children,
headerComponent,
confirmAction,
footerAction,
size,
isFullscreenScroll,
footerAction = null,
size = 'lg',
isFullscreenScroll = true,
bodyStyle,
className,
hideCancelButton,
}) => (
hideCancelButton = false,
}: BaseModalProps) => (
<ModalDialog
isOpen={isOpen}
onClose={close}
Expand All @@ -34,6 +48,7 @@ const BaseModal = ({
isFullscreenScroll={isFullscreenScroll}
title={title}
className={className}
isOverflowVisible={false}
>
<ModalDialog.Header style={{ zIndex: 1, boxShadow: '2px 2px 5px rgba(0, 0, 0, 0.3)' }}>
<ModalDialog.Title>
Expand Down Expand Up @@ -65,29 +80,4 @@ const BaseModal = ({
</ModalDialog>
);

BaseModal.defaultProps = {
footerAction: null,
headerComponent: null,
size: 'lg',
isFullscreenScroll: true,
bodyStyle: null,
className: undefined,
hideCancelButton: false,
};

BaseModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
close: PropTypes.func.isRequired,
title: PropTypes.node.isRequired,
children: PropTypes.node.isRequired,
confirmAction: PropTypes.node.isRequired,
footerAction: PropTypes.node,
headerComponent: PropTypes.node,
size: PropTypes.string,
isFullscreenScroll: PropTypes.bool,
bodyStyle: PropTypes.shape({}),
className: PropTypes.string,
hideCancelButton: PropTypes.bool,
};

export default BaseModal;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useFormikContext } from 'formik';
import React from 'react';

import { Form } from '@openedx/paragon';
import { useIntl } from '@edx/frontend-platform/i18n';
import { ImageConfig } from './types';

import messages from './messages';

const AltTextControls = () => {
const intl = useIntl();
const formik = useFormikContext<ImageConfig>();
return (
<>
<Form.Label className="mb-0">
{intl.formatMessage(messages.accessibilityLabel)}
</Form.Label>
<Form.Group className="mb-1">
<Form.Checkbox
name="isDecorative"
checked={formik.values.isDecorative}
className="mt-2.5 decorative-control-label"
onChange={formik.handleChange}
>
<Form.Label>
{intl.formatMessage(messages.decorativeAltTextCheckboxLabel)}
</Form.Label>
</Form.Checkbox>
</Form.Group>
<Form.Group>
<Form.Control
name="altText"
floatingLabel={intl.formatMessage(messages.altTextFloatingLabel)}
disabled={formik.values.isDecorative}
isInvalid={Boolean(formik.errors.altText)}
onChange={formik.handleChange}
type="input"
value={formik.values.altText}
/>
{formik.errors.altText && (
<Form.Control.Feedback type="invalid">
{formik.errors.altText}
</Form.Control.Feedback>
)}
</Form.Group>
</>
);
};

export const AltTextControlsInternal = AltTextControls; // For testing only
export default AltTextControls;

This file was deleted.

Loading
Loading