Skip to content

Commit

Permalink
Merge pull request #1334 from ember-learn/deprecate-implicit-route-model
Browse files Browse the repository at this point in the history
Deprecate implict route model
  • Loading branch information
MinThaMie authored Jul 28, 2023
2 parents dd2d7fb + b1d4e23 commit f671e3c
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 36 deletions.
91 changes: 55 additions & 36 deletions app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="content" class="main" role="main">
<div class="intro">
<h1 class="anchorable-toc" id="toc_deprecations">Deprecations</h1>
<div id='content' class='main' role='main'>
<div class='intro'>
<h1 class='anchorable-toc' id='toc_deprecations'>Deprecations</h1>
<p>Periodically, various APIs in Ember.js may be deprecated. During a minor
release, for instance when upgrading from version 1.9 to 1.10, you may see
new deprecations fire in your codebase. Until a major revision such as 2.0
Expand All @@ -9,15 +9,15 @@
removed. Private API may be removed at any time without warning in patch
or minor releases, regardless of whether it has a deprecation warning.
This style of change management is commonly referred to as
<a href="http://semver.org/">Semantic Versioning</a>.
<a href='http://semver.org/'>Semantic Versioning</a>.
</p>

<p>
You can use newer versions of the CLI with older Ember apps. It's a good
idea to resolve deprecations as they arise so that when a major version is
available, it's easier to upgrade your app. For some significant changes,
codemods may be available, so check out
<a href="https://emberjs.com/blog/">
<a href='https://emberjs.com/blog/'>
Release Blog Posts
</a>
before you dive in.
Expand All @@ -26,54 +26,73 @@
<p>
If you want to contribute to the text on this website, by editing existing
deprecation documenation or adding new documentation, please see the
<a href="https://github.com/ember-learn/deprecation-app">deprecations app repository</a>.
<a href='https://github.com/ember-learn/deprecation-app'>deprecations app
repository</a>.
</p>

<h2 class="anchorable-toc" id="toc_ember">Versions</h2>
<h2 class='anchorable-toc' id='toc_ember'>Versions</h2>
</div>

