Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Merge button for PR screen #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Merge button for PR screen #60

wants to merge 4 commits into from

Conversation

brascene
Copy link

@brascene brascene commented Oct 7, 2017

I've made UI for now, and later I can configure/add redux and api actions for merging.

import { TouchableOpacity, StyleSheet, ImageBackground } from 'react-native';

type Props = {
children: Object,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React$Element

@@ -8,16 +8,17 @@ import { UIText } from 'components';
type Props = {
children: Object,
onPress: () => any,
style?: ComponentStyles
style?: ComponentStyles,
textStyle: Object
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComponentStyles


return (
<TouchableOpacity onPress={onPress} style={[styles.button, style]}>
<UIText style={styles.text}>
<UIText style={textStyle !== {} ? textStyle : styles.text}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[styles.text, textStyle] m?

export default class ImageButton extends PureComponent<Props> {
render() {
const { onPress } = this.props;
const image = require('../../assets/threeDots.png');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use import, but will be better to use vector icons, we already use https://github.com/oblador/react-native-vector-icons


const styles = StyleSheet.create({
imageBackground: {
width:50, height: 20, marginTop: 10,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every style must be on new line ;)

styleText={styles.buttonText}>
Close PR
</ImageButton>
<Modal
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use openModal instead of manually do modals

".js"
]
}
"name": "ghubber",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert ident for this file
Thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what to revert here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, not needed to change this file (code indentation - spaces)

.eslintrc Outdated
@@ -37,6 +37,7 @@
"Dispatch": true,
"Promise": true,
"ThunkAction": true,
"ActionType": true
"ActionType": true,
"require": true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop, because not needed ;)

@@ -88,6 +98,10 @@ class RepositoryPullRequestScreen extends PureComponent<Props> {
];
}

setModalVisible(visible) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -40,7 +46,11 @@ function getStateColor(state: string): string {
}
}

class RepositoryPullRequestScreen extends PureComponent<Props> {
class RepositoryPullRequestScreen extends PureComponent<Props, ModalState> {
state: ModalState = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

export default connect(
null,
{ addModal }
)(ImageButton);
Copy link

@firec0der firec0der Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connecting a component to the redux store w/o props passing is the wrong way.
Bind dispatch to addModal where you're rendering this component and pass it as a prop here. But seems like you don't use it here, so remove connecting at all.

@@ -0,0 +1,2 @@

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove this unnecessary empty line

@@ -101,6 +115,36 @@ class RepositoryPullRequestScreen extends PureComponent<Props> {
</View>
</View>
<UIText style={styles.body}>{pullRequest.body}</UIText>
<ImageButton
style={styles.button}
onPress={() => this.props.addModal(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such kind of function passing is the anti-pattern.
Related reading

data={[{ type: 'merge' }]}
renderOption={
({ item }) => {
return (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit it.

renderOption={({ item }) => (
    <TouchableOpacity
         key={item.type}
         style={styles.modalContent}
         onPress={() => { // <- remove this arrow function passing
             closeModal();
         }}
    >
        <Text style={styles.modalTitle}>Merge this pull request?</Text>
        <Button
            style={styles.deletePr}
            textStyle={styles.deletePrText}
            onPress={() => this.props.closeModal()} // <- remove this arrow function passing
        >
            Merge
        </Button>
    </TouchableOpacity>
)}

But, I do prefer extract this rendering to a separate function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants