This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/components/builds/BuildList.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-03-11 11:53:55 +00:00
import React from 'react-native';
2016-03-11 20:56:26 +00:00
import GlobalStyles from '../../settings/styles';
2016-03-11 11:53:55 +00:00
import BuildItem from './BuildItem';
const {
ListView,
StyleSheet,
ScrollView
} = React;
const styles = StyleSheet.create({
listView: {
flex: 1,
flexDirection: 'column',
alignItems: 'stretch',
justifyContent: 'center',
flexWrap: 'wrap',
paddingHorizontal: 5
},
});
export default class BuildList extends React.Component {
constructor(props) {
super(props);
2016-03-11 20:56:26 +00:00
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(this.props.builds),
};
2016-03-11 11:53:55 +00:00
}
renderRow(build) {
2016-03-11 21:21:58 +00:00
if (build.build_time_millis < 1) {
return null;
}
2016-03-11 20:56:26 +00:00
const statusColour = build.status === 'failed' ?
GlobalStyles.get('CIRCLE_TEST_FAIL') :
GlobalStyles.get('CIRCLE_TEST_PASS');
return <BuildItem build={build} project={this.props.project} statusColour={statusColour} />;
2016-03-11 11:53:55 +00:00
}
render() {
return (
<ScrollView>
<ListView
contentContainerStyle={styles.listView}
dataSource={this.state.dataSource}
2016-03-11 20:56:26 +00:00
renderRow={this.renderRow.bind(this)} />
2016-03-11 11:53:55 +00:00
</ScrollView>
);
}
};