Skip to content

Conversation

@didoo
Copy link
Collaborator

@didoo didoo commented Mar 19, 2025

Description

What does this PR do?

  • moved template logic for checkboxList of FilterInput under the isHdsField block
  • added handling of label/helpText/subText/docLink + validation errors message for checkboxList
  • moved validationWarning block out of the conditional so it can serve both HDS and non-HDS use cases

Jira ticket: https://hashicorp.atlassian.net/browse/VAULT-34792

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.

didoo added 3 commits March 19, 2025 13:09
…errors message for `checkboxList` (#34792)

(now that is not anymore handled by the shared initial/final blocks of code)
… serve both HDS and non-HDS use cases (#34792)
@didoo didoo added this to the 1.20.0-rc milestone Mar 19, 2025
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Mar 19, 2025
@github-actions
Copy link

CI Results:
All Go tests succeeded! ✅

@didoo didoo marked this pull request as ready for review March 19, 2025 14:02
@didoo didoo requested a review from a team as a code owner March 19, 2025 14:02
@github-actions
Copy link

Build Results:
All builds succeeded! ✅

{{#if this.labelString}}
<G.Legend data-test-form-field-label>{{this.labelString}}</G.Legend>
{{/if}}
{{#if this.showHelpText}}
Copy link
Contributor

Choose a reason for hiding this comment

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

This getter doesn't account for checking if there's helpText, I wonder if we should update that there so this div doesn't render unless helpText exists (instead of having to add it to every conditional wrapping helper text)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hellobontempo what do you prefer? I can update the getter in this PR, or I can create a separate PR for this (no biggie, I just want to follow your existing processes).

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code again, it looks like there is some additional cleanup worth tackling all at once. (Since FormFieldLabel relies on the boolean to pass along the helpText or not). If you want to tackle all of that now, a separate PR may be best. Though I think adding the second check here {{#if (and this.showHelpText @attr.options.helpText)}} might be smoothest for now and that tech cleanup can be postponed until the end. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you look at this PR #29960 you will see that the code is being duplicated here and here (and will be duplicated even more, the more we migrate components here; I am going to think how to abstract this "thing" once we have a few more instances, so for now we have to live with that duplication)

All to say that probably is better to do this at getter level, already (now). I am going to open a PR for this, as parallel stream of work.

Copy link
Contributor

@hellobontempo hellobontempo Mar 19, 2025

Choose a reason for hiding this comment

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

Great! I agree (just didn't want to disrupt your workflow 😄 )
Consolidating the getter to be something like this probably makes sense, and removing all references to @attr.options.helpText but I'll defer to you since you're in the thick of all that logic now.

  get showHelpText() {
    const { options } = this.args.attr;
    if (this.args.showHelpText !== false && options.helpText) return options.helpText;
    return '';
  }

// we leave these fields as they are (for now)
return false;
if (options?.editType === 'checkboxList') {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 one down!! 🎉

{{/if}}
{{#each @attr.options.possibleValues as |option|}}
<G.CheckboxField
checked={{includes option (get @model this.valuePath)}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Mongey @hellobontempo in one of my tests/spikes I added a comment here that says:

TODO! here I've replaced includes with eq because it was not working: includes expects a list/array as second argument, while here we're passing a single value - see: https://github.com/DockYard/ember-composable-helpers?tab=readme-ov-file#includes

and then changed the line to

checked={{eq option (get @model this.valuePath)}}

But I imagine is working correctly in production, so probably nothing to see here. But I wanted to raise it anyway, because I noticed the comment in one of my branches and I wanted to double check with you (that have a little bit more context/knowledge of the codebase :) )

Copy link
Contributor

@hellobontempo hellobontempo Mar 19, 2025

Choose a reason for hiding this comment

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

Thanks for calling this out. When I implemented this originally get @model this.valuePath is an array. So it sounds like we might need to make the input more flexible 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, since multiple items can be selected I think it makes sense to keep the model value type an array (and no need to make it flexible and accept different value types)

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

Great work! 🚀

As I understand it, we'll leave the showHelpText conditional for now (which renders an extra <div> if there's no help text) and update the getter separately to check for attr.options.helpText in a parallel PR)

@didoo didoo merged commit 00ef06a into main Mar 19, 2025
33 checks passed
@didoo didoo deleted the VAULT-34671/refactor-formfield-checkboxlist_VAULT-34792 branch March 19, 2025 17:46
hellobontempo pushed a commit that referenced this pull request May 21, 2025
…xList` under the newly added HDS block (#29958)

* [UI] moved template logic for `checkboxList` of `FilterInput` under the `isHdsField` block (#34792)

* [UI] added handling of `label/helpText/subText/docLink` + validation errors message for `checkboxList` (#34792)

(now that is not anymore handled by the shared initial/final blocks of code)

* [UI] moved `validationWarning` block out of the conditional so it can serve both HDS and non-HDS use cases (#34792)

* [UI] removed `has-error-border` class on validation error (not conformant with HDS specs) (#34792)
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 hds-service HDS Service pr/no-changelog ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants