From b35b8e6c5f9797b01adcf4fc688d2d61b9f636ad Mon Sep 17 00:00:00 2001 From: oleg Date: Wed, 26 Aug 2015 20:06:59 +0300 Subject: [PATCH] datetime and duration components now accepts value --- static/js/app/components/builds/item.jade | 8 ++++---- static/js/app/components/builds/view.jade | 6 +++--- static/js/app/components/common/dateTime/index.js | 3 --- .../app/components/common/dateTime/template.jade | 2 +- .../js/app/components/common/duration/index.jade | 2 +- static/js/app/components/common/duration/index.js | 14 ++++---------- static/js/app/components/projects/view/index.jade | 2 +- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/static/js/app/components/builds/item.jade b/static/js/app/components/builds/item.jade index 95c8491..286dd4f 100644 --- a/static/js/app/components/builds/item.jade +++ b/static/js/app/components/builds/item.jade @@ -51,21 +51,21 @@ mixin statusText(build) span.build_info i.fa.fa-fw.fa-clock-o | finished - DateTime(date=new Date(build.endDate)) + DateTime(value=build.endDate) | , | - Duration(duration=(build.endDate - build.startDate), withSuffix=true) + Duration(value=(build.endDate - build.startDate), withSuffix=true) else if build.startDate span.build_info i.fa.fa-fw.fa-clock-o | started - DateTime(date=new Date(build.startDate)) + DateTime(value=build.startDate) else span.build_info i.fa.fa-fw.fa-clock-o | queued - DateTime(date=new Date(build.createDate)) + DateTime(value=build.createDate) | if build.scm span.build_info diff --git a/static/js/app/components/builds/view.jade b/static/js/app/components/builds/view.jade index 3d38152..210587d 100644 --- a/static/js/app/components/builds/view.jade +++ b/static/js/app/components/builds/view.jade @@ -61,10 +61,10 @@ div.row span if this.state.build.startDate span Started - DateTime(date=new Date(this.state.build.startDate)) + DateTime(value=this.state.build.startDate) else span Queued - DateTime(date=new Date(this.state.build.createDate)) + DateTime(value=this.state.build.createDate) if this.state.build.status !== 'in-progress' p @@ -72,7 +72,7 @@ div.row | | Finished if this.state.build.endDate - DateTime(date=new Date(this.state.build.endDate)) + DateTime(value=this.state.build.endDate) else | - - var rev = this.state.build.scm && this.state.build.scm.rev || {}; diff --git a/static/js/app/components/common/dateTime/index.js b/static/js/app/components/common/dateTime/index.js index 6e3240b..9f8fe3d 100644 --- a/static/js/app/components/common/dateTime/index.js +++ b/static/js/app/components/common/dateTime/index.js @@ -10,9 +10,6 @@ define([ }); var Component = React.createClass({ - propTypes: { - date: React.PropTypes.instanceOf(Date) - }, render: template }); diff --git a/static/js/app/components/common/dateTime/template.jade b/static/js/app/components/common/dateTime/template.jade index 4a8e76a..d3a0901 100644 --- a/static/js/app/components/common/dateTime/template.jade +++ b/static/js/app/components/common/dateTime/template.jade @@ -1,2 +1,2 @@ -- var date = moment(this.props.date); +- var date = moment(this.props.value); span(title= date.format())= date.fromNow() diff --git a/static/js/app/components/common/duration/index.jade b/static/js/app/components/common/duration/index.jade index 164a77b..8841320 100644 --- a/static/js/app/components/common/duration/index.jade +++ b/static/js/app/components/common/duration/index.jade @@ -1,4 +1,4 @@ -- var sec = Math.round(this.props.duration / 1000); +- var sec = Math.round(this.props.value / 1000); - var min = sec >= 60 ? Math.round(sec / 60) : 0; - var suffix = this.props.withSuffix ? 'in ' : ''; span(title= sec + ' sec')= suffix + (min ? min + ' min' : sec + ' sec') diff --git a/static/js/app/components/common/duration/index.js b/static/js/app/components/common/duration/index.js index 5ef4ec6..8487594 100644 --- a/static/js/app/components/common/duration/index.js +++ b/static/js/app/components/common/duration/index.js @@ -7,15 +7,9 @@ define([ moment: moment }); - return React.createClass({ - render: template, - getInitialState: function() { - var seconds = Math.round(this.props.duration / 1000); - - return { - minutes: null, - seconds: seconds - } - } + var Component = React.createClass({ + render: template }); + + return Component; }); diff --git a/static/js/app/components/projects/view/index.jade b/static/js/app/components/projects/view/index.jade index 931fada..b1f9f38 100644 --- a/static/js/app/components/projects/view/index.jade +++ b/static/js/app/components/projects/view/index.jade @@ -25,7 +25,7 @@ - var lastDoneBuild = this.state.project.lastDoneBuild; p Last successfully built: if lastDoneBuild - DateTime(date=new Date(lastDoneBuild.endDate)) + DateTime(value=lastDoneBuild.endDate) | | (build # span= lastDoneBuild.number