From d1bb088b9c3a71e94c8276d74fd290e36e07d2cf Mon Sep 17 00:00:00 2001 From: Xianming Zhong Date: Sat, 1 Dec 2018 11:41:18 +0800 Subject: [PATCH] feat(commit): view commits (#851) * feat(commits): migrate #258 changes * feat(commits): fix i18n * fix(issue): fix issue description styles * feat(commit): Show author and committer, both clickable * chore(i18n): update translation files --- routes.js | 14 + src/auth/screens/events.screen.js | 17 +- src/components/commit-list-item.component.js | 57 ++++ src/components/index.js | 1 + src/components/issue-description.component.js | 46 ++- src/issue/issue.action.js | 24 ++ src/issue/issue.reducer.js | 21 ++ src/issue/issue.type.js | 1 + src/issue/screens/issue.screen.js | 22 +- src/locale/languages/ca.js | 7 +- src/locale/languages/de.js | 5 + src/locale/languages/en.js | 5 + src/locale/languages/eo.js | 5 + src/locale/languages/es.js | 5 + src/locale/languages/eu.js | 5 + src/locale/languages/fr.js | 5 + src/locale/languages/gl.js | 5 + src/locale/languages/nl.js | 5 + src/locale/languages/ph.js | 5 + src/locale/languages/pl.js | 5 + src/locale/languages/pt.js | 5 + src/locale/languages/ptBr.js | 5 + src/locale/languages/ru.js | 5 + src/locale/languages/sr.js | 5 + src/locale/languages/sv.js | 5 + src/locale/languages/th.js | 5 + src/locale/languages/tr.js | 5 + src/locale/languages/uk.js | 5 + src/locale/languages/zhCn.js | 5 + src/locale/languages/zhTw.js | 5 + src/repository/repository.action.js | 82 ++++- src/repository/repository.reducer.js | 62 ++++ src/repository/repository.type.js | 3 + src/repository/screens/commit-list.screen.js | 55 +++ src/repository/screens/commit.screen.js | 312 ++++++++++++++++++ src/repository/screens/index.js | 2 + src/repository/screens/repository.screen.js | 47 ++- 37 files changed, 852 insertions(+), 21 deletions(-) create mode 100644 src/components/commit-list-item.component.js create mode 100644 src/repository/screens/commit-list.screen.js create mode 100644 src/repository/screens/commit.screen.js diff --git a/routes.js b/routes.js index 347b8d982..9e459f42b 100644 --- a/routes.js +++ b/routes.js @@ -50,6 +50,8 @@ import { IssueListScreen, PullListScreen, PullDiffScreen, + CommitScreen, + CommitListScreen, ReadMeScreen, } from 'repository'; @@ -164,6 +166,18 @@ const sharedRoutes = { title: navigation.state.params.title, }), }, + CommitList: { + screen: CommitListScreen, + navigationOptions: ({ navigation }) => ({ + title: navigation.state.params.title, + }), + }, + Commit: { + screen: CommitScreen, + navigationOptions: ({ navigation }) => ({ + title: navigation.state.params.title, + }), + }, EditIssueComment: { screen: EditIssueCommentScreen, navigationOptions: ({ navigation }) => ({ diff --git a/src/auth/screens/events.screen.js b/src/auth/screens/events.screen.js index 20e20a2c5..2f35515c5 100644 --- a/src/auth/screens/events.screen.js +++ b/src/auth/screens/events.screen.js @@ -488,7 +488,7 @@ class Events extends Component { const actor = this.getActorLink(userEvent); const repo = this.getRepoLink(userEvent); const ref = ( - + this.navigateToCommitList(userEvent)}> {userEvent.payload.ref.replace('refs/heads/', '')} ); @@ -543,6 +543,21 @@ class Events extends Component { }); }; + navigateToCommitList = userEvent => { + if (userEvent.payload.commits > 1) { + this.props.navigation.navigate('CommitList', { + commits: userEvent.payload.commits, + title: t('Commits', this.props.locale), + locale: this.props.locale, + }); + } else { + this.props.navigation.navigate('Commit', { + commit: userEvent.payload.commits[0], + title: userEvent.payload.commits[0].sha.substring(0, 7), + }); + } + }; + navigateToIssue = userEvent => { this.props.navigation.navigate('Issue', { issue: diff --git a/src/components/commit-list-item.component.js b/src/components/commit-list-item.component.js new file mode 100644 index 000000000..545e53597 --- /dev/null +++ b/src/components/commit-list-item.component.js @@ -0,0 +1,57 @@ +import React from 'react'; +import { StyleSheet, TouchableHighlight, View } from 'react-native'; +import { ListItem } from 'react-native-elements'; +import { colors, fonts } from 'config'; + +type Props = { + commit: Object, + navigation: Object, +}; + +const styles = StyleSheet.create({ + container: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + paddingRight: 10, + paddingVertical: 5, + borderBottomWidth: 1, + borderBottomColor: colors.greyLight, + }, + listItemContainer: { + flex: 1, + borderBottomWidth: 0, + }, + title: { + color: colors.primaryDark, + ...fonts.fontPrimary, + }, +}); + +export const CommitListItem = ({ commit, navigation }: Props) => + + navigation.navigate('Commit', { + commit, + })} + underlayColor={colors.greyLight} + > + + + + ; diff --git a/src/components/index.js b/src/components/index.js index e2eba48cc..e7f49fe46 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -4,6 +4,7 @@ export * from './code-line.component'; export * from './error-screen'; export * from './comment-input.component'; export * from './comment-list-item.component'; +export * from './commit-list-item.component'; export * from './diff-blocks.component'; export * from './entity-info.component'; export * from './issue-description.component'; diff --git a/src/components/issue-description.component.js b/src/components/issue-description.component.js index bb8c223a0..7fbe57629 100644 --- a/src/components/issue-description.component.js +++ b/src/components/issue-description.component.js @@ -1,6 +1,11 @@ import React, { Component } from 'react'; -import { ActivityIndicator } from 'react-native'; +import { + Text, + ActivityIndicator, + TouchableHighlight, +} from 'react-native'; import { ListItem } from 'react-native-elements'; + import Parse from 'parse-diff'; import styled from 'styled-components'; @@ -56,8 +61,9 @@ const IssueTitle = styled(ListItem).attrs({ const DiffBlocksContainer = styled.View` flex-direction: row; - align-items: center; - justify-content: flex-end; + align-items: stretch; + justify-content: space-between; + padding-left: 10; padding-right: 10; padding-bottom: 10; `; @@ -85,9 +91,11 @@ export class IssueDescription extends Component { issue: Object, repository: Object, diff: string, + commits: Array, isMergeable: boolean, isMerged: boolean, isPendingDiff: boolean, + isPendingCommit: boolean, isPendingCheckMerge: boolean, onRepositoryPress: Function, userHasPushPermission: boolean, @@ -95,6 +103,23 @@ export class IssueDescription extends Component { navigation: Object, }; + navigateToCommitList = () => { + const { commits, locale } = this.props; + + if (commits.length > 1) { + this.props.navigation.navigate('CommitList', { + title: t('Commits', locale), + commits, + locale, + }); + } else { + this.props.navigation.navigate('Commit', { + commit: commits[0], + title: commits[0].sha.substring(0, 7), + }); + } + }; + renderLabelButtons = labels => { return labels .slice(0, 3) @@ -105,10 +130,12 @@ export class IssueDescription extends Component { const { diff, issue, + commits, repository, isMergeable, isMerged, isPendingDiff, + isPendingCommit, isPendingCheckMerge, onRepositoryPress, userHasPushPermission, @@ -168,10 +195,23 @@ export class IssueDescription extends Component { {issue.pull_request && ( + {isPendingCommit && ( + + )} + {isPendingDiff && ( )} + {!isPendingCommit && ( + this.navigateToCommitList()} + underlayColor={colors.greyLight} + > + {`${commits.length} commits`} + + )} + {!isPendingDiff && (lineAdditions !== 0 || lineDeletions !== 0) && ( { }; }; +export const getCommits = url => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + + dispatch({ type: GET_ISSUE_COMMITS.PENDING }); + + return v3 + .getJson(url, accessToken) + .then(data => { + dispatch({ + type: GET_ISSUE_COMMITS.SUCCESS, + payload: data, + }); + }) + .catch(error => { + dispatch({ + type: GET_ISSUE_COMMITS.ERROR, + payload: error, + }); + }); + }; +}; + export const postIssueComment = (body, owner, repoName, issueNum) => { return (dispatch, getState) => { const accessToken = getState().auth.accessToken; diff --git a/src/issue/issue.reducer.js b/src/issue/issue.reducer.js index 69869e637..a67af8353 100644 --- a/src/issue/issue.reducer.js +++ b/src/issue/issue.reducer.js @@ -7,6 +7,7 @@ import { EDIT_ISSUE_BODY, CHANGE_LOCK_STATUS, GET_ISSUE_DIFF, + GET_ISSUE_COMMITS, GET_ISSUE_MERGE_STATUS, GET_PULL_REQUEST_FROM_URL, MERGE_PULL_REQUEST, @@ -21,6 +22,7 @@ export const initialState = { events: [], pr: {}, diff: '', + commits: [], isMerged: false, isPendingComments: false, isPendingEvents: false, @@ -30,6 +32,7 @@ export const initialState = { isEditingIssue: false, isChangingLockStatus: false, isPendingDiff: false, + isPendingCommits: false, isPendingCheckMerge: false, isPendingMerging: false, isPendingIssue: false, @@ -210,6 +213,24 @@ export const issueReducer = (state = initialState, action = {}) => { error: action.payload, isPendingDiff: false, }; + case GET_ISSUE_COMMITS.PENDING: + return { + ...state, + commits: [], + isPendingCommits: true, + }; + case GET_ISSUE_COMMITS.SUCCESS: + return { + ...state, + commits: action.payload, + isPendingCommits: false, + }; + case GET_ISSUE_COMMITS.ERROR: + return { + ...state, + error: action.payload, + isPendingCommits: false, + }; case GET_ISSUE_MERGE_STATUS.PENDING: return { ...state, diff --git a/src/issue/issue.type.js b/src/issue/issue.type.js index ad22aab85..8b786c68d 100644 --- a/src/issue/issue.type.js +++ b/src/issue/issue.type.js @@ -8,6 +8,7 @@ export const EDIT_ISSUE = createActionSet('EDIT_ISSUE'); export const EDIT_ISSUE_BODY = createActionSet('EDIT_ISSUE_BODY'); export const CHANGE_LOCK_STATUS = createActionSet('CHANGE_LOCK_STATUS'); export const GET_ISSUE_DIFF = createActionSet('GET_ISSUE_DIFF'); +export const GET_ISSUE_COMMITS = createActionSet('GET_ISSUE_COMMITS'); export const GET_ISSUE_MERGE_STATUS = createActionSet('GET_ISSUE_MERGE_STATUS'); export const GET_PULL_REQUEST_FROM_URL = createActionSet( 'GET_PULL_REQUEST_FROM_URL' diff --git a/src/issue/screens/issue.screen.js b/src/issue/screens/issue.screen.js index 2e4d4ab6a..014cd7de7 100644 --- a/src/issue/screens/issue.screen.js +++ b/src/issue/screens/issue.screen.js @@ -31,6 +31,7 @@ import { colors } from 'config'; import { getPullRequestDetails, postIssueComment, + getCommits, deleteIssueComment, } from '../issue.action'; @@ -89,6 +90,7 @@ const mapStateToProps = (state, ownProps) => { pr, diff, isMerged, + commits: state.issue.commits, isPendingDiff, isPendingCheckMerge, isPostingComment, @@ -101,6 +103,7 @@ const mapDispatchToProps = { getContributors: RestClient.repos.getContributors, getIssue: RestClient.repos.getIssue, getIssueTimeline: RestClient.repos.getIssueTimeline, + getCommits, getPullRequestDetails, postIssueComment, deleteIssueComment, @@ -162,7 +165,9 @@ class Issue extends Component { getIssueTimeline: Function, getPullRequestDetails: Function, postIssueComment: Function, + getCommits: Function, deleteIssueComment: Function, + commits: Array, issue: Object, timelineItemsPagination: Object, comments: Array, @@ -174,6 +179,7 @@ class Issue extends Component { repository: Object, contributors: Array, isPendingDiff: boolean, + isPendingCommits: boolean, isPendingCheckMerge: boolean, isDeletingComment: boolean, // isPostingComment: boolean, @@ -227,10 +233,15 @@ class Issue extends Component { getIssueTimeline, getRepo, getContributors, + getCommits, getPullRequestDetails, } = this.props; - const { issueRepository, issueNumber } = parseIssueNavigation(navigation); + const { issueURL, issueRepository, issueNumber } = parseIssueNavigation(navigation); + const pullRequestCommitsURL = `${issueURL.replace( + 'issues', + 'pulls' + )}/commits`; Promise.all([ getIssue(issueRepository, issueNumber), @@ -242,7 +253,10 @@ class Issue extends Component { const issue = this.props.issue; if (issue.pull_request) { - return getPullRequestDetails(issue); + return Promise.all([ + getPullRequestDetails(issue), + getCommits(pullRequestCommitsURL), + ]); } return Promise.resolve(); @@ -316,8 +330,10 @@ class Issue extends Component { repository, pr, diff, + commits, isMerged, isPendingDiff, + isPendingCommits, isPendingCheckMerge, locale, navigation, @@ -328,9 +344,11 @@ class Issue extends Component { issue={issue} repository={repository} diff={diff} + commits={commits} isMergeable={pr.mergeable} isMerged={isMerged} isPendingDiff={isPendingDiff} + isPendingCommits={isPendingCommits} isPendingCheckMerge={isPendingCheckMerge} onRepositoryPress={url => this.onRepositoryPress(url)} onLinkPress={node => this.onLinkPress(node)} diff --git a/src/locale/languages/ca.js b/src/locale/languages/ca.js index f19a81685..8f127d931 100644 --- a/src/locale/languages/ca.js +++ b/src/locale/languages/ca.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Estàs segur?', 'Assign Yourself': "Assigna't a tu mateix", Assignees: 'Assignats', + 'Author: ': '', BIO: 'BIOGRAFIA', CANCEL: 'CANCEL•LA', CONTACT: 'CONTACTE', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Accions de comentaris', 'Commit Message': 'Missatge del commit', 'Commit Title': 'Títol del commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': "Communica't en conversacions, fes merge de pull requests i més", Company: 'Companyia', @@ -88,10 +91,11 @@ module.exports = { 'New Issue': 'Nova issue', 'No README.md found': "No s'ha trobat cap README.md", 'No closed issues found!': "No s'ha trobat cap issue tancada!", + 'No commit found!': '', 'No contributors found': "No s'ha trobat cap contribuïdor", 'No description provided.': "No s'ha trobat cap descripció", 'No issues': 'No hi ha ninguna issue', - 'No members found': 'No s\'ha trobat cap membre', + 'No members found': "No s'ha trobat cap membre", 'No open issues': 'No hi ha ninguna issue oberta', 'No open issues found!': "No s'ha trobat cap issue oberta!", 'No open pull requests': 'No hi ha ninguna pull request oberta', @@ -158,6 +162,7 @@ module.exports = { Users: 'Usuaris', 'View All': 'Veure a tots', 'View Code': 'Veure el codi', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Veure i controlar totes les teves notifications sense llegir', Watch: 'Seguir', diff --git a/src/locale/languages/de.js b/src/locale/languages/de.js index 1983b0e86..5e1d5304a 100644 --- a/src/locale/languages/de.js +++ b/src/locale/languages/de.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Bist du dir sicher?', 'Assign Yourself': 'Selbst zuweisen', Assignees: 'Zuständige', + 'Author: ': '', BIO: 'BIO', CANCEL: 'ABBRECHEN', CONTACT: 'KONTAKT', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Kommentar Aktionen', 'Commit Message': 'Commit Nachricht', 'Commit Title': 'Commit Titel', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Unterhalte dich in Konversationen, merge Pull Requests und vieles mehr', Company: 'Firma', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Neues Issue', 'No README.md found': 'Keine README.md-Datei gefunden.', 'No closed issues found!': 'Keine geschlossenen Issues gefunden!', + 'No commit found!': '', 'No contributors found': 'Keine Beitragenden gefunden', 'No description provided.': 'Keine Beschreibung verfügbar.', 'No issues': 'Keine Issues', @@ -158,6 +162,7 @@ module.exports = { Users: 'Benutzern', 'View All': 'Alle anzeigen', 'View Code': 'Quellcode ansehen', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Lese und verwalte alle deine Benachrichtigungen', Watch: 'Watch', diff --git a/src/locale/languages/en.js b/src/locale/languages/en.js index 37b0b61af..ea5887c09 100644 --- a/src/locale/languages/en.js +++ b/src/locale/languages/en.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Are you sure?', 'Assign Yourself': 'Assign Yourself', Assignees: 'Assignees', + 'Author: ': 'Author: ', BIO: 'BIO', CANCEL: 'CANCEL', CONTACT: 'CONTACT', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Comment Actions', 'Commit Message': 'Commit Message', 'Commit Title': 'Commit Title', + Commits: 'Commits', + 'Committer: ': 'Committer: ', 'Communicate on conversations, merge pull requests and more': 'Communicate on conversations, merge pull requests and more', Company: 'Company', @@ -87,6 +90,7 @@ module.exports = { 'New Issue': 'New Issue', 'No README.md found': 'No README.md found', 'No closed issues found!': 'No closed issues found!', + 'No commit found!': 'No commit found!', 'No contributors found': 'No contributors found', 'No description provided.': 'No description provided.', 'No issues': 'No issues', @@ -157,6 +161,7 @@ module.exports = { Users: 'Users', 'View All': 'View All', 'View Code': 'View Code', + 'View Commits': 'View Commits', 'View and control all of your unread and participating notifications': 'View and control all of your unread and participating notifications', Watch: 'Watch', diff --git a/src/locale/languages/eo.js b/src/locale/languages/eo.js index 360fd13ce..6b07598a8 100644 --- a/src/locale/languages/eo.js +++ b/src/locale/languages/eo.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Ĉu vi certas?', 'Assign Yourself': 'asigni vin mem', Assignees: 'Apartaĵoj', + 'Author: ': '', BIO: 'BIO', CANCEL: 'CANCELO', CONTACT: 'KONTAKTU', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Komentoj Agoj', 'Commit Message': 'Komitato Mesaĝo', 'Commit Title': 'Komerca Titolo', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Komuniki sur konversacioj, kunfandi tiri petojn kaj pli', Company: 'Kompanio', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': '', 'No README.md found': '', 'No closed issues found!': 'Neniu fermita afero trovita!', + 'No commit found!': '', 'No contributors found': 'Neniu kontribuantoj trovita', 'No description provided.': 'Neniu priskribo provizita.', 'No issues': 'Neniu afero', @@ -157,6 +161,7 @@ module.exports = { Users: 'Uzantoj', 'View All': 'Rigardi Ĉiuj', 'View Code': 'Vidi Kodon', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Vidi kaj kontroli ĉiujn viajn nelegitajn kaj partoprenajn sciigojn', Watch: 'Vidi', diff --git a/src/locale/languages/es.js b/src/locale/languages/es.js index ef7cba1c6..bb19301d6 100644 --- a/src/locale/languages/es.js +++ b/src/locale/languages/es.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': '¿Estás seguro?', 'Assign Yourself': 'Asígnate a ti mismo', Assignees: 'Asignados', + 'Author: ': '', BIO: 'BIO', CANCEL: 'CANCELAR', CONTACT: 'CONTACTO', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Acciones de comentarios', 'Commit Message': 'Mensaje del commit', 'Commit Title': 'Título del commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Comunícate en conversaciones, haz merges de pull requests y más', Company: 'Compañía', @@ -87,6 +90,7 @@ module.exports = { 'New Issue': 'Nueva issue', 'No README.md found': 'No se ha encontrado README.md', 'No closed issues found!': '¡No se encontraron issues cerradas!', + 'No commit found!': '', 'No contributors found': 'No se encontraron contribuidores', 'No description provided.': 'No se ha proporcionado ninguna descripción.', 'No issues': 'No hay issues', @@ -157,6 +161,7 @@ module.exports = { Users: 'Usuarios', 'View All': 'Ver todo', 'View Code': 'Ver código', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Revisa y gestiona tus notificaciones pendientes', Watch: 'Seguir', diff --git a/src/locale/languages/eu.js b/src/locale/languages/eu.js index d467b0307..7a7a78ebd 100644 --- a/src/locale/languages/eu.js +++ b/src/locale/languages/eu.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Ziur zaude?', 'Assign Yourself': 'Zuri egokitu', Assignees: 'lagapen', + 'Author: ': '', BIO: 'BIO', CANCEL: 'EZEZTATU', CONTACT: 'KONTAKTUA', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Mezuen ekintzak', 'Commit Message': 'Commit mezua', 'Commit Title': 'Commit izenburua', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Elkarrizketetan komunikatu, merge-en pull requests egin eta aber', Company: 'Erakundea', @@ -89,6 +92,7 @@ module.exports = { 'New Issue': 'Issue berria', 'No README.md found': 'Ez da README.md aurkitu', 'No closed issues found!': 'Ez dira aurkitu issues itxita!', + 'No commit found!': '', 'No contributors found': 'Laguntzailerik ez da aurkitu', 'No description provided.': 'Ez dago deskribapena.', 'No issues': 'Ez daude issues', @@ -159,6 +163,7 @@ module.exports = { Users: 'Erabiltzaileak', 'View All': 'Dena ikusi', 'View Code': 'Kodea ikusi', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Zain dauden jakinarazpenak berrikusten eta kudeatzen ditu', Watch: 'Bistaratu', diff --git a/src/locale/languages/fr.js b/src/locale/languages/fr.js index 8ffdd6303..2e6a4be59 100644 --- a/src/locale/languages/fr.js +++ b/src/locale/languages/fr.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Êtes-vous certain ?', 'Assign Yourself': "S'assigner", Assignees: 'Assignés', + 'Author: ': '', BIO: 'BIO', CANCEL: 'ANNULER', CONTACT: 'CONTACT', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Actions sur le commentaire', 'Commit Message': 'Message de commit', 'Commit Title': 'Titre de commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Communiquez dans les conversations, fusionnez les pull requests et plus', Company: 'Société', @@ -89,6 +92,7 @@ module.exports = { 'New Issue': 'Nouveau ticket', 'No README.md found': 'Pas de README.md trouvé', 'No closed issues found!': 'Aucun ticket fermé trouvé !', + 'No commit found!': '', 'No contributors found': 'Aucun contributeur trouvé', 'No description provided.': 'Aucune description fournie.', 'No issues': 'Aucun ticket', @@ -159,6 +163,7 @@ module.exports = { Users: 'Utilisateurs', 'View All': 'Voir tous', 'View Code': 'Voir le code', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Voir et contrôler toutes vos notifications de participations non lues', Watch: 'Surveiller', diff --git a/src/locale/languages/gl.js b/src/locale/languages/gl.js index 9e677873c..5e3e862ac 100644 --- a/src/locale/languages/gl.js +++ b/src/locale/languages/gl.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Estás seguro?', 'Assign Yourself': 'Asígnate a ti mesmo', Assignees: 'Asignada a', + 'Author: ': '', BIO: 'BIO', CANCEL: 'CANCELAR', CONTACT: 'CONTACTO', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Accións de comentario', 'Commit Message': 'Menasaxe do commit', 'Commit Title': 'Título do commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Comunícate en conversas, efectúa merge de pull requests e moito máis', Company: 'Empresa', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Novo Issue', 'No README.md found': 'Non se atopou o README.md', 'No closed issues found!': 'Non se atoparon issues fechados!', + 'No commit found!': '', 'No contributors found': 'No se atopou ningún contribuidor', 'No description provided.': 'Non hai unha description fornecida.', 'No issues': 'Ningún issue', @@ -157,6 +161,7 @@ module.exports = { Users: 'Usuarios', 'View All': 'Velos todos', 'View Code': 'Ver Código', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Ver e controlar tódalas túas notificacións de participacións e sen ler', Watch: 'Vixiar', diff --git a/src/locale/languages/nl.js b/src/locale/languages/nl.js index ae3ae86d8..3b646a25d 100644 --- a/src/locale/languages/nl.js +++ b/src/locale/languages/nl.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Weet u het zeker?', 'Assign Yourself': 'Assign jezelf', Assignees: 'Assignees', + 'Author: ': '', BIO: 'BIO', CANCEL: 'ANNULEER', CONTACT: 'CONTACT', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Acties voor commentaar', 'Commit Message': 'Commit samenvatting', 'Commit Title': 'Commit Title', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Neem deel aan conversaties, merge pull requests en meer', Company: 'Bedrijf', @@ -87,6 +90,7 @@ module.exports = { 'New Issue': 'Nieuw Issue', 'No README.md found': 'Geen README.md gevonden', 'No closed issues found!': 'Geen gesloten issues!', + 'No commit found!': '', 'No contributors found': 'Geen medewerkers', 'No description provided.': 'Niet voorzien van een beschrijving.', 'No issues': 'Geen issues', @@ -156,6 +160,7 @@ module.exports = { Users: 'Gebruikers', 'View All': 'Bekijk Alles', 'View Code': 'Bekijk Code', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Bekijk en beheer al uw ongelezen en deelnemende notificaties', Watch: 'Bekijken', diff --git a/src/locale/languages/ph.js b/src/locale/languages/ph.js index 839e4fff4..be0f44210 100644 --- a/src/locale/languages/ph.js +++ b/src/locale/languages/ph.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Ituloy?', 'Assign Yourself': 'I-assign ang iyong sarili', Assignees: 'Mga in-assign', + 'Author: ': '', BIO: 'BIO', CANCEL: 'KANSELAHIN', CONTACT: 'CONTACT', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Mga aksyon sa Komento', 'Commit Message': 'Mensahe ng Commit', 'Commit Title': 'Titulo ng Commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Makihalubilo sa mga usapin, pag-merge ng mga pull request, atbp.', Company: 'Kumpanya', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Bagong Isyu', 'No README.md found': 'Walang README.md na nahanap', 'No closed issues found!': 'Walang nahanap na mga saradong isyu!', + 'No commit found!': '', 'No contributors found': 'Walang nahanap na kontribyutor', 'No description provided.': 'Walang deskripsyong naibigay', 'No issues': 'Walang mga isyu', @@ -159,6 +163,7 @@ module.exports = { Users: 'Mga User', 'View All': 'Tignan Lahat', 'View Code': 'Tignan ang Code', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Tignan at kontrolin ang lahat ng inyong mga notipikasyon para sa mga nabasa at pinaglalahukan', Watch: 'Panuorin', diff --git a/src/locale/languages/pl.js b/src/locale/languages/pl.js index e86ca49f4..6ad8fa54b 100644 --- a/src/locale/languages/pl.js +++ b/src/locale/languages/pl.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Czy na pewno?', 'Assign Yourself': 'Przypisz Siebie', Assignees: 'Przypisany', + 'Author: ': '', BIO: 'BIO', CANCEL: 'ANULUJ', CONTACT: 'KONTAKT', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Dodaj komentarz akcji', 'Commit Message': 'Treść komitu', 'Commit Title': 'Tytuł Komitu', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Powiadom o konwersjacji, zmergowanym pull requeście i więcej', Company: 'Firma', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Nowy Problem', 'No README.md found': 'Brak README.md', 'No closed issues found!': 'Brak zamkniętych problemów!', + 'No commit found!': '', 'No contributors found': 'Brak kontrybutorów', 'No description provided.': 'Brak opisu.', 'No issues': 'Brak problemów', @@ -157,6 +161,7 @@ module.exports = { Users: 'Użytkownicy', 'View All': 'Zobacz Wszystko', 'View Code': 'Zobacz Kod', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Przeglądanie i kontrola wszystkich nieprzeczytanych notifykacji i konwersjacji', Watch: 'Obserwuj', diff --git a/src/locale/languages/pt.js b/src/locale/languages/pt.js index 42133e215..a7dc843c5 100644 --- a/src/locale/languages/pt.js +++ b/src/locale/languages/pt.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Tem a certeza?', 'Assign Yourself': 'Atribua a você', Assignees: 'Atribuída a', + 'Author: ': '', BIO: 'BIOGRAFIA', CANCEL: 'CANCELAR', CONTACT: 'CONTATO', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Ações do comentário', 'Commit Message': 'Mensagem do Commit', 'Commit Title': 'Título do Commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Comunicar problemas/sugestões, merge pull requests, etc', Company: 'Empresa', @@ -89,6 +92,7 @@ module.exports = { 'New Issue': 'Nova Issue', 'No README.md found': 'Não foi encontrado nenhum ficheiro README.md', 'No closed issues found!': 'Nenhuma issue fechada encontrada!', + 'No commit found!': '', 'No contributors found': 'Nenhum contribuidor encontrado', 'No description provided.': 'Nenhuma descrição fornecida.', 'No issues': 'Nenhuma issue', @@ -158,6 +162,7 @@ module.exports = { Users: 'Utilizadores', 'View All': 'Ver Todos', 'View Code': 'Ver Código', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Ver e controlar todas as suas notificações', Watch: 'Acompanhar', diff --git a/src/locale/languages/ptBr.js b/src/locale/languages/ptBr.js index 4f5db61e5..71054de75 100644 --- a/src/locale/languages/ptBr.js +++ b/src/locale/languages/ptBr.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Tem certeza?', 'Assign Yourself': 'Atribua a você', Assignees: 'Atribuída a', + 'Author: ': '', BIO: 'BIO', CANCEL: 'CANCELAR', CONTACT: 'CONTATO', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Ações do comentário', 'Commit Message': 'Mensagem do Commit', 'Commit Title': 'Título do Commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Comunicar-se em conversas, merge pull requests e mais', Company: 'Empresa', @@ -89,6 +92,7 @@ module.exports = { 'New Issue': 'Nova Issue', 'No README.md found': 'Nenhum README.md foi encontrado', 'No closed issues found!': 'Nenhuma issue fechada encontrada!', + 'No commit found!': '', 'No contributors found': 'Nenhum contribuidor encontrado', 'No description provided.': 'Nenhuma descrição fornecida.', 'No issues': 'Nenhuma issue', @@ -158,6 +162,7 @@ module.exports = { Users: 'Usuários', 'View All': 'Ver Todos', 'View Code': 'Ver Código', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Ver e controlar todas as suas notificações', Watch: 'Acompanhar', diff --git a/src/locale/languages/ru.js b/src/locale/languages/ru.js index 3b5655969..45559ad6b 100644 --- a/src/locale/languages/ru.js +++ b/src/locale/languages/ru.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Вы уверены?', 'Assign Yourself': 'Назначить на самого себя', Assignees: 'Ответственные', + 'Author: ': '', BIO: 'СПРАВКА', CANCEL: 'ОТМЕНА', CONTACT: 'КОНТАКТЫ', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Действия с комментарием', 'Commit Message': 'Текст сообщения коммита', 'Commit Title': 'Заголовок коммита', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Общайтесь, принимайте пулреквесты и делайте многое другое', Company: 'Компания', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Новая ишью', 'No README.md found': 'He yдалось найти README.md', 'No closed issues found!': 'Не найдено закрытых ишью!', + 'No commit found!': '', 'No contributors found': 'Участники не найдены', 'No description provided.': 'Нет описания.', 'No issues': 'Нет ишью', @@ -158,6 +162,7 @@ module.exports = { Users: 'Пользователи', 'View All': 'Смотреть все', 'View Code': 'Смотреть код', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Просматривайте и управляйте всеми вашими непрочитанными и активными уведомлениями', Watch: 'Следить', diff --git a/src/locale/languages/sr.js b/src/locale/languages/sr.js index 7b8fd2d77..363f2044d 100644 --- a/src/locale/languages/sr.js +++ b/src/locale/languages/sr.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Да ли сте сигурни?', 'Assign Yourself': 'Додели себи', Assignees: 'Заступник', + 'Author: ': '', BIO: 'БИОГРАФИЈА', CANCEL: 'ОДУСТАНИ', CONTACT: 'КОНТАКТИ', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Акције на коментарима', 'Commit Message': 'Порука измене', 'Commit Title': 'Наслов измене', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Дискутујте, прихватите захтеве за преузимање и друго', Company: 'Фирма', @@ -87,6 +90,7 @@ module.exports = { 'New Issue': 'Нови поднесак', 'No README.md found': 'Датотека README.md није пронађена', 'No closed issues found!': 'Нема затворених поднесака!', + 'No commit found!': '', 'No contributors found': 'Нема сарадника', 'No description provided.': 'Није достављен опис.', 'No issues': 'Без поднесака', @@ -157,6 +161,7 @@ module.exports = { Users: 'Корисници', 'View All': 'Прегледај све', 'View Code': 'Прегледај код', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Преглед и контрола свих ваших непрочитаних и активних обавештења', Watch: 'Прати', diff --git a/src/locale/languages/sv.js b/src/locale/languages/sv.js index e36e2e0cb..60c4f5e99 100644 --- a/src/locale/languages/sv.js +++ b/src/locale/languages/sv.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Är du säker?', 'Assign Yourself': 'Tilldela till dig själv', Assignees: 'Tilldelare', + 'Author: ': '', BIO: 'BIOGRAFI', CANCEL: 'AVBRYT', CONTACT: 'KONTAKT', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Kommentera Handlingar', 'Commit Message': 'Commit-meddelande', 'Commit Title': 'Commit-titel', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Delta i konversationer, merge:a pull requests och mer', Company: 'Företag', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Nytt Issue', 'No README.md found': 'Hittade ingen README.md', 'No closed issues found!': 'Inga stängda issues hittades!', + 'No commit found!': '', 'No contributors found': 'Inga contributors hittades', 'No description provided.': 'Ingen beskrivning.', 'No issues': 'Inga issues', @@ -158,6 +162,7 @@ module.exports = { Users: 'Användare', 'View All': 'Se Alla', 'View Code': 'Visa kod', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Se och hantera alla dina olästa och medverkande notifikationer', Watch: 'Bevaka', diff --git a/src/locale/languages/th.js b/src/locale/languages/th.js index 9e4cba7ae..8346ef4b6 100644 --- a/src/locale/languages/th.js +++ b/src/locale/languages/th.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'คุณแน่ใจไหม?', 'Assign Yourself': 'หมอบหมายให้ตัวเอง', Assignees: 'ผู้ได้รับการมอบหมาย', + 'Author: ': '', BIO: 'ประวัติ', CANCEL: 'ยกเลิก', CONTACT: 'ติดต่อ', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'การปฏิบัติการของความเห็น', 'Commit Message': 'ข้อความ  commit', 'Commit Title': 'หัวข้อ commit', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'สื่อสารพูดคุยทั่วไป เกี่ยวกับ merge pull requests และอีกมากมาย', Company: 'บริษัท', @@ -88,6 +91,7 @@ module.exports = { 'New Issue': 'Issue  ใหม่', 'No README.md found': 'ไม่เจอ README.md', 'No closed issues found!': 'ไม่เจอ issues ที่ถูกปิด', + 'No commit found!': '', 'No contributors found': 'ไม่เจอผู้มีส่วนร่วม', 'No description provided.': 'ไม่มีการเขียนการบรรยายไว้', 'No issues': 'ไม่มี issues', @@ -158,6 +162,7 @@ module.exports = { Users: 'ผู้ใช้', 'View All': 'ดูทั้งหมด', 'View Code': 'ดูโค้ด', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'ติดตามและควบคุมการแจ้งเตือนที่ยังไม่ได้อ่านของคุณ', Watch: 'ติดตาม', diff --git a/src/locale/languages/tr.js b/src/locale/languages/tr.js index ce8ada4f9..e506aeb6f 100644 --- a/src/locale/languages/tr.js +++ b/src/locale/languages/tr.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Emin misiniz?', 'Assign Yourself': 'Kendini Ata', Assignees: 'Atananlar', + 'Author: ': '', BIO: 'Biyografi', CANCEL: 'İPTAL', CONTACT: 'İLETİŞİM', @@ -33,6 +34,8 @@ module.exports = { 'Comment Actions': 'Yorum Hareketleri', 'Commit Message': 'Commit Mesajı', 'Commit Title': 'Commit Başlığı', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': "Sohbet ederek iletişim kurun, pull request'leri merge edin ve daha fazlası", Company: 'Şirket', @@ -89,6 +92,7 @@ module.exports = { 'New Issue': 'Yeni Issue', 'No README.md found': 'README.md bulunamadı', 'No closed issues found!': 'Kapalı issue bulunamadı!', + 'No commit found!': '', 'No contributors found': 'katkıda bulunan bulunamadı', 'No description provided.': 'Açıklama yapılmadı.', 'No issues': 'issue yok', @@ -158,6 +162,7 @@ module.exports = { Users: 'Kullanıcılar', 'View All': 'Tümünü Göster', 'View Code': 'View Code', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Okunmamış ve katılımcı olduğunuz bildirimlerinizin tümünü görüntüleyin ve kontrol edin', Watch: 'İzle', diff --git a/src/locale/languages/uk.js b/src/locale/languages/uk.js index 855f5fa3a..099876a92 100644 --- a/src/locale/languages/uk.js +++ b/src/locale/languages/uk.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': 'Ви впевнені?', 'Assign Yourself': 'Призначити самому собі', Assignees: 'Відповідальні', + 'Author: ': '', BIO: 'ДОВІДКА', CANCEL: 'ВІДМІНИТИ', CONTACT: 'КОНТАКТИ', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': 'Дії З Коментарем', 'Commit Message': 'Текст повідомленя коміту', 'Commit Title': 'Заголовок коміту', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': 'Спілкуйтесь, приймайте pull-запити і робіть багато іншого', Company: 'Компанія', @@ -87,6 +90,7 @@ module.exports = { 'New Issue': 'Нова задача', 'No README.md found': 'He вдалось знайти README.md', 'No closed issues found!': 'Не знайдено закритих задач!', + 'No commit found!': '', 'No contributors found': 'Учасники не знайдені', 'No description provided.': 'Немає опису.', 'No issues': 'Немає задач', @@ -156,6 +160,7 @@ module.exports = { Users: 'Користувачі', 'View All': 'Дивитись все', 'View Code': 'Дивитись код', + 'View Commits': '', 'View and control all of your unread and participating notifications': 'Переглядайте і керуйте всіма вашими непрочитаними і активними сповіщеннями', Watch: 'Спостерігати', diff --git a/src/locale/languages/zhCn.js b/src/locale/languages/zhCn.js index 40c45a729..8b948c446 100644 --- a/src/locale/languages/zhCn.js +++ b/src/locale/languages/zhCn.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': '你确定吗?', 'Assign Yourself': '分派给自己', Assignees: '被分派者', + 'Author: ': '', BIO: '简介', CANCEL: '取消', CONTACT: '联系方式', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': '评论操作', 'Commit Message': '提交说明', 'Commit Title': '提交标题', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': '查看问题、参与讨论以及处理合并请求', Company: '公司', @@ -86,6 +89,7 @@ module.exports = { 'New Issue': '新建问题', 'No README.md found': '未找到README.md', 'No closed issues found!': '没有已关闭的问题!', + 'No commit found!': '', 'No contributors found': '没有贡献者', 'No description provided.': '没有提供简介', 'No issues': '没有问题', @@ -156,6 +160,7 @@ module.exports = { Users: '搜用户', 'View All': '查看全部', 'View Code': '查看代码', + 'View Commits': '', 'View and control all of your unread and participating notifications': '查看并设定你所有未读和参与的通知', Watch: '关注', diff --git a/src/locale/languages/zhTw.js b/src/locale/languages/zhTw.js index e527beb39..7602689da 100644 --- a/src/locale/languages/zhTw.js +++ b/src/locale/languages/zhTw.js @@ -14,6 +14,7 @@ module.exports = { 'Are you sure?': '您確定嗎?', 'Assign Yourself': '指派給自己', Assignees: '被指派者', + 'Author: ': '', BIO: '簡介', CANCEL: '取消', CONTACT: '聯絡方式', @@ -32,6 +33,8 @@ module.exports = { 'Comment Actions': '評論操作', 'Commit Message': '提交說明', 'Commit Title': '提交標題', + Commits: '', + 'Committer: ': '', 'Communicate on conversations, merge pull requests and more': '參與議題討論、合併請求', Company: '公司', @@ -86,6 +89,7 @@ module.exports = { 'New Issue': '新增議題', 'No README.md found': '找不到 README.md', 'No closed issues found!': '沒有已關閉的議題!', + 'No commit found!': '', 'No contributors found': '沒有貢獻者', 'No description provided.': '沒有提供描述', 'No issues': '沒有議題', @@ -155,6 +159,7 @@ module.exports = { Users: '使用者', 'View All': '查看全部', 'View Code': '查看程式碼', + 'View Commits': '', 'View and control all of your unread and participating notifications': '檢視並設定所有未讀與參與的通知', Watch: '關注', diff --git a/src/repository/repository.action.js b/src/repository/repository.action.js index 024bb78fa..d6694f374 100644 --- a/src/repository/repository.action.js +++ b/src/repository/repository.action.js @@ -1,10 +1,13 @@ -import { fetchReadMe, fetchSearch, v3 } from 'api'; +import { fetchDiff, fetchReadMe, fetchSearch, v3 } from 'api'; import { GET_REPOSITORY, GET_REPOSITORY_CONTRIBUTORS, GET_REPOSITORY_CONTENTS, GET_REPOSITORY_FILE, GET_REPOSITORY_ISSUES, + GET_REPOSITORY_COMMITS, + GET_COMMIT, + GET_COMMIT_DIFF, GET_REPOSITORY_README, GET_REPOSITORY_LABELS, SEARCH_OPEN_ISSUES, @@ -136,6 +139,83 @@ export const getIssues = url => { }; }; +export const getCommits = url => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + + dispatch({ type: GET_REPOSITORY_COMMITS.PENDING }); + + v3 + .getJson(url, accessToken) + .then(data => { + dispatch({ + type: GET_REPOSITORY_COMMITS.SUCCESS, + payload: data, + }); + }) + .catch(error => { + dispatch({ + type: GET_REPOSITORY_COMMITS.ERROR, + payload: error, + }); + }); + }; +}; + +export const getCommitFromUrl = url => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + + dispatch({ type: GET_COMMIT.PENDING }); + + v3 + .getJson(url, accessToken) + .then(data => { + dispatch({ + type: GET_COMMIT.SUCCESS, + payload: data, + }); + }) + .catch(error => { + dispatch({ + type: GET_COMMIT.ERROR, + payload: error, + }); + }); + }; +}; + +export const getCommitDiffFromUrl = url => { + return (dispatch, getState) => { + const accessToken = getState().auth.accessToken; + + dispatch({ type: GET_COMMIT_DIFF.PENDING }); + + fetchDiff(url, accessToken) + .then(data => { + dispatch({ + type: GET_COMMIT_DIFF.SUCCESS, + payload: data, + }); + }) + .catch(error => { + dispatch({ + type: GET_COMMIT_DIFF.ERROR, + payload: error, + }); + }); + }; +}; + +export const getCommitDetails = commit => { + return dispatch => { + const url = commit.url || commit.commit.url; + + dispatch(getCommitFromUrl(url)); + dispatch(getCommitDiffFromUrl(url)); + }; +}; + export const getReadMe = (user, repository) => { return (dispatch, getState) => { const accessToken = getState().auth.accessToken; diff --git a/src/repository/repository.reducer.js b/src/repository/repository.reducer.js index d307127a1..69d6ac939 100644 --- a/src/repository/repository.reducer.js +++ b/src/repository/repository.reducer.js @@ -3,8 +3,11 @@ import { GET_REPOSITORY_CONTRIBUTORS, GET_REPOSITORY_CONTENTS, GET_REPOSITORY_FILE, + GET_REPOSITORY_COMMITS, GET_REPOSITORY_README, GET_REPOSITORY_LABELS, + GET_COMMIT, + GET_COMMIT_DIFF, SEARCH_OPEN_ISSUES, SEARCH_CLOSED_ISSUES, SEARCH_OPEN_PULLS, @@ -17,6 +20,9 @@ export const initialState = { labels: [], contents: {}, fileContent: '', + commits: [], + commit: {}, + diff: '', readMe: '', hasRepoExist: false, forked: false, @@ -28,6 +34,9 @@ export const initialState = { isPendingRepository: false, isPendingContributors: false, isPendingContents: false, + isPendingCommits: false, + isPendingCommit: false, + isPendingDiff: false, isPendingFile: false, isPendingReadMe: false, isPendingLabels: false, @@ -120,6 +129,24 @@ export const repositoryReducer = (state = initialState, action = {}) => { error: action.payload, isPendingFile: false, }; + case GET_REPOSITORY_COMMITS.PENDING: + return { + ...state, + commits: [], + isPendingCommits: true, + }; + case GET_REPOSITORY_COMMITS.SUCCESS: + return { + ...state, + commits: action.payload, + isPendingCommits: false, + }; + case GET_REPOSITORY_COMMITS.ERROR: + return { + ...state, + error: action.payload, + isPendingCommits: false, + }; case GET_REPOSITORY_README.PENDING: return { ...state, @@ -227,6 +254,41 @@ export const repositoryReducer = (state = initialState, action = {}) => { error: action.payload, isPendingSearchClosedPulls: false, }; + case GET_COMMIT.PENDING: + return { + ...state, + commit: {}, + isPendingCommit: true, + }; + case GET_COMMIT.SUCCESS: + return { + ...state, + commit: action.payload, + isPendingCommit: false, + }; + case GET_COMMIT.ERROR: + return { + ...state, + error: action.payload, + isPendingCommit: false, + }; + case GET_COMMIT_DIFF.PENDING: + return { + ...state, + isPendingDiff: true, + }; + case GET_COMMIT_DIFF.SUCCESS: + return { + ...state, + diff: action.payload, + isPendingDiff: false, + }; + case GET_COMMIT_DIFF.ERROR: + return { + ...state, + error: action.payload, + isPendingDiff: false, + }; default: return state; } diff --git a/src/repository/repository.type.js b/src/repository/repository.type.js index 0db8a4e8e..8c6238268 100644 --- a/src/repository/repository.type.js +++ b/src/repository/repository.type.js @@ -7,7 +7,10 @@ export const GET_REPOSITORY_CONTRIBUTORS = createActionSet( export const GET_REPOSITORY_CONTENTS = createActionSet( 'GET_REPOSITORY_CONTENTS' ); +export const GET_COMMIT = createActionSet('GET_COMMIT'); +export const GET_COMMIT_DIFF = createActionSet('GET_COMMIT_DIFF'); export const GET_REPOSITORY_FILE = createActionSet('GET_REPOSITORY_FILE'); +export const GET_REPOSITORY_COMMITS = createActionSet('GET_REPOSITORY_COMMITS'); export const GET_REPOSITORY_README = createActionSet('GET_REPOSITORY_README'); export const GET_REPOSITORY_LABELS = createActionSet('GET_REPOSITORY_LABELS'); export const SEARCH_OPEN_ISSUES = createActionSet('SEARCH_OPEN_ISSUES'); diff --git a/src/repository/screens/commit-list.screen.js b/src/repository/screens/commit-list.screen.js new file mode 100644 index 000000000..9432dfa80 --- /dev/null +++ b/src/repository/screens/commit-list.screen.js @@ -0,0 +1,55 @@ +import React, { Component } from 'react'; +import { FlatList, View, StyleSheet, Text } from 'react-native'; +import { ViewContainer, CommitListItem } from 'components'; +import { t } from 'utils'; +import { normalize } from 'config'; + +const styles = StyleSheet.create({ + marginSpacing: { + marginTop: 40, + }, + noCommit: { + fontSize: normalize(18), + textAlign: 'center', + }, +}); + +class CommitList extends Component { + props: { + locale: string, + navigation: Object, + }; + + keyExtractor = item => { + return item.id; + }; + + renderItem = ({ item }) => + ; + + render() { + const { locale, navigation } = this.props; + const commits = navigation.state.params.commits; + + return ( + + {commits.length > 0 && + } + + {commits.length === 0 && + + + {t('No commit found!', locale)} + + } + + ); + } +} + +export const CommitListScreen = CommitList; diff --git a/src/repository/screens/commit.screen.js b/src/repository/screens/commit.screen.js new file mode 100644 index 000000000..a94cc1619 --- /dev/null +++ b/src/repository/screens/commit.screen.js @@ -0,0 +1,312 @@ +/* eslint-disable react/no-array-index-key */ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { View, ScrollView, Text, FlatList, StyleSheet } from 'react-native'; +import { Card } from 'react-native-elements'; +import { + ViewContainer, + DiffBlocks, + CodeLine, + LoadingContainer, +} from 'components'; +import Parse from 'parse-diff'; +import { t } from 'utils'; +import { colors, fonts, normalize } from 'config'; +import styled from 'styled-components'; +import { getCommitDetails } from '../repository.action'; + +const mapStateToProps = state => ({ + locale: state.auth.locale, + commit: state.repository.commit, + diff: state.repository.diff, + isPendingCommit: state.repository.isPendingCommit, + isPendingDiff: state.repository.isPendingDiff, +}); + +const mapDispatchToProps = dispatch => ({ + getCommitDetailsByDispatch: commit => dispatch(getCommitDetails(commit)), +}); + +const styles = StyleSheet.create({ + fileChangeContainer: { + padding: 0, + marginTop: 12, + marginBottom: 12, + }, + fileTitleContainer: { + flexDirection: 'row', + paddingVertical: 15, + backgroundColor: colors.greyVeryLight, + }, + linesChanged: { + flex: 0.3, + paddingLeft: 10, + flexDirection: 'row', + alignItems: 'center', + }, + lineNumbersChanged: { + ...fonts.fontCode, + marginRight: 5, + }, + fileTitle: { + flex: 1, + marginLeft: 10, + }, + codeStyle: { + ...fonts.fontCode, + fontSize: normalize(10), + }, + dividerStyle: { + marginBottom: 0, + }, + noChangesMessage: { + ...fonts.fontPrimarySemiBold, + paddingVertical: 5, + paddingLeft: 10, + }, + newIndicator: { + ...fonts.fontPrimarySemiBold, + color: colors.green, + }, + deletedIndicator: { + ...fonts.fontPrimarySemiBold, + color: colors.red, + }, + headerContainer: { + paddingTop: 15, + paddingHorizontal: 25, + }, + header: { + flex: 1, + paddingTop: 10, + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + }, + headerItem: { + flex: 1, + }, + headerText: { + ...fonts.fontPrimary, + fontSize: normalize(14), + }, +}); +const FieldTitle = styled.Text` + color: ${colors.greyDark}; +`; +const ProfileLink = styled.Text` + color: ${colors.black}; + ${fonts.fontPrimarySemiBold}; +`; + +class Commit extends Component { + props: { + navigation: Object, + commit: Object, + diff: string, + isPendingCommit: boolean, + isPendingDiff: boolean, + getCommitDetailsByDispatch: Function, + locale: string, + }; + + componentDidMount() { + const { navigation, getCommitDetailsByDispatch } = this.props; + const commit = navigation.state.params.commit; + + getCommitDetailsByDispatch(commit); + } + + keyExtractor = (item, index) => { + return index; + }; + + navigateToProfile = user => { + this.props.navigation.navigate('Profile', { + user, + }); + }; + + renderHeader = () => { + const { commit, locale, isPendingCommit } = this.props; + const message = commit.commit ? commit.commit.message : 'Loading...'; + + if (isPendingCommit || !commit.files) { + return {message}; + } + + return ( + + + {message} + + {!!commit.author && ( + + + {t('Author: ', locale)} + this.navigateToProfile(commit.author)} + > + {commit.author.login} + + + + )} + {!!commit.committer && ( + + + {t('Committer: ', locale)} + this.navigateToProfile(commit.committer)} + > + {commit.committer.login} + + + + )} + + + {t('{numFilesChanged} files', locale, { + numFilesChanged: isPendingCommit ? 0 : commit.files.length, + })} + + + + + + ); + }; + + renderItem = ({ item }) => { + const { locale } = this.props; + const filename = item.deleted ? item.from : item.to; + const chunks = item.chunks.map((chunk, index) => { + return ( + + + + + {chunk.changes.map((change, changesIndex) => ( + + ))} + + + ); + }); + + return ( + + + + + {item.additions + item.deletions} + + + + + {item.new && ( + + + {t('NEW', locale)} + {'\n'} + + + {item.to} + + + )} + + {item.deleted && ( + + + {t('DELETED', locale)} + {'\n'} + + + {item.from} + + + )} + + {!item.new && + !item.deleted && ( + + {item.from === item.to + ? item.to + : `${item.from} \n → ${item.to}`} + + )} + + + {item.chunks.length > 0 && chunks} + + {item.chunks.length === 0 && + !item.new && + !item.deleted && + item.from !== item.to && ( + + {t('File renamed without any changes', locale)} + + )} + + ); + }; + + render() { + const { diff, isPendingCommit, isPendingDiff } = this.props; + const filesChanged = isPendingDiff || diff === {} ? [] : Parse(diff); + + return ( + + {(isPendingCommit || isPendingDiff) && ( + + )} + + {!isPendingCommit && + !isPendingDiff && ( + + )} + + ); + } +} + +export const CommitScreen = connect(mapStateToProps, mapDispatchToProps)( + Commit +); diff --git a/src/repository/screens/index.js b/src/repository/screens/index.js index 3f2da0103..55dd2c931 100644 --- a/src/repository/screens/index.js +++ b/src/repository/screens/index.js @@ -1,3 +1,5 @@ +export * from './commit.screen'; +export * from './commit-list.screen'; export * from './issue-list.screen'; export * from './pull-diff.screen'; export * from './pull-list.screen'; diff --git a/src/repository/screens/repository.screen.js b/src/repository/screens/repository.screen.js index 02021f50d..3ee415f4d 100644 --- a/src/repository/screens/repository.screen.js +++ b/src/repository/screens/repository.screen.js @@ -5,7 +5,7 @@ import styled from 'styled-components'; import { RefreshControl, Share, ActivityIndicator } from 'react-native'; import { ListItem } from 'react-native-elements'; import ActionSheet from 'react-native-actionsheet'; -import { RestClient } from 'api'; +import { v3, RestClient } from 'api'; import { ViewContainer, LoadingRepositoryProfile, @@ -21,6 +21,7 @@ import { } from 'components'; import { t, openURLInView, toOldIssueFormat, toOldUserFormat } from 'utils'; import { colors, fonts } from 'config'; +import { getCommits } from '../repository.action'; const mapStateToProps = (state, ownProps) => { const { @@ -44,6 +45,7 @@ const mapStateToProps = (state, ownProps) => { contributors, contributorsPagination, repository, + commits: state.repository.commits, repoId, locale, }; @@ -57,6 +59,7 @@ const mapDispatchToProps = { watchRepo: RestClient.activity.watchRepo, unwatchRepo: RestClient.activity.unwatchRepo, forkRepo: RestClient.repos.fork, + getCommits, }; const LoadingMembersContainer = styled.View` @@ -78,6 +81,7 @@ class Repository extends Component { props: { getRepoById: Function, getContributors: Function, + getCommits: Function, starRepo: Function, unstarRepo: Function, watchRepo: Function, @@ -86,6 +90,7 @@ class Repository extends Component { repository: Object, repoId: String, contributors: Array, + commits: Array, contributorsPagination: Object, navigation: Object, username: string, @@ -111,15 +116,7 @@ class Repository extends Component { } componentDidMount() { - const { repoId, getRepoById, getContributors } = this.props; - - getRepoById(repoId) - .then(() => { - getContributors(repoId); - }) - .catch(error => { - this.setState({ hasError: true, errorMessage: error }); - }); + this.fetchRepoInfo(); } showMenuActionSheet = () => { @@ -174,14 +171,20 @@ class Repository extends Component { fetchRepoInfo = () => { const { repoId } = this.props; + const repoCommitsURL = `${v3.root}/repos/${repoId}/commits`; this.setState({ refreshing: true }); Promise.all([ this.props.getRepoById(repoId), this.props.getContributors(repoId, { forceRefresh: true }), - ]).then(() => { - this.setState({ refreshing: false }); - }); + this.props.getCommits(repoCommitsURL), + ]) + .then(() => { + this.setState({ refreshing: false }); + }) + .catch(error => { + this.setState({ hasError: true, errorMessage: error }); + }); }; shareRepository = repository => { @@ -223,6 +226,7 @@ class Repository extends Component { repository, repoId, contributors, + commits, contributorsPagination, locale, navigation, @@ -387,6 +391,23 @@ class Repository extends Component { underlayColor={colors.greyLight} disabled={isPendingRepository} /> + {commits.length > 0 && ( + + this.props.navigation.navigate('CommitList', { + commits, + title: t('Commits', locale), + locale, + })} + underlayColor={colors.greyLight} + /> + )} )}