From 0545ecf5a8dc493bccb8b46fc13b8cf6db47ad4e Mon Sep 17 00:00:00 2001 From: ic3w0lf Date: Sat, 28 Jun 2025 02:00:50 -0600 Subject: [PATCH 1/4] Remember last tab in comments & audit events, active mapfix, map->mapfix & mapfix->map Closes #144 Closes #205 (hopefully something we can all agree on!) --- .../comments/CommentsAndAuditSection.tsx | 11 +++- web/src/app/_components/review/ReviewItem.tsx | 1 + .../_components/review/ReviewItemHeader.tsx | 19 +++++-- web/src/app/maps/[mapId]/page.tsx | 56 ++++++++++++++++++- 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/web/src/app/_components/comments/CommentsAndAuditSection.tsx b/web/src/app/_components/comments/CommentsAndAuditSection.tsx index 274304b..abe729c 100644 --- a/web/src/app/_components/comments/CommentsAndAuditSection.tsx +++ b/web/src/app/_components/comments/CommentsAndAuditSection.tsx @@ -27,9 +27,18 @@ export default function CommentsAndAuditSection({ userId, }: CommentsAndAuditSectionProps) { - const [activeTab, setActiveTab] = useState(0); + const [activeTab, setActiveTab] = useState(() => { + if (typeof window !== 'undefined') { + const stored = window.localStorage.getItem('commentsAuditActiveTab'); + return stored !== null ? Number(stored) : 0; + } + return 0; + }); const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { setActiveTab(newValue); + if (typeof window !== 'undefined') { + window.localStorage.setItem('commentsAuditActiveTab', String(newValue)); + } }; return ( diff --git a/web/src/app/_components/review/ReviewItem.tsx b/web/src/app/_components/review/ReviewItem.tsx index 1b531e7..1ce1940 100644 --- a/web/src/app/_components/review/ReviewItem.tsx +++ b/web/src/app/_components/review/ReviewItem.tsx @@ -49,6 +49,7 @@ export function ReviewItem({ { +export const ReviewItemHeader = ({ displayName, assetId, statusId, creator, submitterId }: ReviewItemHeaderProps) => { const isProcessing = StatusMatches(statusId, [Status.Validating, Status.Uploading, Status.Submitting]); const pulse = keyframes` 0%, 100% { opacity: 0.2; transform: scale(0.8); } @@ -57,9 +58,19 @@ export const ReviewItemHeader = ({ displayName, statusId, creator, submitterId } return ( <> - - {displayName} by {creator} - + + + + {displayName} by {creator} + + + + {isProcessing && ( ([]); useTitle(map ? `${map.DisplayName}` : 'Loading Map...'); @@ -87,6 +90,24 @@ export default function MapDetails() { getRoles() }, [mapId]); + useEffect(() => { + if (!map) return; + const targetAssetId = map.ID; + async function fetchMapfixes() { + try { + const res = await fetch(`/api/mapfixes?Page=1&Limit=10&TargetAssetID=${targetAssetId}`); + if (!res.ok) return; + const data = await res.json(); + // Filter out rejected, uploading, uploaded (StatusID > 7) + const active = data.Mapfixes.filter((fix: MapfixInfo) => fix.StatusID <= MapfixStatus.Validated); + setMapfixes(active); + } catch { + setMapfixes([]); + } + } + fetchMapfixes(); + }, [map]); + const formatDate = (timestamp: number) => { return new Date(timestamp * 1000).toLocaleDateString('en-US', { year: 'numeric', @@ -361,13 +382,46 @@ export default function MapDetails() { handleCopyId(mapId as string)} - sx={{ ml: 1 }} + sx={{ ml: 1, p: 0 }} > + + {/* Active Mapfix in Map Details */} + {mapfixes.length > 0 && (() => { + const active = mapfixes.find(fix => fix.StatusID <= MapfixStatus.Validated); + const latest = mapfixes.reduce((a, b) => (a.CreatedAt > b.CreatedAt ? a : b)); + const showFix = active || latest; + return ( + + + Active Mapfix + + + + {showFix.Description} + + + + + ); + })()} -- 2.49.1 From ff69c95cd8a748411d521302b8514eafe45a15f2 Mon Sep 17 00:00:00 2001 From: ic3w0lf Date: Sat, 28 Jun 2025 02:55:18 -0600 Subject: [PATCH 2/4] Undo persistent tab --- .../_components/comments/CommentsAndAuditSection.tsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/web/src/app/_components/comments/CommentsAndAuditSection.tsx b/web/src/app/_components/comments/CommentsAndAuditSection.tsx index abe729c..274304b 100644 --- a/web/src/app/_components/comments/CommentsAndAuditSection.tsx +++ b/web/src/app/_components/comments/CommentsAndAuditSection.tsx @@ -27,18 +27,9 @@ export default function CommentsAndAuditSection({ userId, }: CommentsAndAuditSectionProps) { - const [activeTab, setActiveTab] = useState(() => { - if (typeof window !== 'undefined') { - const stored = window.localStorage.getItem('commentsAuditActiveTab'); - return stored !== null ? Number(stored) : 0; - } - return 0; - }); + const [activeTab, setActiveTab] = useState(0); const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { setActiveTab(newValue); - if (typeof window !== 'undefined') { - window.localStorage.setItem('commentsAuditActiveTab', String(newValue)); - } }; return ( -- 2.49.1 From d7f316eca3229148c8333ec0730cd378950f95ac Mon Sep 17 00:00:00 2001 From: ic3w0lf Date: Sat, 28 Jun 2025 03:38:12 -0600 Subject: [PATCH 3/4] No link if no asset id... :smart: --- .../app/_components/review/ReviewItemHeader.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/src/app/_components/review/ReviewItemHeader.tsx b/web/src/app/_components/review/ReviewItemHeader.tsx index 8996d8d..3fd975d 100644 --- a/web/src/app/_components/review/ReviewItemHeader.tsx +++ b/web/src/app/_components/review/ReviewItemHeader.tsx @@ -58,7 +58,8 @@ export const ReviewItemHeader = ({ displayName, assetId, statusId, creator, subm return ( <> - + {assetId != null ? ( + - + + ) : ( + + {displayName} by {creator} + + )} {isProcessing && ( Date: Sat, 28 Jun 2025 13:56:07 -0600 Subject: [PATCH 4/4] Query multiple mapfixes pages --- web/src/app/maps/[mapId]/page.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/src/app/maps/[mapId]/page.tsx b/web/src/app/maps/[mapId]/page.tsx index c2b2cc0..1989152 100644 --- a/web/src/app/maps/[mapId]/page.tsx +++ b/web/src/app/maps/[mapId]/page.tsx @@ -95,11 +95,20 @@ export default function MapDetails() { const targetAssetId = map.ID; async function fetchMapfixes() { try { - const res = await fetch(`/api/mapfixes?Page=1&Limit=10&TargetAssetID=${targetAssetId}`); - if (!res.ok) return; - const data = await res.json(); + const limit = 100; + let page = 1; + let allMapfixes: MapfixInfo[] = []; + let total = 0; + do { + const res = await fetch(`/api/mapfixes?Page=${page}&Limit=${limit}&TargetAssetID=${targetAssetId}`); + if (!res.ok) break; + const data = await res.json(); + if (page === 1) total = data.Total; + allMapfixes = allMapfixes.concat(data.Mapfixes); + page++; + } while (allMapfixes.length < total); // Filter out rejected, uploading, uploaded (StatusID > 7) - const active = data.Mapfixes.filter((fix: MapfixInfo) => fix.StatusID <= MapfixStatus.Validated); + const active = allMapfixes.filter((fix: MapfixInfo) => fix.StatusID <= MapfixStatus.Validated); setMapfixes(active); } catch { setMapfixes([]); -- 2.49.1