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

UI: Use HDS::Toast for flash messages #25459

Merged
merged 9 commits into from
Feb 16, 2024
Merged

Conversation

hashishaw
Copy link
Contributor

@hashishaw hashishaw commented Feb 15, 2024

This PR updates the Vault UI to use the HDS::Toast component with specified placement and spacing

Example of all the flash types

  • Ent tests pass

@hashishaw hashishaw added the ui label Feb 15, 2024
@hashishaw hashishaw added this to the 1.17.0-rc milestone Feb 15, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Feb 15, 2024
Copy link

github-actions bot commented Feb 15, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Feb 15, 2024

Build Results:
All builds succeeded! ✅

@@ -75,24 +75,7 @@
<div class="global-flash">
{{#each this.flashMessages.queue as |flash|}}
<FlashMessage data-test-flash-message={{true}} @flash={{flash}} as |customComponent flash close|>
{{#if flash.componentName}}
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 didn't see this setting used anywhere so I figured we can remove it

@@ -17,7 +17,6 @@ IF YOUR TOKEN HAS THE PROPER CAPABILITIES, THIS WILL CREATE AND DELETE ITEMS ON
Your token will also be shown on the screen in the example curl command output.`;
this.flashMessages.warning(warning, {
sticky: true,
preformatted: true,
Copy link
Contributor Author

@hashishaw hashishaw Feb 15, 2024

Choose a reason for hiding this comment

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

The new component renders this correctly by default:
Screenshot 2024-02-15 at 13 59 29

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes this build warning:

WARNING: Detected collisions between .js and .ts files of the same name. This can result in nondeterministic build output; see https://git.io/JvIwo for more information.
  - vault/services/flash-messages.{js,ts}

return 'highlight';
case 'danger':
return 'critical';
case 'warning':
Copy link
Contributor

Choose a reason for hiding this comment

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

is this supposed to return 'warning'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a shorthand for when type is warning or success, return the type


get title() {
if (this.args.title) return this.args.title;
switch (this.args.flash.type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I always forget that switch cases allow you to have default values!

Copy link
Contributor

@kiannaquach kiannaquach left a comment

Choose a reason for hiding this comment

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

yay thanks for adding this! 🎉

@hashishaw hashishaw merged commit c5d39c8 into main Feb 16, 2024
31 checks passed
@hashishaw hashishaw deleted the ui/hds-toast-flash-messages branch February 16, 2024 00:06
<Hds::Toast @color={{this.color}} @ class="has-bottom-margin-m" data-test-flash-toast as |T|>
<T.Title data-test-flash-toast-title>{{this.title}}</T.Title>
<T.Description data-test-flash-message-body>
<p class="is-word-break">{{@flash.message}}</p>
Copy link

@didoo didoo Feb 19, 2024

Choose a reason for hiding this comment

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

@hashishaw FYI the Description field of the Alert/Toast already breaking long words, so this could be simply:

<T.Description data-test-flash-message-body>{{@flash.message}}</T.Description>
screenshot_3524

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 ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants