From 6f0c33efd7b359cb240a82f48766b4cbf38deb26 Mon Sep 17 00:00:00 2001 From: nickschot Date: Fri, 1 Dec 2023 17:03:58 +0100 Subject: [PATCH] Drop support for mm.LinkTo component, use LinkTo with on click modifier instead --- .../templates/docs/components/menu-wrapper.md | 10 +++--- docs/app/templates/docs/quickstart.md | 2 +- docs/app/templates/index.hbs | 2 +- ember-mobile-menu/package.json | 2 -- .../src/components/mobile-menu.hbs | 1 - .../src/components/mobile-menu/link-to.js | 29 --------------- pnpm-lock.yaml | 10 ++++-- .../components/mobile-menu-wrapper-test.js | 36 +++++++++---------- .../components/mobile-menu/link-to-test.js | 33 ----------------- 9 files changed, 32 insertions(+), 93 deletions(-) delete mode 100644 ember-mobile-menu/src/components/mobile-menu/link-to.js delete mode 100644 test-app/tests/integration/components/mobile-menu/link-to-test.js diff --git a/docs/app/templates/docs/components/menu-wrapper.md b/docs/app/templates/docs/components/menu-wrapper.md index 6c49bba9..98ffa32b 100644 --- a/docs/app/templates/docs/components/menu-wrapper.md +++ b/docs/app/templates/docs/components/menu-wrapper.md @@ -6,7 +6,7 @@ By default it is set up to detect a pan from respectively the left or the right ```handlebars - Home + Home @@ -30,7 +30,7 @@ By default the menu is setup to be a left menu. By passing `type=right` to the m ```handlebars - Home + Home @@ -45,7 +45,7 @@ You can also use both a left and a right menu. A `target` option is available on ```handlebars - Home + Home @@ -54,7 +54,7 @@ You can also use both a left and a right menu. A `target` option is available on - Home + Home ``` @@ -68,7 +68,7 @@ If a menu is _not_ embedded, the assumption is made that the `Content` component - Home + Home diff --git a/docs/app/templates/docs/quickstart.md b/docs/app/templates/docs/quickstart.md index e2ebce27..8862e782 100644 --- a/docs/app/templates/docs/quickstart.md +++ b/docs/app/templates/docs/quickstart.md @@ -5,7 +5,7 @@ To get started the `` component needs to be placed high in t ```handlebars - Home + Home diff --git a/docs/app/templates/index.hbs b/docs/app/templates/index.hbs index 0b7c0e45..01e005fa 100644 --- a/docs/app/templates/index.hbs +++ b/docs/app/templates/index.hbs @@ -24,7 +24,7 @@
  • - Home + Home
diff --git a/ember-mobile-menu/package.json b/ember-mobile-menu/package.json index 42cd655e..4cd2f03b 100644 --- a/ember-mobile-menu/package.json +++ b/ember-mobile-menu/package.json @@ -40,7 +40,6 @@ "test": "echo 'A v2 addon does not have tests, run tests in test-app'" }, "dependencies": { - "@ember/legacy-built-in-components": "^0.5.0", "@ember/render-modifiers": "^2.0.0", "@ember/test-waiters": "^3.0.0", "@embroider/addon-shim": "^1.0.0", @@ -95,7 +94,6 @@ "./components/mobile-menu-wrapper.js": "./dist/_app_/components/mobile-menu-wrapper.js", "./components/mobile-menu-wrapper/content.js": "./dist/_app_/components/mobile-menu-wrapper/content.js", "./components/mobile-menu.js": "./dist/_app_/components/mobile-menu.js", - "./components/mobile-menu/link-to.js": "./dist/_app_/components/mobile-menu/link-to.js", "./components/mobile-menu/mask.js": "./dist/_app_/components/mobile-menu/mask.js", "./components/mobile-menu/tray.js": "./dist/_app_/components/mobile-menu/tray.js" } diff --git a/ember-mobile-menu/src/components/mobile-menu.hbs b/ember-mobile-menu/src/components/mobile-menu.hbs index b15a020e..07f484cf 100644 --- a/ember-mobile-menu/src/components/mobile-menu.hbs +++ b/ember-mobile-menu/src/components/mobile-menu.hbs @@ -42,7 +42,6 @@ > {{yield (hash - LinkTo=(component "mobile-menu/link-to" onClick=this.closeFromLinkTo) actions=(hash open=this.open close=this.close diff --git a/ember-mobile-menu/src/components/mobile-menu/link-to.js b/ember-mobile-menu/src/components/mobile-menu/link-to.js deleted file mode 100644 index 09ffc8f9..00000000 --- a/ember-mobile-menu/src/components/mobile-menu/link-to.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable ember/no-classic-classes, ember/no-component-lifecycle-hooks */ -import { LinkComponent } from '@ember/legacy-built-in-components'; - -/** - * An extended LinkTo component which provides an onClick hook. - * - * @class LinkTo - * @public - */ -export default LinkComponent.extend({ - didReceiveAttrs() { - this._super(...arguments); - - this.set('current-when', this.qualifiedRouteName); - }, - - /** - * Hook called when the link is clicked. - * - * @argument onClick - * @type function - * @default function(){} - */ - onClick() {}, - - click() { - this.onClick(); - }, -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f42c7aca..1dd6b2af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -174,9 +174,6 @@ importers: ember-mobile-menu: dependencies: - '@ember/legacy-built-in-components': - specifier: ^0.5.0 - version: 0.5.0(ember-source@5.4.0) '@ember/render-modifiers': specifier: ^2.0.0 version: 2.1.0(@babel/core@7.23.5) @@ -2233,6 +2230,7 @@ packages: transitivePeerDependencies: - '@glint/template' - supports-color + dev: true /@ember/optional-features@2.0.0: resolution: {integrity: sha512-4gkvuGRYfpAh1nwAz306cmMeC1mG7wxZnbsBZ09mMaMX/W7IyKOKc/38JwrDPUFUalmNEM7q7JEPcmew2M3Dog==} @@ -5714,6 +5712,7 @@ packages: quick-temp: 0.1.8 rimraf: 2.7.1 symlink-or-copy: 1.3.1 + dev: true /broccoli-plugin@3.1.0: resolution: {integrity: sha512-7w7FP8WJYjLvb0eaw27LO678TGGaom++49O1VYIuzjhXjK5kn2+AMlDm7CaUFw4F7CLGoVQeZ84d8gICMJa4lA==} @@ -5853,6 +5852,7 @@ packages: walk-sync: 1.1.4 transitivePeerDependencies: - supports-color + dev: true /broccoli-string-replace@0.1.2: resolution: {integrity: sha512-QHESTrrrPlKuXQNWsvXawSQbV2g34wCZ5oKgd6bntdOuN8VHxbg1BCBHqVY5HxXJhWelimgGxj3vI7ECkyij8g==} @@ -8465,6 +8465,7 @@ packages: walk-sync: 2.2.0 transitivePeerDependencies: - supports-color + dev: true /ember-cli-typescript@5.2.1: resolution: {integrity: sha512-qqp5TAIuPHxHiGXJKL+78Euyhy0zSKQMovPh8sJpN/ZBYx0H90pONufHR3anaMcp1snVfx4B+mb9+7ijOik8ZA==} @@ -10037,6 +10038,7 @@ packages: onetime: 5.1.2 signal-exit: 3.0.7 strip-final-newline: 2.0.0 + dev: true /execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} @@ -11539,6 +11541,7 @@ packages: /human-signals@1.1.1: resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} engines: {node: '>=8.12.0'} + dev: true /human-signals@2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} @@ -13842,6 +13845,7 @@ packages: engines: {node: '>=8'} dependencies: path-key: 3.1.1 + dev: true /npm-run-path@5.1.0: resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} diff --git a/test-app/tests/integration/components/mobile-menu-wrapper-test.js b/test-app/tests/integration/components/mobile-menu-wrapper-test.js index c46a6f75..072e1eb1 100644 --- a/test-app/tests/integration/components/mobile-menu-wrapper-test.js +++ b/test-app/tests/integration/components/mobile-menu-wrapper-test.js @@ -26,7 +26,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home `); @@ -39,7 +39,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home `); @@ -52,7 +52,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -80,7 +80,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -101,10 +101,10 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home - Home + Home @@ -135,7 +135,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -160,7 +160,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -180,7 +180,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -200,7 +200,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -220,7 +220,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -241,7 +241,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -264,7 +264,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) {
- Home + Home @@ -296,7 +296,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) {
- Home + Home @@ -326,7 +326,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -347,7 +347,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -370,7 +370,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home @@ -403,7 +403,7 @@ module('Integration | Component | mobile-menu-wrapper', function (hooks) { await render(hbs` - Home + Home diff --git a/test-app/tests/integration/components/mobile-menu/link-to-test.js b/test-app/tests/integration/components/mobile-menu/link-to-test.js deleted file mode 100644 index 23033e46..00000000 --- a/test-app/tests/integration/components/mobile-menu/link-to-test.js +++ /dev/null @@ -1,33 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render, click } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; -import Service from '@ember/service'; - -module('Integration | Component | mobile-menu/link-to', function (hooks) { - setupRenderingTest(hooks); - - test('it renders', async function (assert) { - // Template block usage: - await render(hbs` - - My Link - - `); - - assert.strictEqual(this.element.textContent.trim(), 'My Link'); - }); - - test('it fires the onClick hook when clicked', async function (assert) { - this.owner.register('service:router', class Router extends Service {}); - - this.handleClick = (...args) => { - assert.step(`handleClick: ${args}`); - }; - - await render(hbs`{{mobile-menu/link-to "index" onClick=this.handleClick}}`); - await click('a'); - - assert.verifySteps(['handleClick: ']); - }); -});