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

Upgraded frontend-build version to v12 #613

Merged
merged 7 commits into from
Aug 16, 2022
Merged
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');

module.exports = createConfig('eslint');
8,673 changes: 3,587 additions & 5,086 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "^1.1.0",
"@edx/frontend-build": "9.1.2",
"@edx/frontend-build": "^12.0.3",
"@edx/reactifex": "^1.0.3",
"@testing-library/jest-dom": "5.15.1",
"@testing-library/react": "12.1.5",
Expand Down
35 changes: 10 additions & 25 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,13 @@ class AccountSettingsPage extends React.Component {
})),
}));

sortDates = (a, b) => {
const aTimeSinceEpoch = new Date(a).getTime();
const bTimeSinceEpoch = new Date(b).getTime();

return bTimeSinceEpoch - aTimeSinceEpoch;
}

sortVerifiedNameRecords = verifiedNameHistory => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this function unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this function was unused & was triggering react/no-unused-class-component-methods rule, therefore I removed it.

if (Array.isArray(verifiedNameHistory)) {
return [...verifiedNameHistory].sort(this.sortDates);
}

return [];
}

handleEditableFieldChange = (name, value) => {
this.props.updateDraft(name, value);
}
};

handleSubmit = (formId, values) => {
this.props.saveSettings(formId, values);
}
};

handleSubmitProfileName = (formId, values) => {
if (Object.keys(this.props.drafts).includes('useVerifiedNameForCerts')) {
Expand Down Expand Up @@ -195,7 +180,7 @@ class AccountSettingsPage extends React.Component {
} else {
this.props.saveSettings(formId, values);
}
}
};

isEditable(fieldName) {
return !this.props.staticFields.includes(fieldName);
Expand Down Expand Up @@ -280,7 +265,7 @@ class AccountSettingsPage extends React.Component {
}

return this.props.intl.formatMessage(messages[messageString]);
}
};

renderVerifiedNameSuccessMessage = (verifiedName, created) => {
const dateValue = new Date(created).valueOf();
Expand All @@ -295,7 +280,7 @@ class AccountSettingsPage extends React.Component {
body={this.props.intl.formatMessage(messages['account.settings.field.name.verified.success.message'])}
/>
);
}
};

renderVerifiedNameFailureMessage = (verifiedName, created) => {
const dateValue = new Date(created).valueOf();
Expand Down Expand Up @@ -326,7 +311,7 @@ class AccountSettingsPage extends React.Component {
}
/>
);
}
};

renderVerifiedNameSubmittedMessage = (willCertNameChange) => (
<Alert
Expand All @@ -344,7 +329,7 @@ class AccountSettingsPage extends React.Component {
}
</p>
</Alert>
)
);

renderVerifiedNameMessage = verifiedNameRecord => {
const {
Expand Down Expand Up @@ -385,7 +370,7 @@ class AccountSettingsPage extends React.Component {
default:
return null;
}
}
};

renderVerifiedNameIcon = (status) => {
switch (status) {
Expand All @@ -396,7 +381,7 @@ class AccountSettingsPage extends React.Component {
default:
return null;
}
}
};

renderVerifiedNameHelpText = (status, proctoredExamId) => {
let messageStr = 'account.settings.field.name.verified.help.text';
Expand All @@ -421,7 +406,7 @@ class AccountSettingsPage extends React.Component {
}

return this.props.intl.formatMessage(messages[messageStr]);
}
};

