nci/static/js/app/components/builds/view.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-05-17 13:48:16 +00:00
'use strict';
define([
'react',
'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',
'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({
DateTime: CommonComponents.DateTime,
2015-08-26 19:16:06 +00:00
Duration: CommonComponents.Duration,
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;
});