Skip to content

Commit 3a095f9

Browse files
authored
Merge branch 'master' into depbot
2 parents b01f0cb + 72f4a5a commit 3a095f9

File tree

9 files changed

+1844
-603
lines changed

9 files changed

+1844
-603
lines changed

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ further details.
1111
Compatibility
1212
------------------------------------------------------------------------------
1313

14-
* Ember Bootstrap v3
15-
* Ember CP Validations v3
16-
* Ember.js v3.12 or above
17-
* Ember CLI v2.13 or above
14+
* Ember Bootstrap v4
15+
* Ember CP Validations v4
16+
* Ember.js v3.16 or above
17+
* Ember CLI v3.15 or above
1818
* Node.js v10 or above
1919

2020

RELEASE.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Release
2+
3+
Releases are mostly automated using
4+
[release-it](https://github.com/release-it/release-it/) and
5+
[lerna-changelog](https://github.com/lerna/lerna-changelog/).
6+
7+
8+
## Preparation
9+
10+
Since the majority of the actual release process is automated, the primary
11+
remaining task prior to releasing is confirming that all pull requests that
12+
have been merged since the last release have been labeled with the appropriate
13+
`lerna-changelog` labels and the titles have been updated to ensure they
14+
represent something that would make sense to our users. Some great information
15+
on why this is important can be found at
16+
[keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
17+
guiding principle here is that changelogs are for humans, not machines.
18+
19+
When reviewing merged PR's the labels to be used are:
20+
21+
* breaking - Used when the PR is considered a breaking change.
22+
* enhancement - Used when the PR adds a new feature or enhancement.
23+
* bug - Used when the PR fixes a bug included in a previous release.
24+
* documentation - Used when the PR adds or updates documentation.
25+
* internal - Used for internal changes that still require a mention in the
26+
changelog/release notes.
27+
28+
29+
## Release
30+
31+
Once the prep work is completed, the actual release is straight forward:
32+
33+
* First, ensure that you have installed your projects dependencies:
34+
35+
```
36+
yarn install
37+
```
38+
39+
* Second, ensure that you have obtained a
40+
[GitHub personal access token][generate-token] with the `repo` scope (no
41+
other permissions are needed). Make sure the token is available as the
42+
`GITHUB_AUTH` environment variable.
43+
44+
For instance:
45+
46+
```bash
47+
export GITHUB_AUTH=abc123def456
48+
```
49+
50+
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
51+
52+
* And last (but not least 😁) do your release.
53+
54+
```
55+
npx release-it
56+
```
57+
58+
[release-it](https://github.com/release-it/release-it/) manages the actual
59+
release process. It will prompt you to to choose the version number after which
60+
you will have the chance to hand tweak the changelog to be used (for the
61+
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
62+
pushing the tag and commits, etc.

addon/components/bs-form.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
import { notEmpty } from '@ember/object/computed';
21
import ObjectProxy from '@ember/object/proxy';
3-
import { Promise as EmberPromise } from 'rsvp';
42
import BsForm from 'ember-bootstrap/components/bs-form';
53

6-
export default BsForm.extend({
7-
hasValidator: notEmpty('model.validate'),
4+
export default class ValidatedBsFrom extends BsForm {
5+
// Silence subclassing warning, as we need to extend for our current validations API. This means we need to treat
6+
// this addon as a "privileged" one, and guarantee that we will account for possible changes that would things break
7+
// due to us extending from the base class (e.g. when refactoring bs-form components to Glimmer.Component)
8+
'__ember-bootstrap_subclass' = true;
89

9-
validate(model) {
10-
return new EmberPromise((resolve, reject) => {
11-
let m = model;
10+
get hasValidator() {
11+
return !!this.model.validate;
12+
}
13+
14+
async validate(model) {
15+
let m = model;
1216

13-
if(model instanceof ObjectProxy && model.get('content') && typeof model.get('content').validate === 'function') {
14-
m = model.get('content');
15-
}
17+
if (model instanceof ObjectProxy && model.get('content') && typeof model.get('content').validate === 'function') {
18+
m = model.get('content');
19+
}
1620

17-
m.validate().then(() => model.get('validations.isTruelyValid') ? resolve() : reject(), reject);
18-
});
21+
await m.validate()
22+
if (!model.validations.isTruelyValid) {
23+
throw new Error();
24+
}
1925
}
20-
});
26+
}

addon/components/bs-form/element.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@ import { not, notEmpty, and, readOnly } from '@ember/object/computed';
22
import { defineProperty } from '@ember/object';
33
import BsFormElement from 'ember-bootstrap/components/bs-form/element';
44

5-
export default BsFormElement.extend({
6-
_attrValidations: null,
7-
notValidating: not('isValidating').readOnly(),
8-
notDisabled: not('disabled').readOnly(),
9-
_presenceEnabled: not('_attrValidations.options.presence.disabled'),
5+
export default class ValidatedBsFormElement extends BsFormElement {
6+
'__ember-bootstrap_subclass' = true;
107

118
// Overwrite
12-
hasValidator: notEmpty('_attrValidations').readOnly(),
13-
hasErrors: and('_attrValidations.isInvalid', 'notValidating').readOnly(),
14-
isValidating: readOnly('_attrValidations.isValidating'),
9+
@notEmpty('_attrValidations')
10+
hasValidator;
1511

16-
// mark as required only if:
17-
// - field is not disabled,
18-
// - presence validator requires presence
19-
// - presence validator is enabled
20-
required: and('notDisabled', '_attrValidations.options.presence.presence', '_presenceEnabled'),
12+
@not('isValidating')
13+
notValidating;
14+
15+
@and('_attrValidations.isInvalid', 'notValidating')
16+
hasErrors;
17+
18+
@readOnly('_attrValidations.isValidating')
19+
isValidating;
20+
21+
@readOnly('_attrValidations.messages')
22+
errors;
23+
24+
@readOnly('_attrValidations.warningMessages')
25+
warnings;
2126

2227
setupValidations() {
2328
defineProperty(this, '_attrValidations', readOnly(`model.validations.attrs.${this.property}`));
24-
defineProperty(this, 'errors', readOnly('_attrValidations.messages'));
25-
defineProperty(this, 'warnings', readOnly('_attrValidations.warningMessages'));
2629
}
27-
});
30+
}

ember-cli-build.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
44

55
module.exports = function(defaults) {
66
var app = new EmberAddon(defaults, {
7-
// Add options here
7+
'ember-bootstrap': {
8+
bootstrapVersion: 4,
9+
importBootstrapCSS: true
10+
}
811
});
912

1013
/*

package.json

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"bootstrap",
1111
"validations"
1212
],
13+
"repository": {
14+
"type": "git",
15+
"url": "http://github.com/offirgolan/ember-bootstrap-cp-validations.git"
16+
},
1317
"license": "MIT",
1418
"author": "offirgolan@gmail.com",
1519
"directories": {
1620
"doc": "doc",
1721
"test": "tests"
1822
},
19-
"repository": {
20-
"type": "git",
21-
"url": "http://github.com/offirgolan/ember-bootstrap-cp-validations.git"
22-
},
2323
"scripts": {
2424
"build": "ember build --environment=production",
2525
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
@@ -39,16 +39,16 @@
3939
"@glimmer/component": "^1.0.1",
4040
"@glimmer/tracking": "^1.0.1",
4141
"babel-eslint": "^10.1.0",
42-
"bootstrap": "^3.3.7",
42+
"bootstrap": "^4.3.1",
4343
"broccoli-asset-rev": "^3.0.0",
4444
"ember-auto-import": "^1.6.0",
45-
"ember-bootstrap": "^3.1.4",
45+
"ember-bootstrap": "^4.1.0",
4646
"ember-cli": "~3.21.0",
4747
"ember-cli-dependency-checker": "^3.2.0",
4848
"ember-cli-inject-live-reload": "^2.0.2",
4949
"ember-cli-sri": "^2.1.1",
5050
"ember-cli-uglify": "^3.0.0",
51-
"ember-cp-validations": "^3.5.6",
51+
"ember-cp-validations": "^4.0.0-beta.10",
5252
"ember-disable-prototype-extensions": "^1.1.3",
5353
"ember-export-application-global": "^2.0.1",
5454
"ember-getowner-polyfill": "^2.2.0",
@@ -65,16 +65,36 @@
6565
"eslint-plugin-node": "^11.1.0",
6666
"loader.js": "^4.7.0",
6767
"npm-run-all": "^4.1.5",
68-
"qunit-dom": "^1.4.0"
68+
"qunit-dom": "^1.4.0",
69+
"release-it": "^13.6.5",
70+
"release-it-lerna-changelog": "^2.3.0"
6971
},
7072
"engines": {
7173
"node": "10.* || >= 12"
7274
},
75+
"publishConfig": {
76+
"registry": "https://registry.npmjs.org"
77+
},
7378
"ember": {
7479
"edition": "octane"
7580
},
7681
"ember-addon": {
7782
"configPath": "tests/dummy/config",
7883
"after": "ember-bootstrap"
84+
},
85+
"release-it": {
86+
"plugins": {
87+
"release-it-lerna-changelog": {
88+
"infile": "CHANGELOG.md",
89+
"launchEditor": true
90+
}
91+
},
92+
"git": {
93+
"tagName": "v${version}"
94+
},
95+
"github": {
96+
"release": true,
97+
"tokenRef": "GITHUB_AUTH"
98+
}
7999
}
80100
}

tests/integration/components/bs-form-element-test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ObjectProxy from '@ember/object/proxy';
33
import { setOwner } from '@ember/application';
44
import { module, test } from 'qunit';
55
import { setupRenderingTest } from 'ember-qunit';
6-
import { render, triggerEvent } from '@ember/test-helpers';
6+
import { render, triggerEvent, blur, fillIn, focus } from '@ember/test-helpers';
77
import hbs from 'htmlbars-inline-precompile';
88
import { buildValidations, validator } from 'ember-cp-validations';
99

@@ -71,6 +71,29 @@ module('Integration | Component | bs form element', function(hooks) {
7171
assert.dom('input').hasClass('is-invalid', 'input has error class');
7272
});
7373

74+
test('validations are reactive', async function(assert) {
75+
let model = Model.create({
76+
});
77+
setOwner(model, this.owner);
78+
79+
this.set('model', model);
80+
81+
await render(hbs`
82+
<BsForm @model={{this.model}} as |form|>
83+
<form.element @label="test" @property="test" />
84+
</BsForm>
85+
`);
86+
87+
await focus('input');
88+
await blur('input');
89+
assert.dom('input').hasClass('is-invalid', 'input has error class');
90+
91+
await fillIn('input', 'xxx');
92+
await blur('input');
93+
94+
assert.dom('input').hasNoClass('is-invalid', 'input has no error class');
95+
});
96+
7497
test('valid validation is supported as expected when working with an ember-buffered-proxy model', async function(assert) {
7598
let proxiedModel = EmberObject.create();
7699
setOwner(proxiedModel, this.owner);

0 commit comments

Comments
 (0)