mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(ui): render silence modal on the body using portal
This way modal isn't nested under navbar and doesn't get classes from it
This commit is contained in:
@@ -16,9 +16,7 @@ import "./index.css";
|
||||
const Tab = ({ title, active, onClick }) => (
|
||||
<li className="nav-item">
|
||||
<a
|
||||
className={`nav-link cursor-pointer ${
|
||||
active ? "active text-white" : "text-primary"
|
||||
}`}
|
||||
className={`nav-link cursor-pointer ${active ? "active" : ""}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
{title}
|
||||
|
||||
49
ui/src/Components/SilenceModal/SilenceModalContent.js
Normal file
49
ui/src/Components/SilenceModal/SilenceModalContent.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import React, { Component } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { SilenceForm } from "./SilenceForm";
|
||||
import { SilenceSubmitController } from "./SilenceSubmitController";
|
||||
|
||||
class SilenceModalContent extends Component {
|
||||
static propTypes = {
|
||||
alertStore: PropTypes.object.isRequired,
|
||||
silenceFormStore: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const { alertStore, silenceFormStore } = this.props;
|
||||
|
||||
return ReactDOM.createPortal(
|
||||
<div className="modal d-block bg-primary-transparent-80" role="dialog">
|
||||
<div className="modal-dialog modal-lg" role="document">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<h5 className="modal-title">Add new silence</h5>
|
||||
<button
|
||||
type="button"
|
||||
className="close"
|
||||
onClick={silenceFormStore.toggle.hide}
|
||||
>
|
||||
<span className="align-middle">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
{silenceFormStore.data.inProgress ? (
|
||||
<SilenceSubmitController silenceFormStore={silenceFormStore} />
|
||||
) : (
|
||||
<SilenceForm
|
||||
alertStore={alertStore}
|
||||
silenceFormStore={silenceFormStore}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { SilenceModalContent };
|
||||
@@ -6,8 +6,7 @@ import { observer } from "mobx-react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faBellSlash } from "@fortawesome/free-solid-svg-icons/faBellSlash";
|
||||
|
||||
import { SilenceForm } from "./SilenceForm";
|
||||
import { SilenceSubmitController } from "./SilenceSubmitController";
|
||||
import { SilenceModalContent } from "./SilenceModalContent";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
@@ -45,37 +44,10 @@ const SilenceModal = observer(
|
||||
</a>
|
||||
</li>
|
||||
{silenceFormStore.toggle.visible ? (
|
||||
<div
|
||||
className="modal d-block bg-primary-transparent-80"
|
||||
role="dialog"
|
||||
>
|
||||
<div className="modal-dialog modal-lg" role="document">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<h5 className="modal-title">Add new silence</h5>
|
||||
<button
|
||||
type="button"
|
||||
className="close"
|
||||
onClick={silenceFormStore.toggle.hide}
|
||||
>
|
||||
<span className="align-middle">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
{silenceFormStore.data.inProgress ? (
|
||||
<SilenceSubmitController
|
||||
silenceFormStore={silenceFormStore}
|
||||
/>
|
||||
) : (
|
||||
<SilenceForm
|
||||
alertStore={alertStore}
|
||||
silenceFormStore={silenceFormStore}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<SilenceModalContent
|
||||
alertStore={alertStore}
|
||||
silenceFormStore={silenceFormStore}
|
||||
/>
|
||||
) : null}
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user