Skip to content

Commit 87cffd8

Browse files
committed
Migration to native javascript classes - remove the @classic decorator (in components - without migration to glimmer components).
1 parent 93575f6 commit 87cffd8

16 files changed

Lines changed: 181 additions & 153 deletions

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
module.exports = {
44
root: true,
@@ -37,8 +37,8 @@ module.exports = {
3737
// 'ember/no-replace-test-comments': 'error',
3838
// 'ember/no-replace-test-comments': 'error',
3939
// NEW - for ember-classic-decorator and migration to native js classes
40-
'ember/classic-decorator-hooks': 0,
41-
'ember/classic-decorator-no-classic-methods': 0
40+
'ember/classic-decorator-hooks': 2,
41+
'ember/classic-decorator-no-classic-methods': 2
4242
},
4343
overrides: [
4444
// node files

app/components/bar-chart.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { classNameBindings, classNames, tagName } from '@ember-decorators/component';
33
import { action, computed } from '@ember/object';
44
import { schedule } from '@ember/runloop';
@@ -11,8 +11,8 @@ import { timeYears } from 'd3-time';
1111
import { timeFormat } from 'd3-time-format';
1212
import { scaleTime, scaleLinear } from 'd3-scale';
1313
import { A } from '@ember/array';
14+
import { tracked } from '@glimmer/tracking';
1415

15-
@classic
1616
@tagName('div')
1717
@classNames('col-lg-3', 'col-md-4')
1818
@classNameBindings('offset:col-lg-offset-3')
@@ -54,8 +54,8 @@ export default class BarChart extends Component {
5454
cumulative = true;
5555
summarize = false;
5656

57-
init() {
58-
super.init();
57+
constructor(...args) {
58+
super(...args);
5959

6060
schedule('afterRender', this, function () {
6161
this.send('barChart');

app/components/cc-license.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { classNames, tagName } from '@ember-decorators/component';
33
import { htmlSafe } from '@ember/template';
44
import { w } from '@ember/string';
55
import { A } from '@ember/array';
66
import Component from '@ember/component';
77
import URI from 'urijs';
8+
import { tracked } from '@glimmer/tracking';
89

910
const Tooltips = [
1011
{
@@ -39,7 +40,6 @@ const Tooltips = [
3940
}
4041
];
4142

42-
@classic
4343
@tagName('div')
4444
@classNames('license')
4545
export default class CcLicense extends Component {
@@ -79,9 +79,9 @@ export default class CcLicense extends Component {
7979
];
8080
}
8181
}
82-
this.set('licenseLogo', licenseLogo);
82+
this.licenseLogo = licenseLogo;
8383
} else {
84-
this.set('licenseLogo', null);
84+
this.licenseLogo = null;
8585
}
8686
}
8787
}

app/components/create-doi-button.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action } from '@ember/object';
33
import { classNames } from '@ember-decorators/component';
44
import { inject as service } from '@ember/service';
55
import Component from '@ember/component';
6+
import { tracked } from '@glimmer/tracking';
67

7-
@classic
88
@classNames('')
99
export default class CreateDoiButton extends Component {
1010
@service
@@ -13,12 +13,6 @@ export default class CreateDoiButton extends Component {
1313
@service
1414
router;
1515

16-
didReceiveAttrs() {
17-
super.didReceiveAttrs(...arguments);
18-
19-
this.set('currentUser', this.currentUser);
20-
}
21-
2216
@action
2317
createDoi() {
2418
this.router.transitionTo('repositories.show.dois.new');

app/components/doi-alternate-identifier.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action } from '@ember/object';
33
import Component from '@ember/component';
44
import { isBlank } from '@ember/utils';
5+
import { tracked } from '@glimmer/tracking';
56

67
const alternateIdentifierTypeList = [
78
'ARK',
@@ -25,13 +26,12 @@ const alternateIdentifierTypeList = [
2526
'w3id'
2627
];
2728

28-
@classic
2929
export default class DoiAlternateIdentifier extends Component {
3030
alternateIdentifierTypeList = alternateIdentifierTypeList;
3131
alternateIdentifierTypes = alternateIdentifierTypeList;
3232

33-
init(...args) {
34-
super.init(...args);
33+
constructor(...args) {
34+
super(...args);
3535

3636
this.selected = this.selected || [];
3737
}
@@ -48,7 +48,7 @@ export default class DoiAlternateIdentifier extends Component {
4848
this.alternateIdentifierTypes.push(select.searchText);
4949
select.actions.choose(select.searchText);
5050
this.fragment.set('alternateIdentifierType', select.searchText);
51-
this.set('alternateIdentifierTypes', alternateIdentifierTypeList);
51+
this.alternateIdentifierTypes = alternateIdentifierTypeList;
5252
}
5353
}
5454
}
@@ -61,11 +61,11 @@ export default class DoiAlternateIdentifier extends Component {
6161
@action
6262
selectAlternateIdentifierType(alternateIdentifierType) {
6363
this.fragment.set('alternateIdentifierType', alternateIdentifierType);
64-
this.set('alternateIdentifierTypes', alternateIdentifierTypeList);
64+
this.alternateIdentifierTypes = alternateIdentifierTypeList;
6565
}
6666

6767
@action
6868
deleteAlternateIdentifier() {
69-
this.model.get('alternateIdentifiers').removeObject(this.fragment);
69+
this.model.alternateIdentifiers.removeObject(this.fragment);
7070
}
7171
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action } from '@ember/object';
33
import Component from '@ember/component';
4+
import { tracked } from '@glimmer/tracking';
45

5-
@classic
66
export default class DoiAlternateIdentifiers extends Component {
7-
showAlternateIdentifiers = false;
7+
@tracked showAlternateIdentifiers = false;
88

99
didReceiveAttrs() {
1010
super.didReceiveAttrs(...arguments);
1111

12-
if (!this.model.get('alternateIdentifiers')) {
13-
this.model.set('alternateIdentifiers', []);
12+
if (!this.model.alternateIdentifiers) {
13+
this.model.alternateIdentifiers = [];
1414
}
1515
}
1616

1717
@action
1818
addAlternateIdentifier() {
19-
this.model.get('alternateIdentifiers').createFragment();
20-
this.set('showAlternateIdentifiers', true);
19+
this.model.alternateIdentifiers.createFragment();
20+
this.showAlternateIdentifiers = true;
2121
}
2222

2323
@action
2424
toggleAlternateIdentifiers() {
25-
this.set('showAlternateIdentifiers', !this.showAlternateIdentifiers);
25+
this.showAlternateIdentifiers = !this.showAlternateIdentifiers;
2626
}
2727
}

app/components/doi-citation-body.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { tagName } from '@ember-decorators/component';
33
import Component from '@ember/component';
4+
import { tracked } from '@glimmer/tracking';
45

5-
@classic
66
@tagName('div')
77
export default class DoiCitationBody extends Component {
88
didReceiveAttrs() {

app/components/doi-citation.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action } from '@ember/object';
33
import { tagName } from '@ember-decorators/component';
44
import { inject as service } from '@ember/service';
55
import Component from '@ember/component';
66
import fetch from 'fetch';
77
import ENV from 'bracco/config/environment';
88
import { UploadFile, UploadFileReader } from 'ember-file-upload';
9+
import { tracked } from '@glimmer/tracking';
910

10-
@classic
1111
@tagName('div')
1212
export default class DoiCitation extends Component {
1313
@service
@@ -29,17 +29,17 @@ export default class DoiCitation extends Component {
2929
'chicago-fullnote-bibliography': 'Chicago',
3030
ieee: 'IEEE'
3131
};
32-
this.set('citationFormats', citationFormats);
32+
this.citationFormats = citationFormats;
3333
}
3434

3535
selectStyle(style) {
3636
let self = this;
3737
let url =
38-
ENV.API_URL + '/dois/' + this.model.get('doi') + '?style=' + style;
38+
ENV.API_URL + '/dois/' + this.modeldoi + '?style=' + style;
3939
let headers = { Accept: 'text/x-bibliography' };
40-
if (this.currentUser.get('jwt')) {
40+
if (this.currentUser.jwt) {
4141
headers = {
42-
Authorization: 'Bearer ' + this.currentUser.get('jwt'),
42+
Authorization: 'Bearer ' + this.currentUser.jwt,
4343
Accept: 'text/x-bibliography'
4444
};
4545
}
@@ -55,23 +55,22 @@ export default class DoiCitation extends Component {
5555

5656
result.then(async function (response) {
5757
if (typeof response === 'string') {
58-
self.set('citationOutput', response);
58+
self.citationOutput = response;
5959
} else {
6060
if (self.isDestroying || self.isDestroyed) {
6161
return;
6262
}
6363
let reader = UploadFile.fromBlob(response, 'blob')
6464
reader.readAsText().then(
6565
(result) => {
66-
self.set('citationOutput', result);
66+
self.citationOutput = result;
6767
},
6868
(err) => {
6969
console.error(err);
7070
}
7171
);
7272
}
7373
});
74-
// this.get('router').transitionTo({ queryParams: { citation: citation } });
7574
}
7675

7776
@action

app/components/doi-contributor.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action, computed } from '@ember/object';
33
import PersonBaseComponent from './person-base-component';
44
import { pascalCase } from 'pascal-case';
55
import humanizeString from 'humanize-string';
66
import { isBlank } from '@ember/utils';
7+
import { tracked } from '@glimmer/tracking';
78

89
const contributorTypes = [
910
'ContactPerson',
@@ -54,22 +55,21 @@ const personalContributorTypes = [
5455
'WorkPackageLeader'
5556
];
5657

57-
@classic
5858
export default class DoiContributor extends PersonBaseComponent {
5959
humanContributorTypes = humanContributorTypes;
6060

6161
@computed('fragment.contributorType')
6262
get humanContributorType() {
63-
return isBlank(this.get('fragment.contributorType'))
63+
return isBlank(this.fragment.contributorType)
6464
? null
65-
: humanizeString(this.get('fragment.contributorType'));
65+
: humanizeString(this.fragment.contributorType);
6666
}
6767

6868
selectContributorType(contributorType) {
6969
if (contributorType) {
7070
let contributorTypeId = pascalCase(contributorType);
71-
this.fragment.set('contributorType', contributorTypeId);
72-
this.set('contributorType', contributorType);
71+
this.fragment.contributorType = contributorTypeId;
72+
this.contributorType = contributorType;
7373

7474
if (organizationalContributorTypes.includes(contributorTypeId)) {
7575
this.selectNameType('Organizational');
@@ -79,14 +79,14 @@ export default class DoiContributor extends PersonBaseComponent {
7979
this.selectNameType('Personal');
8080
}
8181
} else {
82-
this.fragment.set('contributorType', null);
82+
this.fragment.contributorType = null;
8383
}
84-
this.set('humanContributorTypes', humanContributorTypes);
84+
this.humanContributorTypes = humanContributorTypes;
8585
}
8686

8787
@action
8888
deleteContributorAction() {
89-
this.model.get('contributors').removeObject(this.fragment);
89+
this.model.contributors.removeObject(this.fragment);
9090
}
9191

9292
@action

app/components/doi-contributors.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
1-
import classic from 'ember-classic-decorator';
1+
// Finish conversion of this component to a @glimmer component.
22
import { action } from '@ember/object';
33
import Component from '@ember/component';
4+
import { tracked } from '@glimmer/tracking';
45

5-
@classic
66
export default class DoiContributors extends Component {
7-
showContributors = false;
7+
@tracked showContributors = false;
88

99
didReceiveAttrs() {
1010
super.didReceiveAttrs(...arguments);
1111

12-
if (!this.model.get('contributors')) {
13-
this.model.set('contributors', []);
12+
if (!this.model.contributors) {
13+
this.model.contributors = [];
1414
}
1515
}
1616

1717
@action
1818
addContributor() {
19-
this.model
20-
.get('contributors')
21-
.createFragment({ nameIdentifiers: [], affiliation: [] });
22-
this.model
23-
.get('contributors')
24-
.get('lastObject')
25-
.get('nameIdentifiers')
26-
.createFragment();
27-
this.model
28-
.get('contributors')
29-
.get('lastObject')
30-
.get('affiliation')
31-
.createFragment();
32-
this.set('showContributors', true);
19+
this.model.contributors.createFragment({ nameIdentifiers: [], affiliation: [] });
20+
this.model.contributors.lastObject.nameIdentifiers.createFragment();
21+
this.model.contributors.lastObject.affiliation.createFragment();
22+
this.showContributors = true;
3323
}
3424

3525
@action
3626
toggleContributors() {
37-
this.set('showContributors', !this.showContributors);
27+
this.showContributors = !this.showContributors;
3828
}
3929
}

0 commit comments

Comments
 (0)