Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Update Ember.deprecate and Ember.warn calls to include required information #3575

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions packages/ember-data/lib/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ var BuildURLMixin = Ember.Mixin.create({
*/
urlForFindRecord: function(id, modelName, snapshot) {
if (this.urlForFind !== urlForFind) {
Ember.deprecate('BuildURLMixin#urlForFind has been deprecated and renamed to `urlForFindRecord`.');
Ember.deprecate('BuildURLMixin#urlForFind has been deprecated and renamed to `urlForFindRecord`.', false, {
id: 'ds.adapter.url-for-find-deprecated',
until: '2.0.0'
});
return this.urlForFind(id, modelName, snapshot);
}
return this._buildURL(modelName, id);
Expand Down Expand Up @@ -160,7 +163,10 @@ var BuildURLMixin = Ember.Mixin.create({
*/
urlForQuery: function(query, modelName) {
if (this.urlForFindQuery !== urlForFindQuery) {
Ember.deprecate('BuildURLMixin#urlForFindQuery has been deprecated and renamed to `urlForQuery`.');
Ember.deprecate('BuildURLMixin#urlForFindQuery has been deprecated and renamed to `urlForQuery`.', false, {
id: 'ds.adapter.url-for-find-query-deprecated',
until: '2.0.0'
});
return this.urlForFindQuery(query, modelName);
}
return this._buildURL(modelName);
Expand Down Expand Up @@ -305,12 +311,19 @@ var BuildURLMixin = Ember.Mixin.create({
});

function urlForFind(id, modelName, snapshot) {
Ember.deprecate('BuildURLMixin#urlForFind has been deprecated and renamed to `urlForFindRecord`.');
Ember.deprecate('BuildURLMixin#urlForFind has been deprecated and renamed to `urlForFindRecord`.', false, {
id: 'ds.adapter.url-for-find-deprecated',
until: '2.0.0'
});

return this._buildURL(modelName, id);
}

function urlForFindQuery(query, modelName) {
Ember.deprecate('BuildURLMixin#urlForFindQuery has been deprecated and renamed to `urlForQuery`.');
Ember.deprecate('BuildURLMixin#urlForFindQuery has been deprecated and renamed to `urlForQuery`.', false, {
id: 'ds.adapter.url-for-find-query-deprecated',
until: '2.0.0'
});
return this._buildURL(modelName);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/adapters/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ AdapterError.prototype = create(EmberError.prototype);
*/
export function InvalidError(errors) {
if (!Ember.isArray(errors)) {
Ember.deprecate("`InvalidError` expects json-api formatted errors.");
Ember.deprecate('`InvalidError` expects json-api formatted errors.', false, { id: 'ds.errors.invalid-error-expects-json-api-format', until: '2.0.0' });
errors = errorsHashToArray(errors);
}
AdapterError.call(this, errors, "The adapter rejected the commit because it was invalid");
Expand Down
40 changes: 32 additions & 8 deletions packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
@deprecated Use [findRecord](#method_findRecord) instead
*/
find: function(store, type, id, snapshot) {
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.');
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.', false, {
id: 'ds.adapter.find-renamed-to-find-record',
until: '2.0.0'
});
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'find'), 'GET');
},

Expand All @@ -389,7 +392,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
findRecord: function(store, type, id, snapshot) {
var find = RestAdapter.prototype.find;
if (find !== this.find) {
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.');
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.', false, {
id: 'ds.adapter.find-renamed-to-find-record',
until: '2.0.0'
});
return this.find(store, type, id, snapshot);
}
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'findRecord'), 'GET');
Expand Down Expand Up @@ -440,7 +446,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
@deprecated Use [query](#method_query) instead
*/
findQuery: function(store, type, query) {
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.');
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.', false, {
id: 'ds.adapter.find-query-renamed-to-query',
until: '2.0.0'
});
var url = this.buildURL(type.modelName, null, null, 'findQuery', query);

if (this.sortQueryParams) {
Expand Down Expand Up @@ -470,7 +479,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
query: function(store, type, query) {
var findQuery = RestAdapter.prototype.findQuery;
if (findQuery !== this.findQuery) {
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.');
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.', false, {
id: 'ds.adapter.find-query-renamed-to-query',
until: '2.0.0'
});
return this.findQuery(store, type, query);
}

Expand Down Expand Up @@ -900,7 +912,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
let response;

if (adapter.ajaxSuccess) {
Ember.deprecate("`ajaxSuccess` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.");
Ember.deprecate("`ajaxSuccess` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.", false, {
id: 'ds.adapter.ajax-success-deprecated',
until: '2.0.0'
});
response = adapter.ajaxSuccess(jqXHR, payload);
}

Expand All @@ -923,7 +938,10 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
let error;

if (adapter.ajaxError) {
Ember.deprecate("`ajaxError` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.");
Ember.deprecate("`ajaxError` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.", false, {
id: 'ds.adapter.ajax-error-deprecated',
until: '2.0.0'
});
error = adapter.ajaxError(jqXHR, textStatus, errorThrown);
}

Expand Down Expand Up @@ -1054,12 +1072,18 @@ if (Ember.platform.hasPropertyAccessors) {
Ember.defineProperty(RestAdapter.prototype, 'maxUrlLength', {
enumerable: false,
get: function() {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.', false, {
id: 'ds.adapter.max-url-length-deprecated-case',
until: '2.0.0'
});
return this.maxURLLength;
},

set: function(value) {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.', false, {
id: 'ds.adapter.max-url-length-deprecated-case',
until: '2.0.0'
});
set(this, 'maxURLLength', value);
}
});
Expand Down
13 changes: 10 additions & 3 deletions packages/ember-data/lib/initializers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import ContainerProxy from "ember-data/system/container-proxy";
*/
export default function initializeStore(registry, application) {
Ember.deprecate('Specifying a custom Store for Ember Data on your global namespace as `App.Store` ' +
'has been deprecated. Please use `App.ApplicationStore` instead.', !(application && application.Store));
'has been deprecated. Please use `App.ApplicationStore` instead.', !(application && application.Store),
{ id: 'ds.initializer.specifying-custom-store-on-global-namespace-deprecated', until: '2.0.0' });

registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
Expand All @@ -37,7 +38,10 @@ export default function initializeStore(registry, application) {

var store;
if (registry.has('store:main')) {
Ember.deprecate('Registering a custom store as `store:main` or defining a store in app/store.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`');
Ember.deprecate('Registering a custom store as `store:main` or defining a store in app/store.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`', false, {
id: 'ds.initializer.custom-store-as-store-main-deprecated',
until: '2.0.0'
});
store = registry.lookup('store:main');
} else {
var storeMainProxy = new ContainerProxy(registry);
Expand All @@ -47,7 +51,10 @@ export default function initializeStore(registry, application) {
}

if (registry.has('store:application')) {
Ember.deprecate('Registering a custom store as `store:application` or defining a store in app/stores/application.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`');
Ember.deprecate('Registering a custom store as `store:main` or defining a store in app/store.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`', false, {
id: 'ds.initializer.custom-store-as-store-main-deprecated',
until: '2.0.0'
});
store = registry.lookup('store:application');
} else {
var storeApplicationProxy = new ContainerProxy(registry);
Expand Down
13 changes: 10 additions & 3 deletions packages/ember-data/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ if (Ember.platform.hasPropertyAccessors) {
get: function() {
if (_ActiveModelSerializer === ActiveModelAdapter) {
Ember.deprecate('The ActiveModelAdapter has been moved into a plugin. It will not be bundled with Ember Data in 2.0', false, {
url: 'https://github.com/ember-data/active-model-adapter'
url: 'https://github.com/ember-data/active-model-adapter',
id: 'ds.adapter.active-model-adapter-deprecated',
until: '2.0.0'
});
}
return _ActiveModelAdapter;
Expand All @@ -164,7 +166,9 @@ if (Ember.platform.hasPropertyAccessors) {
get: function() {
if (_ActiveModelSerializer === ActiveModelSerializer) {
Ember.deprecate('The ActiveModelSerializer has been moved into a plugin. It will not be bundled with Ember Data in 2.0', false, {
url: 'https://github.com/ember-data/active-model-adapter'
url: 'https://github.com/ember-data/active-model-adapter',
id: 'ds.serializer.active-model-serializer-deprecated',
until: '2.0.0'
});
}
return _ActiveModelSerializer;
Expand Down Expand Up @@ -201,7 +205,10 @@ if (Ember.platform.hasPropertyAccessors) {
Ember.defineProperty(DS, 'FixtureAdapter', {
get: function() {
if (_FixtureAdapter === FixtureAdapter) {
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master');
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master', false, {
id: 'ds.adapter.fixture-adapter-deprecated',
until: '2.0.0'
});
}
return _FixtureAdapter;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ var EmbeddedRecordsMixin = Ember.Mixin.create({
key = this.keyForAttribute(attr, 'serialize');
hasMany = snapshot.hasMany(attr);

Ember.warn("The embedded relationship '" + key + "' is undefined for '" + snapshot.modelName + "' with id '" + snapshot.id + "'. Please include it in your original payload.", Ember.typeOf(hasMany) !== 'undefined');
Ember.warn(
`The embedded relationship '${key}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`,
Ember.typeOf(hasMany) !== 'undefined',
{ id: 'ds.serializer.embedded-relationship-undefined' }
);

json[key] = Ember.A(hasMany).map(function(embeddedSnapshot) {
var embeddedJson = embeddedSnapshot.record.serialize({ includeId: true });
Expand Down
10 changes: 8 additions & 2 deletions packages/ember-data/lib/serializers/json-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,10 @@ var JSONSerializer = Serializer.extend({
extractSingle: function(store, typeClass, payload, id, requestType) {
if (!this.get('didDeprecateNormalizePayload')) {
this.set('didDeprecateNormalizePayload', true);
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === JSONSerializer.prototype.normalizePayload);
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === JSONSerializer.prototype.normalizePayload, {
id: 'ds.serializer.normalize-payload-deprecated',
until: '2.0.0'
});
}
var normalizedPayload = this.normalizePayload(payload);
return this.normalize(typeClass, normalizedPayload);
Expand Down Expand Up @@ -1505,7 +1508,10 @@ var JSONSerializer = Serializer.extend({
extractArray: function(store, typeClass, arrayPayload, id, requestType) {
if (!this.get('didDeprecateNormalizePayload')) {
this.set('didDeprecateNormalizePayload', true);
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === JSONSerializer.prototype.normalizePayload);
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === JSONSerializer.prototype.normalizePayload, {
id: 'ds.serializer.normalize-payload-deprecated',
until: '2.0.0'
});
}
var normalizedPayload = this.normalizePayload(arrayPayload);
var serializer = this;
Expand Down
Loading