diff --git a/src/account-settings/EditableField.jsx b/src/account-settings/EditableField.jsx index 725f7ad2a..fac1fe85d 100644 --- a/src/account-settings/EditableField.jsx +++ b/src/account-settings/EditableField.jsx @@ -3,10 +3,9 @@ import { connect } from 'react-redux'; import classNames from 'classnames'; import { useIntl } from '@edx/frontend-platform/i18n'; import { - Button, Form, StatefulButton, + ActionRow, Button, Card, Form, StatefulButton, } from '@openedx/paragon'; -import { faPencilAlt } from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { EditOutline } from '@openedx/paragon/icons'; import SwitchContent from './SwitchContent'; import messages from './AccountSettingsPage.messages'; @@ -94,83 +93,95 @@ const EditableField = (props) => { }; return ( - -
- - {label} - - {!!helpText && {helpText}} - {error != null && {error}} - {others.children} - -

- { - // Swallow clicks if the state is pending. - // We do this instead of disabling the button to prevent - // it from losing focus (disabled elements cannot have focus). - // Disabling it would causes upstream issues in focus management. - // Swallowing the onSubmit event on the form would be better, but - // we would have to add that logic for every field given our - // current structure of the application. - if (saveState === 'pending') { e.preventDefault(); } - }} - disabledStates={[]} - data-testid="editable-field-save" - /> - -

-
- {['name', 'verified_name'].includes(name) && ( - - )} - - ), - default: ( -
-
-
{label}
- {isEditable ? ( - - ) : null} -
-

{renderValue(value)}

-

{renderConfirmationMessage() || helpText}

-
- ), - }} - /> + + + +
+ + {label} + + {!!helpText && {helpText}} + {error != null && {error}} + {others.children} + +

+ { + // Swallow clicks if the state is pending. + // We do this instead of disabling the button to prevent + // it from losing focus (disabled elements cannot have focus). + // Disabling it would causes upstream issues in focus management. + // Swallowing the onSubmit event on the form would be better, but + // we would have to add that logic for every field given our + // current structure of the application. + if (saveState === 'pending') { e.preventDefault(); } + }} + disabledStates={[]} + data-testid="editable-field-save" + /> + +

+
+ {['name', 'verified_name'].includes(name) && ( + + )} +
+ + ), + default: ( + <> + {renderValue(value)}

} + actions={isEditable && ( + + + + )} + /> + {(renderConfirmationMessage() || helpText) && ( + + +

{renderConfirmationMessage() || helpText}

+
+
+ )} + + ), + }} + /> +
); }; diff --git a/src/account-settings/EditableSelectField.jsx b/src/account-settings/EditableSelectField.jsx index 1044c272a..eb4043288 100644 --- a/src/account-settings/EditableSelectField.jsx +++ b/src/account-settings/EditableSelectField.jsx @@ -2,10 +2,9 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { useIntl } from '@edx/frontend-platform/i18n'; import { - Button, Form, StatefulButton, + ActionRow, Button, Card, Form, StatefulButton, } from '@openedx/paragon'; -import { faPencilAlt } from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { EditOutline } from '@openedx/paragon/icons'; import SwitchContent from './SwitchContent'; import messages from './AccountSettingsPage.messages'; @@ -122,80 +121,92 @@ const EditableSelectField = (props) => { }); return ( - -
- - {label} - - {options.length > 0 && selectOptions} - - {!!helpText && {helpText}} - {error != null && {error}} - {others.children} - -

- { - // Swallow clicks if the state is pending. - // We do this instead of disabling the button to prevent - // it from losing focus (disabled elements cannot have focus). - // Disabling it would causes upstream issues in focus management. - // Swallowing the onSubmit event on the form would be better, but - // we would have to add that logic for every field given our - // current structure of the application. - if (saveState === 'pending') { e.preventDefault(); } - }} - disabledStates={[]} - /> - -

-
- {['name', 'verified_name'].includes(name) && } - - ), - default: ( -
-
-
{label}
- {isEditable ? ( - - ) : null} -
-

{renderValue(value)}

-

{renderConfirmationMessage() || helpText}

-
- ), - }} - /> + + + +
+ + {label} + + {options.length > 0 && selectOptions} + + {!!helpText && {helpText}} + {error != null && {error}} + {others.children} + +

