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,
|
||||
getRuntimeActivity,
|
||||
} from "../../lib/api";
|
||||
import { getErrorMessage } from "../../lib/errors";
|
||||
import type {
|
||||
Project,
|
||||
WatchedTracker,
|
||||
|
|
@ -70,6 +71,7 @@ export default function ProjectDashboard() {
|
|||
const [activePolls, setActivePolls] = useState<Record<string, string>>({});
|
||||
const [activeAgents, setActiveAgents] = useState<Record<string, string>>({});
|
||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
||||
function appendActivity(level: ActivityLevel, message: string) {
|
||||
const item: ActivityItem = {
|
||||
|
|
@ -84,6 +86,7 @@ export default function ProjectDashboard() {
|
|||
|
||||
const loadData = useCallback(async () => {
|
||||
if (!projectId) return;
|
||||
try {
|
||||
const [proj, trks, tkts, stats] = await Promise.all([
|
||||
getProject(projectId),
|
||||
listTrackers(projectId),
|
||||
|
|
@ -94,6 +97,12 @@ export default function ProjectDashboard() {
|
|||
setTrackers(trks);
|
||||
setTickets(tkts);
|
||||
setThroughput(stats);
|
||||
setLoadError("");
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
setLoadError(message);
|
||||
console.error("Failed to load project dashboard data", error);
|
||||
}
|
||||
}, [projectId]);
|
||||
|
||||
const syncRuntimeActivity = useCallback(async () => {
|
||||
|
|
@ -388,12 +397,14 @@ export default function ProjectDashboard() {
|
|||
}
|
||||
|
||||
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]
|
||||
.sort((a, b) => Date.parse(b.detected_at) - Date.parse(a.detected_at))
|
||||
.slice(0, 10);
|
||||
const recentTickets = tickets.slice(0, 10);
|
||||
const activePollList = Object.entries(activePolls);
|
||||
const activeAgentList = Object.values(activeAgents);
|
||||
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>
|
||||
<button
|
||||
onClick={() => navigate(`/projects/${ticket.project_id}`)}
|
||||
onClick={() => navigate(`/projects/${ticket.project_id}/tickets`)}
|
||||
className={buttonClass({ variant: "ghost", size: "xs" })}
|
||||
>
|
||||
Back
|
||||
|
|
|
|||
Loading…
Reference in a new issue