diff --git a/apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/playground/page-client.tsx b/apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/playground/page-client.tsx index 209ae95a0..5b07ca97d 100644 --- a/apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/playground/page-client.tsx +++ b/apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/playground/page-client.tsx @@ -933,6 +933,14 @@ export default function PageClient() { selectionMode={dgSelectionMode} rowHeight={dgRowHeight} toolbar={dgShowToolbar ? undefined : false} + exportOptions={{ + title: "Export users", + description: "Configure and download user data from this grid.", + entityName: "user", + entityNamePlural: "users", + filenamePrefix: "playground-users", + fetchRows: () => Promise.resolve(DEMO_GRID_USERS), + }} maxHeight={400} /> @@ -2318,6 +2326,12 @@ export default function PageClient() { selectionMode="${dgSelectionMode}" rowHeight={${dgRowHeight}} toolbar={${dgShowToolbar ? "undefined" : "false"}} + exportOptions={{ + title: "Export users", + entityName: "user", + entityNamePlural: "users", + filenamePrefix: "users", + }} maxHeight={400} />`; } diff --git a/packages/dashboard-ui-components/src/components/data-grid/data-grid-export-dialog.tsx b/packages/dashboard-ui-components/src/components/data-grid/data-grid-export-dialog.tsx index 249b158a7..fa03f9bef 100644 --- a/packages/dashboard-ui-components/src/components/data-grid/data-grid-export-dialog.tsx +++ b/packages/dashboard-ui-components/src/components/data-grid/data-grid-export-dialog.tsx @@ -1,10 +1,14 @@ "use client"; import { DownloadSimpleIcon } from "@phosphor-icons/react"; +import { Checkbox, cn } from "@hexclave/ui"; import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { DesignAlert } from "../alert"; import { DesignButton } from "../button"; import { DesignDialog } from "../dialog"; +import { DesignPillToggle } from "../pill-toggle"; +import { DesignProgressBar } from "../progress-bar"; import { formatGridDate, resolveColumnValue } from "./state"; import type { DataGridColumnDef, @@ -185,16 +189,32 @@ export function DataGridExportDialog({ } }; + const footer = isExporting ? ( + + Cancel + + ) : ( + <> + + Cancel + + + + Export {titleCase(entityNamePlural)} + + + ); + return ( {isExporting ? ( ({ subjectLabel={progressSubjectLabel} /> ) : ( -
-
- - +
+
+ Format + setFormat(id === "json" ? "json" : "csv")} + size="sm" + gradient="default" + glassmorphic={false} + />
{hasServerExport ? ( -
- Export Scope - - -
+
+ Scope +
+ setScope("all")} + > + {allScopeLabel} + + setScope("filtered")} + > + {filteredScopeLabel} + +
+
) : null} -
-
- -
- - Select All +
+
+ Fields +
+ + Select all - - Deselect All + + Clear
-
+
{fields.map((field) => ( - ))}
{errorMessage != null ? ( -
-
{exportOptions?.emptyExportTitle ?? "Export unavailable"}
-
{errorMessage}
-
+ ) : null} - -
- - Cancel - - - - Export {titleCase(entityNamePlural)} - -
)} ); } +function ScopeOption({ + selected, + onSelect, + children, +}: { + selected: boolean, + onSelect: () => void, + children: React.ReactNode, +}) { + return ( + + ); +} + function ExportProgressContent(props: { progress: ExportProgress; format: DataGridExportFormat; @@ -311,39 +352,32 @@ function ExportProgressContent(props: { ? `Preparing ${fileLabel}` : `Fetching ${subjectLabel}`; const countLabel = `${progress.fetched.toLocaleString()} ${isComplete ? "exported" : "fetched"}`; + const progressValue = isComplete ? 100 : progress.phase === "generating" ? 72 : 36; return ( -
-
-

{title}

-

{description}

-
- -
+
+
{statusLabel} {countLabel}
-
- {isComplete ? ( -
- ) : ( -
- )} -
+ +

{description}

-
- Do not reload this page until the export finishes. The download will start automatically. -
- -
- - Cancel - -
+
); }