aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmclaugh...@apache.org
Subject aurora git commit: Hide InstanceHistory when there are no old tasks.
Date Tue, 17 Oct 2017 20:15:52 GMT
Repository: aurora
Updated Branches:
  refs/heads/master c7de69532 -> 94999eb75


Hide InstanceHistory when there are no old tasks.

Reviewed at https://reviews.apache.org/r/63082/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/94999eb7
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/94999eb7
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/94999eb7

Branch: refs/heads/master
Commit: 94999eb75b5cd0ea6cea1ff05264369cb748cc0b
Parents: c7de695
Author: David McLaughlin <david@dmclaughlin.com>
Authored: Tue Oct 17 13:15:44 2017 -0700
Committer: David McLaughlin <david@dmclaughlin.com>
Committed: Tue Oct 17 13:15:44 2017 -0700

----------------------------------------------------------------------
 ui/src/main/js/components/InstanceHistory.js              | 10 ++++++----
 .../main/js/components/__tests__/InstanceHistory-test.js  |  7 ++++++-
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/94999eb7/ui/src/main/js/components/InstanceHistory.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/components/InstanceHistory.js b/ui/src/main/js/components/InstanceHistory.js
index fb06390..4d0393a 100644
--- a/ui/src/main/js/components/InstanceHistory.js
+++ b/ui/src/main/js/components/InstanceHistory.js
@@ -3,18 +3,20 @@ import React from 'react';
 import InstanceHistoryItem from 'components/InstanceHistoryItem';
 import PanelGroup, { Container, StandardPanelTitle } from 'components/Layout';
 
+import { isNully } from 'utils/Common';
 import { getLastEventTime } from 'utils/Task';
 
 export default function InstanceHistory({ tasks }) {
+  if (isNully(tasks) || tasks.length === 0) {
+    return <div />;
+  }
+
   const sortedTasks = tasks.sort((a, b) => {
     return getLastEventTime(a) > getLastEventTime(b) ? -1 : 1;
   });
-
   return (<Container className='instance-history'>
     <PanelGroup noPadding title={<StandardPanelTitle title='Instance History' />}>
-      {sortedTasks.length > 0
-        ? sortedTasks.map((t) => <InstanceHistoryItem key={t.assignedTask.taskId} task={t}
/>)
-        : <div>No task history found.</div>}
+      {sortedTasks.map((t) => <InstanceHistoryItem key={t.assignedTask.taskId} task={t}
/>)}
     </PanelGroup>
   </Container>);
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94999eb7/ui/src/main/js/components/__tests__/InstanceHistory-test.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/components/__tests__/InstanceHistory-test.js b/ui/src/main/js/components/__tests__/InstanceHistory-test.js
index 1631481..6f536f3 100644
--- a/ui/src/main/js/components/__tests__/InstanceHistory-test.js
+++ b/ui/src/main/js/components/__tests__/InstanceHistory-test.js
@@ -19,6 +19,11 @@ describe('InstanceHistory', () => {
 
   it('Should handle empty lists', () => {
     const el = shallow(<InstanceHistory tasks={[]} />);
-    expect(el.contains(<div>No task history found.</div>)).toBe(true);
+    expect(el.contains(<div />)).toBe(true);
+  });
+
+  it('Should handle undefined tasks', () => {
+    const el = shallow(<InstanceHistory />);
+    expect(el.contains(<div />)).toBe(true);
   });
 });


Mime
View raw message