From 3468804ff5f3eb542df414680e1838c4183d05ea Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Fri, 3 Mar 2023 14:34:06 +0100 Subject: [PATCH] Alerting: Allow downloading alert rules from subpath (#64136) --- .../features/alerting/unified/RuleList.test.tsx | 2 +- public/app/features/alerting/unified/RuleList.tsx | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/public/app/features/alerting/unified/RuleList.test.tsx b/public/app/features/alerting/unified/RuleList.test.tsx index 81ba90f7178..ca7bd53c184 100644 --- a/public/app/features/alerting/unified/RuleList.test.tsx +++ b/public/app/features/alerting/unified/RuleList.test.tsx @@ -117,7 +117,7 @@ const ui = { moreErrorsButton: byRole('button', { name: /more errors/ }), editCloudGroupIcon: byTestId('edit-group'), newRuleButton: byRole('link', { name: 'Create alert rule' }), - exportButton: byRole('button', { name: /export/i }), + exportButton: byRole('link', { name: /export/i }), editGroupModal: { dialog: byRole('dialog'), namespaceInput: byRole('textbox', { name: /^Namespace/ }), diff --git a/public/app/features/alerting/unified/RuleList.tsx b/public/app/features/alerting/unified/RuleList.tsx index 56437196652..feb0c0d79bf 100644 --- a/public/app/features/alerting/unified/RuleList.tsx +++ b/public/app/features/alerting/unified/RuleList.tsx @@ -27,14 +27,13 @@ import { fetchAllPromAndRulerRulesAction } from './state/actions'; import { useRulesAccess } from './utils/accessControlHooks'; import { RULE_LIST_POLL_INTERVAL_MS } from './utils/constants'; import { getAllRulesSourceNames } from './utils/datasource'; +import { createUrl } from './utils/url'; const VIEWS = { groups: RuleListGroupView, state: RuleListStateView, }; -const onExport = () => window.open('/api/v1/provisioning/alert-rules/export?download=true&format=yaml'); - const RuleList = withErrorBoundary( () => { const dispatch = useDispatch(); @@ -111,9 +110,17 @@ const RuleList = withErrorBoundary( {canReadProvisioning && ( - + )} {(canCreateGrafanaRules || canCreateCloudRules) && (