Skip to content

Commit

Permalink
Merge pull request #1477 from kaliber5/fix-ember-global
Browse files Browse the repository at this point in the history
Fix deprecations
  • Loading branch information
simonihmig authored Apr 30, 2021
2 parents 6c627d8 + 1bf6f58 commit a2c02eb
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 29 deletions.
3 changes: 1 addition & 2 deletions addon/components/bs-contextual-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { cancel, later, next, schedule } from '@ember/runloop';
import transitionEnd from 'ember-bootstrap/utils/transition-end';
import { getDestinationElement } from 'ember-bootstrap/utils/dom';
import usesTransition from 'ember-bootstrap/utils/decorators/uses-transition';
import { assert } from '@ember/debug';
import { assert, deprecate } from '@ember/debug';
import Ember from 'ember';
import { deprecate } from '@ember/application/deprecations';
import arg from '../utils/decorators/arg';
import { tracked } from '@glimmer/tracking';
import { getParentView } from '../utils/dom';
Expand Down
8 changes: 8 additions & 0 deletions addon/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getOwnConfig } from '@embroider/macros';
import Ember from 'ember';

export const VERSION = getOwnConfig().version;

export function registerLibrary() {
Ember.libraries.register('Ember Bootstrap', VERSION);
}
2 changes: 2 additions & 0 deletions app/initializers/load-bootstrap-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import ENV from '../config/environment';
import Config from 'ember-bootstrap/config';
import { registerLibrary } from 'ember-bootstrap/version';

export function initialize(/* container, application */) {
Config.load(ENV['ember-bootstrap'] || {});
registerLibrary();
}

export default {
Expand Down
15 changes: 1 addition & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
const path = require('path');
const mergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const stew = require('broccoli-stew');
const replace = require('broccoli-string-replace');
const map = stew.map;
const rename = stew.rename;
const BroccoliDebug = require('broccoli-debug');
const chalk = require('chalk');
const SilentError = require('silent-error'); // From ember-cli
Expand Down Expand Up @@ -92,12 +89,10 @@ module.exports = {
// import custom addon CSS
this.import(path.join(vendorPath, `bs${options.bootstrapVersion}.css`));

// register library version
this.import(path.join(vendorPath, 'register-version.js'));

// setup config for @embroider/macros
this.options['@embroider/macros'].setOwnConfig.isBS3 = this.getBootstrapVersion() === 3;
this.options['@embroider/macros'].setOwnConfig.isBS4 = this.getBootstrapVersion() === 4;
this.options['@embroider/macros'].setOwnConfig.version = require('./package.json').version;
},

options: {
Expand Down Expand Up @@ -219,14 +214,6 @@ module.exports = {

treeForVendor(tree) {
let trees = [tree];
let versionTree = rename(
map(tree, 'ember-bootstrap/register-version.template', (c) =>
c.replace('###VERSION###', require('./package.json').version)
),
'register-version.template',
'register-version.js'
);
trees.push(versionTree);

if (!this.hasPreprocessor()) {
trees.push(
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@
"broccoli-debug": "^0.6.3",
"broccoli-funnel": "^3.0.2",
"broccoli-merge-trees": "^4.2.0",
"broccoli-stew": "^3.0.0",
"broccoli-string-replace": "^0.1.2",
"chalk": "^4.1.0",
"ember-auto-import": "^1.10.1",
"ember-cli-babel": "^7.23.1",
"ember-cli-babel": "^7.26.4",
"ember-cli-build-config-editor": "0.5.1",
"ember-cli-htmlbars": "^5.6.2",
"ember-cli-version-checker": "^5.1.2",
Expand Down
8 changes: 7 additions & 1 deletion tests/helpers/setup-no-deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ let isRegistered = false;
let deprecations;

// Ignore deprecations that are not caused by our own code, and which we cannot fix easily.
const ignoredDeprecations = [/Versions of modifier manager capabilities prior to 3\.22 have been deprecated/];
const ignoredDeprecations = [
/Versions of modifier manager capabilities prior to 3\.22 have been deprecated/,
/Usage of the Ember Global is deprecated./,
/import .* directly from/,
// this will be fixed in a future PR...
/Using Ember.LinkComponent/,
];

export default function setupNoDeprecations({ beforeEach, afterEach }) {
beforeEach(function () {
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/components/bs-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,10 @@ module('Integration | Component | bs-form', function (hooks) {
});

test('A change to a form elements resets yielded #isSubmitted', async function (assert) {
this.model = {};
this.actions.submit = sinon.fake.resolves();
await render(hbs`
<BsForm @onSubmit={{action "submit"}} @model={{hash }} as |form|>
<BsForm @onSubmit={{action "submit"}} @model={{this.model}} as |form|>
<form.element @property="foo" />
<button type="submit" class={{if form.isSubmitted "is-submitted"}}>submit</button>
</BsForm>
Expand Down Expand Up @@ -787,9 +788,10 @@ module('Integration | Component | bs-form', function (hooks) {
}
};

this.model = {};
this.actions.submit = sinon.fake.rejects(expectedError);
await render(hbs`
<BsForm @onSubmit={{action "submit"}} @model={{hash }} as |form|>
<BsForm @onSubmit={{action "submit"}} @model={{this.model}} as |form|>
<form.element @property="foo" />
<button type="submit" class={{if form.isRejected "is-rejected"}}>submit</button>
</BsForm>
Expand All @@ -803,9 +805,10 @@ module('Integration | Component | bs-form', function (hooks) {
});

test('Triggering resetSubmissionState resets submission state of form', async function (assert) {
this.model = {};
this.actions.submit = sinon.fake.resolves();
await render(hbs`
<BsForm @onSubmit={{action "submit"}} @model={{hash }} as |form|>
<BsForm @onSubmit={{action "submit"}} @model={{this.model}} as |form|>
<input onchange={{form.resetSubmissionState}}>
{{#if form.isSubmitting}}isSubmitting{{/if}}
{{#if form.isSubmitted}}isSubmitted{{/if}}
Expand Down
Loading

0 comments on commit a2c02eb

Please sign in to comment.