Skip to content

Commit

Permalink
Remove config injections via initializer (#1569)
Browse files Browse the repository at this point in the history
* Update package-lock.json

* Remove config injections from routes

* Remove injection from components

Still need to import the config to make sure that it is available in the component templates. Then had to silence the ESLint warnings

* Remove controller injections

* Remove config initializer

* Add missing config references in components

This was breaking certain links/other functionality
  • Loading branch information
clekstro committed Mar 9, 2018
1 parent cf65111 commit 70abde9
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 84 deletions.
4 changes: 4 additions & 0 deletions app/components/header-links.js
@@ -1,15 +1,19 @@
/* global HS */
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "config" }]*/

import Ember from 'ember';
import Component from '@ember/component';
import { htmlSafe } from '@ember/string';
import { service } from 'ember-decorators/service';
import { action, computed } from 'ember-decorators/object';
import { alias } from 'ember-decorators/object/computed';
import config from 'travis/config/environment';

export default Component.extend({
tagName: '',

config,

@service auth: null,
@service features: null,
@service externalLinks: null,
Expand Down
10 changes: 8 additions & 2 deletions app/components/page-footer.js
@@ -1,8 +1,14 @@
import { inject as service } from '@ember/service';
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "config" }]*/

import Component from '@ember/component';
import { service } from 'ember-decorators/service';
import config from 'travis/config/environment';

export default Component.extend({
features: service(),
@service features: null,

config,

tagName: 'footer',
classNames: ['footer']
});
3 changes: 2 additions & 1 deletion app/components/repository-sidebar.js
Expand Up @@ -7,6 +7,7 @@ import { task } from 'ember-concurrency';
import { computed } from 'ember-decorators/object';
import { alias } from 'ember-decorators/object/computed';
import { service } from 'ember-decorators/service';
import config from 'travis/config/environment';

export default Component.extend({
@service tabStates: null,
Expand Down Expand Up @@ -42,7 +43,7 @@ export default Component.extend({
}

if (!Ember.testing) {
Visibility.every(this.config.intervals.updateTimes, () => {
Visibility.every(config.intervals.updateTimes, () => {
const callback = (record) => record.get('currentBuild');
const withCurrentBuild = this.get('_data').filter(callback).map(callback);
this.get('updateTimesService').push(withCurrentBuild);
Expand Down
4 changes: 4 additions & 0 deletions app/components/x-tracer.js
@@ -1,14 +1,18 @@
/* global TravisTracer, window */
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "config" }]*/

import Ember from 'ember';
import Component from '@ember/component';
import { action } from 'ember-decorators/object';
import config from 'travis/config/environment';

export default Component.extend({
tagName: 'div',
panelIsOpen: false,
requests: [],

config,

init() {
this._super(...arguments);

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/account.js
Expand Up @@ -9,6 +9,8 @@ export default Controller.extend({
@service externalLinks: null,
@service features: null,

config,

@alias('auth.currentUser') user: null,

@action
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/accounts.js
@@ -0,0 +1,8 @@
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "config" }]*/

import Controller from '@ember/controller';
import config from 'travis/config/environment';

export default Controller.extend({
config,
});
2 changes: 2 additions & 0 deletions app/controllers/build.js
Expand Up @@ -16,6 +16,8 @@ export default Controller.extend(GithubUrlProperties, Polling, {

@controller('repo') repoController: null,

config,

@alias('repoController.repo') repo: null,
@alias('auth.currentUser') currentUser: null,
@alias('repoController.tab') tab: null,
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/caches.js
Expand Up @@ -11,6 +11,8 @@ export default Controller.extend({

@alias('model.repo') repo: null,

config,

@computed('model.pushes.[]', 'model.pullRequests.[]')
cachesExist(pushes, pullRequests) {
if (pushes || pullRequests) {
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/index.js
Expand Up @@ -13,6 +13,8 @@ export default Controller.extend({
@service statusImages: null,
@service repositories: null,

config,

init() {
this._super(...arguments);
if (!Ember.testing) {
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/owner.js
@@ -1,11 +1,15 @@
import Controller from '@ember/controller';
import { computed } from 'ember-decorators/object';
import config from 'travis/config/environment';

export default Controller.extend({
isLoading: false,

@computed('config.sourceEndpoint', 'model.login')
githubProfile(endpoint, login) {
config,

@computed('model.login')
githubProfile(login) {
const { endpoint } = config;
return `${endpoint}/${login}`;
},

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/plans.js
Expand Up @@ -5,6 +5,8 @@ import { action } from 'ember-decorators/object';
import { service } from 'ember-decorators/service';

export default Controller.extend({
config,

@service auth: null,

@action
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/repo.js
Expand Up @@ -8,6 +8,7 @@ import { service } from 'ember-decorators/service';
import { controller } from 'ember-decorators/controller';
import { computed } from 'ember-decorators/object';
import { alias } from 'ember-decorators/object/computed';
import config from 'travis/config/environment';

export default Controller.extend({
@service auth: null,
Expand All @@ -25,6 +26,8 @@ export default Controller.extend({
@alias('buildsController.model') builds: null,
@alias('jobController.job') job: null,

config,

classNames: ['repo'],

reset() {
Expand All @@ -39,7 +42,7 @@ export default Controller.extend({
init() {
this._super(...arguments);
if (!Ember.testing) {
Visibility.every(this.config.intervals.updateTimes, this.updateTimes.bind(this));
Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/settings.js
@@ -1,13 +1,18 @@
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "config" }]*/

import Controller from '@ember/controller';
import { computed } from 'ember-decorators/object';
import { alias, sort, filterBy } from 'ember-decorators/object/computed';
import config from 'travis/config/environment';

export default Controller.extend({
@computed('unsortedEnvVars')
envVars(envVars) {
return envVars.sortBy('name');
},

config,

@filterBy('model.envVars', 'isNew', false)
unsortedEnvVars: null,

Expand Down
15 changes: 0 additions & 15 deletions app/initializers/config.js

This file was deleted.

7 changes: 5 additions & 2 deletions app/routes/account/repositories.js
@@ -1,7 +1,7 @@
import TravisRoute from 'travis/routes/basic';
// eslint-disable-next-line
import config from 'travis/config/environment';
import { alias } from 'ember-decorators/object/computed';
import { computed } from 'ember-decorators/object';

export default TravisRoute.extend({
queryParams: {
Expand All @@ -10,7 +10,10 @@ export default TravisRoute.extend({
}
},

@alias('config.pagination.profileReposPerPage') recordsPerPage: null,
@computed()
recordsPerPage() {
return config.pagination.profileReposPerPage;
},

model(params) {
const account = this.modelFor('account');
Expand Down
8 changes: 5 additions & 3 deletions app/routes/dashboard/repositories.js
@@ -1,9 +1,8 @@
import { hash } from 'rsvp';
import TravisRoute from 'travis/routes/basic';
import dashboardRepositoriesSort from 'travis/utils/dashboard-repositories-sort';
// eslint-disable-next-line
import config from 'travis/config/environment';
import { alias } from 'ember-decorators/object/computed';
import { computed } from 'ember-decorators/object';

export default TravisRoute.extend({
queryParams: {
Expand All @@ -21,7 +20,10 @@ export default TravisRoute.extend({
}
},

@alias('config.pagination.dashboardReposPerPage') recordsPerPage: null,
@computed()
recordsPerPage() {
return config.pagination.dashboardReposPerPage;
},

model(params) {
const offset = (params.page - 1) * this.get('recordsPerPage');
Expand Down
67 changes: 9 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70abde9

Please sign in to comment.