| 29 | }; |
| 30 | |
| 31 | export const repositoryReducer = (state = initialState, action = {}) => { |
| 32 | switch (action.type) { |
| 33 | case GET_REPOSITORY_CONTENTS.PENDING: |
| 34 | return { |
| 35 | ...state, |
| 36 | isPendingContents: true, |
| 37 | }; |
| 38 | case GET_REPOSITORY_CONTENTS.SUCCESS: |
| 39 | return { |
| 40 | ...state, |
| 41 | contents: |
| 42 | action.level === 'top' |
| 43 | ? { ...state.contents, top: action.results } |
| 44 | : { ...state.contents, [action.level]: action.results }, |
| 45 | isPendingContents: false, |
| 46 | }; |
| 47 | case GET_REPOSITORY_CONTENTS.ERROR: |
| 48 | return { |
| 49 | ...state, |
| 50 | error: action.payload, |
| 51 | isPendingContents: false, |
| 52 | }; |
| 53 | case GET_REPOSITORY_FILE.PENDING: |
| 54 | return { |
| 55 | ...state, |
| 56 | isPendingFile: true, |
| 57 | }; |
| 58 | case GET_REPOSITORY_FILE.SUCCESS: |
| 59 | return { |
| 60 | ...state, |
| 61 | fileContent: action.payload, |
| 62 | isPendingFile: false, |
| 63 | }; |
| 64 | case GET_REPOSITORY_FILE.ERROR: |
| 65 | return { |
| 66 | ...state, |
| 67 | error: action.payload, |
| 68 | isPendingFile: false, |
| 69 | }; |
| 70 | case GET_REPOSITORY_COMMITS.PENDING: |
| 71 | return { |
| 72 | ...state, |
| 73 | commits: [], |
| 74 | isPendingCommits: true, |
| 75 | }; |
| 76 | case GET_REPOSITORY_COMMITS.SUCCESS: |
| 77 | return { |
| 78 | ...state, |
| 79 | commits: action.payload, |
| 80 | isPendingCommits: false, |
| 81 | }; |
| 82 | case GET_REPOSITORY_COMMITS.ERROR: |
| 83 | return { |
| 84 | ...state, |
| 85 | error: action.payload, |
| 86 | isPendingCommits: false, |
| 87 | }; |
| 88 | case GET_REPOSITORY_README.PENDING: |