-
Notifications
You must be signed in to change notification settings - Fork 27
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
imports actualized #1338
base: develop
Are you sure you want to change the base?
imports actualized #1338
Changes from all commits
ce6eb47
1b1c5ed
1ae6973
a18a13f
dbbbc41
0c243aa
1a9024f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,9 +375,9 @@ export default Service.extend(Evented, { | |
|
||
this.initProperties(); | ||
|
||
let originalEmberLoggerError = Ember.Logger.error; | ||
let originalEmberLoggerError = console.error; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
Comment on lines
+378
to
+380
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure correct context when caching original console methods When caching the original Modify the caching of the original methods to include binding: let originalEmberLoggerError = console.error;
+originalEmberLoggerError = originalEmberLoggerError.bind(console);
originalMethodsCache.pushObject({
methodOwner: console,
methodName: 'error',
methodReference: originalEmberLoggerError
}); Repeat this binding for other console methods as needed.
|
||
methodName: 'error', | ||
methodReference: originalEmberLoggerError | ||
}); | ||
|
@@ -398,111 +398,141 @@ export default Service.extend(Evented, { | |
_this._onError(reason, true); | ||
}; | ||
|
||
console.error = function(error) { | ||
originalEmberLoggerError(error); | ||
_this._onError(error, true); | ||
}; | ||
|
||
console.warn = function(warn) { | ||
originalEmberLoggerError(warn); | ||
_this._onError(warn, true); | ||
}; | ||
Comment on lines
+406
to
+409
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect use of In the overridden To fix this, call the appropriate original console method in each override. Ensure that you've cached these original methods correctly. Apply this diff to fix the issue: // Override console.warn
console.warn = function(warn) {
- originalEmberLoggerError(warn);
+ originalEmberLoggerWarn(warn);
_this._onError(warn, true);
};
// Override console.deprecated
console.deprecated = function(deprecate) {
- originalEmberLoggerError(deprecate);
+ originalEmberLoggerDeprecate(deprecate);
_this._onError(deprecate, true);
};
// Override console.log
console.log = function(log) {
- originalEmberLoggerError(log);
+ originalEmberLoggerLog(log);
_this._onError(log, true);
};
// Override console.info
console.info = function(info) {
- originalEmberLoggerError(info);
+ originalEmberLoggerInfo(info);
_this._onError(info, true);
};
// Override console.debug
console.debug = function(debug) {
- originalEmberLoggerError(debug);
+ originalEmberLoggerDebug(debug);
_this._onError(debug, true);
}; Also applies to: 411-414, 416-419, 421-424, 426-429 |
||
|
||
console.deprecated = function(deprecate) { | ||
originalEmberLoggerError(deprecate); | ||
_this._onError(deprecate, true); | ||
}; | ||
Comment on lines
+411
to
+414
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage of non-standard The Consider using |
||
|
||
console.log = function(log) { | ||
originalEmberLoggerError(log); | ||
_this._onError(log, true); | ||
}; | ||
|
||
console.info = function(info) { | ||
originalEmberLoggerError(info); | ||
_this._onError(info, true); | ||
}; | ||
|
||
console.debug = function(debug) { | ||
originalEmberLoggerError(debug); | ||
_this._onError(debug, true); | ||
}; | ||
|
||
// Assign Ember.onerror & RSVP.on('error', ...) handlers (see http://emberjs.com/api/#event_onerror). | ||
Ember.onerror = onError; | ||
RSVP.on('error', onPromiseError); | ||
|
||
// Extend Ember.Logger.error logic. | ||
Ember.Logger.error = function() { | ||
originalEmberLoggerError(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.error, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// Ember.Logger.error = function() { | ||
// originalEmberLoggerError(...arguments); | ||
|
||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.error, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.warn logic. | ||
let originalEmberLoggerWarn = Ember.Logger.warn; | ||
let originalEmberLoggerWarn = console.warn; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'warn', | ||
methodReference: originalEmberLoggerWarn | ||
}); | ||
|
||
Ember.Logger.warn = function() { | ||
originalEmberLoggerWarn(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
let message = joinArguments(...arguments); | ||
if (message.indexOf('DEPRECATION') === 0) { | ||
return _this._storeToApplicationLog(messageCategory.deprecate, message, '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
} else { | ||
return _this._storeToApplicationLog(messageCategory.warn, message, '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
} | ||
}); | ||
}; | ||
// Ember.Logger.warn = function() { | ||
// originalEmberLoggerWarn(...arguments); | ||
|
||
// return _this._queue.attach((resolve, reject) => { | ||
// let message = joinArguments(...arguments); | ||
// if (message.indexOf('DEPRECATION') === 0) { | ||
// return _this._storeToApplicationLog(messageCategory.deprecate, message, '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// } else { | ||
// return _this._storeToApplicationLog(messageCategory.warn, message, '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// } | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.log logic. | ||
let originalEmberLoggerLog = Ember.Logger.log; | ||
let originalEmberLoggerLog = console.log.bind; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'log', | ||
methodReference: originalEmberLoggerLog | ||
}); | ||
|
||
Ember.Logger.log = function() { | ||
originalEmberLoggerLog(...arguments); | ||
// Ember.Logger.log = function() { | ||
// originalEmberLoggerLog(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.log, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.log, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.info logic. | ||
let originalEmberLoggerInfo = Ember.Logger.info; | ||
let originalEmberLoggerInfo = console.info; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'info', | ||
methodReference: originalEmberLoggerInfo | ||
}); | ||
|
||
Ember.Logger.info = function() { | ||
originalEmberLoggerInfo(...arguments); | ||
// Ember.Logger.info = function() { | ||
// originalEmberLoggerInfo(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.info, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.info, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.debug logic. | ||
let originalEmberLoggerDebug = Ember.Logger.debug; | ||
let originalEmberLoggerDebug = console.debug; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'debug', | ||
methodReference: originalEmberLoggerDebug | ||
}); | ||
|
||
Ember.Logger.debug = function() { | ||
originalEmberLoggerDebug(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.debug, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// Ember.Logger.debug = function() { | ||
// originalEmberLoggerDebug(...arguments); | ||
|
||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.debug, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
Comment on lines
+436
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove commented-out code for better maintainability There are large blocks of commented-out code related to If this code is no longer needed, consider removing it to clean up the codebase. |
||
|
||
this.set('_originalMethodsCache', originalMethodsCache); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import Ember from 'ember'; | ||
import { set } from '@ember/object'; | ||
import { run } from '@ember/runloop'; | ||
import $ from 'jquery'; | ||
import { module, test } from 'qunit'; | ||
import startApp from '../../../helpers/start-app'; | ||
import { deleteRecords, addRecords } from './folv-tests-functions'; | ||
|
@@ -27,13 +29,13 @@ module('Acceptance | flexberry-objectlistview | per page user settings', { | |
store = app.__container__.lookup('service:store'); | ||
route = app.__container__.lookup('route:components-acceptance-tests/flexberry-objectlistview/folv-user-settings'); | ||
userService = app.__container__.lookup('service:user-settings') | ||
Ember.set(userService, 'isUserSettingsServiceEnabled', true); | ||
set(userService, 'isUserSettingsServiceEnabled', true); | ||
}, | ||
|
||
afterEach() { | ||
// Destroy application. | ||
Ember.set(userService, 'isUserSettingsServiceEnabled', true); | ||
Ember.run(app, 'destroy'); | ||
set(userService, 'isUserSettingsServiceEnabled', true); | ||
run(app, 'destroy'); | ||
} | ||
}); | ||
|
||
|
@@ -49,7 +51,7 @@ test('check saving of user settings', function(assert) { | |
route.set('developerUserSettings', { FOLVPagingObjectListView: { DEFAULT: { colsOrder: [ { propName: 'name' } ], perPage: 28 } } }); | ||
|
||
// Add records for paging. | ||
Ember.run(() => { | ||
run(() => { | ||
addRecords(store, modelName, uuid).then(function(resolvedPromises) { | ||
assert.ok(resolvedPromises, 'All records saved.'); | ||
let done = assert.async(); | ||
|
@@ -139,10 +141,10 @@ function checkWithDisabledUserSettings(assert, asyncDone, uuid) { | |
andThen(function() { | ||
assert.equal(currentPath(), pathHelp); | ||
route.set('developerUserSettings', { FOLVPagingObjectListView: { DEFAULT: { colsOrder: [ { propName: 'name' } ], perPage: 11 } } }); | ||
Ember.set(userService, 'isUserSettingsServiceEnabled', false); | ||
set(userService, 'isUserSettingsServiceEnabled', false); | ||
|
||
// Remove current saved not in Database settings. | ||
Ember.set(userService, 'currentUserSettings', {}); | ||
set(userService, 'currentUserSettings', {}); | ||
|
||
let done1 = assert.async(); | ||
visit(path); | ||
|
@@ -155,7 +157,7 @@ function checkWithDisabledUserSettings(assert, asyncDone, uuid) { | |
} catch(error) { | ||
throw error; | ||
} finally { | ||
Ember.set(userService, 'isUserSettingsServiceEnabled', true); | ||
set(userService, 'isUserSettingsServiceEnabled', true); | ||
deleteRecords(store, modelName, uuid, assert); | ||
deleteUserSetting(assert); | ||
done1(); | ||
|
@@ -175,14 +177,14 @@ function checkWithDisabledUserSettings(assert, asyncDone, uuid) { | |
// Function to check current perPage value on page. | ||
function checkPaging(assert, expectedCount) { | ||
// check paging. | ||
let $perPageElement = Ember.$('div.flexberry-dropdown div.text'); | ||
let $perPageElement = $('div.flexberry-dropdown div.text'); | ||
assert.equal($perPageElement.length, 1, "Элемент количества записей на странице найден."); | ||
assert.equal($perPageElement.text(), expectedCount, `Количество элементов на странице равно заданному: ${expectedCount}.`) | ||
Comment on lines
+180
to
182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using data-test- selectors for more reliable tests.* While the jQuery usage is correct, the selector - let $perPageElement = $('div.flexberry-dropdown div.text');
+ let $perPageElement = $('[data-test-per-page-dropdown]'); Also update the corresponding component template to include the test selector: <div class="flexberry-dropdown" data-test-per-page-dropdown>
<div class="text">
{{perPage}}
</div>
</div> |
||
} | ||
|
||
// Function for deleting user settings from database. | ||
function deleteUserSetting(assert) { | ||
Ember.run(() => { | ||
run(() => { | ||
let done = assert.async(); | ||
userService._getExistingSettings("FOLVPagingObjectListView", "DEFAULT").then( | ||
foundRecords => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import Ember from 'ember'; //TODO Import Module. Replace Ember.generateGuid, Ember.Logger | ||
import Ember from 'ember'; //TODO Import Module. Replace Ember.Logger | ||
// import { generateGuid } from '@ember/object/internals'; | ||
import generateUniqueId from 'ember-flexberry-data/utils/generate-unique-id'; | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Complete the TODO: Replace Ember.Logger usage with native console methods. The TODO comment indicates that Ember.Logger needs to be replaced, but the file still uses Ember.Logger in multiple places. This is inconsistent with the PR's goal of actualizing imports. Replace Ember.Logger with native console methods throughout the file. For example: -Ember.Logger.error(...)
+console.error(...)
-Ember.Logger.log(...)
+console.log(...)
-Ember.Logger.info(...)
+console.info(...)
|
||
import { computed } from '@ember/object'; | ||
import RSVP from 'rsvp'; | ||
import { deprecate } from '@ember/application/deprecations'; | ||
|
@@ -249,7 +251,7 @@ export default ApplicationLogListFormController.extend({ | |
@private | ||
*/ | ||
_generateUniqueMessagePrefix() { | ||
return '№' + Ember.generateGuid(null, '') + ': '; | ||
return '№' + generateUniqueId() + ': '; | ||
}, | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update remaining Ember namespace usage for consistency
The verification revealed two types of inconsistencies that need to be addressed:
app-state.js
andadv-limit.js
: TheEmber.Service
references appear only in JSDoc comments and don't affect the actual code since both files are already using the importedService
.user-settings.js
: There's an actual usage ofEmber.getOwner
that should be updated to use the imported version for consistency.Specific locations needing attention:
addon/services/user-settings.js
: ReplaceEmber.getOwner
with the importedgetOwner
from '@ember/application'🔗 Analysis chain
Verify consistency of import changes across the codebase.
Let's ensure these import changes are consistently applied across all files using these Ember features.
Let me check the specific usage in the files that still use the Ember namespace to determine if there are inconsistencies that need to be addressed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 743
Script:
Length of output: 985