change element content

This commit is contained in:
Jake Howard 2016-02-24 21:59:55 +00:00
parent 92bebf11ac
commit d41a604f4a

View file

@ -1,6 +1,7 @@
import React from 'react-native';
import GlobalStyles from '../../settings/styles';
import { getProjectRecentBuilds } from '../../api/CircleCI';
import moment from 'moment';
const {
View,
@ -22,10 +23,10 @@ const styles = StyleSheet.create({
repoCell: {
paddingHorizontal: 4,
paddingVertical: 3,
flex: 0.74
flex: 0.84
},
buildCell: {
flex: 0.35,
flex: 0.25,
paddingHorizontal: 6,
paddingVertical: 3,
borderLeftColor: GlobalStyles.get('CIRCLE_ITEM_BORDER'),
@ -66,10 +67,10 @@ export default class ProjectItem extends React.Component {
const buildTime = minutes + ':' + seconds;
const commit = mostRecentBuild.all_commit_details[0];
return (
<View>
<Text style={styles.details} >T: { buildTime }</Text>
<Text style={styles.details} >B: { commit.branch }</Text>
<View style={styles.buildCell}>
<Text style={styles.details} >#{ mostRecentBuild.build_num }</Text>
<Text style={styles.details} >D: { buildTime }</Text>
<Text style={styles.details} >C: { commit.commit.substring(0, 6) }</Text>
</View>
);
}
@ -78,23 +79,26 @@ export default class ProjectItem extends React.Component {
console.log(this.props.userDetails);
const project = this.props.project;
const mostRecentBuild = this.state.recentBuild;
const statusColour = mostRecentBuild.failed ?
const master = project.branches[project.default_branch].recent_builds[0];
const statusColour = master.outcome === 'failed' ?
GlobalStyles.get('CIRCLE_TEST_FAIL') :
GlobalStyles.get('CIRCLE_TEST_PASS');
let username;
if (this.props.userDetails && this.props.userDetails.login !== project.username) {
username = project.username + '/';
}
const username = this.props.userDetails && this.props.userDetails.login !== project.username ?
(<Text>U: {project.username}</Text>) : null;
const language = project.language ?
(<Text>L: {project.language}</Text>) : null;
const buildDetails = mostRecentBuild ? this._displayMoreInfo(mostRecentBuild) : null;
return (
<View style={styles.container}>
<View style={styles.repoCell}>
<Text style={styles.repoName}>{username}{project.reponame}</Text>
</View>
<View style={styles.buildCell}>
{ buildDetails }
<Text style={styles.repoName}>{project.reponame}</Text>
{ username }
{ language }
</View>
{ buildDetails }
<View style={[styles.colourPanel, {backgroundColor: statusColour}]} />
</View>
);