chore(ui): avoid using inject in FetchPauser

This commit is contained in:
Łukasz Mierzwa
2019-10-30 13:24:48 +00:00
parent ca632b7c6a
commit 2d4e2640b2
4 changed files with 23 additions and 31 deletions

View File

@@ -1,31 +1,27 @@
import { Component } from "react";
import PropTypes from "prop-types";
import { inject } from "mobx-react";
import { AlertStore } from "Stores/AlertStore";
const FetchPauser = inject("alertStore")(
class FetchPauser extends Component {
static propTypes = {
children: PropTypes.any,
alertStore: PropTypes.instanceOf(AlertStore).isRequired
};
class FetchPauser extends Component {
static propTypes = {
children: PropTypes.any,
alertStore: PropTypes.instanceOf(AlertStore).isRequired
};
componentDidMount() {
const { alertStore } = this.props;
alertStore.status.pause();
}
componentWillUnmount() {
const { alertStore } = this.props;
alertStore.status.resume();
}
render() {
return this.props.children;
}
componentDidMount() {
const { alertStore } = this.props;
alertStore.status.pause();
}
);
componentWillUnmount() {
const { alertStore } = this.props;
alertStore.status.resume();
}
render() {
return this.props.children;
}
}
export { FetchPauser };

View File

@@ -1,7 +1,5 @@
import React from "react";
import { Provider } from "mobx-react";
import { mount } from "enzyme";
import { AlertStore } from "Stores/AlertStore";
@@ -15,11 +13,9 @@ beforeEach(() => {
const MountedFetchPauser = () => {
return mount(
<Provider alertStore={alertStore}>
<FetchPauser>
<div />
</FetchPauser>
</Provider>
<FetchPauser alertStore={alertStore}>
<div />
</FetchPauser>
);
};

View File

@@ -45,7 +45,7 @@ const MenuContent = onClickOutside(
silenceFormStore
}) => {
return (
<FetchPauser>
<FetchPauser alertStore={alertStore}>
<div
className="dropdown-menu d-block shadow"
ref={popperRef}

View File

@@ -57,7 +57,7 @@ const MenuContent = onClickOutside(
const groupLink = `${baseURL}?${FormatAlertsQ(groupFilters)}`;
return (
<FetchPauser>
<FetchPauser alertStore={alertStore}>
<div
className="dropdown-menu d-block shadow"
ref={popperRef}