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