-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 (sidebranch) WIF Issuer field #28187
UI (sidebranch) WIF Issuer field #28187
Conversation
original = ''; | ||
@tracked issuer = ''; | ||
@tracked noRead = false; | ||
init(initialIssuer: string | undefined) { |
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 was reading a little about init()
vs constructor()
is there a reason you opted to use init()
here?
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.
Since I need to pass in an arg, I wasn't sure if that was going to be available on constructor. I can try it though
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 guess here, but because she calls the init
method later. You initialize the class, and init gets called, but you can also then call init outside the class to isolate calling that specific method? Learning alongside you.
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.
Oh no need to change it, I was just curious if there was a reason! I can read up more on the pros/cons of each one. I do know that you can still pass args using constructor, I used it in the kv patch form.
Yep, Angel from what I was reading init can be called when a class is partially instantiated? Whereas the constructor is before.
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.
Feel free to share what you find! Since the constructor can be called with the arg I like that, but open to pros/cons
} | ||
} | ||
// this is to make it work with FormField | ||
@action set(_: string, val: string) { |
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.
Do you need @action
here?
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 believe so, but I can play around with it
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.
commenting so I can learn here as well (or correct my understanding), but if I remember right the action decorator binds the function directly to the instance of the class it's called from. So by calling this
in the action, you know that this
refers to the class it's within. I believe this is a bigger deal when you're passing actions around, but please correct me if that's wrong.
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.
Good memory Angel, and well said! I believe this is the case
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.
Awesome! But this is a javascript class, right? I thought the @action
decorator was specific to just ember components 🤔
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.
Pretty sure components have evolved to be very thin wrappers around classes, and decorators are pretty class-agnostic. I can't find specific docs on this, but from here we see reference to the binding that Angel mentioned:
The action decorator also binds actions, so you can refer to them directly in templates without the {{action}} helper:
and here we see that an action is applied on a regular old class. Elsewhere in this post we see another reference to the point of @action
, which is binding this
correctly to the class:
Note that we’re using the @action decorator here to bind the context of the someObserver method, so it’s this always refers to the class instance.
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 method specifically is being passed to <FormField />
and called from the class so the decorator is extraneous, but if and when we update this to use HDS components directly or otherwise calling this update from the template, we will need the @action
decorator
CI Results: |
Build Results: |
this.flashMessages.info('No changes detected.'); | ||
this.transition(); | ||
} | ||
@action continueSubmitForm() { |
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 is a little easier to follow how the interruption happens. Nice mix of solutions without the extra tracked property.
}) | ||
); | ||
|
||
save = task( |
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 really like how easily this reads even thought there's a lot happening!
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.
Awesome work 🙌🏻
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!
</M.Body> | ||
<M.Footer> | ||
<Hds::ButtonSet> |
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.
No need to change, but just out of curiosity - is there a reason you didn't use the built-in footer here? For what it's worth, I think it allows you to call F.close
which will call the onClose
function above. I'm not sure of the difference stylistically
<M.Footer as |F|>
<Hds::Button type="button" @text="Confirm" {{on "click" F.close}} />
</M.Footer>
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 copied this from a different component, so that's the only reason
} | ||
} | ||
// this is to make it work with FormField | ||
@action set(_: string, val: string) { |
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.
Awesome! But this is a javascript class, right? I thought the @action
decorator was specific to just ember components 🤔
this.saveIssuerWarning = `You are updating the global issuer config. This will overwrite Vault's current issuer ${ | ||
this.issuerConfig.noRead ? 'if it exists ' : '' | ||
}and may affect other configurations using this value. Continue?`; | ||
// exit task until user confirms |
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 comments, thank you!
e1c9f6d
into
ui/VAULT-27326/wif-aws-sidebranch-3
* manual cherry pick to deal with all the merge things * changelog * test fixes * Update 28148.txt * fix tests failures after main merge * fix test failures after main merge * Add Access Type and conditionally render WIF fields (#28149) * initial work. * remove access_type * better no model logic well kind of * rollback attrs * remove defaults * stopping point * wip changing back to sidebranch * hustling shuffling and serializing * some of the component test coverage * disable acces type if editing * test coverage * hide max retries that sneaky bugger * cleanup * cleanup * Update root-config.js * remove flash message check, locally passes great but on ci flaky * clean up * thank you chelsea * test clean up per enterprise vs community * address pr comments * welp a miss add * UI (sidebranch) WIF Issuer field (#28187) * Add type declaration files for aws config models * use updated task syntax for save method on configure-aws * fix types on edit route * fetch issuer on configure edit page if aws + enterprise * track issuer within configure-aws component * add placeholder support on form-field * Add warning if issuer changed from previous value or could not be read * cleanup * preliminary tests * dont use while loop so we can test the modal * tests * cleanup * fix tests * remove extra tracked value and duplicate changed attrs check * modal footer --------- Co-authored-by: Angel Garbarino <[email protected]> * Display issuer on Configuration details (#28209) * display issuer on configuration details * workflow complete, now on to testing * handle issuer things * fix all the broken tests things * add test coveragE: * cleanup * rename model/adapter * Update configure-aws.ts * Update aws-configuration-test.js * 90 percent there for pr comments * last one for tonight * a few more because why not * hasDirtyAttributes fixes * revert back to previous noRead->queryIssuerError --------- Co-authored-by: Chelsea Shaw <[email protected]>
Description
This PR adds a WIF-only field
issuer
to the AWS configure form. This value is read and written to a global endpoint, not part of the AWS configuration models. On the configuration edit route we attempt to read this value if it's enterprise + AWS, and pass the currently configured value to the form component so a user can choose to update it.The field has a placeholder when issuer is not set or can't be read:
When the issuer could not be read, but the user updates it the modal says:
Otherwise when the value is changed, the modal says: