Merged changes

This commit is contained in:
Philipp Czora
2019-02-19 15:58:53 +01:00
4 changed files with 44 additions and 7 deletions

View File

@@ -2,8 +2,8 @@
import React from "react"; import React from "react";
import injectSheet from "react-jss"; import injectSheet from "react-jss";
import { type ButtonProps } from "./Button"; import { type ButtonProps } from "./Button";
import SubmitButton from "./SubmitButton";
import classNames from "classnames"; import classNames from "classnames";
import Button from "./Button";
const styles = { const styles = {
spacing: { spacing: {
@@ -19,7 +19,7 @@ class CreateButton extends React.Component<ButtonProps> {
const { classes } = this.props; const { classes } = this.props;
return ( return (
<div className={classNames("has-text-centered", classes.spacing)}> <div className={classNames("has-text-centered", classes.spacing)}>
<SubmitButton {...this.props} /> <Button color="primary" {...this.props} />
</div> </div>
); );
} }

View File

@@ -4,7 +4,16 @@ import Button, { type ButtonProps } from "./Button";
class SubmitButton extends React.Component<ButtonProps> { class SubmitButton extends React.Component<ButtonProps> {
render() { render() {
return <Button type="submit" color="primary" {...this.props} />; return (
<Button
type="submit"
color="primary"
{...this.props}
action={() => {
window.scrollTo(0, 0);
}}
/>
);
} }
} }

View File

@@ -14,6 +14,7 @@ import {
} from "../modules/indexResource"; } from "../modules/indexResource";
import PluginLoader from "./PluginLoader"; import PluginLoader from "./PluginLoader";
import type { IndexResources } from "@scm-manager/ui-types"; import type { IndexResources } from "@scm-manager/ui-types";
import ScrollToTop from "./ScrollToTop";
type Props = { type Props = {
error: Error, error: Error,
@@ -32,7 +33,6 @@ type State = {
}; };
class Index extends Component<Props, State> { class Index extends Component<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
this.state = { this.state = {
@@ -66,9 +66,14 @@ class Index extends Component<Props, State> {
return <Loading />; return <Loading />;
} else { } else {
return ( return (
<PluginLoader loaded={ pluginsLoaded } callback={ this.pluginLoaderCallback }> <ScrollToTop>
<PluginLoader
loaded={pluginsLoaded}
callback={this.pluginLoaderCallback}
>
<App /> <App />
</PluginLoader> </PluginLoader>
</ScrollToTop>
); );
} }
} }

View File

@@ -0,0 +1,23 @@
// @flow
import React from "react";
import { withRouter } from "react-router-dom";
type Props = {
location: any,
children: any
}
class ScrollToTop extends React.Component<Props> {
componentDidUpdate(prevProps) {
if (this.props.location.pathname !== prevProps.location.pathname) {
window.scrollTo(0, 0);
}
}
render() {
return this.props.children;
}
}
export default withRouter(ScrollToTop);