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

Updated frontend-build to v12 #962

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

const config = createConfig('eslint', {
rules: {
// TODO: all these rules should be renabled/addressed. temporarily turned off to unblock a release.
'react-hooks/rules-of-hooks': 'off',
'react-hooks/exhaustive-deps': 'off',
'react/function-component-definition': 'off',
'import/no-extraneous-dependencies': 'off',
'no-restricted-exports': 'off',
'react/jsx-no-useless-fragment': 'off',
'react/jsx-no-bind': 'off',
'react/no-unknown-property': 'off',
'react/no-unstable-nested-components': 'off',
'react/jsx-no-constructed-context-values': 'off',
'func-names': 'off',
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/alerts/access-expiration-alert/AccessExpirationAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Info } from '@edx/paragon/icons';

import messages from './messages';

function AccessExpirationAlert({ intl, payload }) {
const AccessExpirationAlert = ({ intl, payload }) => {
const {
accessExpiration,
courseId,
Expand Down Expand Up @@ -116,7 +116,7 @@ function AccessExpirationAlert({ intl, payload }) {
{deadlineMessage}
</Alert>
);
}
};

AccessExpirationAlert.propTypes = {
intl: intlShape.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage, FormattedDate } from '@edx/frontend-platform/i18n';
import { PageBanner } from '@edx/paragon';

function AccessExpirationMasqueradeBanner({ payload }) {
const AccessExpirationMasqueradeBanner = ({ payload }) => {
const {
expirationDate,
userTimezone,
Expand All @@ -27,7 +27,7 @@ function AccessExpirationMasqueradeBanner({ payload }) {
/>
</PageBanner>
);
}
};

AccessExpirationMasqueradeBanner.propTypes = {
payload: PropTypes.shape({
Expand Down
12 changes: 6 additions & 6 deletions src/alerts/access-expiration-alert/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ const AccessExpirationMasqueradeBanner = React.lazy(() => import('./AccessExpira

function useAccessExpirationAlert(accessExpiration, courseId, org, userTimezone, topic, analyticsPageName) {
const isVisible = accessExpiration && !accessExpiration.masqueradingExpiredCourse; // If it exists, show it.
const payload = {
const payload = useMemo(() => ({
accessExpiration,
courseId,
org,
userTimezone,
analyticsPageName,
};
}), [accessExpiration, analyticsPageName, courseId, org, userTimezone]);

useAlert(isVisible, {
code: 'clientAccessExpirationAlert',
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
topic,
});

Expand All @@ -34,14 +34,14 @@ export function useAccessExpirationMasqueradeBanner(courseId, tab) {

const isVisible = accessExpiration && accessExpiration.masqueradingExpiredCourse;
const expirationDate = accessExpiration && accessExpiration.expirationDate;
const payload = {
const payload = useMemo(() => ({
expirationDate,
userTimezone,
};
}), [expirationDate, userTimezone]);

useAlert(isVisible, {
code: 'clientAccessExpirationMasqueradeBanner',
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
topic: 'instructor-toolbar-alerts',
});

Expand Down
4 changes: 2 additions & 2 deletions src/alerts/active-enteprise-alert/ActiveEnterpriseAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WarningFilled } from '@edx/paragon/icons';
import { getConfig } from '@edx/frontend-platform';
import genericMessages from './messages';

function ActiveEnterpriseAlert({ intl, payload }) {
const ActiveEnterpriseAlert = ({ intl, payload }) => {
const { text, courseId } = payload;
const changeActiveEnterprise = (
<Hyperlink
Expand Down Expand Up @@ -35,7 +35,7 @@ function ActiveEnterpriseAlert({ intl, payload }) {
/>
</Alert>
);
}
};

ActiveEnterpriseAlert.propTypes = {
intl: intlShape.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions src/alerts/active-enteprise-alert/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ export default function useActiveEnterpriseAlert(courseId) {
*/
const isVisible = courseAccess && !courseAccess.hasAccess && courseAccess.errorCode === 'incorrect_active_enterprise';

const payload = {
const payload = useMemo(() => ({
text: courseAccess && courseAccess.userMessage,
courseId,
};
}), [courseAccess, courseId]);
useAlert(isVisible, {
code: 'clientActiveEnterpriseAlert',
topic: 'outline',
dismissible: false,
type: ALERT_TYPES.ERROR,
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
});

return { clientActiveEnterpriseAlert: ActiveEnterpriseAlert };
Expand Down
4 changes: 2 additions & 2 deletions src/alerts/course-start-alert/CourseStartAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DAY_SEC = 24 * 60 * 60; // in seconds
const DAY_MS = DAY_SEC * 1000; // in ms
const YEAR_SEC = 365 * DAY_SEC; // in seconds

function CourseStartAlert({ payload }) {
const CourseStartAlert = ({ payload }) => {
const {
courseId,
} = payload;
Expand Down Expand Up @@ -94,7 +94,7 @@ function CourseStartAlert({ payload }) {
/>
</Alert>
);
}
};

CourseStartAlert.propTypes = {
payload: PropTypes.shape({
Expand Down
4 changes: 2 additions & 2 deletions src/alerts/course-start-alert/CourseStartMasqueradeBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PageBanner } from '@edx/paragon';

import { useModel } from '../../generic/model-store';

function CourseStartMasqueradeBanner({ payload }) {
const CourseStartMasqueradeBanner = ({ payload }) => {
const {
courseId,
} = payload;
Expand Down Expand Up @@ -33,7 +33,7 @@ function CourseStartMasqueradeBanner({ payload }) {
/>
</PageBanner>
);
}
};

CourseStartMasqueradeBanner.propTypes = {
payload: PropTypes.shape({
Expand Down
18 changes: 9 additions & 9 deletions src/alerts/course-start-alert/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useModel } from '../../generic/model-store';
const CourseStartAlert = React.lazy(() => import('./CourseStartAlert'));
const CourseStartMasqueradeBanner = React.lazy(() => import('./CourseStartMasqueradeBanner'));

function isStartDateInFuture(courseId) {
function IsStartDateInFuture(courseId) {
const {
start,
} = useModel('courseHomeMeta', courseId);
Expand All @@ -20,15 +20,15 @@ function useCourseStartAlert(courseId) {
isEnrolled,
} = useModel('courseHomeMeta', courseId);

const isVisible = isEnrolled && isStartDateInFuture(courseId);
const isVisible = isEnrolled && IsStartDateInFuture(courseId);

const payload = {
const payload = useMemo(() => ({
courseId,
};
}), [courseId]);

useAlert(isVisible, {
code: 'clientCourseStartAlert',
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
topic: 'outline-course-alerts',
});

Expand All @@ -42,15 +42,15 @@ export function useCourseStartMasqueradeBanner(courseId, tab) {
isMasquerading,
} = useModel('courseHomeMeta', courseId);

const isVisible = isMasquerading && tab === 'progress' && isStartDateInFuture(courseId);
const isVisible = isMasquerading && tab === 'progress' && IsStartDateInFuture(courseId);

const payload = {
const payload = useMemo(() => ({
courseId,
};
}), [courseId]);

useAlert(isVisible, {
code: 'clientCourseStartMasqueradeBanner',
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
topic: 'instructor-toolbar-alerts',
});

Expand Down
4 changes: 2 additions & 2 deletions src/alerts/enrollment-alert/EnrollmentAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useModel } from '../../generic/model-store';
import messages from './messages';
import useEnrollClickHandler from './clickHook';

function EnrollmentAlert({ intl, payload }) {
const EnrollmentAlert = ({ intl, payload }) => {
const {
canEnroll,
courseId,
Expand Down Expand Up @@ -55,7 +55,7 @@ function EnrollmentAlert({ intl, payload }) {
</div>
</Alert>
);
}
};

EnrollmentAlert.propTypes = {
intl: intlShape.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/alerts/enrollment-alert/clickHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function useEnrollClickHandler(courseId, orgId, successText) {
});
global.location.reload();
});
}, [courseId]);
}, [addFlash, courseId, orgId, successText]);

return { enrollClickHandler, loading };
}
Expand Down
6 changes: 3 additions & 3 deletions src/alerts/enrollment-alert/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export function useEnrollmentAlert(courseId) {
* 3. the course is private.
*/
const isVisible = !enrolledUser && authenticatedUser !== null && privateOutline;
const payload = {
const payload = useMemo(() => ({
canEnroll: outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false,
courseId,
extraText: outline && outline.enrollAlert ? outline.enrollAlert.extraText : '',
isStaff: course && course.isStaff,
};
}), [course, courseId, outline]);

useAlert(isVisible, {
code: 'clientEnrollmentAlert',
payload: useMemo(() => payload, Object.values(payload).sort()),
payload,
topic: 'outline',
});

Expand Down
6 changes: 3 additions & 3 deletions src/alerts/logistration-alert/AccountActivationAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/
import { sendActivationEmail } from '../../courseware/data';
import messages from './messages';

function AccountActivationAlert({
const AccountActivationAlert = ({
intl,
}) {
}) => {
const [showModal, setShowModal] = useState(false);
const [showSpinner, setShowSpinner] = useState(false);
const [showCheck, setShowCheck] = useState(false);
Expand Down Expand Up @@ -123,7 +123,7 @@ function AccountActivationAlert({
{children()}
</AlertModal>
);
}
};

AccountActivationAlert.propTypes = {
intl: intlShape.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/alerts/logistration-alert/LogistrationAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WarningFilled } from '@edx/paragon/icons';

import genericMessages from '../../generic/messages';

function LogistrationAlert({ intl }) {
const LogistrationAlert = ({ intl }) => {
const signIn = (
<Hyperlink
style={{ textDecoration: 'underline' }}
Expand Down Expand Up @@ -41,7 +41,7 @@ function LogistrationAlert({ intl }) {
/>
</Alert>
);
}
};

LogistrationAlert.propTypes = {
intl: intlShape.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/course-home/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export async function getOutlineTabData(courseId) {
const timeOffsetMillis = getTimeOffsetMillis(headers && headers.date, requestTime, responseTime);
const userHasPassingGrade = data.user_has_passing_grade;
const verifiedMode = camelCaseObject(data.verified_mode);
const welcomeMessageHtml = data.welcome_message_html;
const welcomeMessageHtml = data.welcome_message_html || '';

return {
accessExpiration,
Expand Down
4 changes: 2 additions & 2 deletions src/course-home/dates-tab/DatesTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ShiftDatesAlert from '../suggested-schedule-messaging/ShiftDatesAlert';
import UpgradeToCompleteAlert from '../suggested-schedule-messaging/UpgradeToCompleteAlert';
import UpgradeToShiftDatesAlert from '../suggested-schedule-messaging/UpgradeToShiftDatesAlert';

function DatesTab({ intl }) {
const DatesTab = ({ intl }) => {
const {
courseId,
} = useSelector(state => state.courseHome);
Expand Down Expand Up @@ -57,7 +57,7 @@ function DatesTab({ intl }) {
<Timeline />
</>
);
}
};

DatesTab.propTypes = {
intl: intlShape.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions src/course-home/dates-tab/timeline/Day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import { useModel } from '../../../generic/model-store';
import { getBadgeListAndColor } from './badgelist';
import { isLearnerAssignment } from '../utils';

function Day({
const Day = ({
date,
first,
intl,
items,
last,
}) {
}) => {
const {
courseId,
} = useSelector(state => state.courseHome);
Expand Down Expand Up @@ -103,7 +103,7 @@ function Day({
</div>
</li>
);
}
};

Day.propTypes = {
date: PropTypes.objectOf(Date).isRequired,
Expand Down
6 changes: 4 additions & 2 deletions src/course-home/dates-tab/timeline/Timeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useModel } from '../../../generic/model-store';
import Day from './Day';
import { daycmp, isLearnerAssignment } from '../utils';

export default function Timeline() {
const Timeline = () => {
const {
courseId,
} = useSelector(state => state.courseHome);
Expand Down Expand Up @@ -67,4 +67,6 @@ export default function Timeline() {
))}
</ul>
);
}
};

export default Timeline;
4 changes: 2 additions & 2 deletions src/course-home/discussion-tab/DiscussionTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { generatePath, useHistory } from 'react-router';
import { useParams } from 'react-router-dom';
import { useIFrameHeight, useIFramePluginEvents } from '../../generic/hooks';

function DiscussionTab() {
const DiscussionTab = () => {
const { courseId } = useSelector(state => state.courseHome);
const { path } = useParams();
const [originalPath] = useState(path);
Expand All @@ -29,7 +29,7 @@ function DiscussionTab() {
title="discussion"
/>
);
}
};

DiscussionTab.propTypes = {};

Expand Down
Loading