Skip to content

Commit 6fca7f8

Browse files
committed
feat(admin/overview): collapse Needs Attention + Credentials lists by default
Both sections rendered every entry. With 18+ attention items and 10+ credential warnings on a half-configured deployment the page was a wall of yellow/red alerts you had to scroll past to reach Quick Actions. Show only the first 3 entries in each section by default and add a "Show N more" toggle (collapses back to "Show less"). Initial render is now 6 entries max across both sections; the rest is one click away. The credentials section's earlier hard cap of 6 is dropped — expanded state shows the full list.
1 parent 3dab818 commit 6fca7f8

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

apps/web/src/components/admin/overview/AdminOverview.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Tooltip from "@mui/material/Tooltip";
2525
import Typography from "@mui/material/Typography";
2626
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
2727
import Link from "next/link";
28+
import { useState } from "react";
2829
import { useEnv } from "@/lib/EnvProvider";
2930
import { useAdminToast } from "../shared/AdminToast";
3031

@@ -151,11 +152,18 @@ function jobStatusColor(status: string): "default" | "success" | "error" | "warn
151152

152153
// Main
153154

155+
// Collapsed list size for the Needs Attention + Credentials Overview
156+
// sections — the page becomes scroll-bound at scale, so we hide the rest
157+
// behind a "Show N more" toggle.
158+
const COLLAPSED_LIST_LIMIT = 3;
159+
154160
export function AdminOverview() {
155161
const env = useEnv();
156162
const apiUrl = env.apiUrl;
157163
const qc = useQueryClient();
158164
const showToast = useAdminToast();
165+
const [attentionExpanded, setAttentionExpanded] = useState(false);
166+
const [credentialsExpanded, setCredentialsExpanded] = useState(false);
159167

160168
const { data, isLoading } = useQuery<OverviewData>({
161169
queryKey: ["admin", "overview"],
@@ -406,7 +414,10 @@ export function AdminOverview() {
406414
Needs Attention
407415
</Typography>
408416
<Stack gap={1}>
409-
{data.attention.map((item) => (
417+
{(attentionExpanded
418+
? data.attention
419+
: data.attention.slice(0, COLLAPSED_LIST_LIMIT)
420+
).map((item) => (
410421
<Alert
411422
key={`${item.type}-${item.message}`}
412423
severity={item.severity}
@@ -421,6 +432,17 @@ export function AdminOverview() {
421432
{item.message}
422433
</Alert>
423434
))}
435+
{data.attention.length > COLLAPSED_LIST_LIMIT && (
436+
<Button
437+
size="small"
438+
onClick={() => setAttentionExpanded((v) => !v)}
439+
sx={{ alignSelf: "flex-start" }}
440+
>
441+
{attentionExpanded
442+
? "Show less"
443+
: `Show ${data.attention.length - COLLAPSED_LIST_LIMIT} more`}
444+
</Button>
445+
)}
424446
</Stack>
425447
</Box>
426448
)}
@@ -448,7 +470,10 @@ export function AdminOverview() {
448470
</Alert>
449471
) : (
450472
<Stack gap={1}>
451-
{missingCredentialIntegrations.slice(0, 6).map((entry) => (
473+
{(credentialsExpanded
474+
? missingCredentialIntegrations
475+
: missingCredentialIntegrations.slice(0, COLLAPSED_LIST_LIMIT)
476+
).map((entry) => (
452477
<Alert
453478
key={entry.integrationId}
454479
severity="warning"
@@ -468,6 +493,17 @@ export function AdminOverview() {
468493
{entry.missingCredentials === 1 ? "" : "s"}
469494
</Alert>
470495
))}
496+
{missingCredentialIntegrations.length > COLLAPSED_LIST_LIMIT && (
497+
<Button
498+
size="small"
499+
onClick={() => setCredentialsExpanded((v) => !v)}
500+
sx={{ alignSelf: "flex-start" }}
501+
>
502+
{credentialsExpanded
503+
? "Show less"
504+
: `Show ${missingCredentialIntegrations.length - COLLAPSED_LIST_LIMIT} more`}
505+
</Button>
506+
)}
471507
</Stack>
472508
)}
473509
</Box>

0 commit comments

Comments
 (0)