Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 25, 2024
1 parent 34bd54c commit 4e12e3e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/course-outline/section-card/SectionCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const SectionCard = ({
isSelfPaced={isSelfPaced}
isCustomRelativeDatesActive={isCustomRelativeDatesActive}
item={section}
/>
/>
<div className="outline-section__status">
<Button
className="section-card__highlights"
Expand Down
65 changes: 34 additions & 31 deletions src/course-outline/xblock-status/XBlockStatus.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import React from 'react';
import PropTypes from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import { Icon, PageBanner } from '@edx/paragon';
import { Icon } from '@edx/paragon';
import {
Check as CheckIcon,
AccessTime as ClockIcon,
Expand Down Expand Up @@ -50,9 +50,9 @@ const XBlockStatus = ({

let releaseLabel = messages.unscheduledLabel;
if (releasedToStudents) {
releaseLabel = messages.releasedLabel
releaseLabel = messages.releasedLabel;
} else if (releaseDate) {
releaseLabel = messages.scheduledLabel
releaseLabel = messages.scheduledLabel;
}

let examValue = '';
Expand All @@ -73,18 +73,17 @@ const XBlockStatus = ({
prereqs.forEach((block) => {
if (block.blockUsageKey === prereq) {
prereqDisplayName = block.blockDisplayName;
return;
}
});
statusMessages.push({
icon: LockIcon,
text: intl.formatMessage(messages.prerequisiteLabel, { prereqDisplayName })
})
text: intl.formatMessage(messages.prerequisiteLabel, { prereqDisplayName }),
});
}

if (!staffOnlyMessage && isVertical) {
const { selectedPartitionIndex, selectedGroupsLabel } = userPartitionInfo;
if (selectedPartitionIndex !== -1 && !isNaN(selectedPartitionIndex)) {
if (selectedPartitionIndex !== -1 && !Number.isNaN(selectedPartitionIndex)) {
statusMessages.push({
icon: GroupsIcon,
text: intl.formatMessage(messages.restrictedUnitAccess, { selectedGroupsLabel }),
Expand All @@ -106,7 +105,7 @@ const XBlockStatus = ({
{intl.formatMessage(releaseLabel)}
{releaseDate && releaseDate}
</div>
)
);

const gradingTypeDiv = () => (
<div className="d-flex align-items-center mr-1" data-testid="grading-type-div">
Expand All @@ -118,17 +117,18 @@ const XBlockStatus = ({
{gradingType || intl.formatMessage(messages.ungradedText)}
</span>
</div>
)
);

const dueDateDiv = () => {
if (dueDate && isInstructorPaced) {
return (
<div className="status-grading-date" data-testid="due-date-div">
{intl.formatMessage(messages.dueLabel)} {dueDate}
</div>
)
);
}
}
return null;
};

const selfPacedRelativeDueWeeksDiv = () => (
<div className="d-flex align-items-center" data-testid="self-paced-relative-due-weeks-div">
Expand All @@ -137,13 +137,13 @@ const XBlockStatus = ({
{intl.formatMessage(messages.customDueDateLabel, { relativeWeeksDue })}
</span>
</div>
)
);

const explanatoryMessageDiv = () => (
<span data-testid='explanatory-message-span'>
<span data-testid="explanatory-message-span">
{explanatoryMessage}
</span>
)
);

const renderGradingTypeAndDueDate = () => {
const showRelativeWeeks = isSelfPaced && isCustomRelativeDatesActive && relativeWeeksDue;
Expand All @@ -160,8 +160,8 @@ const XBlockStatus = ({
</div>
{showRelativeWeeks && (selfPacedRelativeDueWeeksDiv())}
</>
)
} else if ((dueDate && !isSelfPaced) || graded) {
);
} if ((dueDate && !isSelfPaced) || graded) {
return (
<>
<div className="d-flex align-items-center">
Expand All @@ -170,16 +170,17 @@ const XBlockStatus = ({
</div>
{showRelativeWeeks && (selfPacedRelativeDueWeeksDiv())}
</>
)
} else if (showRelativeWeeks) {
);
} if (showRelativeWeeks) {
return (

Check warning on line 175 in src/course-outline/xblock-status/XBlockStatus.jsx

View check run for this annotation

Codecov / codecov/patch

src/course-outline/xblock-status/XBlockStatus.jsx#L175

Added line #L175 was not covered by tests
<>
{gradingTypeDiv()}
{selfPacedRelativeDueWeeksDiv()}
</>
)
);
}
}
return null;
};

const hideAfterDueMessage = () => (
<div className="d-flex align-items-center" data-testid="hide-after-due-message">
Expand All @@ -190,7 +191,7 @@ const XBlockStatus = ({
: intl.formatMessage(messages.hiddenAfterDueDate)}
</span>
</div>
)
);

const renderGradingPolicyAlert = () => {
let gradingPolicyMismatch = false;
Expand All @@ -211,9 +212,10 @@ const XBlockStatus = ({
<Icon className="mr-1 text-warning" size="lg" src={WarningIcon} />
{intl.formatMessage(messages.gradingPolicyMismatchText, { gradingType })}
</div>
)
);
}
}
return null;
};

const renderStatusMessages = () => {
if (statusMessages.length > 0) {
Expand All @@ -226,22 +228,23 @@ const XBlockStatus = ({
</div>
))}
</div>
)
);
}
}
return null;
};

return (
<div className="text-secondary-400 x-small mb-1">
{!isVertical && (
explanatoryMessage ? explanatoryMessageDiv(): isInstructorPaced && releaseStatusDiv()
explanatoryMessage ? explanatoryMessageDiv() : isInstructorPaced && releaseStatusDiv()
)}
{!isVertical && renderGradingTypeAndDueDate()}
{hideAfterDue && hideAfterDueMessage()}
{renderStatusMessages()}
{renderGradingPolicyAlert()}
</div>
)
}
);
};

XBlockStatus.defaultProps = {
isCustomRelativeDatesActive: false,
Expand Down Expand Up @@ -269,14 +272,14 @@ XBlockStatus.propTypes = {
selectedGroupsLabel: PropTypes.string.isRequired,
}),
hasPartitionGroupComponents: PropTypes.bool.isRequired,
gradingType: PropTypes.string,
format: PropTypes.string,
dueDate: PropTypes.string,
relativeWeeksDue: PropTypes.number,
isTimeLimited: PropTypes.bool,
graded: PropTypes.bool,
courseGraders: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
hideAfterDue: PropTypes.bool,
})
}).isRequired,
};

export default XBlockStatus;
28 changes: 13 additions & 15 deletions src/course-outline/xblock-status/XBlockStatus.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import {
act, render, fireEvent, within,
} from '@testing-library/react';
import { render } from '@testing-library/react';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import { AppProvider } from '@edx/frontend-platform/react';
import { initializeMockApp } from '@edx/frontend-platform';
Expand Down Expand Up @@ -40,7 +38,7 @@ const section = {
staffOnlyMessage: false,
userPartitionInfo: {
selectedPartitionIndex: -1,
selectedGroupsLabel: "",
selectedGroupsLabel: '',
},
hasPartitionGroupComponents: false,
format: 'Homework',
Expand Down Expand Up @@ -83,7 +81,7 @@ describe('<XBlockStatus /> for Instructor paced Section', () => {
item: {
...section,
explanatoryMessage: 'some explanatory message',
}
},
});

