Added loading spinner to Changesets

This commit is contained in:
Philipp Czora
2018-09-17 17:20:17 +02:00
parent 2af345bba0
commit b1ffb0a562

View File

@@ -1,9 +1,10 @@
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 { import {
fetchChangesetsByNamespaceAndName, fetchChangesetsByNamespaceNameAndBranch, fetchChangesetsByNamespaceAndName, fetchChangesetsByNamespaceNameAndBranch,
getChangesets, getChangesets, 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";
@@ -39,10 +40,10 @@ class Changesets extends React.Component<State, Props> {
} }
render() { render() {
const {changesets, branchNames} = this.props; const {changesets, branchNames, loading} = this.props;
const branch = this.props.match.params.branch; const branch = this.props.match.params.branch;
if (changesets === null) { if (loading || !changesets) {
return null return <Loading />
} }
if (branchNames) { if (branchNames) {
return <div> return <div>
@@ -65,7 +66,8 @@ class Changesets extends React.Component<State, Props> {
const mapStateToProps = (state, ownProps: Props) => { const mapStateToProps = (state, ownProps: Props) => {
const {namespace, name} = ownProps.repository; const {namespace, name} = ownProps.repository;
return { return {
changesets: getChangesets(namespace, name, ownProps.match.params.branch, state), loading: isFetchChangesetsPending(namespace, name, state),
changesets: getChangesets(state, namespace, name, ownProps.match.params.branch),
branchNames: getBranchNames(namespace, name, state) branchNames: getBranchNames(namespace, name, state)
} }
}; };