refactor: 💡 remove ember-get-config dep from core

This commit is contained in:
Randall Morey committed 2021-11-05 13:20:45 -04:00
1 parent 3aae7c124b
commit 8000002b1b
8 files changed
+61 -42

No files matched your search

+8 -5
View File
@@ -1,6 +1,9 @@
import { helper } from '@ember/component/helper';
import config from 'ember-get-config';
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/application';
export default helper(function appName() {
return config.appName;
});
export default class extends Helper {
compute() {
const config = getOwner(this).resolveRegistration('config:environment');
return config.appName;
}
}
@@ -1,7 +1,10 @@
import { helper } from '@ember/component/helper';
import config from 'ember-get-config';
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/application';
export default helper(function companyCopyright() {
const currentYear = new Date().getFullYear();
return `© ${currentYear} ${config.companyName}`;
});
export default class extends Helper {
compute() {
const config = getOwner(this).resolveRegistration('config:environment');
const currentYear = new Date().getFullYear();
return `© ${currentYear} ${config.companyName}`;
}
}
+8 -5
View File
@@ -1,6 +1,9 @@
import { helper } from '@ember/component/helper';
import config from 'ember-get-config';
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/application';
export default helper(function companyName() {
return config.companyName;
});
export default class extends Helper {
compute() {
const config = getOwner(this).resolveRegistration('config:environment');
return config.companyName;
}
}
+20 -17
View File
@@ -1,20 +1,23 @@
import { helper } from '@ember/component/helper';
import Helper from '@ember/component/helper';
import { getOwner } from '@ember/application';
import { assert } from '@ember/debug';
import config from 'ember-get-config';
export default helper(function docUrl(params /*, hash*/) {
const baseURL = config.documentation.baseURL;
const docKey = params[0] || '';
const configuredPath = config.documentation.topics[docKey];
if (docKey) {
assert(
`
Documentation for "${docKey}" could not be found. Please ensure that
this key exists under "documentation" in your app config.
`,
configuredPath
);
export default class extends Helper {
compute(params) {
const config = getOwner(this).resolveRegistration('config:environment');
const baseURL = config.documentation.baseURL;
const docKey = params[0] || '';
const configuredPath = config.documentation.topics[docKey];
if (docKey) {
assert(
`
Documentation for "${docKey}" could not be found. Please ensure that
this key exists under "documentation" in your app config.
`,
configuredPath
);
}
const path = configuredPath || '';
return `${baseURL}${path}`;
}
const path = configuredPath || '';
return `${baseURL}${path}`;
});
}
@@ -1,9 +1,8 @@
import { registerDeprecationHandler } from '@ember/debug';
import config from 'ember-get-config';
const isTesting = config.environment === 'test';
export function initialize(/* application */) {
export function initialize(application) {
const config = application.resolveRegistration('config:environment');
const isTesting = config.environment === 'test';
if (isTesting) {
// Disable all deprecations for now in tests.
registerDeprecationHandler((/*message, options, next*/) => {
+10 -2
View File
@@ -3,7 +3,7 @@ import { filterBy } from '@ember/object/computed';
import { A } from '@ember/array';
import { tracked } from '@glimmer/tracking';
import { defer, resolve } from 'rsvp';
import config from 'ember-get-config';
import { getOwner } from '@ember/application';
/**
* A simple service that emits Confirmation instances and
@@ -17,13 +17,21 @@ import config from 'ember-get-config';
export default class ConfirmationsService extends Service {
// =attributes
#enabled;
/**
* When the confirm service is disabled, it always returns resolving promises.
* By default the service is enabled but it is useful to disable it for test
* purposes.
* @type {boolean}
*/
enabled = config.enableConfirmService ?? true;
get enabled() {
const config = getOwner(this).resolveRegistration('config:environment');
return this.#enabled ?? config.enableConfirmService ?? true;
}
set enabled(value) {
this.#enabled = value;
}
/**
* @type {Array}