fix(ui): rewrite SilenceSubmitController component with hooks

This commit is contained in:
Łukasz Mierzwa
2020-04-30 17:57:38 +01:00
committed by Łukasz Mierzwa
parent cd41829a27
commit a0b19cb4c1

View File

@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React from "react";
import PropTypes from "prop-types";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -8,41 +8,36 @@ import { AlertStore } from "Stores/AlertStore";
import { SilenceFormStore } from "Stores/SilenceFormStore";
import { SilenceSubmitProgress } from "./SilenceSubmitProgress";
class SilenceSubmitController extends Component {
static propTypes = {
alertStore: PropTypes.instanceOf(AlertStore).isRequired,
silenceFormStore: PropTypes.instanceOf(SilenceFormStore).isRequired,
};
render() {
const { silenceFormStore, alertStore } = this.props;
return (
<React.Fragment>
<div>
{silenceFormStore.data.alertmanagers.map((am) => (
<SilenceSubmitProgress
key={am.label}
cluster={am.label}
members={am.value}
payload={silenceFormStore.data.toAlertmanagerPayload}
alertStore={alertStore}
/>
))}
</div>
<div className="d-flex flex-row-reverse">
<button
type="button"
className="btn btn-primary"
onClick={silenceFormStore.data.resetProgress}
>
<FontAwesomeIcon icon={faArrowLeft} className="pr-1" />
Back
</button>
</div>
</React.Fragment>
);
}
}
const SilenceSubmitController = ({ silenceFormStore, alertStore }) => {
return (
<React.Fragment>
<div>
{silenceFormStore.data.alertmanagers.map((am) => (
<SilenceSubmitProgress
key={am.label}
cluster={am.label}
members={am.value}
payload={silenceFormStore.data.toAlertmanagerPayload}
alertStore={alertStore}
/>
))}
</div>
<div className="d-flex flex-row-reverse">
<button
type="button"
className="btn btn-primary"
onClick={silenceFormStore.data.resetProgress}
>
<FontAwesomeIcon icon={faArrowLeft} className="pr-1" />
Back
</button>
</div>
</React.Fragment>
);
};
SilenceSubmitController.propTypes = {
alertStore: PropTypes.instanceOf(AlertStore).isRequired,
silenceFormStore: PropTypes.instanceOf(SilenceFormStore).isRequired,
};
export { SilenceSubmitController };