-
Notifications
You must be signed in to change notification settings - Fork 783
refactor: switch organization screen to new Redux api #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fdabf02
feat: Make the starred repositories list paged using the new api
machour 0e4f213
Revert "feat: Make the starred repositories list paged using the new …
machour 1774f0b
Merge remote-tracking branch 'upstream/master'
machour 8066c3f
refactor(orgs): add API definitions for Organizations
machour 54cc988
refactor: switch organization profile to new middleware
machour 2686360
feat: paged members list
machour f776cd3
chore: use styled-components
machour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { createPaginationActionSet } from 'utils'; | ||
import { createActionSet, createPaginationActionSet } from 'utils'; | ||
|
||
export const ACTIVITY_GET_EVENTS_RECEIVED = createPaginationActionSet( | ||
'ACTIVITY_GET_EVENTS_RECEIVED' | ||
); | ||
export const ACTIVITY_GET_STARRED_REPOS_FOR_USER = createPaginationActionSet( | ||
'ACTIVITY_GET_STARRED_REPOS_FOR_USER' | ||
); | ||
export const ORGS_GET_MEMBERS = createPaginationActionSet('ORGS_GET_MEMBERS'); | ||
|
||
export const ORGS_GET_BY_ID = createActionSet('ORGS_GET_BY_ID'); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,4 +149,20 @@ export class Client { | |
})); | ||
}, | ||
}; | ||
|
||
orgs = { | ||
getById: async (orgId, params) => { | ||
return this.call(`orgs/${orgId}`, params).then(response => ({ | ||
response, | ||
schema: Schemas.ORG, | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this time, no |
||
}, | ||
getMembers: async (orgId, params) => { | ||
return this.call(`orgs/${orgId}/members`, params).then(response => ({ | ||
response, | ||
nextPageUrl: this.getNextPageUrl(response), | ||
schema: Schemas.USER_ARRAY, | ||
})); | ||
}, | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { eventSchema } from './events'; | ||
import { repoSchema } from './repos'; | ||
import { orgSchema } from './orgs'; | ||
import { userSchema } from './users'; | ||
|
||
export default { | ||
EVENT: eventSchema, | ||
EVENT_ARRAY: [eventSchema], | ||
REPO: repoSchema, | ||
REPO_ARRAY: [repoSchema], | ||
USER: userSchema, | ||
USER_ARRAY: [userSchema], | ||
ORG: orgSchema, | ||
ORG_ARRAY: [orgSchema], | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { schema } from 'normalizr'; | ||
|
||
export const orgSchema = new schema.Entity( | ||
'orgs', | ||
{}, | ||
{ | ||
idAttribute: org => org.login.toLowerCase(), | ||
} | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { schema } from 'normalizr'; | ||
|
||
export const userSchema = new schema.Entity( | ||
'users', | ||
{}, | ||
{ | ||
idAttribute: user => user.login.toLowerCase(), | ||
} | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,15 @@ | ||
import { createAction } from 'redux-actions'; | ||
|
||
import { fetchOrg, fetchOrgMembers, v3 } from 'api'; | ||
import { v3 } from 'api'; | ||
import { | ||
GET_ORG, | ||
GET_ORG_LOADING, | ||
GET_ORG_ERROR, | ||
GET_ORG_REPOS, | ||
GET_ORG_REPOS_LOADING, | ||
GET_ORG_REPOS_ERROR, | ||
GET_ORG_MEMBERS, | ||
GET_ORG_MEMBERS_LOADING, | ||
GET_ORG_MEMBERS_ERROR, | ||
} from './organization.constants'; | ||
|
||
export const getOrg = createAction(GET_ORG); | ||
export const getOrgLoading = createAction(GET_ORG_LOADING); | ||
export const getOrgError = createAction(GET_ORG_ERROR); | ||
export const getOrgRepos = createAction(GET_ORG_REPOS); | ||
export const getOrgReposLoading = createAction(GET_ORG_REPOS_LOADING); | ||
export const getOrgReposError = createAction(GET_ORG_REPOS_ERROR); | ||
export const getOrgMembers = createAction(GET_ORG_MEMBERS); | ||
export const getOrgMembersLoading = createAction(GET_ORG_MEMBERS_LOADING); | ||
export const getOrgMembersError = createAction(GET_ORG_MEMBERS_ERROR); | ||
|
||
export const fetchOrganizations = orgName => (dispatch, getState) => { | ||
// use a selector here | ||
const accessToken = getState().auth.accessToken; | ||
|
||
dispatch(getOrgLoading(true)); | ||
dispatch(getOrgError('')); | ||
|
||
return fetchOrg(orgName, accessToken) | ||
.then(data => { | ||
dispatch(getOrgLoading(false)); | ||
dispatch(getOrg(data)); | ||
}) | ||
.catch(error => { | ||
dispatch(getOrgLoading(false)); | ||
dispatch(getOrgError(error)); | ||
}); | ||
}; | ||
|
||
export const fetchOrganizationRepos = url => (dispatch, getState) => { | ||
const accessToken = getState().auth.accessToken; | ||
|
@@ -58,20 +28,3 @@ export const fetchOrganizationRepos = url => (dispatch, getState) => { | |
dispatch(getOrgReposError(error)); | ||
}); | ||
}; | ||
|
||
export const fetchOrganizationMembers = orgName => (dispatch, getState) => { | ||
const accessToken = getState().auth.accessToken; | ||
|
||
dispatch(getOrgMembersLoading(true)); | ||
dispatch(getOrgMembersError('')); | ||
|
||
return fetchOrgMembers(orgName, accessToken) | ||
.then(data => { | ||
dispatch(getOrgMembersLoading(false)); | ||
dispatch(getOrgMembers(data)); | ||
}) | ||
.catch(error => { | ||
dispatch(getOrgMembersLoading(false)); | ||
dispatch(getOrgMembersError(error)); | ||
}); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sheeeeeesh all this boilerplate gone :) :) :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
export const GET_ORG = 'GET_ORG'; | ||
export const GET_ORG_LOADING = 'GET_ORG_LOADING'; | ||
export const GET_ORG_ERROR = 'GET_ORG_ERROR'; | ||
export const GET_ORG_REPOS = 'GET_ORG_REPOS'; | ||
export const GET_ORG_REPOS_LOADING = 'GET_ORG_REPOS_LOADING'; | ||
export const GET_ORG_REPOS_ERROR = 'GET_ORG_REPOS_ERROR'; | ||
export const GET_ORG_MEMBERS = 'GET_ORG_MEMBERS'; | ||
export const GET_ORG_MEMBERS_LOADING = 'GET_ORG_MEMBERS_LOADING'; | ||
export const GET_ORG_MEMBERS_ERROR = 'GET_ORG_MEMBERS_ERROR'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ORGS_GET_BY_ID uses
createActionSet
instead ofcreatePaginationActionSet
, as we're retrieving a single entity.