From d778c6cbe7b17f461c96cb1d04973c712e99f5a4 Mon Sep 17 00:00:00 2001 From: Marine Dunstetter Date: Fri, 2 Feb 2024 16:28:24 +0100 Subject: [PATCH] feat: remove support for deprecated modal-from-string --- DEPRECATIONS.md | 37 ------------------- addon/services/modals.js | 15 -------- config/ember-try.js | 6 +--- tests/application/deprecations-test.js | 49 -------------------------- tests/dummy/config/environment.js | 1 - 5 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 DEPRECATIONS.md delete mode 100644 tests/application/deprecations-test.js diff --git a/DEPRECATIONS.md b/DEPRECATIONS.md deleted file mode 100644 index baf7c69b..00000000 --- a/DEPRECATIONS.md +++ /dev/null @@ -1,37 +0,0 @@ -# Deprecations - -ember-promise-modals 5.0.0 will be a [v2 addon](https://github.com/embroider-build/embroider/blob/main/README.md#for-addon-authors) compatible with Embroider ecosystem. This document describes what functionalities will no longer exist in the coming major release. - -## ember-promise-modals.modals-from-string - -_Added in 4.1.0, functionality to be removed in 5.0.0_ - -The new Embroider build system prefers static imports when dynamically invoking components. To resolve this deprecation, you need to replace the path to the modal component with an imported component class: - -```js -// before -export class ApplicationController extends Controller { - @service modals; - - @action - async show() { - await this.modals.open('my-modal'); - } -} - -// after -import MyModal from 'my-app/components/my-modal'; - -export class ApplicationController extends Controller { - @service modals; - - @action - async show() { - await this.modals.open(MyModal); - } -} -``` - -> Caution: old-style components that have their template in `app/templates/components` instead of co-located next to their Javascript in `app/components` can't work correctly when discovered via their component class, because there's no way to locate the template. They should either port to being co-located (which is a simple mechanical transformation and highly recommended) or should import their own template and set it as layout as was traditional in addons before co-location was available. - --- [Replacing Component Helper.md](https://github.com/embroider-build/embroider/blob/main/docs/replacing-component-helper.md#when-youre-invoking-a-component-youve-been-given) diff --git a/addon/services/modals.js b/addon/services/modals.js index a49d6297..63452dbd 100644 --- a/addon/services/modals.js +++ b/addon/services/modals.js @@ -1,5 +1,4 @@ import { A } from '@ember/array'; -import { deprecate } from '@ember/debug'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import Service from '@ember/service'; @@ -41,20 +40,6 @@ export default Service.extend({ * @returns {Modal} */ open(componentClass, data, options) { - deprecate( - `Ember Promise Modals: For extended compatibility with Embroider and its tree-shaking ability, you need to import and pass in the component class of the modal component you want to display instead of "${componentClass}".`, - typeof componentClass !== 'string', - { - id: 'ember-promise-modals.modals-from-string', - until: '5.0.0', - for: 'ember-promise-modals', - since: { - enabled: '3.1.0', - }, - url: 'https://github.com/mainmatter/ember-promise-modals/blob/main/DEPRECATIONS.md#ember-promise-modalsmodals-from-string', - }, - ); - let modal = new Modal(this, componentClass, data, options); this._stack.pushObject(modal); diff --git a/config/ember-try.js b/config/ember-try.js index 05a47e14..5f2378ae 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -97,11 +97,7 @@ module.exports = async function () { }, }, embroiderSafe(), - embroiderOptimized({ - env: { - SKIP_EMBROIDER_DEPRECATION_TEST: true, - }, - }), + embroiderOptimized(), ], }; }; diff --git a/tests/application/deprecations-test.js b/tests/application/deprecations-test.js deleted file mode 100644 index f87b1046..00000000 --- a/tests/application/deprecations-test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { visit, click, getDeprecations, waitUntil } from '@ember/test-helpers'; -import { setupApplicationTest } from 'ember-qunit'; -import { module, test } from 'qunit'; - -import ENV from 'dummy/config/environment'; - -import { setupPromiseModals } from 'ember-promise-modals/test-support'; - -module('Application | Deprecations', function (hooks) { - setupApplicationTest(hooks); - setupPromiseModals(hooks); - - if (!ENV.SKIP_EMBROIDER_DEPRECATION_TEST) { - test('opening a modal by its path triggers a deprecation', async function (assert) { - await visit('/'); - - assert.dom('.epm-backdrop').doesNotExist(); - assert.dom('.epm-modal').doesNotExist(); - - this.owner.lookup('service:modals').open('modal1'); - - await waitUntil(() => { - let { opacity } = window.getComputedStyle(document.querySelector('.epm-backdrop')); - return opacity === '1'; - }); - - assert.dom('.epm-modal').exists(); - assert.dom('.epm-backdrop').exists(); - - assert.dom('.epm-backdrop').hasStyle({ - opacity: '1', - pointerEvents: 'auto', - }); - - await click('.epm-backdrop'); - - assert.dom('.epm-backdrop').doesNotExist(); - assert.dom('.epm-modal').doesNotExist(); - - const deprecations = getDeprecations(); - const modalFromString = deprecations.find( - ({ options }) => options.id === 'ember-promise-modals.modals-from-string', - ); - - assert.ok(modalFromString, 'ember-promise-modals.modals-from-string deprecation was triggered'); - console.log(modalFromString.message.includes('"modal1"')); - }); - } -}); diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 9e45156e..6afb7d5a 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -33,7 +33,6 @@ module.exports = function (environment) { if (environment === 'test') { // Testem prefers this... - ENV.SKIP_EMBROIDER_DEPRECATION_TEST = process.env.SKIP_EMBROIDER_DEPRECATION_TEST; ENV.locationType = 'none'; // keep test console output quieter