Skip to content

Commit 1839720

Browse files
committed
Auto merge of #2802 - Turbo87:pagination, r=locks
Replace `pagination` mixin with computed property macro ... and then finally enable the `no-mixin` ESLint rule r? `@locks`
2 parents e056aab + 26e770a commit 1839720

26 files changed

+127
-135
lines changed

.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = {
1818

1919
'ember/no-empty-attrs': 'off',
2020
'ember/no-get': 'off',
21-
'ember/no-mixins': 'off',
2221
'ember/require-computed-property-dependencies': 'off',
2322

2423
'import-helpers/order-imports': [

app/components/pagination.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<nav local-class='pagination' aria-label="Pagination navigation">
2-
<LinkTo @query={{hash page=@prevPage}} local-class="prev" @rel="prev" @title="previous page" data-test-pagination-prev>
2+
<LinkTo @query={{hash page=@pagination.prevPage}} local-class="prev" @rel="prev" @title="previous page" data-test-pagination-prev>
33
{{svg-jar "left-pag"}}
44
</LinkTo>
55
<ol>
6-
{{#each @pages as |page|}}
6+
{{#each @pagination.pages as |page|}}
77
<li>
88
<LinkTo @query={{hash page=page}} @title={{concat "Go to page " page}}>
99
{{ page }}
1010
</LinkTo>
1111
</li>
1212
{{/each}}
1313
</ol>
14-
<LinkTo @query={{hash page=@nextPage}} local-class="next" @rel="next" @title="next page" data-test-pagination-next>
14+
<LinkTo @query={{hash page=@pagination.nextPage}} local-class="next" @rel="next" @title="next page" data-test-pagination-next>
1515
{{svg-jar "right-pag"}}
1616
</LinkTo>
1717
</nav>

app/controllers/categories.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 100,
1111
sort: 'alpha',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
return this.sort === 'crates' ? '# Crates' : 'Alphabetical';

app/controllers/category/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'recent-downloads',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
category: null,
1617

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import Controller from '@ember/controller';
22
import { readOnly } from '@ember/object/computed';
33

4-
import PaginationMixin from '../../mixins/pagination';
4+
import { pagination } from '../../utils/pagination';
55

6-
export default Controller.extend(PaginationMixin, {
6+
export default Controller.extend({
77
queryParams: ['page', 'per_page'],
88
page: '1',
99
per_page: 10,
1010
crate: null,
1111

1212
totalItems: readOnly('model.meta.total'),
13+
pagination: pagination(),
1314
});

app/controllers/crates.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['letter', 'page', 'per_page', 'sort'],
99
letter: null,
1010
page: '1',
@@ -13,6 +13,7 @@ export default Controller.extend(PaginationMixin, {
1313
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/controllers/keyword/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'recent-downloads',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
if (this.sort === 'downloads') {

app/controllers/keywords.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'crates',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
return this.sort === 'crates' ? '# Crates' : 'Alphabetical';

app/controllers/me/crates.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

77
// TODO: reduce duplicatoin with controllers/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/controllers/me/following.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

77
// TODO: reduce duplicatoin with controllers/me/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
return this.sort === 'downloads' ? 'Downloads' : 'Alphabetical';

app/controllers/search.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { bool, readOnly } from '@ember/object/computed';
44

55
import { task } from 'ember-concurrency';
66

7-
import PaginationMixin from '../mixins/pagination';
7+
import { pagination } from '../utils/pagination';
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['all_keywords', 'page', 'per_page', 'q', 'sort'],
1111
q: null,
1212
page: '1',
@@ -23,6 +23,7 @@ export default Controller.extend(PaginationMixin, {
2323
}),
2424

2525
totalItems: readOnly('model.meta.total'),
26+
pagination: pagination(),
2627

2728
currentSortBy: computed('sort', function () {
2829
if (this.sort === 'downloads') {

app/controllers/team.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'alpha',
1212

1313
totalItems: readOnly('model.crates.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
if (this.sort === 'downloads') {

app/controllers/user.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

77
// TODO: reduce duplication with controllers/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.crates.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/mixins/pagination.js

-76
This file was deleted.

app/templates/categories.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
<div local-class="results-meta">
66
<ResultsCount
7-
@start={{this.currentPageStart}}
8-
@end={{this.currentPageEnd}}
7+
@start={{this.pagination.currentPageStart}}
8+
@end={{this.pagination.currentPageEnd}}
99
@total={{this.totalItems}}
1010
data-test-categories-nav
1111
/>
@@ -37,7 +37,7 @@
3737
{{/each}}
3838
</div>
3939

40-
<Pagination @pages={{this.pages}} @prevPage={{this.prevPage}} @nextPage={{this.nextPage}} />
40+
<Pagination @pagination={{this.pagination}} />
4141

4242
<div local-class='categories-footer'>
4343
Want to categorize your crate?

app/templates/category/index.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<h2>Crates</h2>
3737
<div local-class="results-meta">
3838
<ResultsCount
39-
@start={{this.currentPageStart}}
40-
@end={{this.currentPageEnd}}
39+
@start={{this.pagination.currentPageStart}}
40+
@end={{this.pagination.currentPageEnd}}
4141
@total={{this.totalItems}}
4242
data-test-category-nav
4343
/>
@@ -60,4 +60,4 @@
6060
{{/each}}
6161
</div>
6262

63-
<Pagination @pages={{this.pages}} @prevPage={{this.prevPage}} @nextPage={{this.nextPage}} />
63+
<Pagination @pagination={{this.pagination}} />

app/templates/crate/reverse-dependencies.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
<div local-class="results-meta">
66
<ResultsCount
7-
@start={{this.currentPageStart}}
8-
@end={{this.currentPageEnd}}
7+
@start={{this.pagination.currentPageStart}}
8+
@end={{this.pagination.currentPageEnd}}
99
@total={{this.totalItems}}
1010
@name="reverse dependencies of {{this.crate.name}}"
1111
/>
@@ -25,4 +25,4 @@
2525
{{/each}}
2626
</div>
2727

28-
<Pagination @pages={{this.pages}} @prevPage={{this.prevPage}} @nextPage={{this.nextPage}} />
28+
<Pagination @pagination={{this.pagination}} />

app/templates/crates.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<div local-class="results-meta">
2121
<ResultsCount
22-
@start={{this.currentPageStart}}
23-
@end={{this.currentPageEnd}}
22+
@start={{this.pagination.currentPageStart}}
23+
@end={{this.pagination.currentPageEnd}}
2424
@total={{this.totalItems}}
2525
data-test-crates-nav
2626
/>
@@ -43,4 +43,4 @@
4343
{{/each}}
4444
</div>
4545

46-
<Pagination @pages={{this.pages}} @prevPage={{this.prevPage}} @nextPage={{this.nextPage}} />
46+
<Pagination @pagination={{this.pagination}} />

0 commit comments

Comments
 (0)