Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

perf(bundle-size): move antd-table-saveas-excel out of main bundle (#10229)

Vinicius Lourençodf30852296ef
diff --git a/frontend/src/container/Download/Download.tsx b/frontend/src/container/Download/Download.tsx
index bc475edc4e..4a249b6f70 100644
--- a/frontend/src/container/Download/Download.tsx
+++ b/frontend/src/container/Download/Download.tsx
@@ -1,6 +1,6 @@
+import { useState } from 'react';
import { CloudDownloadOutlined } from '@ant-design/icons';
import { Button, Dropdown, MenuProps } from 'antd';
-import { Excel } from 'antd-table-saveas-excel';
import { unparse } from 'papaparse';
import { DownloadProps } from './Download.types';
@@ -8,25 +8,36 @@ import { DownloadProps } from './Download.types';
import './Download.styles.scss';
function Download({ data, isLoading, fileName }: DownloadProps): JSX.Element {
- const downloadExcelFile = (): void => {
- const headers = Object.keys(Object.assign({}, ...data)).map((item) => {
- const updatedTitle = item
- .split('_')
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(' ');
- return {
- title: updatedTitle,
- dataIndex: item,
- };
- });
- const excel = new Excel();
- excel
- .addSheet(fileName)
- .addColumns(headers)
- .addDataSource(data, {
- str2Percent: true,
- })
- .saveAs(`${fileName}.xlsx`);
+ const [isDownloading, setIsDownloading] = useState(false);
+
+ const downloadExcelFile = async (): Promise<void> => {
+ setIsDownloading(true);
+
+ try {
+ const headers = Object.keys(Object.assign({}, ...data)).map((item) => {
+ const updatedTitle = item
+ .split('_')
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(' ');
+ return {
+ title: updatedTitle,
+ dataIndex: item,
+ };
+ });
+
+ const excelLib = await import('antd-table-saveas-excel');
+
+ const excel = new excelLib.Excel();
+ excel
+ .addSheet(fileName)
+ .addColumns(headers)
+ .addDataSource(data, {
+ str2Percent: true,
+ })
+ .saveAs(`${fileName}.xlsx`);
+ } finally {
+ setIsDownloading(false);
+ }
};
const downloadCsvFile = (): void => {
@@ -59,7 +70,7 @@ function Download({ data, isLoading, fileName }: DownloadProps): JSX.Element {
<Dropdown menu={menu} trigger={['click']}>
<Button
className="download-button"
- loading={isLoading}
+ loading={isLoading || isDownloading}
size="small"
type="link"
>
diff --git a/frontend/src/container/DownloadV2/DownloadV2.tsx b/frontend/src/container/DownloadV2/DownloadV2.tsx
index b1847a60a8..14fefbc6f8 100644
--- a/frontend/src/container/DownloadV2/DownloadV2.tsx
+++ b/frontend/src/container/DownloadV2/DownloadV2.tsx
@@ -1,5 +1,5 @@
+import { useState } from 'react';
import { Button, Popover, Typography } from 'antd';
-import { Excel } from 'antd-table-saveas-excel';
import { FileDigit, FileDown, Sheet } from 'lucide-react';
import { unparse } from 'papaparse';
@@ -8,25 +8,34 @@ import { DownloadProps } from './DownloadV2.types';
import './DownloadV2.styles.scss';
function Download({ data, isLoading, fileName }: DownloadProps): JSX.Element {
- const downloadExcelFile = (): void => {
- const headers = Object.keys(Object.assign({}, ...data)).map((item) => {
- const updatedTitle = item
- .split('_')
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(' ');
- return {
- title: updatedTitle,
- dataIndex: item,
- };
- });
- const excel = new Excel();
- excel
- .addSheet(fileName)
- .addColumns(headers)
- .addDataSource(data, {
- str2Percent: true,
- })
- .saveAs(`${fileName}.xlsx`);
+ const [isDownloading, setIsDownloading] = useState(false);
+
+ const downloadExcelFile = async (): Promise<void> => {
+ setIsDownloading(true);
+
+ try {
+ const headers = Object.keys(Object.assign({}, ...data)).map((item) => {
+ const updatedTitle = item
+ .split('_')
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(' ');
+ return {
+ title: updatedTitle,
+ dataIndex: item,
+ };
+ });
+ const excelLib = await import('antd-table-saveas-excel');
+ const excel = new excelLib.Excel();
+ excel
+ .addSheet(fileName)
+ .addColumns(headers)
+ .addDataSource(data, {
+ str2Percent: true,
+ })
+ .saveAs(`${fileName}.xlsx`);
+ } finally {
+ setIsDownloading(false);
+ }
};
const downloadCsvFile = (): void => {
@@ -54,6 +63,7 @@ function Download({ data, isLoading, fileName }: DownloadProps): JSX.Element {
type="text"
onClick={downloadExcelFile}
className="action-btns"
+ loading={isDownloading}
>
Excel (.xlsx)
</Button>