fleet/frontend/pages/admin/components/HostStatusWebhookPreviewModal/HostStatusWebhookPreviewModal.tsx
jacobshandling 0db86ef2f1
UI housekeeping: Update Modal.children from JSX.Element to React.ReactNode, remove empty fragment wrappers (#41394)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Simplified modal structures across multiple dialog components for
improved code maintainability.
* Enhanced modal component's flexibility to support broader content
types.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-03-10 15:30:55 -07:00

64 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from "react";
import { syntaxHighlight } from "utilities/helpers";
import Button from "components/buttons/Button";
import Modal from "components/Modal";
const baseClass = "host-status-webhook-preview-modal";
const getHostStatusPreview = (teamScope?: boolean) => {
const data = {
unseen_hosts: 1,
total_hosts: 2,
days_unseen: 3,
team_id: 123,
} as Record<string, number>;
if (!teamScope) {
delete data.team_id;
}
return {
text:
"More than X% of your hosts have not checked into Fleet for more than Y days. Youve been sent this message because the Host status webhook is enabled in your Fleet instance.",
data,
};
};
interface IHostStatusWebhookPreviewModal {
isTeamScope?: boolean;
toggleModal: () => void;
}
const HostStatusWebhookPreviewModal = ({
isTeamScope = false,
toggleModal,
}: IHostStatusWebhookPreviewModal) => {
return (
<Modal
title="Host status webhook"
onExit={toggleModal}
onEnter={toggleModal}
className={baseClass}
>
<p>
An example request sent to your configured <b>Destination URL</b>.
</p>
<div className={baseClass}>
<pre
dangerouslySetInnerHTML={{
__html: syntaxHighlight(getHostStatusPreview(isTeamScope)),
}}
/>
</div>
<div className="modal-cta-wrap">
<Button type="button" onClick={toggleModal}>
Done
</Button>
</div>
</Modal>
);
};
export default HostStatusWebhookPreviewModal;