-
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: refactor KMIP role model #28418
UI: refactor KMIP role model #28418
Conversation
export default Model.extend(COMPUTEDS, { | ||
backend: attr({ readOnly: true }), | ||
scope: attr({ readOnly: true }), | ||
name: attr({ readOnly: 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.
name
was set on the model, but role
is the attribute that comes back from OpenAPI. Since there's no way to filter out attributes from OpenAPI, I opted to keep role
instead of name
CI Results: |
Build Results: |
}), | ||
@withExpandedAttributes() | ||
export default class KmipRoleModel extends Model { | ||
@attr({ readOnly: true }) backend; |
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 we need to specify the role
attribute 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 that withExpandedAttributes
will populate the model with the properties returned from OpenAPI and it sounds like role
is coming from there.
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 work! Just a couple of questions, nothing blocking! ⭐
<MessageError @model={{@model}} data-test-edit-form-error /> | ||
<div class="box is-sideless is-fullwidth is-marginless"> | ||
<NamespaceReminder @mode="save" /> | ||
{{#if (eq @mode "create")}} |
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.
Instead of passing @mode
do we want to leverage @model.isNew
, since that's been the newer pattern we've used?
ui/app/utils/kmip-role-fields.js
Outdated
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.
Could you explain your reasoning behind making this util file? Just wondering about when to use this pattern in the future. To me it feels like a one-off while we bridge the old model pattern and transition to the new "schema" models, and that typically this sort of thing would live in the form component. But I could be missing something and am curious about your perspective! 💭
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 question! I have it in a util because it was used in the form as well as the adapter for ensuring that the correct fields get sent to the API. As we move toward thinner models it's worth considering what we want the pattern to be, and this file could definitely become obsolete (or part of a different file structure) in the future
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.
Gotcha! Did we ever get around to writing the schema model readme file? I wonder if it's worth considering a model/helpers
file or something. But would have to think about this more... It also seems like since Ember is moving away from adapters/serializers all together (in the looong term plan) so, I think you're right that the need for this may become obsolete all together 🤔 Just spitballin
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 didn't -- probably worth doing a follow-up PR with the doc and a folder pattern for things like this. We are probably a long way from eliminating our adapters and serializers so it's definitely worth establishing a pattern
|
||
operationFormFields: computed('operationFieldsWithoutSpecial', function () { | ||
get operationFormFields() { |
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.
It looks like this has been renamed and moved to operationFormGroups
below in the form component, do we still need this getter 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.
Yes, this is used in the KMIP OperationDetailsDisplay
component for role details page.
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! I had done a search and missed that, thanks for following up
@model={{this.model}} | ||
@mode="edit" |
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.
Same question as above about passing @mode
@model={{this.model}} | ||
@mode="create" | ||
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.scope.roles" this.scope}} | ||
@cancelLinkParams={{array "scope.roles" this.scope}} | ||
@onCancel={{transition-to "vault.cluster.secrets.backend.kmip.scope.roles" this.scope}} |
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.
👏
@@ -17,6 +17,10 @@ module.exports = EngineAddon.extend({ | |||
enabled: true, | |||
}, | |||
|
|||
babel: { | |||
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')], |
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.
What is this?!
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.
😂 required to use the async-arrow notation -- the other engines already had it but when I refactored the form in KMIP I got an error that it needed this transform
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.
Aha! Thank you for explaining 😂
Description
This PR refactors the kmip/role model in preparation for our Ember Data upgrade. During testing, the computed values in the model were causing weirdness with the new
path-help
approach.Our latest best practices include having the models as thin as possible, and calculating things like
fieldGroups
in the components where they are used instead of on the model itself. However, to keep the scope of this PR small I opted to keep some of the model getters for field groups, specifically for the role details page. In the future we may choose to remove these in favor of component getters.Before / After