From 6e04c4d406b3b34e0890c54e6b93474d492ff320 Mon Sep 17 00:00:00 2001 From: alphaeusmote <41258468-alphaeusmote@users.noreply.replit.com> Date: Thu, 10 Apr 2025 01:02:19 +0000 Subject: [PATCH] Add back button and dashboard deletion functionality to the dashboards page. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/5ff33261-9188-4a99-be1b-f873128aabab.jpg --- client/src/pages/dashboard-page.tsx | 131 +++++++++++++++++++++++----- 1 file changed, 109 insertions(+), 22 deletions(-) diff --git a/client/src/pages/dashboard-page.tsx b/client/src/pages/dashboard-page.tsx index dae72b6..0ae43d8 100644 --- a/client/src/pages/dashboard-page.tsx +++ b/client/src/pages/dashboard-page.tsx @@ -1,11 +1,12 @@ import { useState, useEffect } from "react"; import { useQuery } from "@tanstack/react-query"; import { useToast } from "@/hooks/use-toast"; +import { useLocation } from "wouter"; import { DashboardLayout, DashboardConfig } from "@/components/dashboard/dashboard-layout"; import { ShareDashboardDialog } from "@/components/dashboard/share-dashboard-dialog"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Button } from "@/components/ui/button"; -import { Plus, RefreshCw, Share2 } from "lucide-react"; +import { Plus, RefreshCw, Share2, Trash2, ArrowLeft } from "lucide-react"; import { Dialog, DialogContent, @@ -14,6 +15,16 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; import { Form, FormControl, @@ -37,9 +48,12 @@ type DashboardFormValues = z.infer; export default function DashboardPage() { const { toast } = useToast(); + const [, setLocation] = useLocation(); const [dashboards, setDashboards] = useState([]); const [activeTab, setActiveTab] = useState("dashboard-overview"); const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false); + const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); + const [dashboardToDelete, setDashboardToDelete] = useState(null); const [dataSourcesLoading, setDataSourcesLoading] = useState(true); const [dataSources, setDataSources] = useState { + setDashboardToDelete(dashboardId); + setDeleteDialogOpen(true); + }; + + // Execute deletion when confirmed + const executeDelete = () => { + if (dashboardToDelete) { + handleDeleteDashboard(dashboardToDelete); + setDeleteDialogOpen(false); + setDashboardToDelete(null); + } + }; + return (
-

Dashboards

- +
+ +

Dashboards

+
+
+ {dashboards.length > 0 && activeTab !== "dashboard-overview" && ( + + )} + +
@@ -364,22 +416,33 @@ export default function DashboardPage() { ))} - {dashboards.map((dashboard) => ( - - {dataSourcesLoading ? ( -
- - Loading data sources... -
- ) : ( - - )} -
- ))} + {dashboards.length === 0 ? ( +
+

No Dashboards Created

+

Create your first dashboard to start visualizing data

+ +
+ ) : ( + dashboards.map((dashboard) => ( + + {dataSourcesLoading ? ( +
+ + Loading data sources... +
+ ) : ( + + )} +
+ )) + )}
{/* Create Dashboard Dialog */} @@ -420,6 +483,30 @@ export default function DashboardPage() { + + {/* Delete Dashboard Confirmation */} + + + + Are you sure? + + This action cannot be undone. This will permanently delete the dashboard + and all its widgets. + + + + setDashboardToDelete(null)}> + Cancel + + + Delete + + + +
); } \ No newline at end of file