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

fix: tinyMCELanguageSelectorPlugin error related to Button ID #991

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions src/components/EditCoursePage/CollapsibleCourseRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
copied: false,
returnFromStaffPage: false,
hasExternalKey: undefined,
isCourseRunInReview: false,
};

this.openCollapsible = this.openCollapsible.bind(this);
Expand Down Expand Up @@ -251,7 +252,7 @@
courseRunTypeOptions,
courseInfo,
} = this.props;
const { copied, hasExternalKey } = this.state;
const { copied, hasExternalKey, isCourseRunInReview } = this.state;
const { administrator } = getAuthenticatedUser();

const courseRunInReview = IN_REVIEW_STATUS.includes(courseRun.status);
Expand All @@ -278,6 +279,12 @@
const productSource = courseInfo?.data?.product_source?.slug;
const courseType = courseInfo?.data?.course_type;

if (IN_REVIEW_STATUS.includes(courseRun.status) !== isCourseRunInReview) {
setTimeout(() => {
this.setState({ isCourseRunInReview: IN_REVIEW_STATUS.includes(courseRun.status) });

Check warning on line 284 in src/components/EditCoursePage/CollapsibleCourseRun.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/EditCoursePage/CollapsibleCourseRun.jsx#L284

Added line #L284 was not covered by tests
}, 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

this 0.1 value -- what was the reason for selecting this value?

Copy link
Contributor Author

@AfaqShuaib09 AfaqShuaib09 Oct 31, 2024

Choose a reason for hiding this comment

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

I tried random values for the timeout, i.e. 500, 200, 100, 50. It's minimum value at which this error no longer appears.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is from your local testing, I would suggest keeping the deployment environment in mind when deciding this.

Copy link
Contributor Author

@AfaqShuaib09 AfaqShuaib09 Oct 31, 2024

Choose a reason for hiding this comment

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

Hmm, maybe we can increase the timeout a bit, or let's try this out on staging first to check if the error still appears (cause I don't want to add unnecessary delay in rendering of review related fields)

}

return (
<Collapsible
title={formatCourseRunTitle(courseRun, copied, this.setCopied)}
Expand Down Expand Up @@ -678,7 +685,7 @@
</div>
</div>
)}
{administrator && IN_REVIEW_STATUS.includes(courseRun.status)
{administrator && isCourseRunInReview
&& (
<div>
Status: {courseRun.status === REVIEW_BY_LEGAL ? 'Legal Review' : 'PC Review'}
Expand Down
13 changes: 13 additions & 0 deletions src/components/EditCoursePage/CollapsibleCourseRun.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const publishedCourseRun = {
};

const unpublishedCourseRun = { ...publishedCourseRun, status: 'unpublished' };
const inReviewCourseRun = { ...publishedCourseRun, status: 'review_by_internal' };

const currentFormValues = {
course_runs: [publishedCourseRun, unpublishedCourseRun],
Expand Down Expand Up @@ -96,6 +97,18 @@ describe('Collapsible Course Run', () => {
expect(shallowToJson(component)).toMatchSnapshot();
});

it('renders correctly when given a course run in review', () => {
const component = shallow(<CollapsibleCourseRun
languageOptions={languageOptions}
pacingTypeOptions={pacingTypeOptions}
courseRun={inReviewCourseRun}
courseId="test-course"
courseUuid="11111111-1111-1111-1111-111111111111"
index={2}
/>);
expect(shallowToJson(component)).toMatchSnapshot();
});

it('renders correctly with a course run type', () => {
const component = shallow(<CollapsibleCourseRun
languageOptions={languageOptions}
Expand Down
Loading
Loading