import { ActionIcon, Badge, Box, Card, Group, rem, Tooltip, useComputedColorScheme, } from "@mantine/core"; import { IconClockPause, IconClockPlay, IconSearch } from "@tabler/icons-react"; import { FC } from "react"; import { formatPrometheusDuration } from "../lib/formatTime"; import codeboxClasses from "./RuleDefinition.module.css"; import { Rule } from "../api/responseTypes/rules"; import CodeMirror, { EditorView } from "@uiw/react-codemirror"; import { syntaxHighlighting } from "@codemirror/language"; import { baseTheme, darkPromqlHighlighter, lightTheme, promqlHighlighter, } from "../codemirror/theme"; import { PromQLExtension } from "@prometheus-io/codemirror-promql"; import { LabelBadges } from "./LabelBadges"; import { useSettings } from "../state/settingsSlice"; const promqlExtension = new PromQLExtension(); const RuleDefinition: FC<{ rule: Rule }> = ({ rule }) => { const theme = useComputedColorScheme(); const { pathPrefix } = useSettings(); return ( <> { window.open( `${pathPrefix}/query?g0.expr=${encodeURIComponent(rule.query)}&g0.tab=1`, "_blank" ); }} className={codeboxClasses.queryButton} > {rule.type === "alerting" && ( {rule.duration && ( } > for: {formatPrometheusDuration(rule.duration * 1000)} )} {rule.keepFiringFor && ( } > keep_firing_for: {formatPrometheusDuration(rule.duration * 1000)} )} )} {rule.labels && Object.keys(rule.labels).length > 0 && ( )} {/* {Object.keys(r.annotations).length > 0 && ( {Object.entries(r.annotations).map(([k, v]) => ( {k}: {v} ))} )} */} ); }; export default RuleDefinition;