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

EES-4368 api data set preview token log #5125

Merged
merged 1 commit into from
Aug 7, 2024
Merged

EES-4368 api data set preview token log #5125

merged 1 commit into from
Aug 7, 2024

Conversation

amyb-hiveit
Copy link
Collaborator

Adds the preview token log page.

Screenshot 2024-08-05 174424

@amyb-hiveit amyb-hiveit requested a review from ntsim August 5, 2024 16:48
id: 'token-id-1',
label: 'Test label 1',
status: 'Active',
created: new Date('01-01-2024 14:00').toISOString(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would always declare dates with the standard ISO8601 format to avoid any ambiguity and be consistent with the rest of the codebase.

Also, constructing a Date to turn it back into an ISO8601 string is redundant. It'd be better to just omit this and write the ISO8601 string directly i.e. 2024-01-01T14:00Z.

Same applies to dates below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted, don't know why I did that 😆

Comment on lines +111 to +119
to={generatePath<ReleaseDataSetPreviewTokenRouteParams>(
releaseApiDataSetPreviewTokenRoute.path,
{
publicationId,
releaseId,
dataSetId,
previewTokenId: token.id,
},
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue here is that because we're also redirecting to this route after the user generates a new token, the breadcrumb doesn't quite make sense in both contexts:

image

If the user has come from the preview page (after generating the token), 'Go back to API data set details' makes sense.

If the user has come from the preview token log, 'Go back to API preview token log' would make more sense.

We could fix this by one of the following:

  1. Passing extra location state via the to prop and / or history.push. This state can then be accessed via useLocation in the preview token page.
  2. Using the useLastLocation hook on preview token page to check which path the user has come from.
  3. Changing the breadcrumb to always go back to the token log.

Option 3 is the simplest and may be sufficient, but feel free to consider the other options as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used useLastLocation to check the previous page and set the back link appropriately.

Comment on lines 182 to 191
const history = createMemoryHistory();

history.push(
generatePath<ReleaseDataSetRouteParams>(
releaseApiDataSetPreviewTokenLogRoute.path,
{
publicationId: testRelease.publicationId,
releaseId: testRelease.id,
dataSetId: 'data-set-id',
},
),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a biggy, but if we're not planning on checking the history, we could just use MemoryRouter with this route as an initial entry?


expect(previewTokenService.revokePreviewToken).toHaveBeenCalledWith(
'token-id-1',
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check that the table has been updated with the revoked token?

Comment on lines +127 to +130
<ButtonText className="govuk-!-margin-left-2">
Revoke
<VisuallyHidden> {token.label}</VisuallyHidden>
</ButtonText>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to comment above - there's a revoke token button on the preview token page. Upon revoking the token through this button, the user gets redirected to a page that might not necessarily make sense.

image

If the user has come from the preview page (after generating a token), then redirecting back to the preview page upon revoking the token makes sense.

If the user has come from the token log, then redirecting to the token log upon revoking the token makes more sense.

We'll want to consider a similar approach to the above comment to change this behaviour based on where the user has come from.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used useLastLocation to check the previous page and redirect appropriately after revoking.

Comment on lines 138 to 145
to={generatePath<ReleaseDataSetRouteParams>(
releaseApiDataSetPreviewTokenLogRoute.path,
{
publicationId,
releaseId,
dataSetId,
},
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use the tokenLogPagePath variable here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, done now cheers.

@amyb-hiveit amyb-hiveit merged commit c87dc7b into dev Aug 7, 2024
7 checks passed
@amyb-hiveit amyb-hiveit deleted the EES-4368 branch August 7, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants