Skip to content

Commit 5d503c1

Browse files
authored
feat: Support pagination in issue-list screen and pull-list screen (#856)
* refactor(repo/issue): Clean codes * refactor(*): Clean state fields * fix(pr): Fix pr detail fetching due to repo refactoring * refactor(repo): Remove old api codes * feat(issue-list): Support pagination * feat(pull-list): Support pagination * fix(schema): Don't convert to lower case for ids
1 parent 2d17c52 commit 5d503c1

21 files changed

+263
-1087
lines changed

__tests__/tests/reducers/issue.reducer.js

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {
3-
GET_ISSUE_COMMENTS,
43
POST_ISSUE_COMMENT,
54
DELETE_ISSUE_COMMENT,
65
EDIT_ISSUE_COMMENT,
@@ -11,9 +10,7 @@ import {
1110
GET_ISSUE_MERGE_STATUS,
1211
GET_PULL_REQUEST_FROM_URL,
1312
MERGE_PULL_REQUEST,
14-
GET_ISSUE_FROM_URL,
1513
SUBMIT_NEW_ISSUE,
16-
GET_ISSUE_EVENTS,
1714
} from 'issue/issue.type';
1815
import { initialState, issueReducer } from 'issue/issue.reducer';
1916
import { open } from '../../data/api/issue';
@@ -23,68 +20,6 @@ describe('Issuer Reducer', () => {
2320
expect(issueReducer()).toEqual(initialState);
2421
});
2522

26-
describe('GET_ISSUE_COMMENTS', () => {
27-
it('.PENDING should set pending state', () => {
28-
const action = { type: GET_ISSUE_COMMENTS.PENDING };
29-
const expectedState = { ...initialState, isPendingComments: true };
30-
31-
expect(issueReducer(initialState, action)).toEqual(expectedState);
32-
});
33-
34-
it('.ERROR should set error state', () => {
35-
const action = { type: GET_ISSUE_COMMENTS.ERROR, payload: 'error' };
36-
const expectedState = {
37-
...initialState,
38-
isPendingComments: false,
39-
error: 'error',
40-
};
41-
42-
expect(issueReducer(initialState, action)).toEqual(expectedState);
43-
});
44-
45-
it('.SUCCESS should set comments', () => {
46-
const action = { type: GET_ISSUE_COMMENTS.SUCCESS, payload: [{}] };
47-
const expectedState = {
48-
...initialState,
49-
isPendingComments: false,
50-
comments: action.payload,
51-
};
52-
53-
expect(issueReducer(initialState, action)).toEqual(expectedState);
54-
});
55-
});
56-
57-
describe('GET_ISSUE_EVENTS', () => {
58-
it('.PENDING should set pending state', () => {
59-
const action = { type: GET_ISSUE_EVENTS.PENDING };
60-
const expectedState = { ...initialState, isPendingEvents: true };
61-
62-
expect(issueReducer(initialState, action)).toEqual(expectedState);
63-
});
64-
65-
it('.ERROR should set error state', () => {
66-
const action = { type: GET_ISSUE_EVENTS.ERROR, payload: 'error' };
67-
const expectedState = {
68-
...initialState,
69-
isPendingEvents: false,
70-
error: 'error',
71-
};
72-
73-
expect(issueReducer(initialState, action)).toEqual(expectedState);
74-
});
75-
76-
it('.SUCCESS should set events', () => {
77-
const action = { type: GET_ISSUE_EVENTS.SUCCESS, payload: [{}] };
78-
const expectedState = {
79-
...initialState,
80-
isPendingEvents: false,
81-
events: action.payload,
82-
};
83-
84-
expect(issueReducer(initialState, action)).toEqual(expectedState);
85-
});
86-
});
87-
8823
describe('POST_ISSUE_COMMENT', () => {
8924
it('.PEDNING should set pending state', () => {
9025
const action = { type: POST_ISSUE_COMMENT.PENDING };
@@ -521,37 +456,6 @@ describe('Issuer Reducer', () => {
521456
});
522457
});
523458

524-
describe('GET_ISSUE_FROM_URL', () => {
525-
it('.PENDING should set pending state', () => {
526-
const action = { type: GET_ISSUE_FROM_URL.PENDING };
527-
const expectedState = { ...initialState, isPendingIssue: true };
528-
529-
expect(issueReducer(initialState, action)).toEqual(expectedState);
530-
});
531-
532-
it('.ERROR should set error state', () => {
533-
const action = { type: GET_ISSUE_FROM_URL.ERROR, payload: 'error' };
534-
const expectedState = {
535-
...initialState,
536-
isPendingIssue: false,
537-
error: 'error',
538-
};
539-
540-
expect(issueReducer(initialState, action)).toEqual(expectedState);
541-
});
542-
543-
it('.SUCCESS should set issue', () => {
544-
const action = { type: GET_ISSUE_FROM_URL.SUCCESS, payload: open };
545-
const expectedState = {
546-
...initialState,
547-
isPendingIssue: false,
548-
issue: action.payload,
549-
};
550-
551-
expect(issueReducer(initialState, action)).toEqual(expectedState);
552-
});
553-
});
554-
555459
describe('SUBMIT_NEW_ISSUE', () => {
556460
it('.PENDING should set pending state', () => {
557461
const action = { type: SUBMIT_NEW_ISSUE.PENDING };
Lines changed: 0 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import {
2-
GET_REPOSITORY,
3-
GET_REPOSITORY_CONTRIBUTORS,
42
GET_REPOSITORY_CONTENTS,
53
GET_REPOSITORY_FILE,
64
GET_REPOSITORY_README,
75
GET_REPOSITORY_LABELS,
8-
SEARCH_OPEN_ISSUES,
9-
SEARCH_CLOSED_ISSUES,
10-
SEARCH_OPEN_PULLS,
11-
SEARCH_CLOSED_PULLS,
126
} from 'repository/repository.type';
137

148
import { initialState, repositoryReducer } from 'repository/repository.reducer';
@@ -18,84 +12,6 @@ describe('Repository Reducer', () => {
1812
expect(repositoryReducer(undefined)).toEqual(initialState);
1913
});
2014

21-
describe('GET_REPOSITORY', () => {
22-
it('.PENDING should set state to pending', () => {
23-
const action = { type: GET_REPOSITORY.PENDING };
24-
const expectedState = {
25-
...initialState,
26-
isPendingRepository: true,
27-
contributors: [],
28-
issues: [],
29-
readMe: '',
30-
hasRepoExist: false,
31-
hasReadMe: false,
32-
error: '',
33-
topics: [],
34-
isPendingRepository: true,
35-
};
36-
37-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
38-
});
39-
40-
it('.ERROR should set error state', () => {
41-
const action = { type: GET_REPOSITORY.ERROR, payload: 'error' };
42-
const expectedState = { ...initialState, error: action.payload };
43-
44-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
45-
});
46-
47-
it('.SUCCESS should set repository', () => {
48-
const action = { type: GET_REPOSITORY.SUCCESS, payload: { id: 1 } };
49-
const expectedState = {
50-
...initialState,
51-
repository: action.payload,
52-
hasRepoExist: true,
53-
error: '',
54-
isPendingRepository: false,
55-
};
56-
57-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
58-
});
59-
});
60-
61-
describe('GET_REPOSITORY_CONTRIBUTORS', () => {
62-
it('.PENDING should set pending state', () => {
63-
const action = { type: GET_REPOSITORY_CONTRIBUTORS.PENDING };
64-
const expectedState = { ...initialState, isPendingContributors: true };
65-
66-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
67-
});
68-
69-
it('.ERROR should set error state', () => {
70-
const action = {
71-
type: GET_REPOSITORY_CONTRIBUTORS.ERROR,
72-
payload: 'error',
73-
};
74-
const expectedState = {
75-
...initialState,
76-
error: action.payload,
77-
isPendingContributors: false,
78-
contributors: [],
79-
};
80-
81-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
82-
});
83-
84-
it('.SUCCESS should set contributors', () => {
85-
const action = {
86-
type: GET_REPOSITORY_CONTRIBUTORS.SUCCESS,
87-
payload: [{ id: 1 }],
88-
};
89-
const expectedState = {
90-
...initialState,
91-
isPendingContributors: false,
92-
contributors: action.payload,
93-
};
94-
95-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
96-
});
97-
});
98-
9915
describe('GET_REPOSITORY_CONTENTS', () => {
10016
it('.PENDING should set pending state', () => {
10117
const action = { type: GET_REPOSITORY_CONTENTS.PENDING };
@@ -226,130 +142,4 @@ describe('Repository Reducer', () => {
226142
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
227143
});
228144
});
229-
230-
describe('SEARCH_OPEN_ISSUES', () => {
231-
it('.PENDING should set pending state', () => {
232-
const action = { type: SEARCH_OPEN_ISSUES.PENDING };
233-
const expectedState = {
234-
...initialState,
235-
searchedOpenIssues: [],
236-
isPendingSearchOpenIssues: true,
237-
};
238-
239-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
240-
});
241-
242-
it('.ERROR should set error state', () => {
243-
const action = { type: SEARCH_OPEN_ISSUES.ERROR, payload: 'error' };
244-
const expectedState = { ...initialState, error: action.payload };
245-
246-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
247-
});
248-
249-
it('.SUCCESS should set searched open issues', () => {
250-
const action = { type: SEARCH_OPEN_ISSUES.SUCCESS, payload: [{ id: 1 }] };
251-
const expectedState = {
252-
...initialState,
253-
searchedOpenIssues: action.payload,
254-
};
255-
256-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
257-
});
258-
});
259-
260-
describe('SEARCH_CLOSED_ISSUES', () => {
261-
it('.PENDING should set pending state', () => {
262-
const action = { type: SEARCH_CLOSED_ISSUES.PENDING };
263-
const expectedState = {
264-
...initialState,
265-
searchedClosedIssues: [],
266-
isPendingSearchClosedIssues: true,
267-
};
268-
269-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
270-
});
271-
272-
it('.ERROR should set error state', () => {
273-
const action = { type: SEARCH_CLOSED_ISSUES.ERROR, payload: 'error' };
274-
const expectedState = { ...initialState, error: action.payload };
275-
276-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
277-
});
278-
279-
it('.SUCCESS should set searched closed issues', () => {
280-
const action = {
281-
type: SEARCH_CLOSED_ISSUES.SUCCESS,
282-
payload: [{ id: 1 }],
283-
};
284-
const expectedState = {
285-
...initialState,
286-
searchedClosedIssues: action.payload,
287-
};
288-
289-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
290-
});
291-
});
292-
293-
describe('SEARCH_OPEN_PULLS', () => {
294-
it('.PENDING should set pending state', () => {
295-
const action = { type: SEARCH_OPEN_PULLS.PENDING };
296-
const expectedState = {
297-
...initialState,
298-
searchedOpenPulls: [],
299-
isPendingSearchOpenPulls: true,
300-
};
301-
302-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
303-
});
304-
305-
it('.ERROR should set error state', () => {
306-
const action = { type: SEARCH_OPEN_PULLS.ERROR, payload: 'error' };
307-
const expectedState = { ...initialState, error: action.payload };
308-
309-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
310-
});
311-
312-
it('.SUCCESS should set search open pulls', () => {
313-
const action = { type: SEARCH_OPEN_PULLS.SUCCESS, payload: [{ id: 1 }] };
314-
const expectedState = {
315-
...initialState,
316-
searchedOpenPulls: action.payload,
317-
};
318-
319-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
320-
});
321-
});
322-
323-
describe('SEARCH_CLOSED_PULLS', () => {
324-
it('.PENDING should set pending state', () => {
325-
const action = { type: SEARCH_CLOSED_PULLS.PENDING };
326-
const expectedState = {
327-
...initialState,
328-
searchedClosedPulls: [],
329-
isPendingSearchClosedPulls: true,
330-
};
331-
332-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
333-
});
334-
335-
it('.ERROR should set error state', () => {
336-
const action = { type: SEARCH_CLOSED_PULLS.ERROR, payload: 'error' };
337-
const expectedState = { ...initialState, error: action.payload };
338-
339-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
340-
});
341-
342-
it('.SUCCESS should set search closed pulls', () => {
343-
const action = {
344-
type: SEARCH_CLOSED_PULLS.SUCCESS,
345-
payload: [{ id: 1 }],
346-
};
347-
const expectedState = {
348-
...initialState,
349-
searchedClosedPulls: action.payload,
350-
};
351-
352-
expect(repositoryReducer(initialState, action)).toEqual(expectedState);
353-
});
354-
});
355145
});

src/api/actions/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const ACTIVITY_WATCH_REPO = createActionSet('ACTIVITY_WATCH_REPO');
1212
export const ACTIVITY_UNWATCH_REPO = createActionSet('ACTIVITY_UNWATCH_REPO');
1313
export const SEARCH_REPOS = createPaginationActionSet('SEARCH_REPOS');
1414
export const SEARCH_USERS = createPaginationActionSet('SEARCH_USERS');
15+
export const SEARCH_ISSUES = createPaginationActionSet('SEARCH_ISSUES');
1516
export const ORGS_GET_MEMBERS = createPaginationActionSet('ORGS_GET_MEMBERS');
1617
export const ORGS_GET_BY_ID = createActionSet('ORGS_GET_BY_ID');
1718

0 commit comments

Comments
 (0)