Merge pull request #4067 from hashicorp/ui-upgrade-ember

UI: Upgrade Ember to LTS + fix job summary issues
This commit is contained in:
Michael Lange
2018-03-29 12:43:54 -06:00
committed by GitHub
8 changed files with 660 additions and 67 deletions

View File

@@ -1,23 +1,13 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
export default Component.extend({
store: service(),
job: null,
// TEMPORARY: https://github.com/emberjs/data/issues/5209
// The summary relationship can be broken under exact load
// order. This ensures that the summary is always shown, even
// if the summary link on the job is broken.
summary: computed('job.summary.content', function() {
const summary = this.get('job.summary');
if (summary.get('content')) {
return summary;
}
return this.get('store').peekRecord('job-summary', this.get('job.id'));
}),
summary: alias('job.summary'),
classNames: ['boxed-section'],
});

View File

@@ -23,13 +23,13 @@ export default Route.extend(WithWatchers, {
const job = model.get('job');
controller.set('watchers', {
job: this.get('watchJob').perform(job),
summary: this.get('watchSummary').perform(job),
summary: this.get('watchSummary').perform(job.get('summary')),
allocations: this.get('watchAllocations').perform(job),
});
},
watchJob: watchRecord('job'),
watchSummary: watchRelationship('summary'),
watchSummary: watchRecord('job-summary'),
watchAllocations: watchRelationship('allocations'),
watchers: collect('watchJob', 'watchSummary', 'watchAllocations'),

View File

@@ -7,6 +7,7 @@ export default ApplicationSerializer.extend({
// TaskGroupSummary fragment list
hash.PlainJobId = hash.JobID;
hash.ID = JSON.stringify([hash.JobID, hash.Namespace || 'default']);
hash.JobID = hash.ID;
hash.TaskGroupSummaries = Object.keys(get(hash, 'Summary') || {}).map(key => {
const allocStats = get(hash, `Summary.${key}`) || {};

View File

@@ -35,7 +35,16 @@ export default Service.extend({
activeNamespace: computed('namespaces.[]', {
get() {
const namespaceId = window.localStorage.nomadActiveNamespace || 'default';
return this.get('namespaces').findBy('id', namespaceId);
const namespace = this.get('namespaces').findBy('id', namespaceId);
if (namespace) {
return namespace;
}
// If the namespace is localStorage is no longer in the cluster, it needs to
// be cleared from localStorage
this.set('activeNamespace', null);
return this.get('namespaces').findBy('id', 'default');
},
set(key, value) {
if (value == null) {
@@ -43,9 +52,10 @@ export default Service.extend({
} else if (typeof value === 'string') {
window.localStorage.nomadActiveNamespace = value;
return this.get('namespaces').findBy('id', value);
} else {
window.localStorage.nomadActiveNamespace = value.get('name');
return value;
}
window.localStorage.nomadActiveNamespace = value.get('name');
return value;
},
}),
});

View File

@@ -208,6 +208,10 @@
border: 1px solid $grey-blue;
border-width: 0 0 1px;
padding: 1.25em 1.5em;
&.is-one-line {
white-space: nowrap;
}
}
}

View File

@@ -5,7 +5,7 @@
</td>
<td data-test-modify-time>{{moment-format allocation.modifyTime "MM/DD HH:mm:ss"}}</td>
<td data-test-name>{{allocation.name}}</td>
<td data-test-client-status>
<td data-test-client-status class="is-one-line">
<span class="color-swatch {{allocation.clientStatus}}" /> {{allocation.clientStatus}}
</td>
{{#if (eq context "job")}}

View File

@@ -31,7 +31,7 @@
"d3-transition": "^1.1.0",
"ember-ajax": "^3.0.0",
"ember-browserify": "^1.2.0",
"ember-cli": "2.17.1",
"ember-cli": "~2.18.2",
"ember-cli-babel": "^6.0.0",
"ember-cli-bourbon": "2.0.0-beta.1",
"ember-cli-dependency-checker": "^2.1.0",
@@ -49,7 +49,7 @@
"ember-cli-uglify": "^2.0.0",
"ember-composable-helpers": "^2.0.3",
"ember-concurrency": "^0.8.12",
"ember-data": "~2.17.0",
"ember-data": "~2.18.2",
"ember-data-model-fragments": "^2.14.0",
"ember-export-application-global": "^2.0.0",
"ember-fetch": "^3.4.3",
@@ -61,7 +61,7 @@
"ember-power-select": "^1.10.4",
"ember-resolver": "^4.5.0",
"ember-sinon": "^1.0.1",
"ember-source": "~2.17.0",
"ember-source": "~2.18.2",
"ember-test-selectors": "^0.3.8",
"ember-truth-helpers": "^2.0.0",
"ember-welcome-page": "^3.0.0",

File diff suppressed because it is too large Load Diff