Skip to content

Commit

Permalink
feat: Suppress "Return to regular route" button for non-dispatchers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlarson authored Sep 26, 2024
1 parent 8d9d21d commit 8ed2dac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
18 changes: 10 additions & 8 deletions assets/src/components/detours/activeDetourPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ export const ActiveDetourPanel = ({
</Panel.Body.ScrollArea>

<Panel.Body.Footer>
<Button
variant="ui-alert"
className="flex-grow-1 m-3 icon-link text-light"
onClick={onOpenDeactivateModal}
>
<StopCircle />
Return to regular route
</Button>
{onOpenDeactivateModal && (
<Button
variant="ui-alert"
className="flex-grow-1 m-3 icon-link text-light"
onClick={onOpenDeactivateModal}
>
<StopCircle />
Return to regular route
</Button>
)}
</Panel.Body.Footer>
</Panel.Body>
{children}
Expand Down
10 changes: 7 additions & 3 deletions assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,13 @@ export const DiversionPage = ({
routeOrigin={routeOrigin ?? "??"}
routeDirection={routeDirection ?? "??"}
onNavigateBack={onConfirmClose}
onOpenDeactivateModal={() => {
send({ type: "detour.active.open-deactivate-modal" })
}}
onOpenDeactivateModal={
userInTestGroup(TestGroups.DetoursPilot)
? () => {
send({ type: "detour.active.open-deactivate-modal" })
}
: undefined
}
>
{snapshot.matches({
"Detour Drawing": { Active: "Deactivating" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,12 @@ describe("DiversionPage deactivate workflow", () => {

expect(returnModalHeading.query()).not.toBeInTheDocument()
})

test("does not have a 'Return to regular route' button for users who are not dispatchers", async () => {
jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList])

await diversionPageOnActiveDetourScreen()

expect(regularRouteButton.query()).not.toBeInTheDocument()
})
})

0 comments on commit 8ed2dac

Please sign in to comment.