added placeholder buttonGroup, first attempt on fetchingbranch, last correction of regex

This commit is contained in:
Florian Scholdei
2019-03-29 13:52:19 +01:00
parent 7ea2a06b1e
commit 3ac82e4021
7 changed files with 131 additions and 14 deletions

View File

@@ -44,6 +44,8 @@
"subtitle": "Erstellen eines neuen Repository" "subtitle": "Erstellen eines neuen Repository"
}, },
"branches": { "branches": {
"errorTitle": "Fehler",
"errorSubtitle": "Unbekannter Branch Fehler",
"overview": { "overview": {
"title": "Übersicht aller verfügbaren Branches", "title": "Übersicht aller verfügbaren Branches",
"createButton": "Branch erstellen" "createButton": "Branch erstellen"
@@ -57,7 +59,10 @@
}, },
"branch": { "branch": {
"name": "Name", "name": "Name",
"repository": "Repository" "repository": "Repository",
"actions": "Aktionen",
"commits": "Commits",
"sources": "Sources"
}, },
"changesets": { "changesets": {
"errorTitle": "Fehler", "errorTitle": "Fehler",

View File

@@ -44,6 +44,8 @@
"subtitle": "Create a new repository" "subtitle": "Create a new repository"
}, },
"branches": { "branches": {
"errorTitle": "Error",
"errorSubtitle": "Unknown branch error",
"overview": { "overview": {
"title": "Overview of all branches", "title": "Overview of all branches",
"createButton": "Create Branch" "createButton": "Create Branch"
@@ -57,7 +59,10 @@
}, },
"branch": { "branch": {
"name": "Name", "name": "Name",
"repository": "Repository" "repository": "Repository",
"actions": "Actions",
"commits": "Commits",
"sources": "Sources"
}, },
"changesets": { "changesets": {
"errorTitle": "Error", "errorTitle": "Error",

View File

@@ -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<Props> {
render() {
const { repository, branch, t } = this.props;
const changesetLink = "";
const sourcesLink = "";
return (
<ButtonGroup>
<Button link={changesetLink}>
<span className="icon">
<i className="fas fa-exchange-alt" />
</span>
<span className="is-hidden-mobile is-hidden-tablet-only">
{t("branch.commits")}
</span>
</Button>
<Button link={sourcesLink}>
<span className="icon">
<i className="fas fa-code" />
</span>
<span className="is-hidden-mobile is-hidden-tablet-only">
{t("branch.sources")}
</span>
</Button>
</ButtonGroup>
);
}
}
export default translate("repos")(BranchButtonGroup);

View File

@@ -2,6 +2,7 @@
import React from "react"; import React from "react";
import type { Repository, Branch } from "@scm-manager/ui-types"; import type { Repository, Branch } from "@scm-manager/ui-types";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import BranchButtonGroup from "./BranchButtonGroup";
type Props = { type Props = {
repository: Repository, repository: Repository,
@@ -26,6 +27,12 @@ class BranchDetailTable extends React.Component<Props> {
</td> </td>
<td>{repository.name}</td> <td>{repository.name}</td>
</tr> </tr>
<tr>
<td className="has-text-weight-semibold">
{t("branch.actions")}
</td>
<td><BranchButtonGroup repository={repository} branch={branch} /></td>
</tr>
</tbody> </tbody>
</table> </table>
); );

View File

@@ -3,18 +3,54 @@ import React from "react";
import BranchDetailTable from "../components/BranchDetailTable"; import BranchDetailTable from "../components/BranchDetailTable";
import { ExtensionPoint } from "@scm-manager/ui-extensions"; import { ExtensionPoint } from "@scm-manager/ui-extensions";
import type { Repository, Branch } from "@scm-manager/ui-types"; import type { Repository, Branch } from "@scm-manager/ui-types";
import {connect} from "react-redux"; import { connect } from "react-redux";
import {translate} from "react-i18next"; import { translate } from "react-i18next";
import {getBranch} from "../../modules/branches"; import { withRouter } from "react-router-dom";
import {
fetchBranchByName,
getFetchBranchFailure,
isFetchBranchPending
} from "../../modules/branches";
import { ErrorPage, Loading } from "@scm-manager/ui-components";
type Props = { type Props = {
repository: Repository, 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<Props> { class BranchView extends React.Component<Props> {
componentDidMount() {
const { fetchBranchByName, repository, branchName } = this.props;
fetchBranchByName(repository, branchName);
}
render() { render() {
const { repository, branch } = this.props; const { loading, error, t, repository, branch } = this.props;
if (error) {
return (
<ErrorPage
title={t("branches.errorTitle")}
subtitle={t("branches.errorSubtitle")}
error={error}
/>
);
}
if (!branch || loading) {
return <Loading />;
}
return ( return (
<div> <div>
<BranchDetailTable repository={repository} branch={branch} /> <BranchDetailTable repository={repository} branch={branch} />
@@ -23,7 +59,7 @@ class BranchView extends React.Component<Props> {
<ExtensionPoint <ExtensionPoint
name="repos.branch-details.information" name="repos.branch-details.information"
renderAll={true} renderAll={true}
props={{ branch }} props={{ repository, branch }}
/> />
</div> </div>
</div> </div>
@@ -33,13 +69,28 @@ class BranchView extends React.Component<Props> {
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { repository } = 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 { return {
repository, repository,
branch branchName,
loading,
error
}; };
}; };
export default connect( const mapDispatchToProps = dispatch => {
mapStateToProps return {
)(translate("repos")(BranchView)); fetchBranchByName: (repository: string, branchName: string) => {
dispatch(fetchBranchByName(repository, branchName));
}
};
};
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(translate("repos")(BranchView))
);

View File

@@ -77,7 +77,7 @@ class RepositoryRoot extends React.Component<Props> {
matchesBranches = (route: any) => { matchesBranches = (route: any) => {
const url = this.matchedUrl(); const url = this.matchedUrl();
const regex = new RegExp(`${url}(/branch)?/?[^/]*/info?.*`); const regex = new RegExp(`${url}/branch/.+/info`);
return route.location.pathname.match(regex); return route.location.pathname.match(regex);
}; };

View File

@@ -16,6 +16,10 @@ export const FETCH_BRANCHES_FAILURE = `${FETCH_BRANCHES}_${FAILURE_SUFFIX}`;
// Fetching branches // Fetching branches
export function fetchBranch(repositroy: Repository, branchName: string) {
}
export function fetchBranches(repository: Repository) { export function fetchBranches(repository: Repository) {
if (!repository._links.branches) { if (!repository._links.branches) {
return { return {