renderEmptyStaticFieldMessage() {
if (this.isManagedProfile()) {
Expand Down
2 changes: 1 addition & 1 deletion src/account-settings/EditableField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function EditableField(props) {
options={inputOptions}
{...others}
/>
<>{others.children}</>
{others.children}
</ValidationFormGroup>
<p>
<StatefulButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function CertificatePreference({
const [modalIsOpen, setModalIsOpen] = useState(false);
const formId = 'useVerifiedNameForCerts';

function handleCheckboxChange() {
const handleCheckboxChange = () => {
if (!checked) {
if (fieldName === 'verified_name') {
dispatch(updateDraft(formId, true));
Expand All @@ -44,30 +44,30 @@ function CertificatePreference({
} else {
setModalIsOpen(true);
}
}
};

function handleCancel() {
const handleCancel = () => {
setModalIsOpen(false);
dispatch(resetDrafts());
}
};

function handleModalChange(e) {
const handleModalChange = (e) => {
if (e.target.value === 'fullName') {
dispatch(updateDraft(formId, false));
} else {
dispatch(updateDraft(formId, true));
}
}
};

function handleSubmit(e) {
const handleSubmit = (e) => {
e.preventDefault();

if (saveState === 'pending') {
return;
}

dispatch(saveSettings(formId, useVerifiedNameForCerts));
}
};

useEffect(() => {
if (originalVerifiedName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-import-assign */
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
Expand Down
78 changes: 40 additions & 38 deletions src/account-settings/coaching/CoachingConsent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@ import LogoSVG from '../../logo.svg';
import { fetchSettings } from '../data/actions';
import { coachingConsentPageSelector } from '../data/selectors';

const Logo = ({ src, alt, ...attributes }) => (
<>
<img src={src} alt={alt} {...attributes} />
</>
);
function Logo({ src, alt, ...attributes }) {
return <img src={src} alt={alt} {...attributes} />;
}

const SuccessMessage = props => (
<div className="col-12 col-lg-6 shadow-lg mx-auto mt-4 p-5">
<FontAwesomeIcon className="text-success" icon={faCheck} size="5x" />
<div className="h3">{props.header}</div>
<div>{props.message}</div>
<Hyperlink destination={props.continueUrl} className="d-block p-2 my-3 text-center text-white bg-primary rounded">
{props.continue}
</Hyperlink>
</div>
);
function SuccessMessage(props) {
return (
<div className="col-12 col-lg-6 shadow-lg mx-auto mt-4 p-5">
<FontAwesomeIcon className="text-success" icon={faCheck} size="5x" />
<div className="h3">{props.header}</div>
<div>{props.message}</div>
<Hyperlink destination={props.continueUrl} className="d-block p-2 my-3 text-center text-white bg-primary rounded">
{props.continue}
</Hyperlink>
</div>
);
}

const AutoRedirect = (props) => {
function AutoRedirect(props) {
window.location.href = props.redirectUrl;
// eslint-disable-next-line react/jsx-no-useless-fragment
return <></>;
};
}

const VIEWS = {
NOT_LOADED: 'NOT_LOADED',
Expand Down Expand Up @@ -71,6 +72,23 @@ class CoachingConsent extends React.Component {
this.props.fetchSettings();
}

handleSubmit(e) {
e.preventDefault();
const fullName = e.target.fullName.value;
const phoneNumber = e.target.phoneNumber.value;
const body = {
coaching_consent: true,
consent_form_seen: true,
phone_number: phoneNumber,
full_name: fullName,
};
this.setState({
formErrors: {},
formSubmitted: true,
declineSubmitted: false,
}, () => this.patchUsingCoachingConsentForm(body));
}

sanitizeForwardingUrl(url) {
// Redirect to root of MFE if invalid next param is sent
return url && url.startsWith(getConfig().LMS_BASE_URL) ? url : `${getConfig().LMS_BASE_URL}/dashboard/`;
Expand Down Expand Up @@ -99,23 +117,6 @@ class CoachingConsent extends React.Component {
}
}

handleSubmit(e) {
e.preventDefault();
const fullName = e.target.fullName.value;
const phoneNumber = e.target.phoneNumber.value;
const body = {
coaching_consent: true,
consent_form_seen: true,
phone_number: phoneNumber,
full_name: fullName,
};
this.setState({
formErrors: {},
formSubmitted: true,
declineSubmitted: false,
}, () => this.patchUsingCoachingConsentForm(body));
}

declineCoaching(e) {
e.preventDefault();
const body = {
Expand Down Expand Up @@ -160,6 +161,7 @@ class CoachingConsent extends React.Component {
case VIEWS.DECLINED:
return <AutoRedirect redirectUrl={this.state.redirectUrl} />;
default:
// eslint-disable-next-line react/jsx-no-useless-fragment
return <></>;
}
}
Expand Down Expand Up @@ -253,12 +255,12 @@ CoachingConsent.propTypes = {
}),
}).isRequired,
formErrors: PropTypes.shape({
coaching: PropTypes.object,
coaching: PropTypes.shape({}),
}).isRequired,
confirmationValues: PropTypes.shape({
coaching: PropTypes.object,
name: PropTypes.object,
phone_number: PropTypes.object,
coaching: PropTypes.shape({}),
name: PropTypes.shape({}),
phone_number: PropTypes.shape({}),
}).isRequired,
fetchSettings: PropTypes.func.isRequired,
profileDataManager: PropTypes.string,
Expand Down
Loading