added translation and used styled table instead of list

This commit is contained in:
Florian Scholdei
2019-03-28 14:19:53 +01:00
parent 10d46a7ceb
commit f59521a9f1
3 changed files with 48 additions and 20 deletions

View File

@@ -43,6 +43,10 @@
"title": "Repository erstellen", "title": "Repository erstellen",
"subtitle": "Erstellen eines neuen Repository" "subtitle": "Erstellen eines neuen Repository"
}, },
"branchesOverview": {
"title": "Übersicht aller verfügbaren Branches",
"branches": "Branches"
},
"changesets": { "changesets": {
"errorTitle": "Fehler", "errorTitle": "Fehler",
"errorSubtitle": "Changesets konnten nicht abgerufen werden", "errorSubtitle": "Changesets konnten nicht abgerufen werden",

View File

@@ -43,6 +43,10 @@
"title": "Create Repository", "title": "Create Repository",
"subtitle": "Create a new repository" "subtitle": "Create a new repository"
}, },
"branchesOverview": {
"title": "Overview of all branches",
"branches": "Branches"
},
"changesets": { "changesets": {
"errorTitle": "Error", "errorTitle": "Error",
"errorSubtitle": "Could not fetch changesets", "errorSubtitle": "Could not fetch changesets",

View File

@@ -1,12 +1,21 @@
// @flow // @flow
import React from "react"; import React from "react";
import {fetchBranches, getBranches, getFetchBranchesFailure, isFetchBranchesPending} from "../modules/branches"; import {
fetchBranches,
getBranches,
getFetchBranchesFailure,
isFetchBranchesPending
} from "../modules/branches";
import { connect } from "react-redux"; import { connect } from "react-redux";
import type { Branch, Repository } from "@scm-manager/ui-types"; import type { Branch, Repository } from "@scm-manager/ui-types";
import { compose } from "redux"; import { compose } from "redux";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import {withRouter} from "react-router-dom"; import {Link, withRouter} from "react-router-dom";
import {ErrorNotification, Loading} from "@scm-manager/ui-components"; import {
ErrorNotification,
Loading,
Subtitle
} from "@scm-manager/ui-components";
type Props = { type Props = {
repository: Repository, repository: Repository,
@@ -24,19 +33,13 @@ type Props = {
}; };
class BranchesOverview extends React.Component<Props> { class BranchesOverview extends React.Component<Props> {
componentDidMount() { componentDidMount() {
const { const { fetchBranches, repository } = this.props;
fetchBranches,
repository
} = this.props;
fetchBranches(repository); fetchBranches(repository);
} }
render() { render() {
const { const { loading, error, t } = this.props;
loading,
error,
} = this.props;
if (error) { if (error) {
return <ErrorNotification error={error} />; return <ErrorNotification error={error} />;
@@ -46,7 +49,19 @@ class BranchesOverview extends React.Component<Props> {
return <Loading />; return <Loading />;
} }
return <>{this.renderBranches()}</>; return (
<>
<Subtitle subtitle={t("branchesOverview.title")} />
<table className="card-table table is-hoverable is-fullwidth">
<thead>
<tr>
<th>{t("branchesOverview.branches")}</th>
</tr>
</thead>
<tbody>{this.renderBranches()}</tbody>
</table>
</>
);
} }
renderBranches() { renderBranches() {
@@ -55,11 +70,16 @@ class BranchesOverview extends React.Component<Props> {
let branchesList = null; let branchesList = null;
if (branches) { if (branches) {
branchesList = ( branchesList = (
<ul> <>
{branches.map((branch, index) => { {branches.map((branch, index) => {
return <li key={index}>{branch.name}</li>; const to = `../branch/${encodeURIComponent(branch.name)}/changesets/`;
return (
<tr>
<td key={index}><Link to={to}>{branch.name}</Link></td>
</tr>
);
})} })}
</ul> </>
); );
} }
return branchesList; return branchesList;
@@ -84,7 +104,7 @@ const mapDispatchToProps = dispatch => {
return { return {
fetchBranches: (repository: Repository) => { fetchBranches: (repository: Repository) => {
dispatch(fetchBranches(repository)); dispatch(fetchBranches(repository));
}, }
}; };
}; };