Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@
"contributions": [
"doc"
]
},
{
"login": "cheshire137",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎉

"name": "Sarah Vessels",
"avatar_url": "https://avatars3.githubusercontent.com/u/82317?v=4",
"profile": "https://github.com/cheshire137",
"contributions": [
"doc"
]
}
]
}
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ If you want to open a PR that fixes a bug or adds a feature, then we can't thank

### Working on issues

Please feel free to take on any issue that's currently open. Feel free to resolve any issue that you would enjoy working on even if it happens to be a low priority.
Please feel free to take on any issue that's currently open. You could look at
[issues labeled "high priority"](https://github.com/gitpoint/git-point/issues?q=is%3Aopen+is%3Aissue+label%3A%22high+priority%22),
but feel free to resolve any issue that you would enjoy working on even if it happens to be a low priority.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure this should be a part of this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair enough, personally don't mind having this correction included however.

## Setup

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Thank you to all the people who have already contributed to GitPoint!
| [<img src="https://avatars0.githubusercontent.com/u/8962228?v=4" width="100px;"/><br /><sub>Sammy Israwi</sub>](https://github.com/SammyIsra)<br />[💻](https://github.com/gitpoint/git-point/commits?author=SammyIsra "Code") [🐛](https://github.com/gitpoint/git-point/issues?q=author%3ASammyIsra "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/8122587?v=4" width="100px;"/><br /><sub>Chao Ren</sub>](https://github.com/RogerAbyss)<br />[🐛](https://github.com/gitpoint/git-point/issues?q=author%3ARogerAbyss "Bug reports") [💻](https://github.com/gitpoint/git-point/commits?author=RogerAbyss "Code") | [<img src="https://avatars0.githubusercontent.com/u/11228182?v=4" width="100px;"/><br /><sub>Harish Toshniwal</sub>](https://introwit.in)<br />[📖](https://github.com/gitpoint/git-point/commits?author=introwit "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/774577?v=4" width="100px;"/><br /><sub>Ferran Negre</sub>](http://github.com/ferrannp)<br />[💻](https://github.com/gitpoint/git-point/commits?author=ferrannp "Code") | [<img src="https://avatars2.githubusercontent.com/u/29695071?v=4" width="100px;"/><br /><sub>Ganesh Cauda Salim</sub>](https://github.com/caudaganesh)<br />[💻](https://github.com/gitpoint/git-point/commits?author=caudaganesh "Code") | [<img src="https://avatars0.githubusercontent.com/u/4316908?v=4" width="100px;"/><br /><sub>Wanda Ichsanul Isra</sub>](https://www.linkedin.com/in/wlisrausr)<br />[💻](https://github.com/gitpoint/git-point/commits?author=wlisrausr "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/25394678?v=4" width="100px;"/><br /><sub>Cameron Samuels</sub>](http://cameronsamuels.com)<br />[📖](https://github.com/gitpoint/git-point/commits?author=CameronSamuels "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/304450?v=4" width="100px;"/><br /><sub>Mehdi Achour</sub>](https://machour.idk.tn/)<br />[🐛](https://github.com/gitpoint/git-point/issues?q=author%3Amachour "Bug reports") [💻](https://github.com/gitpoint/git-point/commits?author=machour "Code") [🌍](#translation-machour "Translation") | [<img src="https://avatars2.githubusercontent.com/u/5353857?v=4" width="100px;"/><br /><sub>Reyhan Sofian</sub>](https://www.reyhan.tech/)<br />[💻](https://github.com/gitpoint/git-point/commits?author=reyhansofian "Code") | [<img src="https://avatars1.githubusercontent.com/u/11606323?v=4" width="100px;"/><br /><sub>Adrian Hartanto</sub>](https://github.com/adrianhartanto0)<br />[💻](https://github.com/gitpoint/git-point/commits?author=adrianhartanto0 "Code") | [<img src="https://avatars2.githubusercontent.com/u/3624869?v=4" width="100px;"/><br /><sub>Blake Y. Gong</sub>](https://github.com/blakegong)<br />[💻](https://github.com/gitpoint/git-point/commits?author=blakegong "Code") | [<img src="https://avatars3.githubusercontent.com/u/1736154?v=4" width="100px;"/><br /><sub>Xianming Zhong</sub>](https://github.com/chinesedfan)<br />[💻](https://github.com/gitpoint/git-point/commits?author=chinesedfan "Code") [🐛](https://github.com/gitpoint/git-point/issues?q=author%3Achinesedfan "Bug reports") |
| [<img src="https://avatars0.githubusercontent.com/u/13774309?v=4" width="100px;"/><br /><sub>Arthur Denner</sub>](https://github.com/arthurdenner)<br />[🌍](#translation-arthurdenner "Translation") | [<img src="https://avatars1.githubusercontent.com/u/18403881?v=4" width="100px;"/><br /><sub>Florian Taut</sub>](https://taut-fl.de)<br />[💻](https://github.com/gitpoint/git-point/commits?author=FlorianTaut "Code") | [<img src="https://avatars0.githubusercontent.com/u/15075759?v=4" width="100px;"/><br /><sub>Avare Kodcu</sub>](http://www.avarekodcu.com/iletisim)<br />[🌍](#translation-abdurrahmanekr "Translation") | [<img src="https://avatars0.githubusercontent.com/u/23240518?v=4" width="100px;"/><br /><sub>Anas Khan</sub>](http://anask.xyz)<br />[🌍](#translation-anaskhan96 "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1930729?v=4" width="100px;"/><br /><sub>Nelson Henrique</sub>](https://github.com/nersoh)<br />[💻](https://github.com/gitpoint/git-point/commits?author=nersoh "Code") | [<img src="https://avatars3.githubusercontent.com/u/23623237?v=4" width="100px;"/><br /><sub>Charles Kenney</sub>](http://charleskenney.com)<br />[💻](https://github.com/gitpoint/git-point/commits?author=Charliekenney23 "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/18398761?v=4" width="100px;"/><br /><sub>Vitaliy Kanev</sub>](https://github.com/vitalkanev)<br />[📖](https://github.com/gitpoint/git-point/commits?author=vitalkanev "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/3691490?v=4" width="100px;"/><br /><sub>Peter Dave Hello</sub>](https://www.peterdavehello.org/)<br />[📖](https://github.com/gitpoint/git-point/commits?author=PeterDaveHello "Documentation") [🔧](#tool-PeterDaveHello "Tools") | [<img src="https://avatars3.githubusercontent.com/u/10849025?v=4" width="100px;"/><br /><sub>Ernoff</sub>](https://github.com/Ernoff)<br />[💻](https://github.com/gitpoint/git-point/commits?author=Ernoff "Code") [🐛](https://github.com/gitpoint/git-point/issues?q=author%3AErnoff "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/10121964?v=4" width="100px;"/><br /><sub>Arjun Curat</sub>](https://github.com/acurat)<br />[📖](https://github.com/gitpoint/git-point/commits?author=acurat "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/18398761?v=4" width="100px;"/><br /><sub>Vitaliy Kanev</sub>](https://github.com/vitalkanev)<br />[📖](https://github.com/gitpoint/git-point/commits?author=vitalkanev "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/3691490?v=4" width="100px;"/><br /><sub>Peter Dave Hello</sub>](https://www.peterdavehello.org/)<br />[📖](https://github.com/gitpoint/git-point/commits?author=PeterDaveHello "Documentation") [🔧](#tool-PeterDaveHello "Tools") | [<img src="https://avatars3.githubusercontent.com/u/10849025?v=4" width="100px;"/><br /><sub>Ernoff</sub>](https://github.com/Ernoff)<br />[💻](https://github.com/gitpoint/git-point/commits?author=Ernoff "Code") [🐛](https://github.com/gitpoint/git-point/issues?q=author%3AErnoff "Bug reports") | [<img src="https://avatars2.githubusercontent.com/u/11836470?v=4" width="100px;"/><br /><sub>João Fonseca</sub>](https://github.com/Jpfonseca)<br /> | [<img src="https://avatars3.githubusercontent.com/u/10121964?v=4" width="100px;"/><br /><sub>Arjun Curat</sub>](https://github.com/acurat)<br />[📖](https://github.com/gitpoint/git-point/commits?author=acurat "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/82317?v=4" width="100px;"/><br /><sub>Sarah Vessels</sub>](https://github.com/cheshire137)<br />[📖](https://github.com/gitpoint/git-point/commits?author=cheshire137 "Documentation") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
## Introduction

[![Build Status](https://img.shields.io/travis/gitpoint/git-point.svg?style=flat-square)](https://travis-ci.org/gitpoint/git-point)
[![All Contributors](https://img.shields.io/badge/all_contributors-40-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-42-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![Gitter chat](https://img.shields.io/badge/chat-on_gitter-008080.svg?style=flat-square)](https://gitter.im/git-point)
Expand Down
30 changes: 30 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ const METHOD = {
POST: 'POST',
};

export const v4 = {
root: 'https://api.github.com/graphql',
call: async parameters => {
const response = await fetch(v4.root, parameters);
const json = JSON.parse(response._bodyText);

if (response.status >= 200 && response.status < 300) {
return json.data;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we test for failed response.statuses instead before doing the JSON.parse() ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The GraphQL API returns JSON on error as well as success. I do the JSON parsing ahead of this line so I can get the message out of the body as to why the query failed, to put in the Error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Didn't know that, thanks for clarifying it, it's perfect that way then.

Copy link
Copy Markdown
Contributor Author

@cheshire137 cheshire137 Oct 9, 2017

Choose a reason for hiding this comment

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

I might be able to do await response.json() instead of parsing the body myself, though. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And it makes more sense along with Promise.reject() 👌

const error = new Error(json.message);

error.response = response;
throw error;
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about return Promise.reject(error.response) instead?

parameters: (accessToken, body = {}) => {
return {
method: METHOD.POST,
headers: {
Authorization: `token ${accessToken}`,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't tried GraphQL on my side yet. Are this header enough? Shouldn't we be passing a User-Agent ? (GitPoint/Android-3.2 for example).

I'd like to have it shared between GraphQL & Rest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is all that's necessary to use the endpoint, though I could add a user-agent header. See the example at https://developer.github.com/v4/guides/forming-calls/#communicating-with-graphql.

For trying the GraphQL API, I like https://developer.github.com/v4/explorer/, which lets you run queries as your GitHub user in the browser.

body: JSON.stringify(body),
};
},
post: async (accessToken, body) => {
const response = await v4.call(v4.parameters(accessToken, body));

return response;
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is post() the only method that will exist to access GraphQL ?
If that's the case, maybe we can merge call() & parameters() inside it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, all requests whether they're reading or writing, are POSTs; see https://developer.github.com/v4/guides/forming-calls/#communicating-with-graphql.

I can merge these methods!

};

export const v3 = {
root: 'https://api.github.com',
call: async (url, parameters) => {
Expand Down
114 changes: 53 additions & 61 deletions src/components/issue-description.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class IssueDescription extends Component {

return (
<View style={(styles.container, styles.borderBottom)}>
{issue.repository_url && (
{issue.repository_url &&
<ListItem
title={issue.repository_url.replace(`${v3.root}/repos/`, '')}
titleStyle={styles.titleSmall}
Expand All @@ -127,14 +127,13 @@ export class IssueDescription extends Component {
}}
onPress={() => onRepositoryPress(issue.repository_url)}
hideChevron
/>
)}
/>}

<View style={styles.headerContainer}>
<ListItem
title={issue.title}
titleStyle={styles.title}
subtitle={moment(issue.created_at).fromNow()}
subtitle={moment(issue.createdAt).fromNow()}
containerStyle={styles.listItemContainer}
leftIcon={{
name: issue.pull_request ? 'git-pull-request' : 'issue-opened',
Expand All @@ -147,75 +146,68 @@ export class IssueDescription extends Component {

{!issue.pull_request ||
(issue.pull_request &&
!isPendingCheckMerge && (
<StateBadge
style={styles.badge}
issue={issue}
isMerged={isMerged && issue.pull_request}
language={language}
/>
))}
!isPendingCheckMerge &&
<StateBadge
style={styles.badge}
issue={issue}
isMerged={isMerged && issue.pull_request}
language={language}
/>)}
</View>

{issue.pull_request && (
{issue.pull_request &&
<View style={styles.diffBlocksContainer}>
{isPendingDiff && (
<ActivityIndicator animating={isPendingDiff} size="small" />
)}
{isPendingDiff &&
<ActivityIndicator animating={isPendingDiff} size="small" />}

{!isPendingDiff &&
(lineAdditions !== 0 || lineDeletions !== 0) && (
<DiffBlocks
additions={lineAdditions}
deletions={lineDeletions}
showNumbers
onPress={() =>
navigation.navigate('PullDiff', {
title: translate('repository.pullDiff.title', language),
language,
diff,
})}
/>
)}
</View>
)}
(lineAdditions !== 0 || lineDeletions !== 0) &&
<DiffBlocks
additions={lineAdditions}
deletions={lineDeletions}
showNumbers
onPress={() =>
navigation.navigate('PullDiff', {
title: translate('repository.pullDiff.title', language),
language,
diff,
})}
/>}
</View>}

{issue.labels &&
issue.labels.length > 0 && (
<View style={styles.labelButtonGroup}>
{this.renderLabelButtons(issue.labels)}
</View>
)}
issue.labels.length > 0 &&
<View style={styles.labelButtonGroup}>
{this.renderLabelButtons(issue.labels)}
</View>}
{issue.assignees &&
issue.assignees.length > 0 && (
<View style={styles.assigneesSection}>
<MembersList
title={translate('issue.main.assignees', language)}
members={issue.assignees}
containerStyle={{ marginTop: 0, paddingTop: 0, paddingLeft: 0 }}
smallTitle
navigation={navigation}
/>
</View>
)}
issue.assignees.length > 0 &&
<View style={styles.assigneesSection}>
<MembersList
title={translate('issue.main.assignees', language)}
members={issue.assignees}
containerStyle={{ marginTop: 0, paddingTop: 0, paddingLeft: 0 }}
smallTitle
navigation={navigation}
/>
</View>}

{issue.pull_request &&
!isMerged &&
issue.state === 'open' &&
userHasPushPermission && (
<View style={styles.mergeButtonContainer}>
<Button
type={isMergeable ? 'success' : 'default'}
icon={{ name: 'git-merge', type: 'octicon' }}
disabled={!isMergeable}
onPress={() =>
navigation.navigate('PullMerge', {
title: translate('issue.pullMerge.title', language),
})}
title={translate('issue.main.mergeButton', language)}
/>
</View>
)}
userHasPushPermission &&
<View style={styles.mergeButtonContainer}>
<Button
type={isMergeable ? 'success' : 'default'}
icon={{ name: 'git-merge', type: 'octicon' }}
disabled={!isMergeable}
onPress={() =>
navigation.navigate('PullMerge', {
title: translate('issue.pullMerge.title', language),
})}
title={translate('issue.main.mergeButton', language)}
/>
</View>}
</View>
);
}
Expand Down
95 changes: 49 additions & 46 deletions src/components/issue-list-item.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,55 +55,58 @@ const styles = StyleSheet.create({

const getIconName = (type, issue) => {
if (type === 'issue') {
return issue.state === 'closed' ? 'issue-closed' : 'issue-opened';
return issue.state === 'CLOSED' ? 'issue-closed' : 'issue-opened';
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CLOSED, OPEN, .. should be moved in a string enum


return 'git-pull-request';
};

export const IssueListItem = ({ type, issue, navigation, language }: Props) =>
<TouchableHighlight
style={issue.state === 'closed' && styles.closedIssue}
onPress={() =>
navigation.navigate('Issue', {
issue,
isPR: !!issue.pull_request,
language,
})}
underlayColor={colors.greyLight}
>
<View style={styles.container}>
<ListItem
containerStyle={styles.listItemContainer}
title={issue.title}
subtitle={
issue.state === 'open'
? translate('issue.main.openIssueSubTitle', language, {
number: issue.number,
user: issue.user.login,
time: moment(issue.created_at).fromNow(),
})
: translate('issue.main.closedIssueSubTitle', language, {
number: issue.number,
user: issue.user.login,
time: moment(issue.closed_at).fromNow(),
})
}
leftIcon={{
name: getIconName(type, issue),
size: 36,
color: issue.state === 'open' ? colors.green : colors.red,
type: 'octicon',
}}
hideChevron
titleStyle={styles.title}
subtitleStyle={styles.subtitle}
/>
<View style={styles.commentsContainer}>
<Icon name="comment" type="octicon" size={18} color={colors.grey} />
<Text style={styles.comments}>
{issue.comments}
</Text>
export const IssueListItem = ({ type, issue, navigation, language }: Props) => {
return (
<TouchableHighlight
style={issue.state === 'CLOSED' && styles.closedIssue}
onPress={() =>
navigation.navigate('Issue', {
issue,
isPR: type !== 'issue',
language,
})}
underlayColor={colors.greyLight}
>
<View style={styles.container}>
<ListItem
containerStyle={styles.listItemContainer}
title={issue.title}
subtitle={
issue.state === 'OPEN'
? translate('issue.main.openIssueSubTitle', language, {
number: issue.number,
user: issue.author.login,
time: moment(issue.createdAt).fromNow(),
})
: translate('issue.main.closedIssueSubTitle', language, {
number: issue.number,
user: issue.author.login,
time: moment(issue.lastEditedAt).fromNow(),
})
}
leftIcon={{
name: getIconName(type, issue),
size: 36,
color: issue.state === 'OPEN' ? colors.green : colors.red,
type: 'octicon',
}}
hideChevron
titleStyle={styles.title}
subtitleStyle={styles.subtitle}
/>
<View style={styles.commentsContainer}>
<Icon name="comment" type="octicon" size={18} color={colors.grey} />
<Text style={styles.comments}>
{issue.comments.totalCount}
</Text>
</View>
</View>
</View>
</TouchableHighlight>;
</TouchableHighlight>
);
};
Loading