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

feat: Suppress "Return to regular route" button for non-dispatchers #2811

Merged
Merged
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
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()
})
})
Loading