diff --git a/scm-ui/public/locales/de/repos.json b/scm-ui/public/locales/de/repos.json index 6e8a51a9f7..8350ecc581 100644 --- a/scm-ui/public/locales/de/repos.json +++ b/scm-ui/public/locales/de/repos.json @@ -44,6 +44,8 @@ "subtitle": "Erstellen eines neuen Repository" }, "branches": { + "errorTitle": "Fehler", + "errorSubtitle": "Unbekannter Branch Fehler", "overview": { "title": "Übersicht aller verfügbaren Branches", "createButton": "Branch erstellen" @@ -57,7 +59,10 @@ }, "branch": { "name": "Name", - "repository": "Repository" + "repository": "Repository", + "actions": "Aktionen", + "commits": "Commits", + "sources": "Sources" }, "changesets": { "errorTitle": "Fehler", diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index b1fbd76d95..fef882c90e 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -44,6 +44,8 @@ "subtitle": "Create a new repository" }, "branches": { + "errorTitle": "Error", + "errorSubtitle": "Unknown branch error", "overview": { "title": "Overview of all branches", "createButton": "Create Branch" @@ -57,7 +59,10 @@ }, "branch": { "name": "Name", - "repository": "Repository" + "repository": "Repository", + "actions": "Actions", + "commits": "Commits", + "sources": "Sources" }, "changesets": { "errorTitle": "Error", diff --git a/scm-ui/src/repos/branches/components/BranchButtonGroup.js b/scm-ui/src/repos/branches/components/BranchButtonGroup.js new file mode 100644 index 0000000000..2ed49d7b1f --- /dev/null +++ b/scm-ui/src/repos/branches/components/BranchButtonGroup.js @@ -0,0 +1,45 @@ +//@flow +import React from "react"; +import type { Repository, Branch } from "@scm-manager/ui-types"; +import { ButtonGroup, Button } from "@scm-manager/ui-components"; +import { translate } from "react-i18next"; + +type Props = { + repository: Repository, + branch: Branch, + + // context props + t: string => string +}; + +class BranchButtonGroup extends React.Component { + render() { + const { repository, branch, t } = this.props; + + const changesetLink = ""; + const sourcesLink = ""; + + return ( + + + + + ); + } +} + +export default translate("repos")(BranchButtonGroup); diff --git a/scm-ui/src/repos/branches/components/BranchDetailTable.js b/scm-ui/src/repos/branches/components/BranchDetailTable.js index 4577bbee72..15a8b6236e 100644 --- a/scm-ui/src/repos/branches/components/BranchDetailTable.js +++ b/scm-ui/src/repos/branches/components/BranchDetailTable.js @@ -2,6 +2,7 @@ import React from "react"; import type { Repository, Branch } from "@scm-manager/ui-types"; import { translate } from "react-i18next"; +import BranchButtonGroup from "./BranchButtonGroup"; type Props = { repository: Repository, @@ -26,6 +27,12 @@ class BranchDetailTable extends React.Component { {repository.name} + + + {t("branch.actions")} + + + ); diff --git a/scm-ui/src/repos/branches/containers/BranchView.js b/scm-ui/src/repos/branches/containers/BranchView.js index a225f0c7fb..459a532b4a 100644 --- a/scm-ui/src/repos/branches/containers/BranchView.js +++ b/scm-ui/src/repos/branches/containers/BranchView.js @@ -3,18 +3,54 @@ import React from "react"; import BranchDetailTable from "../components/BranchDetailTable"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; import type { Repository, Branch } from "@scm-manager/ui-types"; -import {connect} from "react-redux"; -import {translate} from "react-i18next"; -import {getBranch} from "../../modules/branches"; +import { connect } from "react-redux"; +import { translate } from "react-i18next"; +import { withRouter } from "react-router-dom"; +import { + fetchBranchByName, + getFetchBranchFailure, + isFetchBranchPending +} from "../../modules/branches"; +import { ErrorPage, Loading } from "@scm-manager/ui-components"; type Props = { repository: Repository, - branch: Branch // TODO: get branch from props + branchName: string, + loading: boolean, + error: Error, + branch: Branch, + + // dispatch functions + fetchBranchByName: (repository: Repository, branchName: string) => void, + + // context props + t: string => string }; class BranchView extends React.Component { + componentDidMount() { + const { fetchBranchByName, repository, branchName } = this.props; + + fetchBranchByName(repository, branchName); + } + render() { - const { repository, branch } = this.props; + const { loading, error, t, repository, branch } = this.props; + + if (error) { + return ( + + ); + } + + if (!branch || loading) { + return ; + } + return (
@@ -23,7 +59,7 @@ class BranchView extends React.Component {
@@ -33,13 +69,28 @@ class BranchView extends React.Component { const mapStateToProps = (state, ownProps) => { const { repository } = ownProps; - const branch = getBranch(state, repository, "VisualStudio"); // TODO: !!! + const branchName = decodeURIComponent(ownProps.match.params.branch); + const loading = isFetchBranchPending(state, repository, branchName); + const error = getFetchBranchFailure(state, repository, branchName); return { repository, - branch + branchName, + loading, + error }; }; -export default connect( - mapStateToProps -)(translate("repos")(BranchView)); +const mapDispatchToProps = dispatch => { + return { + fetchBranchByName: (repository: string, branchName: string) => { + dispatch(fetchBranchByName(repository, branchName)); + } + }; +}; + +export default withRouter( + connect( + mapStateToProps, + mapDispatchToProps + )(translate("repos")(BranchView)) +); diff --git a/scm-ui/src/repos/containers/RepositoryRoot.js b/scm-ui/src/repos/containers/RepositoryRoot.js index c1b14f4086..8c481f1adc 100644 --- a/scm-ui/src/repos/containers/RepositoryRoot.js +++ b/scm-ui/src/repos/containers/RepositoryRoot.js @@ -77,7 +77,7 @@ class RepositoryRoot extends React.Component { matchesBranches = (route: any) => { const url = this.matchedUrl(); - const regex = new RegExp(`${url}(/branch)?/?[^/]*/info?.*`); + const regex = new RegExp(`${url}/branch/.+/info`); return route.location.pathname.match(regex); }; diff --git a/scm-ui/src/repos/modules/branches.js b/scm-ui/src/repos/modules/branches.js index f819b07700..7d14a189fa 100644 --- a/scm-ui/src/repos/modules/branches.js +++ b/scm-ui/src/repos/modules/branches.js @@ -16,6 +16,10 @@ export const FETCH_BRANCHES_FAILURE = `${FETCH_BRANCHES}_${FAILURE_SUFFIX}`; // Fetching branches +export function fetchBranch(repositroy: Repository, branchName: string) { + +} + export function fetchBranches(repository: Repository) { if (!repository._links.branches) { return {