mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 18:51:10 +01:00
Added displaying of errors in changesets
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import {connect} from "react-redux";
|
import {connect} from "react-redux";
|
||||||
import {Loading} from "@scm-manager/ui-components";
|
import {ErrorNotification, Loading} from "@scm-manager/ui-components";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
fetchChangesetsByNamespaceAndName, fetchChangesetsByNamespaceNameAndBranch,
|
fetchChangesetsByNamespaceAndName, fetchChangesetsByNamespaceNameAndBranch,
|
||||||
getChangesets, isFetchChangesetsPending,
|
getChangesets, getFetchChangesetsFailure, isFetchChangesetsPending,
|
||||||
} from "../modules/changesets";
|
} from "../modules/changesets";
|
||||||
import type { History } from "history";
|
import type {History} from "history";
|
||||||
import {fetchBranchesByNamespaceAndName, getBranchNames} from "../../repos/modules/branches";
|
import {fetchBranchesByNamespaceAndName, getBranchNames} from "../../repos/modules/branches";
|
||||||
import type {Repository} from "@scm-manager/ui-types";
|
import type {Repository} from "@scm-manager/ui-types";
|
||||||
import ChangesetTable from "../components/ChangesetTable";
|
import ChangesetTable from "../components/ChangesetTable";
|
||||||
@@ -24,8 +24,7 @@ type Props = {
|
|||||||
class Changesets extends React.Component<State, Props> {
|
class Changesets extends React.Component<State, Props> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -40,24 +39,35 @@ class Changesets extends React.Component<State, Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {changesets, branchNames, loading} = this.props;
|
const {changesets, loading, error} = this.props;
|
||||||
const branch = this.props.match.params.branch;
|
|
||||||
if (loading || !changesets) {
|
if (loading || !changesets) {
|
||||||
return <Loading />
|
return <Loading/>
|
||||||
}
|
}
|
||||||
|
return <div>
|
||||||
|
<ErrorNotification error={error}/>
|
||||||
|
{this.renderContent()}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
renderContent = () => {
|
||||||
|
const branch = this.props.match.params.branch;
|
||||||
|
const {changesets, branchNames} = this.props;
|
||||||
|
|
||||||
if (branchNames) {
|
if (branchNames) {
|
||||||
return <div>
|
return <div>
|
||||||
<DropDown options={branchNames} preselectedOption={branch} optionSelected={branch => this.branchChanged(branch)}/>
|
<DropDown options={branchNames} preselectedOption={branch}
|
||||||
|
optionSelected={branch => this.branchChanged(branch)}/>
|
||||||
<ChangesetTable changesets={changesets}/>
|
<ChangesetTable changesets={changesets}/>
|
||||||
</div>;
|
</div>;
|
||||||
} else {
|
|
||||||
return <ChangesetTable changesets={changesets}/>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return <ChangesetTable changesets={changesets}/>
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
branchChanged = (branchName: string) => {
|
branchChanged = (branchName: string) => {
|
||||||
const { history, repository } = this.props;
|
const {history, repository} = this.props;
|
||||||
history.push(`/repo/${repository.namespace}/${repository.name}/history/${branchName}`);
|
history.push(`/repo/${repository.namespace}/${repository.name}/history/${branchName}`);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -68,7 +78,8 @@ const mapStateToProps = (state, ownProps: Props) => {
|
|||||||
return {
|
return {
|
||||||
loading: isFetchChangesetsPending(namespace, name, state),
|
loading: isFetchChangesetsPending(namespace, name, state),
|
||||||
changesets: getChangesets(state, namespace, name, ownProps.match.params.branch),
|
changesets: getChangesets(state, namespace, name, ownProps.match.params.branch),
|
||||||
branchNames: getBranchNames(namespace, name, state)
|
branchNames: getBranchNames(namespace, name, state),
|
||||||
|
error: getFetchChangesetsFailure(state, namespace, name, ownProps.match.params.branch)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export function getChangesetsForNamespaceAndNameFromState(namespace: string, nam
|
|||||||
return Object.values(state.changesets[key].byId);
|
return Object.values(state.changesets[key].byId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChangesets(namespace: string, name: string, branch: string, state: Object) {
|
export function getChangesets(state: Object, namespace: string, name: string, branch: string) {
|
||||||
const key = createItemId(namespace, name, branch);
|
const key = createItemId(namespace, name, branch);
|
||||||
if (!state.changesets[key]) {
|
if (!state.changesets[key]) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user