Alerting: Allow downloading alert rules from subpath (#64136)

This commit is contained in:
Gilles De Mey 2023-03-03 14:34:06 +01:00 committed by GitHub
parent 4a7fbea7a4
commit 3468804ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -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/ }),

View File

@ -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(
</div>
<Stack direction="row" gap={0.5}>
{canReadProvisioning && (
<Button icon="download-alt" type="button" onClick={onExport}>
<LinkButton
href={createUrl('/api/v1/provisioning/alert-rules/export', {
download: 'true',
format: 'yaml',
})}
icon="download-alt"
target="_blank"
rel="noopener"
>
Export
</Button>
</LinkButton>
)}
{(canCreateGrafanaRules || canCreateCloudRules) && (
<LinkButton