FIX: Exported dashboard include response of the queries #1981 (#2052)

* clear the queryData
* avoid creation of inline func and move logic to utils
* remove console.log
* fix
This commit is contained in:
Fellipe Montes 2023-01-30 07:37:23 -03:00 committed by GitHub
parent ed4a01dea6
commit b72815ca2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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: [],
},
},
})),
};
}