mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Pass yaml as a query param in export request (#62751)
* Set YAML as default value for exporting alert rules * use YAML format for rule list export Co-authored-by: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> * lint * Add new format query param to swagger+docs * Fix broken test --------- Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com> Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import { useAsyncFn, useInterval } from 'react-use';
|
||||
|
||||
import { GrafanaTheme2, urlUtil } from '@grafana/data';
|
||||
import { Stack } from '@grafana/experimental';
|
||||
import { BackendSrvRequest, getBackendSrv, logInfo } from '@grafana/runtime';
|
||||
import { logInfo } from '@grafana/runtime';
|
||||
import { Button, LinkButton, useStyles2, withErrorBoundary } from '@grafana/ui';
|
||||
import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
||||
import { useDispatch } from 'app/types';
|
||||
@@ -33,20 +33,7 @@ const VIEWS = {
|
||||
state: RuleListStateView,
|
||||
};
|
||||
|
||||
const onExport = async () => {
|
||||
const exportURL = `/api/v1/provisioning/alert-rules/export?download=true`;
|
||||
const options: BackendSrvRequest = {
|
||||
url: exportURL,
|
||||
headers: { Accept: 'yaml' },
|
||||
responseType: 'blob',
|
||||
};
|
||||
const blob = await getBackendSrv().get(exportURL, undefined, undefined, options);
|
||||
const fileUrl = window.URL.createObjectURL(blob);
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.href = fileUrl;
|
||||
downloadLink.download = 'export.yaml';
|
||||
downloadLink.click();
|
||||
};
|
||||
const onExport = () => window.open('/api/v1/provisioning/alert-rules/export?download=true&format=yaml');
|
||||
|
||||
const RuleList = withErrorBoundary(
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user