Skip to content

Commit 3e930ee

Browse files
authored
UAI dashboard - unenrolled module card changes (#2231)
* hide the context menu on DashboardCard if status is not completed or enrolled * add new unenrolled status indicator * fix status indicator test
1 parent 039ac79 commit 3e930ee

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed
Lines changed: 3 additions & 0 deletions
Loading

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/DashboardCard.test.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,11 @@ describe.each([
305305
expectedLabel: "Enrolled",
306306
hiddenImage: true,
307307
},
308-
{ status: EnrollmentStatus.NotEnrolled, expectedLabel: "Not Enrolled" },
308+
{
309+
status: EnrollmentStatus.NotEnrolled,
310+
expectedLabel: "Not Enrolled",
311+
hiddenImage: true,
312+
},
309313
])(
310314
"Enrollment indicator shows meaningful text",
311315
({ status, expectedLabel, hiddenImage }) => {
@@ -345,6 +349,10 @@ describe.each([
345349
"getDefaultContextMenuItems returns correct items",
346350
async ({ contextMenuItems }) => {
347351
const course = dashboardCourse()
352+
course.enrollment = {
353+
status: EnrollmentStatus.Completed,
354+
mode: EnrollmentMode.Verified,
355+
}
348356
renderWithProviders(
349357
<DashboardCard
350358
dashboardResource={course}
@@ -372,4 +380,31 @@ describe.each([
372380
}
373381
},
374382
)
383+
384+
test.each([
385+
{ status: EnrollmentStatus.Completed },
386+
{ status: EnrollmentStatus.Enrolled },
387+
{ status: EnrollmentStatus.NotEnrolled },
388+
{ status: undefined },
389+
])(
390+
"Context menu button is not shown when enrollment status is not Completed or Enrolled",
391+
({ status }) => {
392+
renderWithProviders(
393+
<DashboardCard
394+
dashboardResource={dashboardCourse({ enrollment: { status } })}
395+
/>,
396+
)
397+
const card = getCard()
398+
const expectedVisible =
399+
status === EnrollmentStatus.Completed ||
400+
status === EnrollmentStatus.Enrolled
401+
const contextMenuButton = within(card).queryByRole("button", {
402+
name: "More options",
403+
hidden: !expectedVisible,
404+
})
405+
if (expectedVisible) {
406+
expect(contextMenuButton).toBeVisible()
407+
}
408+
},
409+
)
375410
})

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/DashboardCard.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,22 @@ const TitleLink = styled(Link)(({ theme }) => ({
6161
},
6262
}))
6363

64-
const MenuButton = styled(ActionButton)(({ theme }) => ({
65-
marginLeft: "-8px",
66-
[theme.breakpoints.down("md")]: {
67-
position: "absolute",
68-
top: "0",
69-
right: "0",
64+
const MenuButton = styled(ActionButton)<{
65+
status?: EnrollmentStatus
66+
}>(({ theme, status }) => [
67+
{
68+
marginLeft: "-8px",
69+
[theme.breakpoints.down("md")]: {
70+
position: "absolute",
71+
top: "0",
72+
right: "0",
73+
},
7074
},
71-
}))
75+
status !== EnrollmentStatus.Completed &&
76+
status !== EnrollmentStatus.Enrolled && {
77+
visibility: "hidden",
78+
},
79+
])
7280

7381
const getDefaultContextMenuItems = (title: string) => {
7482
return [
@@ -323,7 +331,12 @@ const DashboardCard: React.FC<DashboardCardProps> = ({
323331
<SimpleMenu
324332
items={menuItems}
325333
trigger={
326-
<MenuButton size="small" variant="text" aria-label="More options">
334+
<MenuButton
335+
size="small"
336+
variant="text"
337+
aria-label="More options"
338+
status={enrollment?.status}
339+
>
327340
<RiMore2Line />
328341
</MenuButton>
329342
}

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentStatusIndicator.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Image from "next/image"
33
import { styled, VisuallyHidden } from "ol-components"
44
import CourseComplete from "@/public/images/icons/course-complete.svg"
55
import CourseInProgress from "@/public/images/icons/course-in-progress.svg"
6+
import CourseUnenrolled from "@/public/images/icons/course-unenrolled.svg"
67
import { EnrollmentStatus } from "./types"
78

89
const CompletedImage = styled(Image)({
@@ -63,6 +64,12 @@ const EnrollmentStatusIndicator: React.FC<EnrollmentStatusIndicatorProps> = ({
6364

6465
return (
6566
<Ring data-testid="enrollment-status">
67+
<Image
68+
src={CourseUnenrolled}
69+
alt=""
70+
// use VisuallyHidden text for consistency with the non-image case.
71+
aria-hidden
72+
/>
6673
<VisuallyHidden>Not Enrolled</VisuallyHidden>
6774
</Ring>
6875
)

0 commit comments

Comments
 (0)