fix(ui): harden ticket detail back navigation workflow
This commit is contained in:
parent
f55977e215
commit
64c1dd1789
2 changed files with 26 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ import {
|
||||||
getProjectThroughput,
|
getProjectThroughput,
|
||||||
getRuntimeActivity,
|
getRuntimeActivity,
|
||||||
} from "../../lib/api";
|
} from "../../lib/api";
|
||||||
|
import { getErrorMessage } from "../../lib/errors";
|
||||||
import type {
|
import type {
|
||||||
Project,
|
Project,
|
||||||
WatchedTracker,
|
WatchedTracker,
|
||||||
|
|
@ -70,6 +71,7 @@ export default function ProjectDashboard() {
|
||||||
const [activePolls, setActivePolls] = useState<Record<string, string>>({});
|
const [activePolls, setActivePolls] = useState<Record<string, string>>({});
|
||||||
const [activeAgents, setActiveAgents] = useState<Record<string, string>>({});
|
const [activeAgents, setActiveAgents] = useState<Record<string, string>>({});
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
|
const [loadError, setLoadError] = useState("");
|
||||||
|
|
||||||
function appendActivity(level: ActivityLevel, message: string) {
|
function appendActivity(level: ActivityLevel, message: string) {
|
||||||
const item: ActivityItem = {
|
const item: ActivityItem = {
|
||||||
|
|
@ -84,16 +86,23 @@ export default function ProjectDashboard() {
|
||||||
|
|
||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async () => {
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
const [proj, trks, tkts, stats] = await Promise.all([
|
try {
|
||||||
getProject(projectId),
|
const [proj, trks, tkts, stats] = await Promise.all([
|
||||||
listTrackers(projectId),
|
getProject(projectId),
|
||||||
listProcessedTickets(projectId),
|
listTrackers(projectId),
|
||||||
getProjectThroughput(projectId),
|
listProcessedTickets(projectId),
|
||||||
]);
|
getProjectThroughput(projectId),
|
||||||
setProject(proj);
|
]);
|
||||||
setTrackers(trks);
|
setProject(proj);
|
||||||
setTickets(tkts);
|
setTrackers(trks);
|
||||||
setThroughput(stats);
|
setTickets(tkts);
|
||||||
|
setThroughput(stats);
|
||||||
|
setLoadError("");
|
||||||
|
} catch (error) {
|
||||||
|
const message = getErrorMessage(error);
|
||||||
|
setLoadError(message);
|
||||||
|
console.error("Failed to load project dashboard data", error);
|
||||||
|
}
|
||||||
}, [projectId]);
|
}, [projectId]);
|
||||||
|
|
||||||
const syncRuntimeActivity = useCallback(async () => {
|
const syncRuntimeActivity = useCallback(async () => {
|
||||||
|
|
@ -388,12 +397,14 @@ export default function ProjectDashboard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!project) {
|
if (!project) {
|
||||||
return <div className="p-8 text-gray-400">Loading...</div>;
|
return (
|
||||||
|
<div className="p-8 text-gray-400">
|
||||||
|
{loadError ? `Unable to load project: ${loadError}` : "Loading..."}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentTickets = [...tickets]
|
const recentTickets = tickets.slice(0, 10);
|
||||||
.sort((a, b) => Date.parse(b.detected_at) - Date.parse(a.detected_at))
|
|
||||||
.slice(0, 10);
|
|
||||||
const activePollList = Object.entries(activePolls);
|
const activePollList = Object.entries(activePolls);
|
||||||
const activeAgentList = Object.values(activeAgents);
|
const activeAgentList = Object.values(activeAgents);
|
||||||
const done24h = throughput?.done_last_24h ?? 0;
|
const done24h = throughput?.done_last_24h ?? 0;
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ export default function TicketDetail() {
|
||||||
<div className="mb-6 flex items-center justify-between">
|
<div className="mb-6 flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(`/projects/${ticket.project_id}`)}
|
onClick={() => navigate(`/projects/${ticket.project_id}/tickets`)}
|
||||||
className={buttonClass({ variant: "ghost", size: "xs" })}
|
className={buttonClass({ variant: "ghost", size: "xs" })}
|
||||||
>
|
>
|
||||||
Back
|
Back
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue