mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove rule group edit from single rule editor (#100191)
remove rule group edit from single rule editor
This commit is contained in:
parent
6723159b12
commit
afab71e28c
@ -10,7 +10,6 @@ import {
|
||||
Button,
|
||||
Field,
|
||||
Icon,
|
||||
IconButton,
|
||||
Input,
|
||||
Label,
|
||||
Modal,
|
||||
@ -28,7 +27,6 @@ import { alertRuleApi } from '../../api/alertRuleApi';
|
||||
import { GRAFANA_RULER_CONFIG } from '../../api/featureDiscoveryApi';
|
||||
import { DEFAULT_GROUP_EVALUATION_INTERVAL } from '../../rule-editor/formDefaults';
|
||||
import { RuleFormValues } from '../../types/rule-form';
|
||||
import { GRAFANA_RULES_SOURCE_NAME } from '../../utils/datasource';
|
||||
import {
|
||||
isGrafanaAlertingRuleByType,
|
||||
isGrafanaManagedRuleByType,
|
||||
@ -38,7 +36,7 @@ import {
|
||||
import { parsePrometheusDuration } from '../../utils/time';
|
||||
import { CollapseToggle } from '../CollapseToggle';
|
||||
import { ProvisioningBadge } from '../Provisioning';
|
||||
import { EditRuleGroupModal, evaluateEveryValidationOptions } from '../rules/EditRuleGroupModal';
|
||||
import { evaluateEveryValidationOptions } from '../rules/EditRuleGroupModal';
|
||||
|
||||
import { EvaluationGroupQuickPick } from './EvaluationGroupQuickPick';
|
||||
import { GrafanaAlertStatePicker } from './GrafanaAlertStatePicker';
|
||||
@ -160,7 +158,6 @@ export function GrafanaEvaluationBehaviorStep({
|
||||
const isGrafanaAlertingRule = isGrafanaAlertingRuleByType(type);
|
||||
const isGrafanaRecordingRule = isGrafanaRecordingRuleByType(type);
|
||||
const { currentData: rulerNamespace, isLoading: loadingGroups } = useFetchGroupsForFolder(folder?.uid ?? '');
|
||||
const [isEditingGroup, setIsEditingGroup] = useState(false);
|
||||
|
||||
const groupOptions = useMemo(() => {
|
||||
return rulerNamespace ? namespaceToGroupOptions(rulerNamespace, enableProvisionedGroups) : [];
|
||||
@ -169,7 +166,6 @@ export function GrafanaEvaluationBehaviorStep({
|
||||
const existingGroup = Object.values(rulerNamespace ?? {})
|
||||
.flat()
|
||||
.find((ruleGroup) => ruleGroup.name === group);
|
||||
const isNewGroup = !existingGroup && !loadingGroups;
|
||||
|
||||
// synchronize the evaluation interval with the group name when it's an existing group
|
||||
useEffect(() => {
|
||||
@ -178,11 +174,6 @@ export function GrafanaEvaluationBehaviorStep({
|
||||
}
|
||||
}, [existingGroup, setValue]);
|
||||
|
||||
const closeEditGroupModal = () => setIsEditingGroup(false);
|
||||
const onOpenEditGroupModal = () => setIsEditingGroup(true);
|
||||
|
||||
const editGroupDisabled = loadingGroups || isNewGroup || !folder?.uid || !group;
|
||||
|
||||
const [isCreatingEvaluationGroup, setIsCreatingEvaluationGroup] = useState(false);
|
||||
|
||||
const handleEvalGroupCreation = (groupName: string, evaluationInterval: string) => {
|
||||
@ -287,38 +278,15 @@ export function GrafanaEvaluationBehaviorStep({
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{folder?.uid && isEditingGroup && (
|
||||
<EditRuleGroupModal
|
||||
ruleGroupIdentifier={{
|
||||
dataSourceName: GRAFANA_RULES_SOURCE_NAME,
|
||||
groupName: existingGroup?.name ?? '',
|
||||
namespaceName: folder?.uid ?? '',
|
||||
}}
|
||||
rulerConfig={GRAFANA_RULER_CONFIG}
|
||||
onClose={() => closeEditGroupModal()}
|
||||
intervalEditOnly
|
||||
hideFolder={true}
|
||||
/>
|
||||
)}
|
||||
{folder?.title && group && (
|
||||
<div className={styles.evaluationContainer}>
|
||||
<Stack direction="column" gap={0}>
|
||||
<div className={styles.marginTop}>
|
||||
<Stack direction="column" gap={1}>
|
||||
{getValues('group') && getValues('evaluateEvery') && (
|
||||
<Stack direction="row" gap={1} alignItems="center">
|
||||
<Trans i18nKey="alerting.rule-form.evaluation.group-text" values={{ evaluateEvery }}>
|
||||
All rules in the selected group are evaluated every {{ evaluateEvery }}.
|
||||
</Trans>
|
||||
{!isNewGroup && (
|
||||
<IconButton
|
||||
name="pen"
|
||||
aria-label="Edit"
|
||||
disabled={editGroupDisabled}
|
||||
onClick={onOpenEditGroupModal}
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
<Trans i18nKey="alerting.rule-form.evaluation.group-text" values={{ evaluateEvery }}>
|
||||
All rules in the selected group are evaluated every {{ evaluateEvery }}.
|
||||
</Trans>
|
||||
)}
|
||||
</Stack>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user