mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: enforce roles on frontend (#33997)
This commit is contained in:
@@ -16,7 +16,7 @@ import { saveRuleFormAction } from '../../state/actions';
|
||||
import { RuleWithLocation } from 'app/types/unified-alerting';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useCleanup } from 'app/core/hooks/useCleanup';
|
||||
import { rulerRuleToFormValues, defaultFormValues, getDefaultQueries } from '../../utils/rule-form';
|
||||
import { rulerRuleToFormValues, getDefaultFormValues, getDefaultQueries } from '../../utils/rule-form';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||
|
||||
@@ -36,7 +36,7 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
|
||||
return rulerRuleToFormValues(existing);
|
||||
}
|
||||
return {
|
||||
...defaultFormValues,
|
||||
...getDefaultFormValues(),
|
||||
queries: getDefaultQueries(),
|
||||
...(queryParams['defaults'] ? JSON.parse(queryParams['defaults'] as string) : {}),
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import { DataSourcePicker } from '@grafana/runtime';
|
||||
import { useRulesSourcesWithRuler } from '../../hooks/useRuleSourcesWithRuler';
|
||||
import { RuleFolderPicker } from './RuleFolderPicker';
|
||||
import { GroupAndNamespaceFields } from './GroupAndNamespaceFields';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
const alertTypeOptions: SelectableValue[] = [
|
||||
{
|
||||
@@ -17,12 +18,15 @@ const alertTypeOptions: SelectableValue[] = [
|
||||
value: RuleFormType.threshold,
|
||||
description: 'Metric alert based on a defined threshold',
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (contextSrv.isEditor) {
|
||||
alertTypeOptions.push({
|
||||
label: 'System or application',
|
||||
value: RuleFormType.system,
|
||||
description: 'Alert based on a system or application behavior. Based on Prometheus.',
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
interface Props {
|
||||
editingExistingRule: boolean;
|
||||
|
||||
Reference in New Issue
Block a user