mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 17:59:01 +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 { DashboardData } from 'types/api/dashboard/getAll';
|
||||
|
||||
import { downloadObjectAsJson } from './util';
|
||||
import { cleardQueryData, downloadObjectAsJson } from './util';
|
||||
|
||||
function ShareModal({
|
||||
isJSONModalVisible,
|
||||
@ -51,6 +51,7 @@ function ShareModal({
|
||||
}
|
||||
}, [state.error, state.value, t]);
|
||||
|
||||
const selectedDataCleaned = cleardQueryData(selectedData);
|
||||
const GetFooterComponent = useMemo(() => {
|
||||
if (!isViewJSON) {
|
||||
return (
|
||||
@ -66,7 +67,7 @@ function ShareModal({
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={(): void => {
|
||||
downloadObjectAsJson(selectedData, selectedData.title);
|
||||
downloadObjectAsJson(selectedDataCleaned, selectedData.title);
|
||||
}}
|
||||
>
|
||||
{t('download_json')}
|
||||
@ -79,7 +80,7 @@ function ShareModal({
|
||||
{t('copy_to_clipboard')}
|
||||
</Button>
|
||||
);
|
||||
}, [isViewJSON, jsonValue, selectedData, setCopy, t]);
|
||||
}, [isViewJSON, jsonValue, selectedData, selectedDataCleaned, setCopy, t]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { DashboardData } from 'types/api/dashboard/getAll';
|
||||
|
||||
export function downloadObjectAsJson(
|
||||
exportObj: unknown,
|
||||
exportName: string,
|
||||
@ -12,3 +14,18 @@ export function downloadObjectAsJson(
|
||||
downloadAnchorNode.click();
|
||||
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