Skip to content

Commit

Permalink
feat: Add visual indicator for closed courses (#6066)
Browse files Browse the repository at this point in the history
  • Loading branch information
swayam-agrahari authored Dec 18, 2024
1 parent 1e1e8b2 commit a8b016d
Showing 1 changed file with 52 additions and 30 deletions.
82 changes: 52 additions & 30 deletions app/assets/javascripts/components/overview/admin_quick_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,65 @@ const DetailsText = ({ flags }) => (
</p>
);

const isCourseClosed = flags => !!(flags && flags.closed_date);

const NoDetailsText = () => (
<p>
This course has not yet been marked as having been reviewed by a staff member.
Click below to mark it as reviewed!
</p>
);

export const AdminQuickActions = ({ course, current_user, persistCourse, greetStudents }) => (
<div className="module admin-quick-actions" style={{ textAlign: 'center' }}>
{current_user.isStaff && (
<>
{course.flags && course.flags.last_reviewed && course.flags.last_reviewed.username ? (
<DetailsText flags={course.flags} />
) : (
<NoDetailsText />
)}
<button
className="button mark-as-review"
onClick={() => {
course.last_reviewed = {
username: current_user.username,
timestamp: getUTCDateString(),
};
persistCourse(course.slug);
}}
>
Mark as Reviewed
</button>
<br />
<br />
<GreetStudentsButton course={course} current_user={current_user} greetStudents={greetStudents} />
<br />
</>
)}
{current_user.admin && <div><NotesPanel/><AdminStatusPanel course={course} /></div>}
</div>
);
export const AdminQuickActions = ({ course, current_user, persistCourse, greetStudents }) => {
const closedCourseStyle = isCourseClosed(course.flags)
? {
backgroundColor: '#f8d7da',
color: '#721c24',
padding: '15px',
borderRadius: '2px',
fontWeight: 'bold',
}
: {};

return (
<div className="module admin-quick-actions" style={{ textAlign: 'center', ...closedCourseStyle }}>
{isCourseClosed(course.flags) && (
<div style={{ marginBottom: '15px' }}>
<p>
<strong>This course was closed on:</strong>&nbsp;
{format(toDate(parseISO(course.flags.closed_date)), 'PPPP')}.
</p>
</div>
)}
{current_user.isStaff && (
<>
{course.flags && course.flags.last_reviewed && course.flags.last_reviewed.username ? (
<DetailsText flags={course.flags} />
) : (
<NoDetailsText />
)}
<button
className="button mark-as-review"
onClick={() => {
course.last_reviewed = {
username: current_user.username,
timestamp: getUTCDateString(),
};
persistCourse(course.slug);
}}
>
Mark as Reviewed
</button>
<br />
<br />
<GreetStudentsButton course={course} current_user={current_user} greetStudents={greetStudents} />
<br />
</>
)}
{current_user.admin && <div><NotesPanel /><AdminStatusPanel course={course} /></div>}
</div>
);
};

AdminQuickActions.propTypes = {
course: PropTypes.shape({
Expand Down

0 comments on commit a8b016d

Please sign in to comment.