+ { + // Swallow clicks if the state is pending. + // We do this instead of disabling the button to prevent + // it from losing focus (disabled elements cannot have focus). + // Disabling it would causes upstream issues in focus management. + // Swallowing the onSubmit event on the form would be better, but + // we would have to add that logic for every field given our + // current structure of the application. + if (saveState === 'pending') { e.preventDefault(); } + }} + disabledStates={[]} + /> + +

+
+ {['name', 'verified_name'].includes(name) && } +
+ + ), + default: ( + <> + {renderValue(value)}

} + actions={isEditable && ( + + + + )} + /> + {(renderConfirmationMessage() || helpText) && ( + + +

{renderConfirmationMessage() || helpText}

+
+
+ )} + + ), + }} + /> +
); }; diff --git a/src/account-settings/EmailField.jsx b/src/account-settings/EmailField.jsx index c2402701c..f0afe907f 100644 --- a/src/account-settings/EmailField.jsx +++ b/src/account-settings/EmailField.jsx @@ -2,10 +2,11 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n'; import { - Button, StatefulButton, Form, Tooltip, OverlayTrigger, + ActionRow, Button, Card, StatefulButton, Form, Tooltip, OverlayTrigger, } from '@openedx/paragon'; +import { EditOutline } from '@openedx/paragon/icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faExclamationTriangle, faPencilAlt } from '@fortawesome/free-solid-svg-icons'; +import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; import Alert from './Alert'; import SwitchContent from './SwitchContent'; @@ -100,82 +101,97 @@ const EmailField = (props) => { }; return ( - - - {label} - - {!!helpText && {helpText}} - {error != null && {error}} - -

- { - // Swallow clicks if the state is pending. - // We do this instead of disabling the button to prevent - // it from losing focus (disabled elements cannot have focus). - // Disabling it would causes upstream issues in focus management. - // Swallowing the onSubmit event on the form would be better, but - // we would have to add that logic for every field given our - // current structure of the application. - if (saveState === 'pending') { e.preventDefault(); } - }} - disabledStates={[]} + + + +

+ + {label} + + {!!helpText && {helpText}} + {error != null && {error}} + +

+ { + // Swallow clicks if the state is pending. + // We do this instead of disabling the button to prevent + // it from losing focus (disabled elements cannot have focus). + // Disabling it would causes upstream issues in focus management. + // Swallowing the onSubmit event on the form would be better, but + // we would have to add that logic for every field given our + // current structure of the application. + if (saveState === 'pending') { e.preventDefault(); } + }} + disabledStates={[]} + /> + +

+
+ + + ), + default: ( + <> + + {renderValue()} + + )} + > +

{renderValue()}

+ + )} + actions={isEditable && ( + + + + )} /> - -

- - ), - default: ( -
-
-
{label}
- {isEditable ? ( - - ) : null} -
- - {renderValue()} - + {(renderConfirmationMessage() || helpText) && ( + + +

{renderConfirmationMessage() || helpText}

+
+
)} - > -

{renderValue()}

-
- {renderConfirmationMessage() ||

{helpText}

} -
- ), - }} - /> + + ), + }} + /> + ); }; diff --git a/src/account-settings/reset-password/ResetPassword.jsx b/src/account-settings/reset-password/ResetPassword.jsx index ea0a75f52..1cca33804 100644 --- a/src/account-settings/reset-password/ResetPassword.jsx +++ b/src/account-settings/reset-password/ResetPassword.jsx @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n'; -import { StatefulButton } from '@openedx/paragon'; +import { Card, StatefulButton } from '@openedx/paragon'; import { resetPassword } from './data/actions'; import messages from './messages'; @@ -13,40 +13,48 @@ const ResetPassword = (props) => { const intl = useIntl(); return ( -
-
- -
-

- { - // Swallow clicks if the state is pending. - // We do this instead of disabling the button to prevent - // it from losing focus (disabled elements cannot have focus). - // Disabling it would causes upstream issues in focus management. - // Swallowing the onSubmit event on the form would be better, but - // we would have to add that logic for every field given our - // current structure of the application. - if (status === 'pending') { - e.preventDefault(); - } - props.resetPassword(email); - }} - disabledStates={[]} - labels={{ - default: intl.formatMessage(messages['account.settings.editable.field.password.reset.button']), - }} - /> -

- {status === 'complete' ? : null} - {status === 'forbidden' ? : null} -
+ + + )} + /> + + + { + // Swallow clicks if the state is pending. + // We do this instead of disabling the button to prevent + // it from losing focus (disabled elements cannot have focus). + // Disabling it would causes upstream issues in focus management. + // Swallowing the onSubmit event on the form would be better, but + // we would have to add that logic for every field given our + // current structure of the application. + if (status === 'pending') { + e.preventDefault(); + } + props.resetPassword(email); + }} + disabledStates={[]} + labels={{ + default: intl.formatMessage(messages['account.settings.editable.field.password.reset.button']), + }} + /> + + {status && ( + + {status === 'complete' ? : null} + {status === 'forbidden' ? : null} + + )} + + ); }; diff --git a/src/account-settings/test/__snapshots__/EditableSelectField.test.jsx.snap b/src/account-settings/test/__snapshots__/EditableSelectField.test.jsx.snap index dc26695a0..28853054d 100644 --- a/src/account-settings/test/__snapshots__/EditableSelectField.test.jsx.snap +++ b/src/account-settings/test/__snapshots__/EditableSelectField.test.jsx.snap @@ -2,68 +2,97 @@ exports[`EditableSelectField renders EditableSelectField correctly with editing disabled 1`] = `
-
- Main Label -
-
+
+

+ Test Field +

+
+
+
- - Edit - + +
+
-

- Test Field -

-

- Default Confirmation Message -

+
+

+ Default Confirmation Message +

+
+ @@ -71,205 +100,248 @@ exports[`EditableSelectField renders EditableSelectField correctly with editing exports[`EditableSelectField renders EditableSelectField correctly with editing enabled 1`] = `
-
-
- - - - - - -
-

- - -

- +
`; exports[`EditableSelectField renders EditableSelectField with an error 1`] = `
-
- Main Label -
-
+
+

+ Test Field +

+
+
+
- - Edit - + +
+
-

- Test Field -

-

- Default Confirmation Message -

+
+

+ Default Confirmation Message +

+
+ @@ -277,68 +349,97 @@ exports[`EditableSelectField renders EditableSelectField with an error 1`] = ` exports[`EditableSelectField renders selectOptions when option does not have a group 1`] = `
-
- Main Label -
-
+
+

+ Test Field +

+
+
+
- - Edit - + +
+
-

- Test Field -

-

- Default Confirmation Message -

+
+

+ Default Confirmation Message +

+
+ @@ -346,68 +447,97 @@ exports[`EditableSelectField renders selectOptions when option does not have a g exports[`EditableSelectField renders selectOptions when option has a group 1`] = `
-
- Main Label -
-
+
+

+ Test Field +

+
+
+
- - Edit - + +
+
-

- Test Field -

-

- Default Confirmation Message -

+
+

+ Default Confirmation Message +

+
+ @@ -415,68 +545,97 @@ exports[`EditableSelectField renders selectOptions when option has a group 1`] = exports[`EditableSelectField renders selectOptions with multiple groups 1`] = `
-
- Main Label -
-
+
+

+ Test Field +

+
+
+
- - Edit - + +
+
-

- Test Field -

-

- Default Confirmation Message -

+
+

+ Default Confirmation Message +

+
+