Skip to content

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

Merged

Conversation

lane-wetmore
Copy link
Contributor

@lane-wetmore lane-wetmore commented Mar 31, 2025

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. Clicking Generate code on the details view.

TOTP.generate.code.mov

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    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.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Mar 31, 2025
Copy link

github-actions bot commented Mar 31, 2025

CI Results:
All Go tests succeeded! ✅

@lane-wetmore lane-wetmore marked this pull request as ready for review April 2, 2025 17:18
@lane-wetmore lane-wetmore requested a review from a team as a code owner April 2, 2025 17:18
Copy link

github-actions bot commented Apr 2, 2025

Build Results:
All builds succeeded! ✅

Comment on lines 63 to 65
@action redirectPreviousPage() {
window.history.back();
}
Copy link
Contributor

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.

Copy link
Contributor

@hellobontempo hellobontempo Apr 2, 2025

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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));
Copy link
Contributor

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}"]`,
Copy link
Contributor

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!

Copy link
Contributor

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();
Copy link
Contributor

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();
  }

Copy link
Contributor

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

Copy link
Contributor Author

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 😄

Copy link
Contributor

@emoncuso emoncuso left a 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")}}
Copy link
Contributor

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

Suggested change
{{on "click" (action "redirectPreviousPage")}}
{{on "click" this.redirectPreviousPage}}

@@ -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.`);
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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 awaited 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.

@lane-wetmore lane-wetmore changed the title UI/vault 34069 update read and generate flow UI: Update TOTP Code Generation + Details Flow Apr 2, 2025
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();
Copy link
Contributor

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

@lane-wetmore lane-wetmore merged commit 9185dd9 into ui-totp-sidebranch Apr 15, 2025
25 checks passed
@lane-wetmore lane-wetmore deleted the ui/VAULT-34069-Update-Read-and-Generate-Flow branch April 15, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants