From 48f2316b1cc09491199ebccd375d2b9930191a64 Mon Sep 17 00:00:00 2001 From: Tudor Prodan Date: Sun, 22 Oct 2017 15:03:46 +0300 Subject: [PATCH 1/2] Added list with open pull requests on user profile pages --- .all-contributorsrc | 9 ++++++++ CONTRIBUTORS.md | 1 + src/auth/auth.action.js | 30 +++++++++++++++++++++++++ src/auth/auth.reducer.js | 18 +++++++++++++++ src/auth/auth.type.js | 1 + src/auth/screens/auth-profile.screen.js | 30 +++++++++++++++++++++++-- src/user/screens/profile.screen.js | 30 ++++++++++++++++++++++++- src/user/user.action.js | 28 +++++++++++++++++++++++ src/user/user.reducer.js | 20 +++++++++++++++++ src/user/user.type.js | 1 + 10 files changed, 165 insertions(+), 3 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0f5ae1034..3795a4ce9 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -517,6 +517,15 @@ "contributions": [ "tool" ] + }, + { + "login": "radiKal07", + "name": "Tudor Prodan", + "avatar_url": "https://avatars0.githubusercontent.com/u/7441453?v=4", + "profile": "https://github.com/radiKal07", + "contributions": [ + "code" + ] } ] } diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1a9fcb9bd..b53f80d44 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,4 +13,5 @@ Thank you to all the people who have already contributed to GitPoint! | [
Vitaliy Kanev](https://github.com/vitalkanev)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=vitalkanev "Documentation") | [
Peter Dave Hello](https://www.peterdavehello.org/)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=PeterDaveHello "Documentation") [πŸ”§](#tool-PeterDaveHello "Tools") | [
Ernoff](https://github.com/Ernoff)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=Ernoff "Code") [πŸ›](https://github.com/gitpoint/git-point/issues?q=author%3AErnoff "Bug reports") | [
Matthew Brandly](http://words.brandly.me/about/)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=brandly "Code") | [
JoΓ£o Fonseca](https://github.com/Jpfonseca)
[🌍](#translation-Jpfonseca "Translation") | [
Arjun Curat](https://github.com/acurat)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=acurat "Documentation") | | [
siderio2](https://github.com/siderio2)
[🌍](#translation-siderio2 "Translation") | [
Kodo Verkisto](https://github.com/kodisto)
[🌍](#translation-kodisto "Translation") | [
Sarah Vessels](http://sarahvessels.com/)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=cheshire137 "Documentation") | [
Thales Sousa](https://github.com/tminussi)
[🌍](#translation-tminussi "Translation") | [
Aseem Sood](https://github.com/asood123)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=asood123 "Documentation") | [
Eliott hauteclair](https://eliott.be)
[🌍](#translation-Eliottiosdevs "Translation") | | [
Peter Blazejewicz](http://www.linkedin.com/in/peterblazejewicz)
[🌍](#translation-peterblazejewicz "Translation") | [
Eric Adamski](https://github.com/ericadamski)
[πŸ›](https://github.com/gitpoint/git-point/issues?q=author%3Aericadamski "Bug reports") | [
Jouderian Nobre Junior](https://github.com/jouderianjr)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=jouderianjr "Code") | [
Phi Dong](http://www.phidong.com)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=pdong "Code") | [
Γ“scar Carretero](https://github.com/ocarreterom)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=ocarreterom "Code") | [
Dyesse YUMBA](https://github.com/dyesseyumba)
[πŸ”§](#tool-dyesseyumba "Tools") | +| [
Tudor Prodan](https://github.com/radiKal07)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=radiKal07 "Code") | diff --git a/src/auth/auth.action.js b/src/auth/auth.action.js index 0c05b23cc..0667546c8 100644 --- a/src/auth/auth.action.js +++ b/src/auth/auth.action.js @@ -10,6 +10,7 @@ import { fetchUserOrgs, fetchUserEvents, fetchStarCount, + fetchSearch } from 'api'; import { LOGIN, @@ -19,6 +20,7 @@ import { GET_EVENTS, CHANGE_LOCALE, GET_AUTH_STAR_COUNT, + SEARCH_USER_OPEN_PULL_REQUESTS, } from './auth.type'; export const auth = (code, state) => { @@ -157,6 +159,34 @@ export const getUserEvents = user => { }; }; +export const searchUserOpenPullRequests = () => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + const user = getState().auth.user.login; + + dispatch({ type: SEARCH_USER_OPEN_PULL_REQUESTS.PENDING }); + + return fetchSearch( + 'issues', + '', + accessToken, + `author:${user}+state:open+type:pr` + ) + .then(data => { + dispatch({ + type: SEARCH_USER_OPEN_PULL_REQUESTS.SUCCESS, + payload: data.items, + }); + }) + .catch(error => { + dispatch({ + type: SEARCH_USER_OPEN_PULL_REQUESTS.ERROR, + payload: error, + }); + }); + }; +}; + export const changeLocale = locale => { return dispatch => { dispatch({ type: CHANGE_LOCALE.SUCCESS, payload: locale }); diff --git a/src/auth/auth.reducer.js b/src/auth/auth.reducer.js index 88e3c6c3e..71c836970 100644 --- a/src/auth/auth.reducer.js +++ b/src/auth/auth.reducer.js @@ -7,6 +7,7 @@ import { GET_EVENTS, CHANGE_LOCALE, GET_AUTH_STAR_COUNT, + SEARCH_USER_OPEN_PULL_REQUESTS } from './auth.type'; const initialState = { @@ -137,6 +138,23 @@ export const authReducer = (state = initialState, action = {}) => { ...state, locale: action.payload, }; + case SEARCH_USER_OPEN_PULL_REQUESTS.PENDING: + return { + ...state, + isPendingSearchUserOpenPullRequests: true, + }; + case SEARCH_USER_OPEN_PULL_REQUESTS.SUCCESS: + return { + ...state, + searchedUserOpenPullRequests: action.payload, + isPendingSearchUserOpenPullRequests: false, + }; + case SEARCH_USER_OPEN_PULL_REQUESTS.ERROR: + return { + ...state, + error: action.payload, + isPendingSearchUserOpenPullRequests: false, + }; default: return state; } diff --git a/src/auth/auth.type.js b/src/auth/auth.type.js index 00e5dd515..48be7b088 100644 --- a/src/auth/auth.type.js +++ b/src/auth/auth.type.js @@ -7,3 +7,4 @@ export const GET_AUTH_ORGS = createActionSet('GET_AUTH_ORGS'); export const GET_EVENTS = createActionSet('GET_EVENTS'); export const CHANGE_LOCALE = createActionSet('CHANGE_LOCALE'); export const GET_AUTH_STAR_COUNT = createActionSet('GET_AUTH_STAR_COUNT'); +export const SEARCH_USER_OPEN_PULL_REQUESTS = createActionSet('SEARCH_USER_OPEN_PULL_REQUESTS'); \ No newline at end of file diff --git a/src/auth/screens/auth-profile.screen.js b/src/auth/screens/auth-profile.screen.js index 2ebc8d9c9..64400eba6 100644 --- a/src/auth/screens/auth-profile.screen.js +++ b/src/auth/screens/auth-profile.screen.js @@ -18,19 +18,22 @@ import { ParallaxScroll, UserListItem, EntityInfo, + IssueListItem } from 'components'; import { colors, fonts, normalize } from 'config'; -import { getUser, getOrgs, getStarCount } from 'auth'; +import { getUser, getOrgs, getStarCount, searchUserOpenPullRequests } from 'auth'; import { emojifyText, openURLInView, translate } from 'utils'; const mapStateToProps = state => ({ user: state.auth.user, orgs: state.auth.orgs, + searchedUserOpenPullRequests: state.user.searchedUserOpenPullRequests, locale: state.auth.locale, starCount: state.auth.starCount, isPendingUser: state.auth.isPendingUser, isPendingOrgs: state.auth.isPendingOrgs, hasInitialUser: state.auth.hasInitialUser, + isPendingSearchUserOpenPullRequests: state.user.isPendingSearchUserOpenPullRequests, }); const mapDispatchToProps = dispatch => @@ -39,6 +42,7 @@ const mapDispatchToProps = dispatch => getUser, getOrgs, getStarCount, + searchUserOpenPullRequests, }, dispatch ); @@ -81,12 +85,15 @@ class AuthProfile extends Component { getUser: Function, getOrgs: Function, getStarCount: Function, + searchUserOpenPullRequests: Function, user: Object, orgs: Array, + searchedUserOpenPullRequests: Arrray, locale: string, starCount: string, isPendingUser: boolean, isPendingOrgs: boolean, + isPendingSearchUserOpenPullRequests: boolean, hasInitialUser: boolean, navigation: Object, }; @@ -99,14 +106,17 @@ class AuthProfile extends Component { this.props.getUser(); this.props.getOrgs(); this.props.getStarCount(); + this.props.searchUserOpenPullRequests(); }; render() { const { user, orgs, + searchedUserOpenPullRequests, isPendingUser, isPendingOrgs, + isPendingSearchUserOpenPullRequests, locale, starCount, navigation, @@ -115,7 +125,7 @@ class AuthProfile extends Component { const hasBackButton = navigation.state.routeName === 'AuthProfile'; - const isPending = isPendingUser || isPendingOrgs; + const isPending = isPendingUser || isPendingOrgs || isPendingSearchUserOpenPullRequests; return ( @@ -204,6 +214,22 @@ class AuthProfile extends Component { + + + {searchedUserOpenPullRequests.map(item => + + )} + + )} diff --git a/src/user/screens/profile.screen.js b/src/user/screens/profile.screen.js index 8ff44b800..e223eb4d6 100644 --- a/src/user/screens/profile.screen.js +++ b/src/user/screens/profile.screen.js @@ -19,6 +19,7 @@ import { ParallaxScroll, UserListItem, EntityInfo, + IssueListItem, } from 'components'; import { emojifyText, translate, openURLInView } from 'utils'; import { colors, fonts } from 'config'; @@ -28,6 +29,7 @@ import { getIsFollowing, getIsFollower, changeFollowStatus, + searchUserOpenPullRequests, } from '../user.action'; const mapStateToProps = state => ({ @@ -36,6 +38,7 @@ const mapStateToProps = state => ({ orgs: state.user.orgs, starCount: state.user.starCount, locale: state.auth.locale, + searchedUserOpenPullRequests: state.user.searchedUserOpenPullRequests, isFollowing: state.user.isFollowing, isFollower: state.user.isFollower, isPendingUser: state.user.isPendingUser, @@ -43,6 +46,7 @@ const mapStateToProps = state => ({ isPendingStarCount: state.user.isPendingStarCount, isPendingCheckFollowing: state.user.isPendingCheckFollowing, isPendingCheckFollower: state.user.isPendingCheckFollower, + isPendingSearchUserOpenPullRequests: state.user.isPendingSearchUserOpenPullRequests, }); const mapDispatchToProps = dispatch => @@ -53,6 +57,7 @@ const mapDispatchToProps = dispatch => getIsFollowing, getIsFollower, changeFollowStatus, + searchUserOpenPullRequests, }, dispatch ); @@ -75,9 +80,11 @@ class Profile extends Component { getIsFollowing: Function, getIsFollower: Function, changeFollowStatus: Function, + searchUserOpenPullRequests: Function, auth: Object, user: Object, orgs: Array, + searchedUserOpenPullRequests: Arrray, starCount: string, locale: string, isFollowing: boolean, @@ -87,6 +94,7 @@ class Profile extends Component { isPendingStarCount: boolean, isPendingCheckFollowing: boolean, isPendingCheckFollower: boolean, + isPendingSearchUserOpenPullRequests: boolean, navigation: Object, }; @@ -116,6 +124,7 @@ class Profile extends Component { this.props.getStarCount(user.login), this.props.getIsFollowing(user.login, auth.login), this.props.getIsFollower(user.login, auth.login), + this.props.searchUserOpenPullRequests(user.login, auth.login), ]).then(() => { this.setState({ refreshing: false }); }); @@ -139,6 +148,7 @@ class Profile extends Component { const { user, orgs, + searchedUserOpenPullRequests, starCount, locale, isFollowing, @@ -148,6 +158,7 @@ class Profile extends Component { isPendingStarCount, isPendingCheckFollowing, isPendingCheckFollower, + isPendingSearchUserOpenPullRequests, navigation, } = this.props; const { refreshing } = this.state; @@ -157,7 +168,8 @@ class Profile extends Component { isPendingOrgs || isPendingStarCount || isPendingCheckFollowing || - isPendingCheckFollower; + isPendingCheckFollower || + isPendingSearchUserOpenPullRequests; const userActions = [ isFollowing ? translate('user.profile.unfollow', locale) @@ -235,6 +247,22 @@ class Profile extends Component { /> )} + + + {searchedUserOpenPullRequests.map(item => + + )} + + } diff --git a/src/user/user.action.js b/src/user/user.action.js index 5fd732f89..654d5100b 100644 --- a/src/user/user.action.js +++ b/src/user/user.action.js @@ -15,6 +15,7 @@ import { GET_FOLLOWERS, GET_FOLLOWING, SEARCH_USER_REPOS, + SEARCH_USER_OPEN_PULL_REQUESTS, CHANGE_FOLLOW_STATUS, GET_STAR_COUNT, } from './user.type'; @@ -250,3 +251,30 @@ export const searchUserRepos = (query, user) => { }); }; }; + +export const searchUserOpenPullRequests = (query, user) => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + + dispatch({ type: SEARCH_USER_OPEN_PULL_REQUESTS.PENDING }); + + return fetchSearch( + 'issues', + '', + accessToken, + `author:${query}+state:open+type:pr` + ) + .then(data => { + dispatch({ + type: SEARCH_USER_OPEN_PULL_REQUESTS.SUCCESS, + payload: data.items, + }); + }) + .catch(error => { + dispatch({ + type: SEARCH_USER_OPEN_PULL_REQUESTS.ERROR, + payload: error, + }); + }); + }; +}; diff --git a/src/user/user.reducer.js b/src/user/user.reducer.js index cd1e09f3c..0c2f3f407 100644 --- a/src/user/user.reducer.js +++ b/src/user/user.reducer.js @@ -7,6 +7,7 @@ import { GET_FOLLOWERS, GET_FOLLOWING, SEARCH_USER_REPOS, + SEARCH_USER_OPEN_PULL_REQUESTS, CHANGE_FOLLOW_STATUS, GET_STAR_COUNT, } from './user.type'; @@ -20,6 +21,7 @@ const initialState = { followers: [], following: [], searchedUserRepos: [], + searchedUserOpenPullRequests: [], isPendingUser: false, isPendingOrgs: false, isPendingStarCount: false, @@ -29,6 +31,7 @@ const initialState = { isPendingFollowers: false, isPendingFollowing: false, isPendingSearchUserRepos: false, + isPendingSearchUserOpenPullRequests: false, error: '', }; @@ -213,6 +216,23 @@ export const userReducer = (state = initialState, action = {}) => { error: action.payload, isPendingSearchUserRepos: false, }; + case SEARCH_USER_OPEN_PULL_REQUESTS.PENDING: + return { + ...state, + isPendingSearchUserOpenPullRequests: true, + }; + case SEARCH_USER_OPEN_PULL_REQUESTS.SUCCESS: + return { + ...state, + searchedUserOpenPullRequests: action.payload, + isPendingSearchUserOpenPullRequests: false, + }; + case SEARCH_USER_OPEN_PULL_REQUESTS.ERROR: + return { + ...state, + error: action.payload, + isPendingSearchUserOpenPullRequests: false, + }; default: return state; } diff --git a/src/user/user.type.js b/src/user/user.type.js index 8cbbd1bdd..c139b61dc 100644 --- a/src/user/user.type.js +++ b/src/user/user.type.js @@ -8,5 +8,6 @@ export const GET_REPOSITORIES = createActionSet('GET_REPOSITORIES'); export const GET_FOLLOWERS = createActionSet('GET_FOLLOWERS'); export const GET_FOLLOWING = createActionSet('GET_FOLLOWING'); export const SEARCH_USER_REPOS = createActionSet('SEARCH_USER_REPOS'); +export const SEARCH_USER_OPEN_PULL_REQUESTS = createActionSet('SEARCH_USER_OPEN_PULL_REQUESTS'); export const CHANGE_FOLLOW_STATUS = createActionSet('CHANGE_FOLLOW_STATUS'); export const GET_STAR_COUNT = createActionSet('GET_STAR_COUNT'); From ff97ffc0d9d2d5518d53252cdfc3cc343a909c23 Mon Sep 17 00:00:00 2001 From: Tudor Prodan Date: Sun, 22 Oct 2017 16:00:15 +0300 Subject: [PATCH 2/2] Fixed eslint errors --- src/auth/auth.action.js | 2 +- src/auth/auth.reducer.js | 2 +- src/auth/auth.type.js | 2 +- src/auth/screens/auth-profile.screen.js | 4 ++-- src/user/screens/profile.screen.js | 4 ++-- src/user/user.action.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/auth/auth.action.js b/src/auth/auth.action.js index 0667546c8..2df1fbcf5 100644 --- a/src/auth/auth.action.js +++ b/src/auth/auth.action.js @@ -10,7 +10,7 @@ import { fetchUserOrgs, fetchUserEvents, fetchStarCount, - fetchSearch + fetchSearch, } from 'api'; import { LOGIN, diff --git a/src/auth/auth.reducer.js b/src/auth/auth.reducer.js index 71c836970..15e0ac682 100644 --- a/src/auth/auth.reducer.js +++ b/src/auth/auth.reducer.js @@ -7,7 +7,7 @@ import { GET_EVENTS, CHANGE_LOCALE, GET_AUTH_STAR_COUNT, - SEARCH_USER_OPEN_PULL_REQUESTS + SEARCH_USER_OPEN_PULL_REQUESTS, } from './auth.type'; const initialState = { diff --git a/src/auth/auth.type.js b/src/auth/auth.type.js index 48be7b088..605e14e86 100644 --- a/src/auth/auth.type.js +++ b/src/auth/auth.type.js @@ -7,4 +7,4 @@ export const GET_AUTH_ORGS = createActionSet('GET_AUTH_ORGS'); export const GET_EVENTS = createActionSet('GET_EVENTS'); export const CHANGE_LOCALE = createActionSet('CHANGE_LOCALE'); export const GET_AUTH_STAR_COUNT = createActionSet('GET_AUTH_STAR_COUNT'); -export const SEARCH_USER_OPEN_PULL_REQUESTS = createActionSet('SEARCH_USER_OPEN_PULL_REQUESTS'); \ No newline at end of file +export const SEARCH_USER_OPEN_PULL_REQUESTS = createActionSet('SEARCH_USER_OPEN_PULL_REQUESTS'); diff --git a/src/auth/screens/auth-profile.screen.js b/src/auth/screens/auth-profile.screen.js index 64400eba6..c02d76ed5 100644 --- a/src/auth/screens/auth-profile.screen.js +++ b/src/auth/screens/auth-profile.screen.js @@ -18,7 +18,7 @@ import { ParallaxScroll, UserListItem, EntityInfo, - IssueListItem + IssueListItem, } from 'components'; import { colors, fonts, normalize } from 'config'; import { getUser, getOrgs, getStarCount, searchUserOpenPullRequests } from 'auth'; @@ -88,7 +88,7 @@ class AuthProfile extends Component { searchUserOpenPullRequests: Function, user: Object, orgs: Array, - searchedUserOpenPullRequests: Arrray, + searchedUserOpenPullRequests: Array, locale: string, starCount: string, isPendingUser: boolean, diff --git a/src/user/screens/profile.screen.js b/src/user/screens/profile.screen.js index e223eb4d6..a62702532 100644 --- a/src/user/screens/profile.screen.js +++ b/src/user/screens/profile.screen.js @@ -84,7 +84,7 @@ class Profile extends Component { auth: Object, user: Object, orgs: Array, - searchedUserOpenPullRequests: Arrray, + searchedUserOpenPullRequests: Array, starCount: string, locale: string, isFollowing: boolean, @@ -124,7 +124,7 @@ class Profile extends Component { this.props.getStarCount(user.login), this.props.getIsFollowing(user.login, auth.login), this.props.getIsFollower(user.login, auth.login), - this.props.searchUserOpenPullRequests(user.login, auth.login), + this.props.searchUserOpenPullRequests(user.login), ]).then(() => { this.setState({ refreshing: false }); }); diff --git a/src/user/user.action.js b/src/user/user.action.js index 654d5100b..0fcfa42d8 100644 --- a/src/user/user.action.js +++ b/src/user/user.action.js @@ -252,7 +252,7 @@ export const searchUserRepos = (query, user) => { }; }; -export const searchUserOpenPullRequests = (query, user) => { +export const searchUserOpenPullRequests = query => { return (dispatch, getState) => { const accessToken = getState().auth.accessToken;