2015-05-17 13:48:16 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
define([
|
|
|
|
'react',
|
2015-07-11 15:15:18 +00:00
|
|
|
'react-router',
|
2015-05-17 13:48:16 +00:00
|
|
|
'reflux',
|
|
|
|
'app/actions/build',
|
|
|
|
'app/stores/build',
|
|
|
|
'app/components/terminal/terminal',
|
2015-12-08 20:58:31 +00:00
|
|
|
'app/components/buildSidebar/index',
|
2015-05-19 20:48:20 +00:00
|
|
|
'templates/app/components/builds/view',
|
|
|
|
'app/components/common/index'
|
2015-05-17 13:48:16 +00:00
|
|
|
], function(
|
2015-12-08 20:58:31 +00:00
|
|
|
React, Router, Reflux, BuildActions, buildStore, TerminalComponent,
|
|
|
|
BuildSidebar, template, CommonComponents
|
2015-05-17 13:48:16 +00:00
|
|
|
) {
|
|
|
|
template = template.locals({
|
2015-05-19 20:48:20 +00:00
|
|
|
DateTime: CommonComponents.DateTime,
|
2015-08-26 19:16:06 +00:00
|
|
|
Duration: CommonComponents.Duration,
|
2015-07-11 15:15:18 +00:00
|
|
|
Scm: CommonComponents.Scm,
|
|
|
|
Terminal: TerminalComponent,
|
2015-12-08 20:58:31 +00:00
|
|
|
Link: Router.Link,
|
|
|
|
BuildSidebar: BuildSidebar
|
2015-05-17 13:48:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var Component = React.createClass({
|
|
|
|
mixins: [Reflux.ListenerMixin],
|
2015-07-11 18:31:23 +00:00
|
|
|
statics: {
|
|
|
|
willTransitionTo: function(transition, params, query) {
|
|
|
|
BuildActions.read(Number(params.id));
|
|
|
|
}
|
|
|
|
},
|
2015-05-17 13:48:16 +00:00
|
|
|
componentDidMount: function() {
|
|
|
|
this.listenTo(buildStore, this.updateBuild);
|
|
|
|
},
|
|
|
|
updateBuild: function(build) {
|
2015-12-08 20:58:31 +00:00
|
|
|
if (build) {
|
|
|
|
BuildActions.readAll({projectName: build.project.name});
|
2015-05-17 13:48:16 +00:00
|
|
|
}
|
|
|
|
this.setState({build: build});
|
|
|
|
},
|
|
|
|
render: template,
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2015-12-08 20:58:31 +00:00
|
|
|
build: null,
|
|
|
|
showConsole: false
|
2015-05-17 13:48:16 +00:00
|
|
|
};
|
2015-12-08 20:58:31 +00:00
|
|
|
},
|
|
|
|
toggleConsole: function() {
|
|
|
|
var consoleState = !this.state.showConsole;
|
|
|
|
if (consoleState) {
|
|
|
|
BuildActions.readTerminalOutput(this.state.build);
|
|
|
|
}
|
|
|
|
this.setState({showConsole: consoleState});
|
2015-05-17 13:48:16 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return Component;
|
|
|
|
});
|