mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-07 11:45:48 +02:00
added branches overview and navlink
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
"menu": {
|
||||
"navigationLabel": "Repository Navigation",
|
||||
"informationNavLink": "Informationen",
|
||||
"branchesNavLink": "Branches",
|
||||
"historyNavLink": "Commits",
|
||||
"sourcesNavLink": "Sources",
|
||||
"settingsNavLink": "Einstellungen",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"menu": {
|
||||
"navigationLabel": "Repository Navigation",
|
||||
"informationNavLink": "Information",
|
||||
"branchesNavLink": "Branches",
|
||||
"historyNavLink": "Commits",
|
||||
"sourcesNavLink": "Sources",
|
||||
"settingsNavLink": "Settings",
|
||||
|
||||
98
scm-ui/src/repos/containers/BranchesOverview.js
Normal file
98
scm-ui/src/repos/containers/BranchesOverview.js
Normal file
@@ -0,0 +1,98 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import {fetchBranches, getBranches, getFetchBranchesFailure, isFetchBranchesPending} 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 {withRouter} from "react-router-dom";
|
||||
import {ErrorNotification, Loading} from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
branches: Branch[],
|
||||
|
||||
// dispatch props
|
||||
fetchBranches: Repository => void,
|
||||
|
||||
// Context props
|
||||
history: any,
|
||||
match: any,
|
||||
t: string => string
|
||||
};
|
||||
class BranchesOverview extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const {
|
||||
fetchBranches,
|
||||
repository
|
||||
} = this.props;
|
||||
|
||||
fetchBranches(repository);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
loading,
|
||||
error,
|
||||
} = this.props;
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return <>{this.renderBranches()}</>;
|
||||
}
|
||||
|
||||
renderBranches() {
|
||||
const { branches } = this.props;
|
||||
|
||||
let branchesList = null;
|
||||
if (branches) {
|
||||
branchesList = (
|
||||
<ul>
|
||||
{branches.map((branch, index) => {
|
||||
return <li key={index}>{branch.name}</li>;
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
return branchesList;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { repository } = ownProps;
|
||||
const loading = isFetchBranchesPending(state, repository);
|
||||
const error = getFetchBranchesFailure(state, repository);
|
||||
const branches = getBranches(state, repository);
|
||||
|
||||
return {
|
||||
repository,
|
||||
loading,
|
||||
error,
|
||||
branches
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchBranches: (repository: Repository) => {
|
||||
dispatch(fetchBranches(repository));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default compose(
|
||||
translate("repos"),
|
||||
withRouter,
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)
|
||||
)(BranchesOverview);
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { translate } from "react-i18next";
|
||||
import RepositoryDetails from "../components/RepositoryDetails";
|
||||
import EditRepo from "./EditRepo";
|
||||
import BranchesOverview from "./BranchesOverview";
|
||||
import CreateBranch from "./CreateBranch";
|
||||
import Permissions from "../permissions/containers/Permissions";
|
||||
|
||||
@@ -171,6 +172,14 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/branches`}
|
||||
render={() => (
|
||||
<BranchesOverview
|
||||
repository={repository}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/branches/create`}
|
||||
render={() => (
|
||||
@@ -199,6 +208,14 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
icon="fas fa-info-circle"
|
||||
label={t("repositoryRoot.menu.informationNavLink")}
|
||||
/>
|
||||
<RepositoryNavLink
|
||||
repository={repository}
|
||||
linkName="branches"
|
||||
to={`${url}/branches/`}
|
||||
icon="fas fa-folder-open"
|
||||
label={t("repositoryRoot.menu.branchesNavLink")}
|
||||
activeOnlyWhenExact={false}
|
||||
/>
|
||||
<RepositoryNavLink
|
||||
repository={repository}
|
||||
linkName="changesets"
|
||||
|
||||
Reference in New Issue
Block a user