2016-10-28 22:39:34 +00:00
|
|
|
import * as React from "react";
|
2016-12-15 20:57:18 +00:00
|
|
|
|
2016-12-12 20:05:22 +00:00
|
|
|
import Build from "./build";
|
2016-12-15 20:57:18 +00:00
|
|
|
import Throbber from "./throbber";
|
2016-10-28 22:39:34 +00:00
|
|
|
|
2016-11-29 20:57:53 +00:00
|
|
|
interface IBody {
|
2016-12-12 20:05:22 +00:00
|
|
|
description: string;
|
|
|
|
api: Object;
|
|
|
|
repository: Object;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IBodyState {
|
|
|
|
currentBuild: any;
|
2016-12-14 23:04:56 +00:00
|
|
|
intervalId: number;
|
2016-11-10 19:30:47 +00:00
|
|
|
}
|
|
|
|
|
2016-11-29 20:57:53 +00:00
|
|
|
/**
|
|
|
|
* The Component for the main body of the repo page
|
|
|
|
* @param {string} description - The description of the repository
|
2016-12-07 08:15:21 +00:00
|
|
|
* @param {object} api - The ApiService injected from Angular
|
2016-12-12 20:05:22 +00:00
|
|
|
* @param {object} repository - The list of properties for the repository
|
2016-11-29 20:57:53 +00:00
|
|
|
*/
|
2016-12-12 20:05:22 +00:00
|
|
|
class body extends React.Component<IBody, IBodyState> {
|
2016-11-10 19:30:47 +00:00
|
|
|
static propTypes = {
|
|
|
|
description: React.PropTypes.string.isRequired,
|
2016-12-12 20:05:22 +00:00
|
|
|
api: React.PropTypes.object.isRequired,
|
|
|
|
repository: React.PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
constructor(props){
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
2016-12-14 23:04:56 +00:00
|
|
|
currentBuild: [],
|
|
|
|
intervalId: null
|
2016-12-12 20:05:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
componentDidMount() {
|
2016-12-14 23:04:56 +00:00
|
|
|
let intervalId: number = setInterval(() => this.getBuilds(), 1000);
|
|
|
|
this.setState({
|
|
|
|
currentBuild: this.state.currentBuild,
|
|
|
|
intervalId: intervalId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
comoponentDidUnmount() {
|
|
|
|
clearInterval(this.state.intervalId);
|
2016-12-12 20:05:22 +00:00
|
|
|
}
|
|
|
|
getBuilds() {
|
|
|
|
let api: any = this.props.api;
|
|
|
|
let repository: any = this.props.repository;
|
|
|
|
let params: Object = {
|
|
|
|
'repository': repository.namespace + '/' + repository.name,
|
|
|
|
'limit': 8
|
|
|
|
};
|
|
|
|
|
|
|
|
api.getRepoBuildsAsResource(params, true).get((data) => {
|
|
|
|
let builds: Array<Object> = [];
|
|
|
|
data.builds.forEach((element, i) => {
|
|
|
|
builds.push({
|
|
|
|
user: element.manual_user,
|
|
|
|
id: element.id,
|
|
|
|
display_name: element.display_name,
|
|
|
|
started: element.started,
|
|
|
|
tags: element.tags,
|
|
|
|
phase: element.phase,
|
|
|
|
trigger: element.trigger,
|
|
|
|
trigger_metadata: element.trigger_metadata
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.setState({
|
2016-12-14 23:04:56 +00:00
|
|
|
currentBuild: builds,
|
|
|
|
intervalId: this.state.intervalId
|
2016-12-12 20:05:22 +00:00
|
|
|
});
|
|
|
|
});
|
2016-11-10 19:30:47 +00:00
|
|
|
}
|
2016-10-28 22:39:34 +00:00
|
|
|
render () {
|
2016-11-29 20:57:53 +00:00
|
|
|
let description: string = this.props.description;
|
2016-12-06 01:29:40 +00:00
|
|
|
if (description === null || description === "") {
|
2016-11-29 20:57:53 +00:00
|
|
|
description = "No Description";
|
|
|
|
}
|
2016-11-10 19:30:47 +00:00
|
|
|
return(
|
|
|
|
<div>
|
|
|
|
<ul className="nav nav-tabs rp-tabs">
|
2016-12-06 01:29:40 +00:00
|
|
|
<li className="active">
|
|
|
|
<a data-target="#tab1" data-toggle="tab">Description</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a data-target="#tab2" data-toggle="tab">Automated Builds</a>
|
|
|
|
</li>
|
2016-11-10 19:30:47 +00:00
|
|
|
</ul>
|
|
|
|
<div className="panel-body rp-panelBody">
|
|
|
|
<div className="tab-content">
|
|
|
|
<div className="tab-pane in active" id="tab1">
|
2016-11-29 20:57:53 +00:00
|
|
|
<div className="rp-description">{description}</div>
|
2016-11-10 19:30:47 +00:00
|
|
|
</div>
|
2016-12-15 20:57:18 +00:00
|
|
|
<div className="tab-pane" id="tab2">
|
2016-12-12 20:05:22 +00:00
|
|
|
<div className="panel-body">
|
2016-12-15 20:57:18 +00:00
|
|
|
<h3 className="tab-header">Repository Builds</h3>
|
2016-12-12 20:05:22 +00:00
|
|
|
<Build data={this.state.currentBuild}/>
|
|
|
|
</div>
|
2016-11-10 19:30:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2016-10-28 22:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:21:45 +00:00
|
|
|
export default body;
|
2016-10-28 22:39:34 +00:00
|
|
|
|