Skip to content

Commit e5f0bdf

Browse files
Merge pull request #226 from renganathc/feature/db-export-pipeline
feat (db-export): connect collection page to export pipeline
2 parents a743727 + 2b5fe60 commit e5f0bdf

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

apps/web-dashboard/src/components/Database/DatabaseHeader.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22
import {
33
Menu, List as ListIcon, Table as TableIcon, Code,
4-
Filter, RefreshCw, Shield, Plus
4+
Filter, RefreshCw, Shield, Plus, Download
55
} from 'lucide-react';
66
import AiQueryBar from './AiQueryBar';
77

88
const DatabaseHeader = ({
99
project, activeCollection, dataLength, viewMode, setViewMode,
1010
showFilterMenu, setShowFilterMenu, filtersCount,
1111
onRefresh, onRlsClick, onAddRecord, onOpenSidebar,
12-
showDeleted, setShowDeleted, onFiltersGenerated
12+
showDeleted, setShowDeleted, onFiltersGenerated, onExport, isExporting
1313
}) => {
1414
return (
1515
<header className="db-header glass-panel" style={{
@@ -105,6 +105,16 @@ const DatabaseHeader = ({
105105
</button>
106106
)}
107107

108+
109+
{activeCollection?.name !== 'users' && (
110+
<button onClick={onExport} disabled={isExporting} className="btn btn-secondary" style={{ padding: '6px 12px', height: '32px', gap: '6px', fontSize: '0.75rem' }}>
111+
<Download size={14} /> Export
112+
</button>
113+
114+
)}
115+
116+
117+
108118
{activeCollection?.name !== 'users' && (
109119
<button onClick={onAddRecord} className="btn btn-primary" style={{ padding: '6px 12px', height: '32px', gap: '6px', fontSize: '0.75rem' }}>
110120
<Plus size={14} /> Add Record

apps/web-dashboard/src/pages/Database.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ export default function Database() {
170170
}));
171171
};
172172

173+
const [isExporting, setIsExporting] = useState(false);
174+
175+
const handleExportCollection = async () => {
176+
if (!activeCollection || isExporting) return;
177+
setIsExporting(true);
178+
const toastId = toast.loading("Requesting export...");
179+
try {
180+
const res = await api.post(`/api/projects/${projectId}/collections/${activeCollection.name}/export`);
181+
toast.success(res.data.message || "Export initiated! Check your email.", { id: toastId, duration: 6000 });
182+
} catch (err) {
183+
const errMsg = err.response?.data?.message || err.response?.data?.error || "Failed to export collection";
184+
toast.error(errMsg, { id: toastId });
185+
} finally {
186+
setIsExporting(false);
187+
}
188+
};
189+
173190
/**
174191
* Restores a soft-deleted record from the trash for the active collection.
175192
* @param {string} id - The ID of the record to recover.
@@ -253,6 +270,8 @@ export default function Database() {
253270
}
254271
setIsAddModalOpen(true);
255272
}}
273+
onExport={handleExportCollection}
274+
isExporting={isExporting}
256275
onOpenSidebar={() => setIsSidebarOpen(true)}
257276
showDeleted={showDeleted}
258277
setShowDeleted={setShowDeleted}

0 commit comments

Comments
 (0)