mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
added placeholder buttonGroup, first attempt on fetchingbranch, last correction of regex
This commit is contained in:
@@ -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<Props> {
|
||||
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 (
|
||||
<ErrorPage
|
||||
title={t("branches.errorTitle")}
|
||||
subtitle={t("branches.errorSubtitle")}
|
||||
error={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!branch || loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<BranchDetailTable repository={repository} branch={branch} />
|
||||
@@ -23,7 +59,7 @@ class BranchView extends React.Component<Props> {
|
||||
<ExtensionPoint
|
||||
name="repos.branch-details.information"
|
||||
renderAll={true}
|
||||
props={{ branch }}
|
||||
props={{ repository, branch }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,13 +69,28 @@ class BranchView extends React.Component<Props> {
|
||||
|
||||
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))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user