mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
chore(ui): avoid using inject in FetchPauser
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const MenuContent = onClickOutside(
|
||||
silenceFormStore
|
||||
}) => {
|
||||
return (
|
||||
<FetchPauser>
|
||||
<FetchPauser alertStore={alertStore}>
|
||||
<div
|
||||
className="dropdown-menu d-block shadow"
|
||||
ref={popperRef}
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user