From 9ef2e8d7da7ac101cc40067d327c87b2be88c04d Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 3 Mar 2023 08:44:03 -0500 Subject: [PATCH] [v9.4.x] Alerting: Allow downloading alert rules from subpath (#64138) Co-authored-by: Gilles De Mey --- .../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 fccb1899192..8ddc8283721 100644 --- a/public/app/features/alerting/unified/RuleList.test.tsx +++ b/public/app/features/alerting/unified/RuleList.test.tsx @@ -122,7 +122,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: { namespaceInput: byRole('textbox', { hidden: true, name: /namespace/i }), ruleGroupInput: byRole('textbox', { name: 'Evaluation group', exact: true }), 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) && (