diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx index 32994e1061c..ebb273dc03f 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx @@ -11,9 +11,9 @@ import { Alert, Button, ConfirmModal, + Divider, Dropdown, Field, - Icon, Menu, MenuItem, Stack, @@ -160,7 +160,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange, mod } }, [simplifiedQueryStep, expressionQueries, isGrafanaAlertingType, setSimpleCondition]); - const { rulesSourcesWithRuler } = useRulesSourcesWithRuler(); + const { rulesSourcesWithRuler, isLoading: rulerSourcesIsLoading } = useRulesSourcesWithRuler(); const runQueriesPreview = useCallback( (condition?: string) => { @@ -474,6 +474,8 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange, mod } : undefined; + const hasDatasourcesForDataSourceManaged = Boolean(rulesSourcesWithRuler.length); + return ( <> )} + {rulerSourcesIsLoading && ( + + Loading data sources... + + )} + {/* This is the PromQL Editor for Cloud rules */} - {isCloudAlertRuleType && dataSourceName && ( + {!rulerSourcesIsLoading && isCloudAlertRuleType && dataSourceName && ( {mode === 'edit' && ( - + <> + + + )} )} {/* This is the editor for Grafana managed rules and Grafana managed recording rules */} - {isGrafanaManagedRuleByType(type) && ( + {!rulerSourcesIsLoading && isGrafanaManagedRuleByType(type) && ( {/* Data Queries */} {!simplifiedQueryStep && ( - + ); diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SmartAlertTypeDetector.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SmartAlertTypeDetector.tsx index f5fe77493dd..6fcbf4675a1 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SmartAlertTypeDetector.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SmartAlertTypeDetector.tsx @@ -86,8 +86,11 @@ export function SmartAlertTypeDetector({ const canSwitch = getCanSwitch({ queries, ruleFormType, rulesSourcesWithRuler }); const options = [ - { label: 'Grafana-managed', value: RuleFormType.grafana }, - { label: 'Data source-managed', value: RuleFormType.cloudAlerting }, + { label: t('alerting.smart-alert-type-detector.grafana-managed', 'Grafana-managed'), value: RuleFormType.grafana }, + { + label: t('alerting.smart-alert-type-detector.data-source-managed', 'Data source-managed'), + value: RuleFormType.cloudAlerting, + }, ]; // if we can't switch to data-source managed, disable it diff --git a/public/app/features/alerting/unified/rule-editor/RuleEditorCloudOnlyAllowed.test.tsx b/public/app/features/alerting/unified/rule-editor/RuleEditorCloudOnlyAllowed.test.tsx index 059743c99a3..86d92dac4fe 100644 --- a/public/app/features/alerting/unified/rule-editor/RuleEditorCloudOnlyAllowed.test.tsx +++ b/public/app/features/alerting/unified/rule-editor/RuleEditorCloudOnlyAllowed.test.tsx @@ -179,7 +179,7 @@ describe('RuleEditor cloud: checking editable data sources', () => { await ui.inputs.name.find(); - const switchToCloudButton = screen.getByText('Data source-managed'); + const switchToCloudButton = await screen.findByText('Data source-managed'); expect(switchToCloudButton).toBeInTheDocument(); await user.click(switchToCloudButton); diff --git a/public/app/features/alerting/unified/rule-editor/RuleEditorCloudRules.test.tsx b/public/app/features/alerting/unified/rule-editor/RuleEditorCloudRules.test.tsx index d70177fc7a9..0ed8255932b 100644 --- a/public/app/features/alerting/unified/rule-editor/RuleEditorCloudRules.test.tsx +++ b/public/app/features/alerting/unified/rule-editor/RuleEditorCloudRules.test.tsx @@ -45,7 +45,7 @@ describe('RuleEditor cloud', () => { it('can create a new cloud alert', async () => { const { user } = renderRuleEditor(); - const removeExpressionsButtons = screen.getAllByLabelText(/Remove expression/); + const removeExpressionsButtons = await screen.findAllByLabelText(/Remove expression/); expect(removeExpressionsButtons).toHaveLength(2); // Needs to wait for featrue discovery API call to finish - Check if ruler enabled diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 59a08fe9210..21154720720 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -1712,7 +1712,9 @@ "add-query": "Add query", "body-queries-expressions-configured": "Create at least one query or expression to be alerted on", "expressions": "Expressions", + "loading-data-sources": "Loading data sources...", "manipulate-returned-queries-other-operations": "Manipulate data returned from queries with math and other operations.", + "no-compatible-sources": "You appear to have no compatible data sources", "title-deactivate-advanced-options": "Deactivate advanced options", "title-queries-expressions-configured": "No queries or expressions have been configured" }, @@ -2213,8 +2215,10 @@ "alertCondition": "Alert condition" }, "smart-alert-type-detector": { + "data-source-managed": "Data source-managed", "data-sourcemanaged-alert-rules": "Data source-managed alert rules", "data-sourcemanaged-alert-rules-description": "Data source-managed alert rules can be used for Grafana Mimir or Grafana Loki data sources which have been configured to support rule creation. The use of expressions or multiple queries is not supported.", + "grafana-managed": "Grafana-managed", "grafanamanaged-alert-rules": "Grafana-managed alert rules", "grafanamanaged-alert-rules-description": "Grafana-managed alert rules allow you to create alerts that can act on data from any of our supported data sources, including having multiple data sources in the same rule. You can also add expressions to transform your data and set alert conditions. Using images in alert notifications is also supported.", "rule-type": "Rule type",