Skip to content

Commit

Permalink
plenty of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
makemp committed Nov 15, 2023
1 parent bec41c6 commit ed0ddec
Show file tree
Hide file tree
Showing 24 changed files with 4,209 additions and 2,598 deletions.
2 changes: 1 addition & 1 deletion app/adapters/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import V3Adapter from 'travis/adapters/v3';
import { testing } from 'ember';
import Ember from 'ember';

let includes = 'build.commit,build.branch,build.request,build.created_by';

Expand Down
2 changes: 1 addition & 1 deletion app/components/broadcast-tower.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { later } from '@ember/runloop';
import { Promise as EmberPromise } from 'rsvp';
import Component from '@ember/component';
import { testing } from 'ember';
import Ember from 'ember';
import { task } from 'ember-concurrency';

export default Component.extend({
Expand Down
4 changes: 2 additions & 2 deletions app/components/queued-jobs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';
import { testing } from 'ember';
import Ember from 'ember';
import { reads } from '@ember/object/computed';
import config from 'travis/config/environment';
import Visibility from 'visibilityjs';
Expand All @@ -13,7 +13,7 @@ export default Component.extend({

init() {
this._super(...arguments);
if (!testing) {
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/components/repository-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isEmpty } from '@ember/utils';
import { schedule } from '@ember/runloop';
import Component from '@ember/component';
import { testing } from 'ember';
import Ember from 'ember';
import Visibility from 'visibilityjs';
import { task } from 'ember-concurrency';
import { computed } from '@ember/object';
Expand Down Expand Up @@ -42,7 +42,7 @@ export default Component.extend({
this.set('_data', this.get('repositories.accessible'));
}

if (!testing) {
if (!Ember.testing) {
Visibility.every(config.intervals.updateTimes, () => {
const callback = (record) => record.get('currentBuild');
const withCurrentBuild = this._data.filter(callback).map(callback);
Expand Down
4 changes: 2 additions & 2 deletions app/components/running-jobs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@ember/component';
import { testing } from 'ember';
import Ember from 'ember';
import { reads } from '@ember/object/computed';
import config from 'travis/config/environment';
import Visibility from 'visibilityjs';
Expand All @@ -13,7 +13,7 @@ export default Component.extend({

init() {
this._super(...arguments);
if (!testing) {
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
Expand Down
7 changes: 4 additions & 3 deletions app/components/top-bar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { scheduleOnce } from '@ember/runloop';
import Component from '@ember/component';
import { testing } from 'ember';
import Ember from 'ember';
import {
computed,
setProperties,
Expand All @@ -27,7 +27,7 @@ export default class TopBar extends Component {
landingPage = false;
isNavigationOpen = false;
isActivation = false;

viewportTolerance = { top: 0, bottom: 0, left: 0, right: 0 };
activeModel = null;
@reads('activeModel') model;

Expand Down Expand Up @@ -84,11 +84,12 @@ export default class TopBar extends Component {
}

didInsertElement() {
if (testing) {
if (Ember.testing) {
super.didInsertElement(...arguments);
return;
}


set(this, 'viewportSpy', true);
super.didInsertElement(...arguments);
scheduleOnce('afterRender', this, () => {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Controller, { inject as controller } from '@ember/controller';
import { testing } from 'ember';
import Ember from 'ember';
import Polling from 'travis/mixins/polling';
import Visibility from 'visibilityjs';
import config from 'travis/config/environment';
Expand Down Expand Up @@ -28,7 +28,7 @@ export default Controller.extend(Polling, {

init() {
this._super(...arguments);
if (!testing) {
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/dashboard/builds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Controller from '@ember/controller';
import { testing } from 'ember';
import Ember from 'ember';
import Visibility from 'visibilityjs';
import { inject as service } from '@ember/service';
import config from 'travis/config/environment';
Expand All @@ -9,7 +9,7 @@ export default Controller.extend({

init() {
this._super(...arguments);
if (!testing) {
if (!Ember.testing) {
Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Controller from '@ember/controller';
import { testing } from 'ember';
import Ember from 'ember';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import Visibility from 'visibilityjs';
Expand All @@ -18,8 +18,8 @@ export default Controller.extend({

init() {
this._super(...arguments);
if (!testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
if (!Ember.testing) {
return Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/repo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { scheduleOnce } from '@ember/runloop';
import { isEmpty } from '@ember/utils';
import Controller, { inject as controller } from '@ember/controller';
import { testing } from 'ember';
import Ember from 'ember';
import eventually from 'travis/utils/eventually';
import Visibility from 'visibilityjs';
import { inject as service } from '@ember/service';
Expand Down Expand Up @@ -63,7 +63,7 @@ export default Controller.extend({

init() {
this._super(...arguments);
if (!testing) {
if (!Ember.testing) {
Visibility.every(config.intervals.updateTimes, this.updateTimes.bind(this));
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/services/animation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Service from '@ember/service';
import { computed } from '@ember/object';
import { testing } from 'ember';
import Ember from 'ember';
import fade from 'ember-animated/transitions/fade';

const isTest = testing;
const isTest = Ember.testing;

export const DURATION_NAMES = {
QUICK: 'quick',
Expand Down
3 changes: 2 additions & 1 deletion app/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default Service.extend({
this.set('state', STATE.SIGNED_OUT);

const { accounts, activeAccount } = this.storage;
accounts.removeObject(activeAccount);
if(accounts.removeObject) // not in case accounts is just a plain array
accounts.removeObject(activeAccount);
this.storage.setProperties({ accounts, activeAccount: null });

if (runTeardown) {
Expand Down
3 changes: 2 additions & 1 deletion app/services/flashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Service, { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { assert } from '@ember/debug';
import { A } from '@ember/array';

const messageTypeToIcon = {
notice: 'icon-flag',
Expand Down Expand Up @@ -43,7 +44,7 @@ export default Service.extend({

messages: computed('flashes.[]', function () {
let flashes = this.flashes;
let model = [];
let model = A([]);
if (flashes.length) {
model.pushObjects(flashes.toArray());
}
Expand Down
33 changes: 15 additions & 18 deletions app/services/storage/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ const storage = getStorage();
const Auth = Service.extend({
store: service(),

accounts: computed({
get() {
const accountsData = storage.getItem('travis.auth.accounts');
const accounts = parseWithDefault(accountsData, []).map(account =>
extractAccountRecord(this.store, account)
);
return accounts;
},
set(key, accounts_) {
this.persistAccounts(accounts_);
return accounts_;
}
}),

token: computed({
get() {
return storage.getItem('travis.token') || null;
Expand Down Expand Up @@ -118,6 +132,7 @@ function getStorage() {
// primary storage for auth is the one in which auth data was updated last
const sessionStorageUpdatedAt = +sessionStorage.getItem('travis.auth.updatedAt');
const localStorageUpdatedAt = +localStorage.getItem('travis.auth.updatedAt');

return sessionStorageUpdatedAt > localStorageUpdatedAt ? sessionStorage : localStorage;
}

Expand All @@ -130,22 +145,4 @@ function extractAccountRecord(store, userData) {
return record || store.push(store.normalize('user', userData));
}

Object.defineProperty(Auth.prototype, 'accounts', {
@tracked
accounts_: [],

get() {
const accountsData = storage.getItem('travis.auth.accounts');
this.accounts_ = parseWithDefault(accountsData, []).map(account =>
extractAccountRecord(this.store, account)
);
return this.accounts_;
},
set(key, accounts_) {
const records = (accounts_ || []).map(record => serializeUserRecord(record));
storage.setItem('travis.auth.accounts', JSON.stringify(records));
return accounts_;
}
});

export default Auth;
3 changes: 0 additions & 3 deletions app/services/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export default class ExtendedStore extends Store {
}

if (!dependencies) {
console.log("No dependency");
console.log(this.filteredArraysManager);
console.log(this.filteredArraysManager.filter);
return this.filteredArraysManager.filter(modelName, queryParams, filterFunction, ['']);
} else {
return this.filteredArraysManager.fetchArray(modelName, queryParams, filterFunction, dependencies, forceReload);
Expand Down
20 changes: 15 additions & 5 deletions app/services/update-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,41 @@ import Service from '@ember/service';
import config from 'travis/config/environment';
import eventually from 'travis/utils/eventually';
import Visibility from 'visibilityjs';
import { task } from 'ember-concurrency';
import { on } from '@ember/object/evented';

export default Service.extend({
allowFinishedBuilds: false,
isDestroyedOrDestroying: false,

init() {
const visibilityId = Visibility.every(config.intervals.updateTimes, bind(this, 'updateTimes'));
const intervalId = setInterval(this.resetAllowFinishedBuilds.bind(this), 60000);
const records = [];

this.setProperties({ visibilityId, intervalId, records });
this.setProperties({ records });

return this._super(...arguments);
},

updateTimesTask: task(function* () {
while (true) {
yield this.updateTimes();
yield timeout(config.intervals.updateTimes);
}
}).on('init'),


willDestroy() {
Visibility.stop(this.visibilityId);
clearInterval(this.intervalId);
this.set('isDestroyedOrDestroying', true);
this._super(...arguments);
},

resetAllowFinishedBuilds() {
if (this.isDestroyedOrDestroying) { return; }
this.set('allowFinishedBuilds', true);
},

updateTimes() {
if (this.isDestroyedOrDestroying) { return; }
let records = this.records;

records.filter(record => this.allowFinishedBuilds || !record.get('isFinished'))
Expand Down
2 changes: 1 addition & 1 deletion app/services/utm.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default Service.extend({
}),

hasParamsInUrl: computed('searchParams', function () {
return UTM_FIELD_NAMES.any(field => this.searchParams.has(field));
return UTM_FIELD_NAMES.some(field => this.searchParams.has(field));
}),

peek(fields, includeEmpty = true) {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/external-link-to.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#if hasBlock}}
{{#if (has-block)}}
{{yield}}
{{else}}
{{this.content}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/missing-notice.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{this.title}}
</h2>
{{/if}}
{{#if hasBlock}}
{{#if (has-block)}}
{{yield}}
{{/if}}
</div>
2 changes: 1 addition & 1 deletion app/templates/components/page-footer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</h3>
<ul>
<li>
<TravisStatus @showDescription={{false}} />
<TravisStatus @description={{null}} />
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/repository-layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/>
</div>
<div class="travistab-body repo-body">
{{#if hasBlock}}
{{#if (has-block)}}
{{yield}}
{{else}}
<BuildLayout @build={{this.build}} @repo={{this.repo}} />
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/top-bar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
{{#unless this.features.proVersion}}
<MigrationBanner />
{{/unless}}
{{#if hasBlock}}
{{#if (has-block)}}
{{yield}}
{{/if}}
Loading

0 comments on commit ed0ddec

Please sign in to comment.