feat: seed dashboard, fix My tickets filter

- Add demo dashboard with 7 widgets to seed script
- Dashboard is_default=true — appears as home page on fresh seed
- Add views/dashboards/dashboardWidgets to seed reset
- Fix My tickets: now filters by first non-system user (not any owner)
- Pass owner param in sidebar My tickets link
- Update page.tsx view=my to respect owner URL param
- Scrip engine already sorts by sort_order (verified)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Gjermund Høsøien Wiggen
2026-06-09 13:09:02 +02:00
parent c6c5272e50
commit 6263ce1332
3 changed files with 74 additions and 6 deletions

View File

@@ -409,7 +409,11 @@ function TicketWorkbenchContent() {
return tickets
.filter((ticket) => {
if (view === "my" && !ticket.owner_id) return false;
if (view === "my") {
const myOwner = searchParams.get("owner");
if (myOwner && ticket.owner_id !== myOwner) return false;
if (!myOwner && !ticket.owner_id) return false;
}
if (view === "unassigned" && ticket.owner_id) return false;
if (view === "recent") {
const week = 7 * 24 * 60 * 60 * 1000;

View File

@@ -13,8 +13,8 @@ import {
PanelLeftIcon,
CommandIcon,
} from "lucide-react";
import { getTickets, getQueues, getViews, getDashboards } from "@/lib/api";
import type { Dashboard, Queue, SavedView } from "@/lib/types";
import { getTickets, getQueues, getViews, getDashboards, getUsers } from "@/lib/api";
import type { Dashboard, Queue, SavedView, User } from "@/lib/types";
import { CommandPalette } from "@/components/command-palette";
import { ThemeToggle } from "@/components/theme-toggle";
import { cn } from "@/lib/utils";
@@ -88,15 +88,23 @@ function SidebarNav() {
const [queues, setQueues] = useState<(Queue & { count: number })[]>([]);
const [savedViews, setSavedViews] = useState<SavedView[]>([]);
const [dashboards, setDashboards] = useState<Dashboard[]>([]);
const [currentUserId, setCurrentUserId] = useState<string | null>(null);
useEffect(() => {
getTickets().then(({ data }) => {
// Find current user and compute view counts
Promise.all([getTickets(), getUsers()]).then(([ticketRes, userRes]) => {
const data = ticketRes.data;
const users = userRes.data ?? [];
const currentUser = users.find((u) => u.username !== 'system') ?? users[0] ?? null;
if (currentUser) setCurrentUserId(currentUser.id);
if (data) {
const myId = currentUser?.id;
const now = Date.now();
const week = 7 * 24 * 60 * 60 * 1000;
setCounts({
all: data.length,
my: data.filter((t) => t.owner_id).length,
my: myId ? data.filter((t) => t.owner_id === myId).length : 0,
unassigned: data.filter((t) => !t.owner_id).length,
recent: data.filter(
(t) => new Date(t.updated_at).getTime() > now - week
@@ -139,7 +147,7 @@ function SidebarNav() {
},
{
label: "My tickets",
href: "/?view=my",
href: currentUserId ? `/?view=my&owner=${currentUserId}` : "/?view=my",
param: "my",
count: counts.my,
icon: UserIcon,