-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
PKI role non-default options #17393
PKI role non-default options #17393
Conversation
> | ||
<RadioSelectTtlOrString @model={{@model}} @attr={{attr}} /> | ||
</FormFieldGroupsLoop> | ||
{{#each @model.fieldGroups as |fieldGroup|}} |
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.
ended up not being able to use FormFieldGroupsLoop
for two main reasons:
- because there is a lot of custom work required to make the CSS grid for Key Usage work, and it didn't make sense to apply that logic to a widely used component where PKI might be a unique situation where CSS grid is needed.
- I needed to pass in a conditional attr when dealing with key_bits, this complicated a whole mess of things and again is a one off situation specific to pki.
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.
Wow lots of work here good job. I left some comments but mainly want to discuss the serializer work further.
{{#each fields as |attr|}} | ||
<FormField | ||
data-test-field={{true}} | ||
@attr={{if (eq attr.name "keyBits") @model.keyBitsConditional attr}} |
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 wonder if it would be tidier to do this in the fieldGroups
getter on the model instead? After doing fieldToAttrs
you could replace the keyBits
attr with the result from the keyBitsConditional
getter.
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 couldn't get that to work. And it doesn't feel cleaner in the model because I have to really dig into the _fieldToAttrsGroups.
// inside the model on row 256, just before I return this_fieldToAttrsGroups
this._fieldToAttrsGroups[2]['Key parameters'][2] = this.keyBitsConditional;
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.
Thoughts?
import Component from '@glimmer/component'; | ||
|
||
/** | ||
* @module FormFieldGroupsLoop | ||
* FormFieldGroupsLoop components loop through the "groups" set on a model and display them either as default or behind toggle components. | ||
* | ||
* @example | ||
* ```js | ||
<FormFieldGroupsLoop @model={{this.model}} @mode={{if @model.isNew "create" "update"}}/> | ||
* ``` | ||
* @param {class} model - The routes model class. | ||
* @param {string} mode - "create" or "update" used to hide the name form field. TODO: not ideal, would prefer to disable it to follow new design patterns. | ||
* @param {function} [modelValidations] - Passed through to formField. | ||
* @param {boolean} [showHelpText] - Passed through to formField. | ||
*/ | ||
/* eslint ember/no-empty-glimmer-component-classes: 'warn' */ | ||
export default class FormFieldGroupsLoop extends Component {} |
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 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.
Left some comments! Kind of have wonky end of day brain, but I'll revisit tomorrow!
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.
Great work on this so far! It's so nice seeing the PKI work come together 😄
/> | ||
{{#if (get @model prop)}} | ||
<div class="box is-tall is-marginless"> | ||
<FormFieldLabel |
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.
🎉
* @param {string} group - The name of the group created in the model. In this case, it's the "Key usage" group. | ||
*/ | ||
|
||
const KEY_USAGE_FIELDS = { |
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.
Nice! I think this is much clearer with the label attr removed 😄
CrlSign: { label: 'CRL Sign' }, | ||
KeyAgreement: { | ||
label: 'Key Agreement', | ||
value: true, |
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 setting these values here means that they will always be true. So when editing a role, these will always change back to true
regardless of what the @model
value is..
Starting to think that writing component tests earlier than later for these forms will save a bunch of time/energy speculating the various what ifs
for this form 🤔
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 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.
So by default are all the true
values checked? And then what happens when editing and the model has false
values instead?
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.
By default the true values are checked. On any click for any of the checkboxes it updates the keyUsage list. So if it has a false value it's removed from the list. In the screenshot only Key Encipherment is checked, so it's the only one in the list.
CodeSigning: { label: 'Code Signing' }, | ||
}; | ||
|
||
export default class PkiKeyUsage extends Component { |
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 a test for this component would be 😍
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.
Just a few small cleanup comments. Really great work on this! All of that custom form work is 🤯
ed25519: [0], | ||
any: [0], | ||
}; | ||
const attrs = expandAttributeMeta(this, ['keyBits']); |
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.
👏
@@ -9,15 +9,15 @@ | |||
) | |||
) | |||
}} | |||
{{#unless (eq @attr.type "object")}} | |||
{{#if (not (or (eq @attr.type "object") (eq @attr.options.editType "moreInfo")))}} |
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 we can revert this back and remove moreInfo
@@ -21,7 +21,7 @@ import { dasherize } from 'vault/helpers/dasherize'; | |||
* label: "Foo", // custom label to be shown, otherwise attr.name will be displayed | |||
* defaultValue: "", // default value to display if model value is not present | |||
* fieldValue: "bar", // used for value lookup on model over attr.name | |||
* editType: "ttl", type of field to use. List of editTypes:boolean, file, json, kv, optionalText, mountAccessor, password, radio, regex, searchSelect, stringArray,textarea, ttl, yield. | |||
* editType: "ttl", type of field to use. List of editTypes:boolean, file, json, kv, optionalText, mountAccessor, moreInfo, password, radio, regex, searchSelect, stringArray, textarea, ttl, yield. |
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.
moreInfo
can be removed here, too?
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.
Ug, I know I did a whole search for moreInfo, but I've been working off this branch for testing and I think I messed up a push 🤦🏻♀️
CrlSign: { label: 'CRL Sign' }, | ||
KeyAgreement: { | ||
label: 'Key Agreement', | ||
value: true, |
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.
So by default are all the true
values checked? And then what happens when editing and the model has false
values instead?
const value = event.target['checked']; | ||
type === 'keyUsage' | ||
? this.args.model.set('keyUsage', this._amendList(checkboxName, value, type)) | ||
: this.args.model.set('extKeyUsage', this._amendList(checkboxName, value, type)); |
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.
if type
is the attr name on the model could the conditional be removed and this change to:
: this.args.model.set('extKeyUsage', this._amendList(checkboxName, value, type)); | |
this.args.model.set(type, this._amendList(checkboxName, value, type)); |
or, since this component is glimmerized, do we need to use `.set` here?
: this.args.model.set('extKeyUsage', this._amendList(checkboxName, value, type)); | |
this.args.model[type] = this._amendList(checkboxName, value, type) |
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.
Nice, yep. This works: this.args.model.set(type, this._amendList(checkboxName, value, type));
/> | ||
{{#if (get @model prop)}} | ||
<div class="box is-marginless"> | ||
{{#let (get @model.fieldGroupsInfo group) as |groupInfo|}} |
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.
🎉
* dynamically render the secretlistheader in the parent route. * start getting form setup even without openAPi working * add in create and cancel * making openAPI work * add default openAPI params * wip for new component with two radio options a ttl and input * handle createRecord on pki-roles-form * remove tooltips and cleanup * move formfieldgroupsloop back to non addon * cleanup * move secretListHeader * broadcast from radioSelectTtlOrString to parent * cleanup * hide tooltips * pass through sub text to stringArray * Add conditional for keybits and keyType * set defaults for keyBits ... 🤮 * fix some small issues * more info form field typ * show only label and subText * wip context switch 🤮 * fix dontShowLabel * getting css grid setup * more on flex groups * adding the second chunk to key usage * serialize the post for key_usage * finish for ext_key_usage * clean up * fix snack_case issue * commit for working state, next trying to remove form-field-group-loops because it's causing issues. * remove usage of formfieldgroupsloop because of issues with css grid and conditionals * clean up * remove string-list helpText changes for tooltip removal because that should be it's own pr. * clarification from design and backend. * small cleanup * pull key_usage and ext_key_usage out of the model and into a component * clean up * clean up * restructure css grid: * clean up * broke some things * fix error when roles list returned 404 * claires feedback * cleanup * clean up
2 of 3 PRs needed to finish the PKI Roles Create View
This PR handles the three Toggle Options: Domain handling, Key parameters, and Key usage.
Some notes:
Domain handling needed another kind of formField option that only showed a more-info type callout.
Key Parameters two special cases:
a. it needed a subText formField with no input and no label.
b. the
keyBits
param'spossibleValues
are conditional depending on whatkeyType
the user selected.https://user-images.githubusercontent.com/6618863/194140779-529f7d70-08e1-4182-90bf-6090d6189b9d.mov
Key Usage needed to use CSS Grid to match the designs AND all those checkboxes are just list items, not actually API params, so I append them to the
ext_key_usage
andkey_usage
parameters in a component.You can see why I stopped at this PR instead of finishing the view. This custom functionality is outside our normal patterns so a lot of custom work and modifications to formFields, etc had to be made, but in the end it makes PKI a LOT easier for users to navigate.
TODO: