From fe510d592a459b7255a2a05f63b8cfd5ee408e7d Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Thu, 28 Mar 2019 17:09:59 +0100 Subject: [PATCH] structured branch code and translations --- scm-ui/public/locales/de/repos.json | 16 +++++-- scm-ui/public/locales/en/repos.json | 16 +++++-- .../branches/components/BranchDetailTable.js | 35 ++++++++++++++++ .../repos/branches/components/BranchTable.js | 40 ++++++++++++++++++ .../repos/branches/components/BranchView.js | 31 ++++++++++++++ .../containers/BranchesOverview.js | 42 ++++--------------- .../repos/branches/containers/CreateBranch.js | 18 ++++++++ scm-ui/src/repos/containers/CreateBranch.js | 13 ------ scm-ui/src/repos/containers/RepositoryRoot.js | 21 ++++++++-- .../src/users/components/table/UserTable.js | 2 - 10 files changed, 174 insertions(+), 60 deletions(-) create mode 100644 scm-ui/src/repos/branches/components/BranchDetailTable.js create mode 100644 scm-ui/src/repos/branches/components/BranchTable.js create mode 100644 scm-ui/src/repos/branches/components/BranchView.js rename scm-ui/src/repos/{ => branches}/containers/BranchesOverview.js (64%) create mode 100644 scm-ui/src/repos/branches/containers/CreateBranch.js delete mode 100644 scm-ui/src/repos/containers/CreateBranch.js diff --git a/scm-ui/public/locales/de/repos.json b/scm-ui/public/locales/de/repos.json index 4b023b08f0..24a5941a61 100644 --- a/scm-ui/public/locales/de/repos.json +++ b/scm-ui/public/locales/de/repos.json @@ -43,10 +43,18 @@ "title": "Repository erstellen", "subtitle": "Erstellen eines neuen Repository" }, - "branchesOverview": { - "title": "Übersicht aller verfügbaren Branches", - "branches": "Branches", - "createButton": "Branch erstellen" + "branches": { + "overview": { + "title": "Übersicht aller verfügbaren Branches", + "createButton": "Branch erstellen" + }, + "table": { + "branches": "Branches" + } + }, + "branch": { + "name": "Name", + "repository": "Repository" }, "changesets": { "errorTitle": "Fehler", diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index e9c00b17d9..f0f0dcf349 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -43,10 +43,18 @@ "title": "Create Repository", "subtitle": "Create a new repository" }, - "branchesOverview": { - "title": "Overview of all branches", - "branches": "Branches", - "createButton": "Create Branch" + "branches": { + "overview": { + "title": "Overview of all branches", + "createButton": "Create Branch" + }, + "table": { + "branches": "Branches" + } + }, + "branch": { + "name": "Name", + "repository": "Repository" }, "changesets": { "errorTitle": "Error", diff --git a/scm-ui/src/repos/branches/components/BranchDetailTable.js b/scm-ui/src/repos/branches/components/BranchDetailTable.js new file mode 100644 index 0000000000..4577bbee72 --- /dev/null +++ b/scm-ui/src/repos/branches/components/BranchDetailTable.js @@ -0,0 +1,35 @@ +//@flow +import React from "react"; +import type { Repository, Branch } from "@scm-manager/ui-types"; +import { translate } from "react-i18next"; + +type Props = { + repository: Repository, + branch: Branch, + // context props + t: string => string +}; + +class BranchDetailTable extends React.Component { + render() { + const { repository, branch, t } = this.props; + return ( + + + + + + + + + + + +
{t("branch.name")}branch.name
+ {t("branch.repository")} + {repository.name}
+ ); + } +} + +export default translate("repos")(BranchDetailTable); diff --git a/scm-ui/src/repos/branches/components/BranchTable.js b/scm-ui/src/repos/branches/components/BranchTable.js new file mode 100644 index 0000000000..7ccd09290a --- /dev/null +++ b/scm-ui/src/repos/branches/components/BranchTable.js @@ -0,0 +1,40 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import type { Branch } from "@scm-manager/ui-types"; +import { Link } from "react-router-dom"; + +type Props = { + baseUrl: string, + t: string => string, + branches: Branch[] +}; + +class UserTable extends React.Component { + render() { + const { baseUrl, branches, t } = this.props; + return ( + + + + + + + + {branches.map((branch, index) => { + const to = `${baseUrl}/${encodeURIComponent(branch.name)}/info`; + return ( + + + + ); + })} + +
{t("branches.table.branches")}
+ {branch.name} +
+ ); + } +} + +export default translate("users")(UserTable); diff --git a/scm-ui/src/repos/branches/components/BranchView.js b/scm-ui/src/repos/branches/components/BranchView.js new file mode 100644 index 0000000000..ebaa779be4 --- /dev/null +++ b/scm-ui/src/repos/branches/components/BranchView.js @@ -0,0 +1,31 @@ +// @flow +import React from "react"; +import BranchDetailTable from "./BranchDetailTable"; +import { ExtensionPoint } from "@scm-manager/ui-extensions"; +import type { Repository, Branch } from "@scm-manager/ui-types"; + +type Props = { + repository: Repository, + branch?: Branch // TODO: get branch from props +}; + +class BranchView extends React.Component { + render() { + const { repository, branch } = this.props; + return ( +
+ +
+
+ +
+
+ ); + } +} + +export default BranchView; diff --git a/scm-ui/src/repos/containers/BranchesOverview.js b/scm-ui/src/repos/branches/containers/BranchesOverview.js similarity index 64% rename from scm-ui/src/repos/containers/BranchesOverview.js rename to scm-ui/src/repos/branches/containers/BranchesOverview.js index b14d59889a..8589d5565f 100644 --- a/scm-ui/src/repos/containers/BranchesOverview.js +++ b/scm-ui/src/repos/branches/containers/BranchesOverview.js @@ -5,21 +5,23 @@ import { getBranches, getFetchBranchesFailure, isFetchBranchesPending -} from "../modules/branches"; +} from "../../modules/branches"; import { connect } from "react-redux"; import type { Branch, Repository } from "@scm-manager/ui-types"; import { compose } from "redux"; import { translate } from "react-i18next"; -import {Link, withRouter} from "react-router-dom"; +import { withRouter } from "react-router-dom"; import { CreateButton, ErrorNotification, Loading, Subtitle } from "@scm-manager/ui-components"; +import BranchTable from "../components/BranchTable"; type Props = { repository: Repository, + baseUrl: string, loading: boolean, error: Error, branches: Branch[], @@ -41,7 +43,7 @@ class BranchesOverview extends React.Component { } render() { - const { loading, error, t } = this.props; + const { baseUrl, loading, error, branches, t } = this.props; if (error) { return ; @@ -53,46 +55,18 @@ class BranchesOverview extends React.Component { return ( <> - - - - - - - - {this.renderBranches()} -
{t("branchesOverview.branches")}
+ + {this.renderCreateButton()} ); } - renderBranches() { - const { branches } = this.props; - - let branchesList = null; - if (branches) { - branchesList = ( - <> - {branches.map((branch, index) => { - const to = `../branch/${encodeURIComponent(branch.name)}/changesets/`; - return ( - - {branch.name} - - ); - })} - - ); - } - return branchesList; - } - renderCreateButton() { const { showCreateButton, t } = this.props; if (showCreateButton || true ) { // TODO return ( - + ); } return null; diff --git a/scm-ui/src/repos/branches/containers/CreateBranch.js b/scm-ui/src/repos/branches/containers/CreateBranch.js new file mode 100644 index 0000000000..d1443e767a --- /dev/null +++ b/scm-ui/src/repos/branches/containers/CreateBranch.js @@ -0,0 +1,18 @@ +// @flow +import React from "react"; +import { Subtitle } from "@scm-manager/ui-components"; + +class CreateBranch extends React.Component<> { + render() { + const { t } = this.props; + + return ( + <> + +

Create placeholder

+ + ); + } +} + +export default CreateBranch; diff --git a/scm-ui/src/repos/containers/CreateBranch.js b/scm-ui/src/repos/containers/CreateBranch.js deleted file mode 100644 index be20fe0a03..0000000000 --- a/scm-ui/src/repos/containers/CreateBranch.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import React from "react"; - -class CreateBranch extends React.Component<> { - - render() { - return ( -

Create placeholder

- ); - } -} - -export default CreateBranch; diff --git a/scm-ui/src/repos/containers/RepositoryRoot.js b/scm-ui/src/repos/containers/RepositoryRoot.js index 97e21cf4b5..817dc7baa2 100644 --- a/scm-ui/src/repos/containers/RepositoryRoot.js +++ b/scm-ui/src/repos/containers/RepositoryRoot.js @@ -23,8 +23,9 @@ import { import { translate } from "react-i18next"; import RepositoryDetails from "../components/RepositoryDetails"; import EditRepo from "./EditRepo"; -import BranchesOverview from "./BranchesOverview"; -import CreateBranch from "./CreateBranch"; +import BranchesOverview from "../branches/containers/BranchesOverview"; +import BranchView from "../branches/components/BranchView"; +import CreateBranch from "../branches/containers/CreateBranch"; import Permissions from "../permissions/containers/Permissions"; import type { History } from "history"; @@ -168,6 +169,15 @@ class RepositoryRoot extends React.Component { /> )} /> + ( + + )} + /> ( @@ -181,7 +191,12 @@ class RepositoryRoot extends React.Component { } + render={() => ( + + )} /> { render() { const { users, t } = this.props;