-
Notifications
You must be signed in to change notification settings - Fork 4.3k
UI: Update TOTP Code Generation + Details Flow #30123
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
UI: Update TOTP Code Generation + Details Flow #30123
Conversation
CI Results: |
Build Results: |
@action redirectPreviousPage() { | ||
window.history.back(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious on the decision to not use the router here and thinking of some potential issues. One possibility is a user direct linking from somewhere other than Vault and if they are authenticated then history.back()
would then take them out of Vault. Another case might be if there was previously a redirect to the login route (token expired) and on successful login the user is returned here, they would then be taken back to the login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plus one to this, we should know where the user goes in this case and do something like this in the template or like this in the component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are good points. I had looked at this for reference, but it seems like it doesn't suit this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a comment explaining this, but the reason I added this and removed the direct route was that there are two pages that enter this code generation view. So I wanted the back button to navigate the user to either the details view or the list view depending on which one the user came from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up grabbing the previous route and passing it along from the route file. Let me know what you think 😄
} catch (err) { | ||
// err will display via model state | ||
return; | ||
this.flashMessages.danger(errorMessage(err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@@ -34,6 +34,7 @@ export const GENERAL = { | |||
emptyStateMessage: '[data-test-empty-state-message]', | |||
emptyStateActions: '[data-test-empty-state-actions]', | |||
menuTrigger: '[data-test-popup-menu-trigger]', | |||
menuItem: (name: string) => `[data-test-popup-menu="${name}"]`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a common thing to click. Thanks for adding it in here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job with the test coverage!
@@ -58,4 +59,8 @@ export default class GenerateCredentialsTotp extends Component { | |||
return; | |||
} | |||
} | |||
|
|||
@action redirectPreviousPage() { | |||
window.history.back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to accomplish this utilizing the router instead? like
export default class GenerateCredentialsTotp extends Component {
@service router;
...
@action redirectPreviousPage() {
router.goBack();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this as well. I don't know if the ember router has a back
method, but you can explicitly choose point it back to the TOTP list page with transitionTo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up grabbing the previous route and passing it along from the route file. Let me know what you think 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one quick modernization change!
Otherwise looks good!
@@ -40,8 +40,7 @@ | |||
<Hds::Button | |||
@text="Back" | |||
@color="secondary" | |||
@route="vault.cluster.secrets.backend.list-root" | |||
@model={{this.backendPath}} | |||
{{on "click" (action "redirectPreviousPage")}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use the more modern style
{{on "click" (action "redirectPreviousPage")}} | |
{{on "click" this.redirectPreviousPage}} |
ui/app/components/totp-edit.js
Outdated
@@ -70,11 +71,10 @@ export default class TotpEdit extends Component { | |||
try { | |||
await this.args.model.destroyRecord(); | |||
this.transitionToRoute(LIST_ROOT_ROUTE); | |||
this.flashMessages.success(`${this.args.model.id} was successfully deleted.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this render as expected? since the model is destroyed, i'm not sure id
will have a value. we could save it as a const above line 72 and interpolate that here instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but I could see that being a bit uncertain, so I can update it just to be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if the transition was await
ed that would be the case but since it's synchronous the component isn't torn down before this fires (disclaimer: haven't actually tested 😁). But I agree that from a code flow standpoint it would be better to move it before.
Co-authored-by: Shannon Roberts (Beagin) <beagins@users.noreply.github.com>
@@ -58,4 +59,8 @@ export default class GenerateCredentialsTotp extends Component { | |||
return; | |||
} | |||
} | |||
|
|||
@action redirectPreviousPage() { | |||
window.history.back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this as well. I don't know if the ember router has a back
method, but you can explicitly choose point it back to the TOTP list page with transitionTo
Description
This PR updates the flow of generating a code and viewing the details page to align with the latest design. It also adds component tests.
Previously when selecting an item from the list, it would navigate to the code generation view. Now, it will navigate to the details view.
TOTP.details.view.mov
The code generation page can be accessed two ways: 1. By clicking the
Generate Code
menu dropdown option in the list view and 2. ClickingGenerate code
on the details view.TOTP.generate.code.mov
TODO only if you're a HashiCorp employee
backport/
label that matches the desired release branch. Note that in the CE repo, the latest release branch will look likebackport/x.x.x
, but older release branches will bebackport/ent/x.x.x+ent
.of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.