From 1ddb2b78893b41652511f37b40a2c7f6824f673f Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 5 Oct 2017 15:21:10 -0700 Subject: [PATCH] Fixes issue regarding allocation rows Sometimes the job name and/or task group name wouldn't show up. --- ui/app/components/allocation-row.js | 40 +++++++++++++++++++++-------- ui/app/models/allocation.js | 3 +++ ui/app/serializers/allocation.js | 3 +++ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/ui/app/components/allocation-row.js b/ui/app/components/allocation-row.js index 044d368d2..b210d5b01 100644 --- a/ui/app/components/allocation-row.js +++ b/ui/app/components/allocation-row.js @@ -1,9 +1,11 @@ import Ember from 'ember'; import { lazyClick } from '../helpers/lazy-click'; -const { Component } = Ember; +const { Component, inject } = Ember; export default Component.extend({ + store: inject.service(), + tagName: 'tr', classNames: ['allocation-row', 'is-interactive'], @@ -20,17 +22,35 @@ export default Component.extend({ }, didReceiveAttrs() { + // TODO: Use this code again once the temporary workaround below + // is resolved. + // If the job for this allocation is incomplete, reload it to get // detailed information. + // const allocation = this.get('allocation'); + // if ( + // allocation && + // allocation.get('job') && + // !allocation.get('job.isPending') && + // !allocation.get('taskGroup') + // ) { + // const job = allocation.get('job.content'); + // job && job.reload(); + // } + + // TEMPORARY: https://github.com/emberjs/data/issues/5209 + // Ember Data doesn't like it when relationships aren't reflective, + // which means the allocation's job will be null if it hasn't been + // resolved through the allocation (allocation.get('job')) before + // being resolved through the store (store.findAll('job')). The + // workaround is to persist the jobID as a string on the allocation + // and manually re-link the two records here. + const allocation = this.get('allocation'); - if ( - allocation && - allocation.get('job') && - !allocation.get('job.isPending') && - !allocation.get('taskGroup') - ) { - const job = allocation.get('job.content'); - job && job.reload(); - } + this.get('store') + .findRecord('job', allocation.get('originalJobId')) + .then(job => { + allocation.set('job', job); + }); }, }); diff --git a/ui/app/models/allocation.js b/ui/app/models/allocation.js index ea24a54db..1665980e1 100644 --- a/ui/app/models/allocation.js +++ b/ui/app/models/allocation.js @@ -19,6 +19,9 @@ export default Model.extend({ resources: fragment('resources'), modifyIndex: attr('number'), + // TEMPORARY: https://github.com/emberjs/data/issues/5209 + originalJobId: attr('string'), + clientStatus: attr('string'), desiredStatus: attr('string'), diff --git a/ui/app/serializers/allocation.js b/ui/app/serializers/allocation.js index 1eec7ec7b..6d46dcaef 100644 --- a/ui/app/serializers/allocation.js +++ b/ui/app/serializers/allocation.js @@ -20,6 +20,9 @@ export default ApplicationSerializer.extend({ return summary; }); + // TEMPORARY: https://github.com/emberjs/data/issues/5209 + hash.OriginalJobId = hash.JobID; + return this._super(typeHash, hash); }, });