expect(queryByTestId('explanatory-message-span')).toBeInTheDocument();
Expand All @@ -99,7 +97,7 @@ describe('<XBlockStatus /> for Instructor paced Section', () => {
const releaseStatusDiv = queryByTestId('release-status-div');
expect(releaseStatusDiv).toBeInTheDocument();
expect(releaseStatusDiv).toHaveTextContent(
`${messages.releasedLabel.defaultMessage}${section.releaseDate}`
`${messages.releasedLabel.defaultMessage}${section.releaseDate}`,
);

// check grading type
Expand All @@ -114,7 +112,7 @@ describe('<XBlockStatus /> for Instructor paced Section', () => {
const dueDateDiv = queryByTestId('due-date-div');
expect(dueDateDiv).toBeInTheDocument();
expect(dueDateDiv).toHaveTextContent(
`${messages.dueLabel.defaultMessage} ${section.dueDate}`
`${messages.dueLabel.defaultMessage} ${section.dueDate}`,
);
// self paced weeks should not be visible as
// isSelfPaced is false as well as isCustomRelativeDatesActive is false
Expand Down Expand Up @@ -170,7 +168,7 @@ describe('<XBlockStatus /> for self paced Section', () => {
const selfPacedRelativeDueWeeksDiv = queryByTestId('self-paced-relative-due-weeks-div');
expect(selfPacedRelativeDueWeeksDiv).toBeInTheDocument();
expect(selfPacedRelativeDueWeeksDiv).toHaveTextContent(
messages.customDueDateLabel.defaultMessage
messages.customDueDateLabel.defaultMessage,
);

// check hide after due date message
Expand Down Expand Up @@ -225,7 +223,7 @@ const subsection = {
staffOnlyMessage: false,
userPartitionInfo: {
selectedPartitionIndex: -1,
selectedGroupsLabel: "",
selectedGroupsLabel: '',
},
hasPartitionGroupComponents: false,
format: 'Homework',
Expand Down Expand Up @@ -259,7 +257,7 @@ describe('<XBlockStatus /> for Instructor paced Subsection', () => {
const releaseStatusDiv = queryByTestId('release-status-div');
expect(releaseStatusDiv).toBeInTheDocument();
expect(releaseStatusDiv).toHaveTextContent(
`${messages.scheduledLabel.defaultMessage}${subsection.releaseDate}`
`${messages.scheduledLabel.defaultMessage}${subsection.releaseDate}`,
);

// check grading type
Expand All @@ -274,7 +272,7 @@ describe('<XBlockStatus /> for Instructor paced Subsection', () => {
const dueDateDiv = queryByTestId('due-date-div');
expect(dueDateDiv).toBeInTheDocument();
expect(dueDateDiv).toHaveTextContent(
`${messages.dueLabel.defaultMessage} ${subsection.dueDate}`
`${messages.dueLabel.defaultMessage} ${subsection.dueDate}`,
);
// self paced weeks should not be visible as
// isSelfPaced is false as well as isCustomRelativeDatesActive is false
Expand Down Expand Up @@ -358,7 +356,7 @@ describe('<XBlockStatus /> for Instructor paced Subsection', () => {
const dueDateDiv = queryByTestId('due-date-div');
expect(dueDateDiv).toBeInTheDocument();
expect(dueDateDiv).toHaveTextContent(
`${messages.dueLabel.defaultMessage} ${subsection.dueDate}`
`${messages.dueLabel.defaultMessage} ${subsection.dueDate}`,
);
// self paced weeks should not be visible as
// isSelfPaced is false as well as isCustomRelativeDatesActive is false
Expand Down Expand Up @@ -405,7 +403,7 @@ describe('<XBlockStatus /> for self paced Subsection', () => {
const selfPacedRelativeDueWeeksDiv = queryByTestId('self-paced-relative-due-weeks-div');
expect(selfPacedRelativeDueWeeksDiv).toBeInTheDocument();
expect(selfPacedRelativeDueWeeksDiv).toHaveTextContent(
messages.customDueDateLabel.defaultMessage
messages.customDueDateLabel.defaultMessage,
);

// check hide after due date message
Expand Down Expand Up @@ -437,7 +435,7 @@ const unit = {
staffOnlyMessage: false,
userPartitionInfo: {
selectedPartitionIndex: 1,
selectedGroupsLabel: "Some label",
selectedGroupsLabel: 'Some label',
},
hasPartitionGroupComponents: false,
format: 'Homework',
Expand Down Expand Up @@ -493,7 +491,7 @@ describe('<XBlockStatus /> for unit', () => {
hasPartitionGroupComponents: true,
userPartitionInfo: {
selectedPartitionIndex: -1,
selectedGroupsLabel: "",
selectedGroupsLabel: '',
},
},
});
Expand Down
1 change: 0 additions & 1 deletion src/course-outline/xblock-status/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ const messages = defineMessages({
});

export default messages;

0 comments on commit 4e12e3e

Please sign in to comment.