Skip to content

Conversation

@didoo
Copy link
Collaborator

@didoo didoo commented Mar 17, 2025

Description

What does this PR do?

This PR lays the groundwork for migrating (one by one) the different input types handled within the FormField component to their equivalent HDS components (eg. we will start with textarea, password, generic select, generic input, etc)

For now the PR doesn't contain actual code migration, there are just placeholder comments. If you want to have an idea of what the migrated code would look like (approximately) have a look at this explorations/spike that I did, that led to this "official" PR: https://github.com/hashicorp/vault/pull/29943/files

The goal of this PR is to validate the approach with the Vault UI Engineers and see if this is a direction they approve, gather their feedback, and have them do a code review to see if things could be done in a different way.

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

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 didoo added this to the 1.20.0-rc milestone Mar 17, 2025
@didoo didoo requested a review from a team as a code owner March 17, 2025 20:09
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Mar 17, 2025
{{#if this.isHdsFormField}}
{{! TODO the template logic for the form fields migrated to HDS will appear here }}
{{else}}
{{#unless this.hideLabel}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a lot of code change here, but I've just nested the existing code under the {{else}} condition (which changed the code indentation)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the note! I often suggest folks review with "hide whitespace" if there's a code change like this
Screenshot 2025-03-18 at 10 16 41 AM

@github-actions
Copy link

Build Results:
All builds succeeded! ✅

const { type, options } = this.args.attr;

// here we replicate the logic in the template, to make sure we don't change the order in which the "ifs" are evaluated
if (options?.possibleValues?.length > 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole conditional logic will be little by little populated, depending on the component that are migrated to HDS. If you want to see an example have a look at this similar (spike) PR:

get isHdsFormField() {
const { type, options } = this.args.attr;
// here we replicate the logic in the template, to make sure we don't change the order in which the "ifs" are evaluated
if (options?.possibleValues?.length > 0) {
// for now we leave these fields as they are
return false;
} else {
// converted to HDS fields
if ((type === 'number' || type === 'string') && options?.editType === 'password') {
return true;
} else {
// everything is the same as before
return false;
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I desperately want to clean the template logic up, but I think this approach makes sense to streamline adoption and narrow the scope of this work as much as possible!

@github-actions
Copy link

CI Results:
All Go tests succeeded! ✅

Copy link
Contributor

@zofskeez zofskeez left a comment

Choose a reason for hiding this comment

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

This makes good sense to me and I appreciate the incremental approach 🎉

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.

I think this makes sense! I'm curious about the logic flow for displaying the actual HDS components, but this seems like a great way to tackle this work as non-invasively as possible.

@didoo didoo merged commit c11dfaa into main Mar 19, 2025
50 checks passed
@didoo didoo deleted the VAULT-34671/prepare-formfield-template-logic-for-hds__VAULT-34728 branch March 19, 2025 08:37
hellobontempo pushed a commit that referenced this pull request May 21, 2025
… HDS components (#29944)

* [VAULT-34728] UI: added `isHdsFormField` logic to the `FormField` controller

* [VAULT-34728] UI: added `isHdsFormField` logic to the `FormField` template
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.

3 participants