Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paragon form component deprecations #612

Merged
merged 17 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
90f46fc
refactor: removed deprecated paragon components from CoachingToggle a…
abdullahwaheed Jul 18, 2022
b529310
refactor: removed deprecated paragon components from ConfirmationModa…
abdullahwaheed Jul 19, 2022
f8234d5
refactor: removed deprecations from EditableField and created separat…
abdullahwaheed Jul 19, 2022
0d108d6
refactor: updated DemographicsSection to use new select component
abdullahwaheed Jul 19, 2022
fbc9b49
refactor: removed deprecations from EmailField and used alternatives
abdullahwaheed Jul 19, 2022
3c3e5f8
refactor: removed deprecated Input from CoachingConsentForm
abdullahwaheed Jul 19, 2022
6c93e9b
refactor: removed deprecated Input from DemographicsSection
abdullahwaheed Jul 19, 2022
2909365
refactor: removed deprecated Input from SummaryPanel component
abdullahwaheed Jul 19, 2022
418122f
refactor: removed deprecated CheckBox and used Form.CheckBox
abdullahwaheed Jul 19, 2022
71390d0
refactor: fixed unit tests
abdullahwaheed Jul 19, 2022
b59cadb
Merge branch 'master' of github.com:edx/frontend-app-account into abd…
abdullahwaheed Aug 11, 2022
8a3650e
refactor: changes based on PR reviews
abdullahwaheed Aug 12, 2022
31e66d4
Merge branch 'master' of github.com:edx/frontend-app-account into abd…
abdullahwaheed Aug 17, 2022
810056e
Merge branch 'master' of github.com:edx/frontend-app-account into abd…
abdullahwaheed Aug 19, 2022
342c163
Merge branch 'master' of github.com:edx/frontend-app-account into abd…
abdullahwaheed Aug 23, 2022
6e3356b
Merge branch 'master' of github.com:edx/frontend-app-account into abd…
abdullahwaheed Nov 7, 2022
3b445c0
fix: linting issue
abdullahwaheed Nov 7, 2022
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
21 changes: 12 additions & 9 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import PageLoading from './PageLoading';
import JumpNav from './JumpNav';
import DeleteAccount from './delete-account';
import EditableField from './EditableField';
import EditableSelectField from './EditableSelectField';
import ResetPassword from './reset-password';
import NameChange from './name-change';
import ThirdPartyAuth from './third-party-auth';
Expand Down Expand Up @@ -609,7 +610,7 @@ class AccountSettingsPage extends React.Component {
<ResetPassword email={this.props.formValues.email} />
{(!getConfig().ENABLE_COPPA_COMPLIANCE)
&& (
<EditableField
<EditableSelectField
name="year_of_birth"
type="select"
label={this.props.intl.formatMessage(messages['account.settings.field.dob'])}
Expand All @@ -619,7 +620,7 @@ class AccountSettingsPage extends React.Component {
{...editableFieldProps}
/>
)}
<EditableField
<EditableSelectField
name="country"
type="select"
value={this.props.formValues.country}
Expand All @@ -635,7 +636,7 @@ class AccountSettingsPage extends React.Component {
/>
{showState
&& (
<EditableField
<EditableSelectField
name="state"
type="select"
value={this.props.formValues.state}
Expand All @@ -657,16 +658,18 @@ class AccountSettingsPage extends React.Component {
{this.props.intl.formatMessage(messages['account.settings.section.profile.information'])}
</h2>

<EditableField
<EditableSelectField
name="level_of_education"
type="select"
value={this.props.formValues.level_of_education}
options={educationLevelOptions}
options={getConfig().ENABLE_COPPA_COMPLIANCE
? educationLevelOptions.filter(option => option.value !== 'el')
: educationLevelOptions}
label={this.props.intl.formatMessage(messages['account.settings.field.education'])}
emptyLabel={this.props.intl.formatMessage(messages['account.settings.field.education.empty'])}
{...editableFieldProps}
/>
<EditableField
<EditableSelectField
name="gender"
type="select"
value={this.props.formValues.gender}
Expand All @@ -675,7 +678,7 @@ class AccountSettingsPage extends React.Component {
emptyLabel={this.props.intl.formatMessage(messages['account.settings.field.gender.empty'])}
{...editableFieldProps}
/>
<EditableField
<EditableSelectField
name="language_proficiencies"
type="select"
value={this.props.formValues.language_proficiencies}
Expand Down Expand Up @@ -738,7 +741,7 @@ class AccountSettingsPage extends React.Component {
</h2>

<BetaLanguageBanner />
<EditableField
<EditableSelectField
name="siteLanguage"
type="select"
options={this.props.siteLanguageOptions}
Expand All @@ -747,7 +750,7 @@ class AccountSettingsPage extends React.Component {
helpText={this.props.intl.formatMessage(messages['account.settings.field.site.language.help.text'])}
{...editableFieldProps}
/>
<EditableField
<EditableSelectField
name="time_zone"
type="select"
value={this.props.formValues.time_zone}
Expand Down
42 changes: 10 additions & 32 deletions src/account-settings/EditableField.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable react/jsx-no-useless-fragment */
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import {
Button, Input, StatefulButton, ValidationFormGroup,
Button, Form, StatefulButton,
} from '@edx/paragon';
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
Expand All @@ -28,7 +26,6 @@ const EditableField = (props) => {
type,
value,
userSuppliedValue,
options,
saveState,
error,
confirmationMessageDefinition,
Expand All @@ -45,10 +42,6 @@ const EditableField = (props) => {
...others
} = props;
const id = `field-${name}`;
let inputOptions = options;
if (getConfig().ENABLE_COPPA_COMPLIANCE && name === 'level_of_education' && options) {
inputOptions = options.filter(option => option.value !== 'el');
}

const handleSubmit = (e) => {
e.preventDefault();
Expand Down Expand Up @@ -80,15 +73,6 @@ const EditableField = (props) => {
}
let finalValue = rawValue;

if (options) {
// Use == instead of === to prevent issues when HTML casts numbers as strings
// eslint-disable-next-line eqeqeq
const selectedOption = options.find(option => option.value == rawValue);
if (selectedOption) {
finalValue = selectedOption.label;
}
}

if (userSuppliedValue) {
finalValue += `: ${userSuppliedValue}`;
}
Expand All @@ -112,25 +96,24 @@ const EditableField = (props) => {
editing: (
<>
<form onSubmit={handleSubmit}>
<ValidationFormGroup
for={id}
invalid={error != null}
invalidMessage={error}
helpText={helpText}
<Form.Group
controlId={id}
isInvalid={error != null}
>
<label className="h6 d-block" htmlFor={id}>{label}</label>
<Input
<Form.Label size="sm" className="h6 d-block" htmlFor={id}>{label}</Form.Label>
<Form.Control
data-hj-suppress
name={name}
id={id}
type={type}
value={value}
onChange={handleChange}
options={inputOptions}
{...others}
/>
<>{others.children}</>
</ValidationFormGroup>
{!!helpText && <Form.Text>{helpText}</Form.Text>}
{error != null && <Form.Control.Feedback hasIcon={false}>{error}</Form.Control.Feedback>}
{others.children}
</Form.Group>
<p>
<StatefulButton
type="submit"
Expand Down Expand Up @@ -188,10 +171,6 @@ EditableField.propTypes = {
type: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
userSuppliedValue: PropTypes.string,
options: PropTypes.arrayOf(PropTypes.shape({
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
})),
saveState: PropTypes.oneOf(['default', 'pending', 'complete', 'error']),
error: PropTypes.string,
confirmationMessageDefinition: PropTypes.shape({
Expand All @@ -213,7 +192,6 @@ EditableField.propTypes = {

EditableField.defaultProps = {
value: undefined,
options: undefined,
saveState: undefined,
label: undefined,
emptyLabel: undefined,
Expand Down
Loading