-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
support Ember Bootstrap v4.5 #79
support Ember Bootstrap v4.5 #79
Conversation
addon/components/bs-form/element.js
Outdated
setupValidations() { | ||
defineProperty(this, '_attrValidations', readOnly(`model.validations.attrs.${this.property}`)); | ||
defineProperty(this, '_attrValidations', readOnly(`args.model.validations.attrs.${this.args.property}`)); | ||
} |
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 would recommend to use a native getter instead. But didn't wanted to change to much in this hotfix.
get _attrValidations() {
const { model, property } = this.args;
return get(model, `validations.attrs.${property}`);
}
Need to use get
because property
may be a path. We didn't decided yet if we treat as officially supported (ember-bootstrap/ember-bootstrap#1173) but changing it caused immediate bug reports in ember-bootstrap-changeset-validations
(ember-bootstrap/ember-bootstrap-changeset-validations#28).
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.
When using the getter approach, wouldn't that allow us to easily support both ember-bootstrap <4.5 and >=4.5, by something like this:
get _attrValidations() {
const model = this.args.model ? this.args.model : this.model;
const property ? this.args.property ? this.args.property : this.property;
return get(model, `validations.attrs.${property}`);
}
Or would the getter not interoperate well with the CP-world used in e-b <4.5? 🤔
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. Such a getter should support both versions.
But that could be also done even without refactoring to the getter:
if (typeof this.args === 'object') {
defineProperty(this, '_attrValidations', readOnly(`args.model.validations.attrs.${this.args.property}`));
} else {
defineProperty(this, '_attrValidations', readOnly(`model.validations.attrs.${this.property}`));
}
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.
Ok, so...
- if supporting all ember-bootstrap versions is as easy as it seems, I think we should do that
- when we have to touch the code anyway, I would rather do the refactoring towards a 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 tried to refactor to this getter but reactivity was not working as expected. I guess you were right that the getter is not working well with the computed properties used in Ember Bootstrap < 4.4.
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.
Added support for Ember Bootstrap v4.4 back in 379f60f. Still using the defineProperty
approach. Decided to not introduce @embroider/macros
but use a simple if guard as the run-time overhead should not be relevant.
Canary is failing with a strange error. Cannot see how this could be related to the changes here, but als haven't seen thiss elsewhere so far. 🤔 |
I guess you are talking about this error:
Have seen it in ember-bootstrap and ember-bootstrap-changeset-validations as well. |
I would recommend to change the GitHub Actions CI workflow on this repository to continue if |
Yes. It has been mentioned on Discord, so we can ignore this here
Makes sense. Can you do this here? To not cause merge conflicts, as you already touched the workflow file here, and also would like to merge once the new 4.4 scenario passes. |
Done so in 3b2171f. Please note that the merge request is still shown with an error state even if I don't have permissions for this repository to merge myself. |
Awesome, thanks your work here!
Yeah, I also realized this recently. This is a bit annoying, as it prevents dependabot PRs from auto-merging... 😔
You got mail 😉 |
This adds support for Ember Bootstrap v4.5 while keeping support for Ember Boostrap v4.4 and before.