<ul class="ember-version-graphics">
<li class="item list-unstyled">
<EmberVersionGraphic @mascot="ember" />
<ul class="links">
<li class="list-unstyled" data-test-ember-1-link>
<LinkTo @route="ember" @model="v1.x">v1.x</LinkTo>
<ul class='ember-version-graphics'>
<li class='item list-unstyled'>
<EmberVersionGraphic @mascot='ember' />
<ul class='links'>
<li class='list-unstyled' data-test-ember-1-link>
<LinkTo @route='ember' @model='v1.x'>v1.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-2-link>
<LinkTo @route="ember" @model="v2.x">v2.x</LinkTo>
<li class='list-unstyled' data-test-ember-2-link>
<LinkTo @route='ember' @model='v2.x'>v2.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-3-link>
<LinkTo @route="ember" @model="v3.x">v3.x</LinkTo>
<li class='list-unstyled' data-test-ember-3-link>
<LinkTo @route='ember' @model='v3.x'>v3.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-4-link>
<LinkTo @route="ember" @model="v4.x">v4.x</LinkTo>
<li class='list-unstyled' data-test-ember-4-link>
<LinkTo @route='ember' @model='v4.x'>v4.x</LinkTo>
</li>
<li class='list-unstyled' data-test-ember-5-link>
<LinkTo @route='ember' @model='v5.x'>v5.x</LinkTo>
</li>
</ul>
</li>
<li class="item list-unstyled">
<EmberVersionGraphic @mascot="ember-cli" />
<ul class="links">
<li class="list-unstyled" data-test-ember-cli-2-link>
<LinkTo @route="show" @models={{array "ember-cli" "v2.x" }}>v2.x</LinkTo>
<li class='item list-unstyled'>
<EmberVersionGraphic @mascot='ember-cli' />
<ul class='links'>
<li class='list-unstyled' data-test-ember-cli-2-link>
<LinkTo
@route='show'
@models={{array 'ember-cli' 'v2.x'}}
>v2.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-cli-4-link>
<LinkTo @route="show" @models={{array "ember-cli" "v4.x" }}>v4.x</LinkTo>
<li class='list-unstyled' data-test-ember-cli-4-link>
<LinkTo
@route='show'
@models={{array 'ember-cli' 'v4.x'}}
>v4.x</LinkTo>
</li>
</ul>
</li>
<li class="item list-unstyled">
<EmberVersionGraphic @mascot="ember-data" />
<ul class="links">
<li class="list-unstyled" data-test-ember-data-2-link>
<LinkTo @route="show" @models={{array "ember-data" "v2.x" }}>v2.x</LinkTo>
<li class='item list-unstyled'>
<EmberVersionGraphic @mascot='ember-data' />
<ul class='links'>
<li class='list-unstyled' data-test-ember-data-2-link>
<LinkTo
@route='show'
@models={{array 'ember-data' 'v2.x'}}
>v2.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-data-3-link>
<LinkTo @route="show" @models={{array "ember-data" "v3.x" }}>v3.x</LinkTo>
<li class='list-unstyled' data-test-ember-data-3-link>
<LinkTo
@route='show'
@models={{array 'ember-data' 'v3.x'}}
>v3.x</LinkTo>
</li>
<li class="list-unstyled" data-test-ember-data-4-link>
<LinkTo @route="show" @models={{array "ember-data" "v4.x" }}>v4.x</LinkTo>
<li class='list-unstyled' data-test-ember-data-4-link>
<LinkTo
@route='show'
@models={{array 'ember-data' 'v4.x'}}
>v4.x</LinkTo>
</li>
</ul>
</li>
</ul>
</div>
</div>
24 changes: 24 additions & 0 deletions content/ember/v5/deprecate-implicit-route-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Implicit Route Model
until: 6.0.0
since: 5.3.0
---

Previously, if no `Route#model` hook was specified and a `_id` parameter was present, Ember would attempt to figure out how to load that model for you. Specify your own model hook to load from the store, if desired.

For example:

```js
import { Route } from '@ember/routing/route';
import { service } from '@ember/service';

export default class MyModelRoute extends Route {
@service store;

model({ my_model_id }) {
return this.store.findRecord('my-model', my_model_id);
}
}
```

For more background, read the [RFC](https://github.com/snewcomer/rfcs/blob/master/text/0774-implicit-record-route-loading.md).
2 changes: 2 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ module.exports = function (defaults) {
prember: {
urls: [
'/',
'/v5.x',
'/v4.x',
'/v3.x',
'/v2.x',
'/v1.x',
'/ember/v5.x',
'/ember/v4.x',
'/ember/v3.x',
'/ember/v2.x',
Expand Down
1 change: 1 addition & 0 deletions lib/content-docs-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const contentFolders = [
'ember/v2',
'ember/v3',
'ember/v4',
'ember/v5',
'ember-data/v2',
'ember-data/v3',
'ember-data/v4',
Expand Down
11 changes: 11 additions & 0 deletions tests/acceptance/visual-regression-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ module('Acceptance | visual regression', function (hooks) {

await percySnapshot('ember-cli-4.x');

// v5.x Ember
await click('[data-test-main-deprecations-link]');
await click('[data-test-ember-5-link] > a');

assert
.dom('[data-test-deprecations-added-in]')
.hasText('Deprecations Added in Ember 5.x');

await percySnapshot('ember-5.x');

// Individual page
await visit('/id/ember-polyfills-deprecate-assign');
assert.dom('h1').hasText('Deprecation Guide for Ember.assign');
await percySnapshot('individual-deprecation-page');
Expand Down

0 comments on commit f671e3c

Please sign in to comment.