From 2d8abde7523a87a8d7f85423b299421e847bf054 Mon Sep 17 00:00:00 2001 From: Brian Runnells Date: Mon, 12 Feb 2018 16:54:55 -0600 Subject: [PATCH] properly deprecate removed properties --- addon/models/github-organization.js | 15 +++++++++++++-- addon/models/github-release.js | 4 ++-- addon/models/github-user.js | 9 ++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/addon/models/github-organization.js b/addon/models/github-organization.js index 56525e1..74ab6b0 100644 --- a/addon/models/github-organization.js +++ b/addon/models/github-organization.js @@ -1,12 +1,23 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; import { hasMany } from 'ember-data/relationships'; +import { deprecate } from '@ember/application/deprecations'; +import { computed } from '@ember/object'; export default Model.extend({ login: attr('string'), name: attr('string'), avatarUrl: attr('string'), - members: hasMany('github-member', { inverse: null }), - repositories: hasMany('github-repository') + members: hasMany('github-member'), + repositories: hasMany('github-repository'), + + githubUsers: computed('members.[]', function() { + deprecate('The githubUsers property on the github-organization model has been deprecated. Please use the members property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); + return this.get('members'); + }), + githubRepositories: computed('repositories.[]', function() { + deprecate('The githubRepositories property on the github-organization model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); + return this.get('repositories'); + }) }); diff --git a/addon/models/github-release.js b/addon/models/github-release.js index 5f9b13a..908ec7b 100644 --- a/addon/models/github-release.js +++ b/addon/models/github-release.js @@ -21,8 +21,8 @@ export default Model.extend({ publishedAt: attr('date'), author: belongsTo('github-user', { inverse: null }), - user: computed(function() { - deprecate('The user property on the github-release model has been deprecated. Please use the author property.', false, { id: 'ember-data-github.release-author', until: '1.0.0' }); + user: computed('author', function() { + deprecate('The user property on the github-release model has been deprecated. Please use the author property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); return this.get('author'); }), repository: belongsTo('github-repository') diff --git a/addon/models/github-user.js b/addon/models/github-user.js index 95ace00..0de8c9d 100644 --- a/addon/models/github-user.js +++ b/addon/models/github-user.js @@ -1,6 +1,8 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; import { hasMany } from 'ember-data/relationships'; +import { deprecate } from '@ember/application/deprecations'; +import { computed } from '@ember/object'; export default Model.extend({ login: attr('string'), @@ -21,5 +23,10 @@ export default Model.extend({ email: attr('string'), bio: attr('string'), - repositories: hasMany('github-repository') + repositories: hasMany('github-repository'), + + githubRepositories: computed('repositories.[]', function() { + deprecate('The githubRepositories property on the github-user model has been deprecated. Please use the repositories property.', false, { id: 'ember-data-github.deprecated-model-props', until: '1.0.0' }); + return this.get('repositories'); + }), });