mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 02:19:02 +08:00
* clear the queryData * avoid creation of inline func and move logic to utils * remove console.log * fix
This commit is contained in:
parent
ed4a01dea6
commit
b72815ca2f
@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useCopyToClipboard } from 'react-use';
|
import { useCopyToClipboard } from 'react-use';
|
||||||
import { DashboardData } from 'types/api/dashboard/getAll';
|
import { DashboardData } from 'types/api/dashboard/getAll';
|
||||||
|
|
||||||
import { downloadObjectAsJson } from './util';
|
import { cleardQueryData, downloadObjectAsJson } from './util';
|
||||||
|
|
||||||
function ShareModal({
|
function ShareModal({
|
||||||
isJSONModalVisible,
|
isJSONModalVisible,
|
||||||
@ -51,6 +51,7 @@ function ShareModal({
|
|||||||
}
|
}
|
||||||
}, [state.error, state.value, t]);
|
}, [state.error, state.value, t]);
|
||||||
|
|
||||||
|
const selectedDataCleaned = cleardQueryData(selectedData);
|
||||||
const GetFooterComponent = useMemo(() => {
|
const GetFooterComponent = useMemo(() => {
|
||||||
if (!isViewJSON) {
|
if (!isViewJSON) {
|
||||||
return (
|
return (
|
||||||
@ -66,7 +67,7 @@ function ShareModal({
|
|||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={(): void => {
|
onClick={(): void => {
|
||||||
downloadObjectAsJson(selectedData, selectedData.title);
|
downloadObjectAsJson(selectedDataCleaned, selectedData.title);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('download_json')}
|
{t('download_json')}
|
||||||
@ -79,7 +80,7 @@ function ShareModal({
|
|||||||
{t('copy_to_clipboard')}
|
{t('copy_to_clipboard')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}, [isViewJSON, jsonValue, selectedData, setCopy, t]);
|
}, [isViewJSON, jsonValue, selectedData, selectedDataCleaned, setCopy, t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { DashboardData } from 'types/api/dashboard/getAll';
|
||||||
|
|
||||||
export function downloadObjectAsJson(
|
export function downloadObjectAsJson(
|
||||||
exportObj: unknown,
|
exportObj: unknown,
|
||||||
exportName: string,
|
exportName: string,
|
||||||
@ -12,3 +14,18 @@ export function downloadObjectAsJson(
|
|||||||
downloadAnchorNode.click();
|
downloadAnchorNode.click();
|
||||||
downloadAnchorNode.remove();
|
downloadAnchorNode.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function cleardQueryData(param: DashboardData): DashboardData {
|
||||||
|
return {
|
||||||
|
...param,
|
||||||
|
widgets: param.widgets?.map((widget) => ({
|
||||||
|
...widget,
|
||||||
|
queryData: {
|
||||||
|
...widget.queryData,
|
||||||
|
data: {
|
||||||
|
queryData: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user