-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[VAULT-34728] UI: prepare FormField template logic for migration to HDS components
#29944
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
[VAULT-34728] UI: prepare FormField template logic for migration to HDS components
#29944
Conversation
| {{#if this.isHdsFormField}} | ||
| {{! TODO the template logic for the form fields migrated to HDS will appear here }} | ||
| {{else}} | ||
| {{#unless this.hideLabel}} |
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.
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)
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.
|
Build Results: |
| 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) { |
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 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:
vault/ui/lib/core/addon/components/form-field.js
Lines 90 to 106 in 21a890a
| 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; | |
| } | |
| } | |
| } |
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 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!
|
CI Results: |
zofskeez
left a comment
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 makes good sense to me and I appreciate the incremental approach 🎉
hellobontempo
left a comment
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 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.
… HDS components (#29944) * [VAULT-34728] UI: added `isHdsFormField` logic to the `FormField` controller * [VAULT-34728] UI: added `isHdsFormField` logic to the `FormField` template

Description
What does this PR do?
This PR lays the groundwork for migrating (one by one) the different input types handled within the
FormFieldcomponent to their equivalent HDS components (eg. we will start withtextarea,password, genericselect, genericinput, 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/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.