anton-bakker-feedback 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/admin/FeedbackDetailPage.d.ts +7 -25
- package/dist/react/admin/FeedbackDetailPage.d.ts.map +1 -1
- package/dist/react/admin/FeedbackListPage.d.ts +20 -0
- package/dist/react/admin/FeedbackListPage.d.ts.map +1 -0
- package/dist/react/admin/FeedbackUpdatePage.d.ts +8 -30
- package/dist/react/admin/FeedbackUpdatePage.d.ts.map +1 -1
- package/dist/react/admin/__tests__/FeedbackListPage.test.d.ts.map +1 -0
- package/dist/react/admin/index.d.ts +3 -2
- package/dist/react/admin/index.d.ts.map +1 -1
- package/dist/react/admin/index.js +352 -1259
- package/dist/react/admin/index.js.map +1 -1
- package/dist/react/admin/types.d.ts +20 -14
- package/dist/react/admin/types.d.ts.map +1 -1
- package/dist/react.js +6 -6
- package/dist/react.js.map +1 -1
- package/package.json +7 -1
- package/dist/react/admin/__tests__/FeedbackUpdatePage.integration.test.d.ts +0 -2
- package/dist/react/admin/__tests__/FeedbackUpdatePage.integration.test.d.ts.map +0 -1
- package/dist/react/admin/components/BrowserContext.d.ts +0 -32
- package/dist/react/admin/components/BrowserContext.d.ts.map +0 -1
- package/dist/react/admin/components/DataTable.d.ts +0 -55
- package/dist/react/admin/components/DataTable.d.ts.map +0 -1
- package/dist/react/admin/components/DialogueHistory.d.ts +0 -27
- package/dist/react/admin/components/DialogueHistory.d.ts.map +0 -1
- package/dist/react/admin/components/EditableFields.d.ts +0 -126
- package/dist/react/admin/components/EditableFields.d.ts.map +0 -1
- package/dist/react/admin/components/FeedbackListPage.d.ts +0 -19
- package/dist/react/admin/components/FeedbackListPage.d.ts.map +0 -1
- package/dist/react/admin/components/FeedbackListPage.test.d.ts.map +0 -1
- package/dist/react/admin/components/FilterControls.d.ts +0 -28
- package/dist/react/admin/components/FilterControls.d.ts.map +0 -1
- package/dist/react/admin/components/NavigationLink.d.ts +0 -31
- package/dist/react/admin/components/NavigationLink.d.ts.map +0 -1
- package/dist/react/admin/components/QuickActions.d.ts +0 -43
- package/dist/react/admin/components/QuickActions.d.ts.map +0 -1
- package/dist/react/admin/components/ScreenshotViewer.d.ts +0 -38
- package/dist/react/admin/components/ScreenshotViewer.d.ts.map +0 -1
- package/dist/react/admin/components/SortControls.d.ts +0 -29
- package/dist/react/admin/components/SortControls.d.ts.map +0 -1
- package/dist/react/admin/components/StatusBadge.d.ts +0 -23
- package/dist/react/admin/components/StatusBadge.d.ts.map +0 -1
- package/dist/react/admin/components/TypeBadge.d.ts +0 -23
- package/dist/react/admin/components/TypeBadge.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/BrowserContext.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/BrowserContext.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/DialogueHistory.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/DialogueHistory.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/EditableFields.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/EditableFields.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/QuickActions.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/QuickActions.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/ScreenshotViewer.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/ScreenshotViewer.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/badges.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/badges.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/controls.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/controls.test.d.ts.map +0 -1
- package/dist/react/admin/components/__tests__/table-navigation.test.d.ts +0 -2
- package/dist/react/admin/components/__tests__/table-navigation.test.d.ts.map +0 -1
- package/dist/react/admin/components/index.d.ts +0 -13
- package/dist/react/admin/components/index.d.ts.map +0 -1
- package/dist/react/admin/hooks/useFeedbackFilters.d.ts +0 -31
- package/dist/react/admin/hooks/useFeedbackFilters.d.ts.map +0 -1
- package/dist/react/admin/hooks/useFeedbackSort.d.ts +0 -42
- package/dist/react/admin/hooks/useFeedbackSort.d.ts.map +0 -1
- /package/dist/react/admin/{components → __tests__}/FeedbackListPage.test.d.ts +0 -0
|
@@ -1,1313 +1,406 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ListPage, Badge, DetailPage, Button, DetailSection, DetailRow, UpdatePage, EnumField, TextField, TextareaField, SaveFooter } from "anton-bakker-tailwind-components";
|
|
4
|
+
const STATUS_VARIANT = {
|
|
5
|
+
open: "warning",
|
|
6
|
+
approved: "default",
|
|
7
|
+
deferred: "secondary",
|
|
8
|
+
resolved: "success",
|
|
9
|
+
wontfix: "destructive"
|
|
7
10
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const clearFilters = useCallback(() => {
|
|
14
|
-
setFiltersState(DEFAULT_FILTERS);
|
|
15
|
-
}, []);
|
|
16
|
-
const applyFilters = useCallback(
|
|
17
|
-
(items) => {
|
|
18
|
-
return items.filter((item) => {
|
|
19
|
-
if (filters.status !== "" && item.status !== filters.status) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (filters.type !== "" && item.type !== filters.type) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
if (filters.environment !== "" && item.environment !== filters.environment) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
[filters]
|
|
32
|
-
);
|
|
33
|
-
return { filters, setFilters, clearFilters, applyFilters };
|
|
34
|
-
}
|
|
35
|
-
const DEFAULT_SORT = {
|
|
36
|
-
field: "priority",
|
|
37
|
-
direction: "desc"
|
|
11
|
+
const TYPE_VARIANT = {
|
|
12
|
+
bug: "destructive",
|
|
13
|
+
feature: "default",
|
|
14
|
+
ux: "warning",
|
|
15
|
+
other: "secondary"
|
|
38
16
|
};
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
const strB = b ?? "";
|
|
42
|
-
const cmp = strA.localeCompare(strB);
|
|
43
|
-
return direction === "asc" ? cmp : -cmp;
|
|
17
|
+
function StatusBadge({ status }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(Badge, { variant: STATUS_VARIANT[status] ?? "secondary", children: status });
|
|
44
19
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
const numB = b ?? 0;
|
|
48
|
-
const cmp = numA - numB;
|
|
49
|
-
return direction === "asc" ? cmp : -cmp;
|
|
20
|
+
function TypeBadge({ type }) {
|
|
21
|
+
return /* @__PURE__ */ jsx(Badge, { variant: TYPE_VARIANT[type] ?? "secondary", children: type });
|
|
50
22
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
23
|
+
const FeedbackListPage = React.forwardRef(
|
|
24
|
+
({ items, loading = false, onNavigate, className, emptyStateMessage, currentUser, ...rest }, ref) => {
|
|
25
|
+
const [search, setSearch] = React.useState("");
|
|
26
|
+
const [statusFilter, setStatusFilter] = React.useState("");
|
|
27
|
+
const [typeFilter, setTypeFilter] = React.useState("");
|
|
28
|
+
const filteredItems = React.useMemo(() => {
|
|
29
|
+
let result = items;
|
|
30
|
+
if (statusFilter) result = result.filter((i) => i.status === statusFilter);
|
|
31
|
+
if (typeFilter) result = result.filter((i) => i.type === typeFilter);
|
|
32
|
+
if (search) {
|
|
33
|
+
const q = search.toLowerCase();
|
|
34
|
+
result = result.filter((i) => i.content?.toLowerCase().includes(q) || i.id.toLowerCase().includes(q));
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}, [items, statusFilter, typeFilter, search]);
|
|
38
|
+
const columns = React.useMemo(() => [
|
|
39
|
+
{ header: "Content", accessor: (row) => row.content?.slice(0, 60) || row.id, sortable: true },
|
|
40
|
+
{ header: "Type", accessor: (row) => /* @__PURE__ */ jsx(TypeBadge, { type: row.type }), sortable: true },
|
|
41
|
+
{ header: "Status", accessor: (row) => /* @__PURE__ */ jsx(StatusBadge, { status: row.status }), sortable: true },
|
|
42
|
+
{ header: "Priority", accessor: "priority", sortable: true },
|
|
43
|
+
{ header: "Reporters", accessor: "reporterCount", sortable: true },
|
|
44
|
+
{
|
|
45
|
+
header: "Date",
|
|
46
|
+
accessor: (row) => row.submittedAt ? new Date(row.submittedAt).toLocaleDateString() : "—",
|
|
47
|
+
sortable: true
|
|
48
|
+
}
|
|
49
|
+
], []);
|
|
50
|
+
const filterBar = statusFilter || typeFilter ? {
|
|
51
|
+
filters: [
|
|
52
|
+
...statusFilter ? [{ field: "status", label: `Status: ${statusFilter}`, value: statusFilter }] : [],
|
|
53
|
+
...typeFilter ? [{ field: "type", label: `Type: ${typeFilter}`, value: typeFilter }] : []
|
|
54
|
+
],
|
|
55
|
+
onFilterRemove: (field) => {
|
|
56
|
+
if (field === "status") setStatusFilter("");
|
|
57
|
+
if (field === "type") setTypeFilter("");
|
|
58
|
+
},
|
|
59
|
+
onFiltersClear: () => {
|
|
60
|
+
setStatusFilter("");
|
|
61
|
+
setTypeFilter("");
|
|
62
|
+
}
|
|
63
|
+
} : void 0;
|
|
64
|
+
const headerActions = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
65
|
+
/* @__PURE__ */ jsxs(
|
|
66
|
+
"select",
|
|
67
|
+
{
|
|
68
|
+
value: statusFilter,
|
|
69
|
+
onChange: (e) => setStatusFilter(e.target.value),
|
|
70
|
+
className: "h-8 rounded-md border border-border bg-transparent px-2 text-sm",
|
|
71
|
+
"aria-label": "Filter by status",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "All statuses" }),
|
|
74
|
+
/* @__PURE__ */ jsx("option", { value: "open", children: "Open" }),
|
|
75
|
+
/* @__PURE__ */ jsx("option", { value: "approved", children: "Approved" }),
|
|
76
|
+
/* @__PURE__ */ jsx("option", { value: "deferred", children: "Deferred" }),
|
|
77
|
+
/* @__PURE__ */ jsx("option", { value: "resolved", children: "Resolved" }),
|
|
78
|
+
/* @__PURE__ */ jsx("option", { value: "wontfix", children: "Won't fix" })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ jsxs(
|
|
83
|
+
"select",
|
|
84
|
+
{
|
|
85
|
+
value: typeFilter,
|
|
86
|
+
onChange: (e) => setTypeFilter(e.target.value),
|
|
87
|
+
className: "h-8 rounded-md border border-border bg-transparent px-2 text-sm",
|
|
88
|
+
"aria-label": "Filter by type",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "All types" }),
|
|
91
|
+
/* @__PURE__ */ jsx("option", { value: "bug", children: "Bug" }),
|
|
92
|
+
/* @__PURE__ */ jsx("option", { value: "feature", children: "Feature" }),
|
|
93
|
+
/* @__PURE__ */ jsx("option", { value: "ux", children: "UX" }),
|
|
94
|
+
/* @__PURE__ */ jsx("option", { value: "other", children: "Other" })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] });
|
|
99
|
+
const listProps = {
|
|
100
|
+
title: "Feedback",
|
|
101
|
+
columns,
|
|
102
|
+
items: filteredItems,
|
|
103
|
+
loading,
|
|
104
|
+
onRowClick: (row) => onNavigate(`/feedback/${row.id}`),
|
|
105
|
+
search,
|
|
106
|
+
onSearchChange: setSearch,
|
|
107
|
+
searchPlaceholder: "Search feedback...",
|
|
108
|
+
headerActions,
|
|
109
|
+
testId: "feedback-list-page",
|
|
110
|
+
...filterBar ? { filterBar } : {},
|
|
111
|
+
...emptyStateMessage ? { emptyState: emptyStateMessage } : {},
|
|
112
|
+
...className ? { className } : {}
|
|
113
|
+
};
|
|
114
|
+
return /* @__PURE__ */ jsx(ListPage, { ref, ...listProps });
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
FeedbackListPage.displayName = "FeedbackListPage";
|
|
118
|
+
const FeedbackDetailPage = React.forwardRef(
|
|
119
|
+
({ feedbackId, fetchItem, onNavigate, currentUser, className }, ref) => {
|
|
120
|
+
const [item, setItem] = React.useState(null);
|
|
121
|
+
const [loading, setLoading] = React.useState(true);
|
|
122
|
+
const [error, setError] = React.useState(null);
|
|
123
|
+
React.useEffect(() => {
|
|
124
|
+
let cancelled = false;
|
|
125
|
+
setLoading(true);
|
|
126
|
+
setError(null);
|
|
127
|
+
fetchItem(feedbackId).then((data) => {
|
|
128
|
+
if (!cancelled) setItem(data);
|
|
129
|
+
}).catch((err) => {
|
|
130
|
+
if (!cancelled) setError(err?.message ?? "Failed to load item");
|
|
131
|
+
}).finally(() => {
|
|
132
|
+
if (!cancelled) setLoading(false);
|
|
133
|
+
});
|
|
134
|
+
return () => {
|
|
135
|
+
cancelled = true;
|
|
136
|
+
};
|
|
137
|
+
}, [feedbackId, fetchItem]);
|
|
138
|
+
if (error) {
|
|
139
|
+
return /* @__PURE__ */ jsx("div", { ref, className, children: /* @__PURE__ */ jsx(DetailPage, { title: "Feedback", headerActions: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onNavigate("/feedback"), children: "Back to list" }), children: /* @__PURE__ */ jsx("div", { className: "p-6 text-destructive", children: error }) }) });
|
|
73
140
|
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
const headerActions = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
142
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onNavigate("/feedback"), children: "Back to list" }),
|
|
143
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => onNavigate(`/feedback/${feedbackId}/edit`), children: "Edit" })
|
|
144
|
+
] });
|
|
145
|
+
return /* @__PURE__ */ jsx("div", { ref, className, children: /* @__PURE__ */ jsx(
|
|
146
|
+
DetailPage,
|
|
147
|
+
{
|
|
148
|
+
title: item?.content?.slice(0, 50) || `Feedback ${feedbackId.slice(0, 12)}…`,
|
|
149
|
+
headerActions,
|
|
150
|
+
loading,
|
|
151
|
+
testId: "feedback-detail-page",
|
|
152
|
+
children: item && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
153
|
+
/* @__PURE__ */ jsxs(DetailSection, { title: "Overview", children: [
|
|
154
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Status", children: /* @__PURE__ */ jsx(StatusBadge, { status: item.status }) }),
|
|
155
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Type", children: /* @__PURE__ */ jsx(TypeBadge, { type: item.type }) }),
|
|
156
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Priority", children: item.priority }),
|
|
157
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Environment", children: item.environment || "—" }),
|
|
158
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Submitted", children: item.submittedAt ? new Date(item.submittedAt).toLocaleString() : "—" }),
|
|
159
|
+
/* @__PURE__ */ jsx(DetailRow, { label: "Reporters", children: item.reporterCount ?? 1 }),
|
|
160
|
+
item.assignedTo && /* @__PURE__ */ jsx(DetailRow, { label: "Assigned to", children: item.assignedTo }),
|
|
161
|
+
item.scope && /* @__PURE__ */ jsx(DetailRow, { label: "Scope", children: /* @__PURE__ */ jsx(Badge, { variant: "outline", children: item.scope }) }),
|
|
162
|
+
item.size && /* @__PURE__ */ jsx(DetailRow, { label: "Size", children: /* @__PURE__ */ jsx(Badge, { variant: "outline", children: item.size }) })
|
|
163
|
+
] }),
|
|
164
|
+
/* @__PURE__ */ jsx(DetailSection, { title: "Content", children: /* @__PURE__ */ jsx(DetailRow, { label: "Description", children: /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: item.content }) }) }),
|
|
165
|
+
item.dialogueHistory && item.dialogueHistory.length > 0 && /* @__PURE__ */ jsx(DetailSection, { title: "Dialogue History", collapsible: true, defaultOpen: false, children: item.dialogueHistory.map((entry, i) => /* @__PURE__ */ jsxs(DetailRow, { label: entry.role === "user" ? "User" : "Assistant", children: [
|
|
166
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-sm", children: entry.content }),
|
|
167
|
+
entry.timestamp && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: new Date(entry.timestamp).toLocaleString() })
|
|
168
|
+
] }, i)) }),
|
|
169
|
+
item.context && /* @__PURE__ */ jsxs(DetailSection, { title: "Browser Context", collapsible: true, defaultOpen: false, children: [
|
|
170
|
+
item.context.url && /* @__PURE__ */ jsx(DetailRow, { label: "URL", children: item.context.url }),
|
|
171
|
+
item.context.userAgent && /* @__PURE__ */ jsx(DetailRow, { label: "User Agent", children: item.context.userAgent }),
|
|
172
|
+
item.context.viewport && /* @__PURE__ */ jsx(DetailRow, { label: "Viewport", children: `${item.context.viewport.width}×${item.context.viewport.height}` })
|
|
173
|
+
] }),
|
|
174
|
+
item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx(DetailSection, { title: "Tags", children: /* @__PURE__ */ jsx(DetailRow, { label: "Tags", children: /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: item.tags.map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "outline", children: tag }, tag)) }) }) })
|
|
175
|
+
] })
|
|
82
176
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return { sort, setSortField, setSort, applySort };
|
|
94
|
-
}
|
|
95
|
-
const STATUS_LABELS$1 = {
|
|
96
|
-
open: "Open",
|
|
97
|
-
approved: "Approved",
|
|
98
|
-
deferred: "Deferred",
|
|
99
|
-
resolved: "Resolved",
|
|
100
|
-
wontfix: "Won't fix"
|
|
101
|
-
};
|
|
102
|
-
function StatusBadge({ status, className }) {
|
|
103
|
-
return /* @__PURE__ */ jsx("span", { className, "data-status": status, children: STATUS_LABELS$1[status] ?? status });
|
|
104
|
-
}
|
|
105
|
-
const TYPE_LABELS$1 = {
|
|
106
|
-
bug: "Bug",
|
|
107
|
-
feature: "Feature",
|
|
108
|
-
ux: "UX issue",
|
|
109
|
-
other: "Other"
|
|
177
|
+
) });
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
FeedbackDetailPage.displayName = "FeedbackDetailPage";
|
|
181
|
+
const ALLOWED_TRANSITIONS = {
|
|
182
|
+
open: ["approved", "deferred", "wontfix"],
|
|
183
|
+
approved: ["open", "resolved", "deferred"],
|
|
184
|
+
deferred: ["open", "approved", "wontfix"],
|
|
185
|
+
resolved: ["open", "approved"],
|
|
186
|
+
wontfix: ["open", "deferred"]
|
|
110
187
|
};
|
|
111
|
-
function
|
|
112
|
-
|
|
188
|
+
function useStatusTransition(currentStatus) {
|
|
189
|
+
const allowedTargets = ALLOWED_TRANSITIONS[currentStatus] ?? [];
|
|
190
|
+
return { allowedTargets };
|
|
113
191
|
}
|
|
114
192
|
const STATUS_OPTIONS = [
|
|
115
|
-
{ value: "", label: "All" },
|
|
116
193
|
{ value: "open", label: "Open" },
|
|
117
194
|
{ value: "approved", label: "Approved" },
|
|
118
195
|
{ value: "deferred", label: "Deferred" },
|
|
119
196
|
{ value: "resolved", label: "Resolved" },
|
|
120
|
-
{ value: "wontfix", label: "Won't
|
|
197
|
+
{ value: "wontfix", label: "Won't Fix" }
|
|
121
198
|
];
|
|
122
199
|
const TYPE_OPTIONS = [
|
|
123
|
-
{ value: "", label: "All" },
|
|
124
200
|
{ value: "bug", label: "Bug" },
|
|
125
201
|
{ value: "feature", label: "Feature" },
|
|
126
|
-
{ value: "ux", label: "UX
|
|
202
|
+
{ value: "ux", label: "UX Issue" },
|
|
127
203
|
{ value: "other", label: "Other" }
|
|
128
204
|
];
|
|
129
|
-
const
|
|
130
|
-
{ value: "", label: "
|
|
131
|
-
{ value: "
|
|
132
|
-
{ value: "
|
|
133
|
-
{ value: "
|
|
205
|
+
const SCOPE_OPTIONS = [
|
|
206
|
+
{ value: "", label: "— not set —" },
|
|
207
|
+
{ value: "component", label: "Component" },
|
|
208
|
+
{ value: "page", label: "Page" },
|
|
209
|
+
{ value: "workflow", label: "Workflow" }
|
|
134
210
|
];
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
] });
|
|
195
|
-
}
|
|
196
|
-
function formatDate(iso) {
|
|
197
|
-
try {
|
|
198
|
-
return new Date(iso).toLocaleDateString(void 0, {
|
|
199
|
-
year: "numeric",
|
|
200
|
-
month: "short",
|
|
201
|
-
day: "numeric"
|
|
202
|
-
});
|
|
203
|
-
} catch {
|
|
204
|
-
return iso;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function SortIndicator({
|
|
208
|
-
active,
|
|
209
|
-
direction,
|
|
210
|
-
className
|
|
211
|
-
}) {
|
|
212
|
-
if (!active) {
|
|
213
|
-
return /* @__PURE__ */ jsx("span", { className, "aria-hidden": "true", children: " ↕" });
|
|
214
|
-
}
|
|
215
|
-
return /* @__PURE__ */ jsx("span", { className, "aria-hidden": "true", children: direction === "asc" ? " ↑" : " ↓" });
|
|
216
|
-
}
|
|
217
|
-
function FeedbackListPage({
|
|
218
|
-
items,
|
|
219
|
-
loading = false,
|
|
220
|
-
onNavigate,
|
|
221
|
-
className,
|
|
222
|
-
tableClassName,
|
|
223
|
-
filterClassName,
|
|
224
|
-
emptyStateMessage = "No feedback items found."
|
|
225
|
-
}) {
|
|
226
|
-
const { filters, setFilters, clearFilters, applyFilters } = useFeedbackFilters();
|
|
227
|
-
const { sort, setSortField, applySort } = useFeedbackSort();
|
|
228
|
-
const visibleItems = applySort(applyFilters(items));
|
|
229
|
-
function thProps(field) {
|
|
230
|
-
return {
|
|
231
|
-
scope: "col",
|
|
232
|
-
className: `feedback-admin-list__th feedback-admin-list__th--sortable${sort.field === field ? " feedback-admin-list__th--sorted" : ""}`,
|
|
233
|
-
onClick: () => setSortField(field),
|
|
234
|
-
onKeyDown: (e) => {
|
|
235
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
236
|
-
e.preventDefault();
|
|
237
|
-
setSortField(field);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
tabIndex: 0,
|
|
241
|
-
role: "columnheader",
|
|
242
|
-
"aria-sort": sort.field === field ? sort.direction === "asc" ? "ascending" : "descending" : "none"
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
const renderBody = () => {
|
|
246
|
-
if (loading) {
|
|
247
|
-
return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
248
|
-
"td",
|
|
249
|
-
{
|
|
250
|
-
colSpan: 7,
|
|
251
|
-
className: "feedback-admin-list__loading",
|
|
252
|
-
"aria-live": "polite",
|
|
253
|
-
"aria-busy": "true",
|
|
254
|
-
children: "Loading…"
|
|
211
|
+
const SIZE_OPTIONS = [
|
|
212
|
+
{ value: "", label: "— not set —" },
|
|
213
|
+
{ value: "trivial", label: "Trivial" },
|
|
214
|
+
{ value: "small", label: "Small" },
|
|
215
|
+
{ value: "medium", label: "Medium" },
|
|
216
|
+
{ value: "large", label: "Large" }
|
|
217
|
+
];
|
|
218
|
+
const FeedbackUpdatePage = React.forwardRef(
|
|
219
|
+
({ feedbackId, fetchItem, updateItem, onNavigate, currentUser, className }, ref) => {
|
|
220
|
+
const [item, setItem] = React.useState(null);
|
|
221
|
+
const [loading, setLoading] = React.useState(true);
|
|
222
|
+
const [saving, setSaving] = React.useState(false);
|
|
223
|
+
const [status, setStatus] = React.useState("open");
|
|
224
|
+
const [type, setType] = React.useState("bug");
|
|
225
|
+
const [scope, setScope] = React.useState("");
|
|
226
|
+
const [size, setSize] = React.useState("");
|
|
227
|
+
const [assignedTo, setAssignedTo] = React.useState("");
|
|
228
|
+
const [tags, setTags] = React.useState("");
|
|
229
|
+
const [correctionNote, setCorrectionNote] = React.useState("");
|
|
230
|
+
React.useEffect(() => {
|
|
231
|
+
let cancelled = false;
|
|
232
|
+
setLoading(true);
|
|
233
|
+
fetchItem(feedbackId).then((data) => {
|
|
234
|
+
if (cancelled) return;
|
|
235
|
+
setItem(data);
|
|
236
|
+
setStatus(data.status);
|
|
237
|
+
setType(data.type);
|
|
238
|
+
setScope(data.scope ?? "");
|
|
239
|
+
setSize(data.size ?? "");
|
|
240
|
+
setAssignedTo(data.assignedTo ?? "");
|
|
241
|
+
setTags(data.tags?.join(", ") ?? "");
|
|
242
|
+
}).finally(() => {
|
|
243
|
+
if (!cancelled) setLoading(false);
|
|
244
|
+
});
|
|
245
|
+
return () => {
|
|
246
|
+
cancelled = true;
|
|
247
|
+
};
|
|
248
|
+
}, [feedbackId, fetchItem]);
|
|
249
|
+
const { allowedTargets } = useStatusTransition(status);
|
|
250
|
+
const statusOptions = STATUS_OPTIONS.filter(
|
|
251
|
+
(opt) => opt.value === status || allowedTargets.includes(opt.value)
|
|
252
|
+
);
|
|
253
|
+
const classificationChanged = item && (type !== item.type || scope !== (item.scope ?? "") || size !== (item.size ?? ""));
|
|
254
|
+
const isDirty = item && (status !== item.status || type !== item.type || scope !== (item.scope ?? "") || size !== (item.size ?? "") || assignedTo !== (item.assignedTo ?? "") || tags !== (item.tags?.join(", ") ?? ""));
|
|
255
|
+
const handleSave = async () => {
|
|
256
|
+
if (!item) return;
|
|
257
|
+
setSaving(true);
|
|
258
|
+
try {
|
|
259
|
+
const patch = { lastModifiedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
260
|
+
if (status !== item.status) patch.status = status;
|
|
261
|
+
if (type !== item.type) patch.type = type;
|
|
262
|
+
if (scope !== (item.scope ?? "")) patch.scope = scope || void 0;
|
|
263
|
+
if (size !== (item.size ?? "")) patch.size = size || void 0;
|
|
264
|
+
if (assignedTo !== (item.assignedTo ?? "")) patch.assignedTo = assignedTo || void 0;
|
|
265
|
+
const newTags = tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
266
|
+
if (JSON.stringify(newTags) !== JSON.stringify(item.tags ?? [])) patch.tags = newTags;
|
|
267
|
+
if (status === "resolved" && item.status !== "resolved") {
|
|
268
|
+
patch.resolvedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
269
|
+
patch.resolvedBy = currentUser?.userId ?? "unknown";
|
|
255
270
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 7, className: "feedback-admin-list__empty", "aria-live": "polite", children: emptyStateMessage }) });
|
|
260
|
-
}
|
|
261
|
-
return visibleItems.map((item) => /* @__PURE__ */ jsxs(
|
|
262
|
-
"tr",
|
|
263
|
-
{
|
|
264
|
-
className: "feedback-admin-list__row feedback-admin-list__row--clickable",
|
|
265
|
-
onClick: () => onNavigate(`/feedback/${item.id}`),
|
|
266
|
-
onKeyDown: (e) => {
|
|
267
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
268
|
-
e.preventDefault();
|
|
269
|
-
onNavigate(`/feedback/${item.id}`);
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
tabIndex: 0,
|
|
273
|
-
role: "button",
|
|
274
|
-
"aria-label": `View feedback item ${item.id}`,
|
|
275
|
-
children: [
|
|
276
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--title", children: item.content }),
|
|
277
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--type", children: /* @__PURE__ */ jsx(
|
|
278
|
-
TypeBadge,
|
|
279
|
-
{
|
|
280
|
-
type: item.type,
|
|
281
|
-
className: `feedback-admin-badge feedback-admin-badge--type feedback-admin-badge--${item.type}`
|
|
282
|
-
}
|
|
283
|
-
) }),
|
|
284
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--status", children: /* @__PURE__ */ jsx(
|
|
285
|
-
StatusBadge,
|
|
271
|
+
if (classificationChanged && correctionNote) {
|
|
272
|
+
patch.corrections = [
|
|
273
|
+
...item.corrections ?? [],
|
|
286
274
|
{
|
|
287
|
-
|
|
288
|
-
|
|
275
|
+
field: [type !== item.type && "type", scope !== (item.scope ?? "") && "scope", size !== (item.size ?? "") && "size"].filter(Boolean).join(", "),
|
|
276
|
+
before: { type: item.type, scope: item.scope, size: item.size },
|
|
277
|
+
after: { type, scope: scope || void 0, size: size || void 0 },
|
|
278
|
+
correctedBy: currentUser?.userId ?? "unknown",
|
|
279
|
+
correctedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
280
|
+
reason: correctionNote
|
|
289
281
|
}
|
|
290
|
-
|
|
291
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--priority", children: item.priority }),
|
|
292
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--reporters", children: item.reporterCount.toLocaleString() }),
|
|
293
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--environment", children: item.environment ?? "—" }),
|
|
294
|
-
/* @__PURE__ */ jsx("td", { className: "feedback-admin-list__td feedback-admin-list__td--date", children: formatDate(item.submittedAt) })
|
|
295
|
-
]
|
|
296
|
-
},
|
|
297
|
-
item.id
|
|
298
|
-
));
|
|
299
|
-
};
|
|
300
|
-
return /* @__PURE__ */ jsxs("div", { className: `feedback-admin-list${className ? ` ${className}` : ""}`, children: [
|
|
301
|
-
/* @__PURE__ */ jsxs("div", { className: `feedback-admin-list__filters${filterClassName ? ` ${filterClassName}` : ""}`, children: [
|
|
302
|
-
/* @__PURE__ */ jsx(
|
|
303
|
-
FilterControls,
|
|
304
|
-
{
|
|
305
|
-
filters,
|
|
306
|
-
onChange: setFilters,
|
|
307
|
-
className: "feedback-admin-filter-controls"
|
|
308
|
-
}
|
|
309
|
-
),
|
|
310
|
-
/* @__PURE__ */ jsx(
|
|
311
|
-
"button",
|
|
312
|
-
{
|
|
313
|
-
type: "button",
|
|
314
|
-
className: "feedback-admin-list__clear-btn",
|
|
315
|
-
onClick: clearFilters,
|
|
316
|
-
"aria-label": "Clear all filters",
|
|
317
|
-
children: "Clear filters"
|
|
282
|
+
];
|
|
318
283
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/* @__PURE__ */ jsx(
|
|
334
|
-
SortIndicator,
|
|
335
|
-
{
|
|
336
|
-
active: sort.field === "type",
|
|
337
|
-
direction: sort.direction,
|
|
338
|
-
className: "feedback-admin-list__sort-icon"
|
|
339
|
-
}
|
|
340
|
-
)
|
|
341
|
-
] }),
|
|
342
|
-
/* @__PURE__ */ jsxs("th", { ...thProps("status"), children: [
|
|
343
|
-
"Status",
|
|
344
|
-
/* @__PURE__ */ jsx(
|
|
345
|
-
SortIndicator,
|
|
346
|
-
{
|
|
347
|
-
active: sort.field === "status",
|
|
348
|
-
direction: sort.direction,
|
|
349
|
-
className: "feedback-admin-list__sort-icon"
|
|
350
|
-
}
|
|
351
|
-
)
|
|
352
|
-
] }),
|
|
353
|
-
/* @__PURE__ */ jsxs("th", { ...thProps("priority"), children: [
|
|
354
|
-
"Priority",
|
|
355
|
-
/* @__PURE__ */ jsx(
|
|
356
|
-
SortIndicator,
|
|
357
|
-
{
|
|
358
|
-
active: sort.field === "priority",
|
|
359
|
-
direction: sort.direction,
|
|
360
|
-
className: "feedback-admin-list__sort-icon"
|
|
361
|
-
}
|
|
362
|
-
)
|
|
363
|
-
] }),
|
|
364
|
-
/* @__PURE__ */ jsxs("th", { ...thProps("reporterCount"), children: [
|
|
365
|
-
"Reporters",
|
|
284
|
+
await updateItem(feedbackId, patch);
|
|
285
|
+
onNavigate(`/feedback/${feedbackId}`);
|
|
286
|
+
} finally {
|
|
287
|
+
setSaving(false);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const headerActions = /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onNavigate(`/feedback/${feedbackId}`), children: "Cancel" });
|
|
291
|
+
return /* @__PURE__ */ jsx("div", { ref, className, children: /* @__PURE__ */ jsx(
|
|
292
|
+
UpdatePage,
|
|
293
|
+
{
|
|
294
|
+
title: `Edit: ${item?.content?.slice(0, 40) || feedbackId.slice(0, 12)}…`,
|
|
295
|
+
headerActions,
|
|
296
|
+
dataLoading: loading,
|
|
297
|
+
actions: /* @__PURE__ */ jsxs(SaveFooter, { dirty: !!isDirty, saving, children: [
|
|
298
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onNavigate(`/feedback/${feedbackId}`), children: "Cancel" }),
|
|
366
299
|
/* @__PURE__ */ jsx(
|
|
367
|
-
|
|
300
|
+
Button,
|
|
368
301
|
{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
302
|
+
onClick: handleSave,
|
|
303
|
+
disabled: saving || !isDirty || !!classificationChanged && !correctionNote,
|
|
304
|
+
children: saving ? "Saving…" : "Save changes"
|
|
372
305
|
}
|
|
373
306
|
)
|
|
374
307
|
] }),
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
{
|
|
378
|
-
|
|
379
|
-
className: "
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
className: "feedback-admin-list__sort-icon"
|
|
391
|
-
}
|
|
392
|
-
)
|
|
393
|
-
] })
|
|
394
|
-
] }) }),
|
|
395
|
-
/* @__PURE__ */ jsx("tbody", { className: "feedback-admin-list__tbody", children: renderBody() })
|
|
396
|
-
] }) })
|
|
397
|
-
] });
|
|
398
|
-
}
|
|
399
|
-
function DialogueHistory({
|
|
400
|
-
dialogue,
|
|
401
|
-
className
|
|
402
|
-
}) {
|
|
403
|
-
if (!dialogue || dialogue.length === 0) {
|
|
404
|
-
return /* @__PURE__ */ jsx("div", { className, "data-testid": "dialogue-history-empty", children: /* @__PURE__ */ jsx("p", { className: "feedback-admin-dialogue__empty", children: "No dialogue recorded." }) });
|
|
405
|
-
}
|
|
406
|
-
return /* @__PURE__ */ jsx("div", { className, "data-testid": "dialogue-history", children: /* @__PURE__ */ jsx("ol", { className: "feedback-admin-dialogue__list", "aria-label": "Dialogue history", children: dialogue.map((entry, index) => {
|
|
407
|
-
if (!entry || typeof entry !== "object") {
|
|
408
|
-
return null;
|
|
409
|
-
}
|
|
410
|
-
const role = entry.role === "assistant" ? "assistant" : "user";
|
|
411
|
-
const content = typeof entry.content === "string" ? entry.content : "";
|
|
412
|
-
const timestamp = typeof entry.timestamp === "string" ? entry.timestamp : "";
|
|
413
|
-
let displayTime = "";
|
|
414
|
-
if (timestamp) {
|
|
415
|
-
try {
|
|
416
|
-
displayTime = new Date(timestamp).toLocaleString();
|
|
417
|
-
} catch {
|
|
418
|
-
displayTime = timestamp;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return /* @__PURE__ */ jsxs(
|
|
422
|
-
"li",
|
|
423
|
-
{
|
|
424
|
-
className: "feedback-admin-dialogue__turn",
|
|
425
|
-
"data-role": role,
|
|
426
|
-
children: [
|
|
427
|
-
/* @__PURE__ */ jsxs("header", { className: "feedback-admin-dialogue__turn-header", children: [
|
|
308
|
+
testId: "feedback-update-page",
|
|
309
|
+
children: item && /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
310
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border p-4 bg-muted/30", children: [
|
|
311
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-2", children: "Original submission" }),
|
|
312
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-sm", children: item.content }),
|
|
313
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 mt-3 text-xs text-muted-foreground", children: [
|
|
314
|
+
/* @__PURE__ */ jsx("span", { children: item.submittedAt ? new Date(item.submittedAt).toLocaleString() : "" }),
|
|
315
|
+
/* @__PURE__ */ jsx("span", { children: item.environment }),
|
|
316
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
317
|
+
item.reporterCount ?? 1,
|
|
318
|
+
" reporter(s)"
|
|
319
|
+
] })
|
|
320
|
+
] })
|
|
321
|
+
] }),
|
|
322
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
428
323
|
/* @__PURE__ */ jsx(
|
|
429
|
-
|
|
324
|
+
EnumField,
|
|
430
325
|
{
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
326
|
+
label: "Status",
|
|
327
|
+
options: statusOptions,
|
|
328
|
+
value: status,
|
|
329
|
+
onChange: (v) => setStatus(v)
|
|
434
330
|
}
|
|
435
331
|
),
|
|
436
|
-
|
|
437
|
-
|
|
332
|
+
/* @__PURE__ */ jsx(
|
|
333
|
+
EnumField,
|
|
438
334
|
{
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
335
|
+
label: "Type",
|
|
336
|
+
options: TYPE_OPTIONS,
|
|
337
|
+
value: type,
|
|
338
|
+
onChange: (v) => setType(v)
|
|
442
339
|
}
|
|
443
|
-
)
|
|
444
|
-
] }),
|
|
445
|
-
/* @__PURE__ */ jsx("div", { className: "feedback-admin-dialogue__turn-content", children: content.split("\n").map((line, lineIndex) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
446
|
-
line,
|
|
447
|
-
lineIndex < content.split("\n").length - 1 && /* @__PURE__ */ jsx("br", {})
|
|
448
|
-
] }, lineIndex)) })
|
|
449
|
-
]
|
|
450
|
-
},
|
|
451
|
-
`dialogue-${index}`
|
|
452
|
-
);
|
|
453
|
-
}) }) });
|
|
454
|
-
}
|
|
455
|
-
function ScreenshotViewer({
|
|
456
|
-
screenshotS3Key,
|
|
457
|
-
generateScreenshotUrl,
|
|
458
|
-
alt = "Feedback screenshot",
|
|
459
|
-
className
|
|
460
|
-
}) {
|
|
461
|
-
const [imageUrl, setImageUrl] = useState(null);
|
|
462
|
-
const [loading, setLoading] = useState(false);
|
|
463
|
-
const [error, setError] = useState(null);
|
|
464
|
-
useEffect(() => {
|
|
465
|
-
if (!screenshotS3Key) {
|
|
466
|
-
setImageUrl(null);
|
|
467
|
-
setLoading(false);
|
|
468
|
-
setError(null);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
if (!generateScreenshotUrl) {
|
|
472
|
-
setImageUrl(null);
|
|
473
|
-
setLoading(false);
|
|
474
|
-
setError(null);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
setLoading(true);
|
|
478
|
-
setError(null);
|
|
479
|
-
generateScreenshotUrl(screenshotS3Key).then((url) => {
|
|
480
|
-
setImageUrl(url);
|
|
481
|
-
setLoading(false);
|
|
482
|
-
}).catch(() => {
|
|
483
|
-
setImageUrl(null);
|
|
484
|
-
setLoading(false);
|
|
485
|
-
setError("Failed to load screenshot.");
|
|
486
|
-
});
|
|
487
|
-
}, [screenshotS3Key, generateScreenshotUrl]);
|
|
488
|
-
return /* @__PURE__ */ jsxs("div", { className, "data-testid": "screenshot-viewer", children: [
|
|
489
|
-
loading && /* @__PURE__ */ jsx("p", { className: "feedback-admin-screenshot__loading", children: "Loading screenshot…" }),
|
|
490
|
-
!loading && imageUrl && /* @__PURE__ */ jsx(
|
|
491
|
-
"img",
|
|
492
|
-
{
|
|
493
|
-
src: imageUrl,
|
|
494
|
-
alt,
|
|
495
|
-
className: "feedback-admin-screenshot__image"
|
|
496
|
-
}
|
|
497
|
-
),
|
|
498
|
-
!loading && !imageUrl && screenshotS3Key && !generateScreenshotUrl && /* @__PURE__ */ jsx("p", { className: "feedback-admin-screenshot__configure", children: "Configure generateScreenshotUrl to display screenshot." }),
|
|
499
|
-
!loading && !imageUrl && screenshotS3Key && generateScreenshotUrl && error && /* @__PURE__ */ jsx("p", { className: "feedback-admin-screenshot__error", children: error }),
|
|
500
|
-
!loading && !screenshotS3Key && /* @__PURE__ */ jsx("p", { className: "feedback-admin-screenshot__missing", children: "No screenshot captured." })
|
|
501
|
-
] });
|
|
502
|
-
}
|
|
503
|
-
function BrowserContext({
|
|
504
|
-
context,
|
|
505
|
-
className
|
|
506
|
-
}) {
|
|
507
|
-
if (!context) {
|
|
508
|
-
return /* @__PURE__ */ jsx("div", { className, "data-testid": "browser-context-empty", children: /* @__PURE__ */ jsx("p", { className: "feedback-admin-context__empty", children: "No browser context available." }) });
|
|
509
|
-
}
|
|
510
|
-
const { url, pageTitle, userAgent, viewport, locale, timezone } = context;
|
|
511
|
-
return /* @__PURE__ */ jsx("div", { className, "data-testid": "browser-context", children: /* @__PURE__ */ jsxs("dl", { className: "feedback-admin-context__list", children: [
|
|
512
|
-
url && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
513
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "URL" }),
|
|
514
|
-
/* @__PURE__ */ jsx("dd", { className: "feedback-admin-context__value feedback-admin-context__value--url", children: url })
|
|
515
|
-
] }),
|
|
516
|
-
pageTitle && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
517
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "Page title" }),
|
|
518
|
-
/* @__PURE__ */ jsx("dd", { className: "feedback-admin-context__value", children: pageTitle })
|
|
519
|
-
] }),
|
|
520
|
-
userAgent && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
521
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "User agent" }),
|
|
522
|
-
/* @__PURE__ */ jsx("dd", { className: "feedback-admin-context__value feedback-admin-context__value--user-agent", children: userAgent })
|
|
523
|
-
] }),
|
|
524
|
-
viewport && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
525
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "Viewport" }),
|
|
526
|
-
/* @__PURE__ */ jsxs("dd", { className: "feedback-admin-context__value", children: [
|
|
527
|
-
viewport.width,
|
|
528
|
-
" × ",
|
|
529
|
-
viewport.height
|
|
530
|
-
] })
|
|
531
|
-
] }),
|
|
532
|
-
locale && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
533
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "Locale" }),
|
|
534
|
-
/* @__PURE__ */ jsx("dd", { className: "feedback-admin-context__value", children: locale })
|
|
535
|
-
] }),
|
|
536
|
-
timezone && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
537
|
-
/* @__PURE__ */ jsx("dt", { className: "feedback-admin-context__term", children: "Timezone" }),
|
|
538
|
-
/* @__PURE__ */ jsx("dd", { className: "feedback-admin-context__value", children: timezone })
|
|
539
|
-
] })
|
|
540
|
-
] }) });
|
|
541
|
-
}
|
|
542
|
-
const ALLOWED_TRANSITIONS$1 = {
|
|
543
|
-
open: ["approved", "deferred", "wontfix"],
|
|
544
|
-
approved: ["resolved", "deferred", "wontfix"],
|
|
545
|
-
deferred: ["open", "approved", "wontfix"],
|
|
546
|
-
resolved: ["open"],
|
|
547
|
-
wontfix: ["open"]
|
|
548
|
-
};
|
|
549
|
-
const STATUS_TRANSITION_LABELS = {
|
|
550
|
-
open: "Reopen",
|
|
551
|
-
approved: "Approve",
|
|
552
|
-
deferred: "Defer",
|
|
553
|
-
resolved: "Resolve",
|
|
554
|
-
wontfix: "Won't fix"
|
|
555
|
-
};
|
|
556
|
-
function QuickActions({
|
|
557
|
-
item,
|
|
558
|
-
updateItem,
|
|
559
|
-
onNavigate,
|
|
560
|
-
className
|
|
561
|
-
}) {
|
|
562
|
-
const [saving, setSaving] = useState(false);
|
|
563
|
-
const [error, setError] = useState(null);
|
|
564
|
-
const allowedTargets = ALLOWED_TRANSITIONS$1[item.status] ?? [];
|
|
565
|
-
const handleStatusTransition = async (targetStatus) => {
|
|
566
|
-
setSaving(true);
|
|
567
|
-
setError(null);
|
|
568
|
-
try {
|
|
569
|
-
await updateItem(item.id, { status: targetStatus });
|
|
570
|
-
} catch {
|
|
571
|
-
setError("Failed to update status. Please try again.");
|
|
572
|
-
} finally {
|
|
573
|
-
setSaving(false);
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
const handleEdit = () => {
|
|
577
|
-
onNavigate(`/feedback/${item.id}/edit`);
|
|
578
|
-
};
|
|
579
|
-
const handleBackToList = () => {
|
|
580
|
-
onNavigate("/feedback");
|
|
581
|
-
};
|
|
582
|
-
return /* @__PURE__ */ jsxs("div", { className, "data-testid": "quick-actions", children: [
|
|
583
|
-
/* @__PURE__ */ jsx("div", { className: "feedback-admin-actions__status-group", role: "group", "aria-label": "Status actions", children: allowedTargets.map((targetStatus) => /* @__PURE__ */ jsx(
|
|
584
|
-
"button",
|
|
585
|
-
{
|
|
586
|
-
type: "button",
|
|
587
|
-
className: "feedback-admin-actions__status-btn",
|
|
588
|
-
"data-target-status": targetStatus,
|
|
589
|
-
onClick: () => void handleStatusTransition(targetStatus),
|
|
590
|
-
disabled: saving,
|
|
591
|
-
"aria-disabled": saving,
|
|
592
|
-
children: STATUS_TRANSITION_LABELS[targetStatus]
|
|
593
|
-
},
|
|
594
|
-
targetStatus
|
|
595
|
-
)) }),
|
|
596
|
-
error && /* @__PURE__ */ jsx(
|
|
597
|
-
"p",
|
|
598
|
-
{
|
|
599
|
-
className: "feedback-admin-actions__error",
|
|
600
|
-
role: "alert",
|
|
601
|
-
"data-testid": "quick-actions-error",
|
|
602
|
-
children: error
|
|
603
|
-
}
|
|
604
|
-
),
|
|
605
|
-
/* @__PURE__ */ jsxs("div", { className: "feedback-admin-actions__nav-group", children: [
|
|
606
|
-
/* @__PURE__ */ jsx(
|
|
607
|
-
"button",
|
|
608
|
-
{
|
|
609
|
-
type: "button",
|
|
610
|
-
className: "feedback-admin-actions__edit-btn",
|
|
611
|
-
onClick: handleEdit,
|
|
612
|
-
disabled: saving,
|
|
613
|
-
"aria-disabled": saving,
|
|
614
|
-
"data-testid": "quick-actions-edit",
|
|
615
|
-
children: "Edit"
|
|
616
|
-
}
|
|
617
|
-
),
|
|
618
|
-
/* @__PURE__ */ jsx(
|
|
619
|
-
"button",
|
|
620
|
-
{
|
|
621
|
-
type: "button",
|
|
622
|
-
className: "feedback-admin-actions__back-btn",
|
|
623
|
-
onClick: handleBackToList,
|
|
624
|
-
disabled: saving,
|
|
625
|
-
"aria-disabled": saving,
|
|
626
|
-
"data-testid": "quick-actions-back",
|
|
627
|
-
children: "Back to list"
|
|
628
|
-
}
|
|
629
|
-
)
|
|
630
|
-
] })
|
|
631
|
-
] });
|
|
632
|
-
}
|
|
633
|
-
function FeedbackDetailPage({
|
|
634
|
-
feedbackId,
|
|
635
|
-
fetchItem,
|
|
636
|
-
onNavigate,
|
|
637
|
-
currentUser,
|
|
638
|
-
className,
|
|
639
|
-
generateScreenshotUrl
|
|
640
|
-
}) {
|
|
641
|
-
const [item, setItem] = useState(null);
|
|
642
|
-
const [loading, setLoading] = useState(true);
|
|
643
|
-
const [error, setError] = useState(null);
|
|
644
|
-
useEffect(() => {
|
|
645
|
-
let cancelled = false;
|
|
646
|
-
setLoading(true);
|
|
647
|
-
setError(null);
|
|
648
|
-
fetchItem(feedbackId).then((fetched) => {
|
|
649
|
-
if (!cancelled) {
|
|
650
|
-
setItem(fetched);
|
|
651
|
-
setLoading(false);
|
|
652
|
-
}
|
|
653
|
-
}).catch(() => {
|
|
654
|
-
if (!cancelled) {
|
|
655
|
-
setError("Failed to load feedback item.");
|
|
656
|
-
setLoading(false);
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
return () => {
|
|
660
|
-
cancelled = true;
|
|
661
|
-
};
|
|
662
|
-
}, [feedbackId, fetchItem]);
|
|
663
|
-
if (loading) {
|
|
664
|
-
return /* @__PURE__ */ jsx(
|
|
665
|
-
"div",
|
|
666
|
-
{
|
|
667
|
-
className,
|
|
668
|
-
"data-testid": "feedback-detail-loading",
|
|
669
|
-
"aria-busy": "true",
|
|
670
|
-
"aria-label": "Loading feedback item",
|
|
671
|
-
children: /* @__PURE__ */ jsx("p", { className: "feedback-admin-detail__loading", children: "Loading…" })
|
|
672
|
-
}
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
if (error || !item) {
|
|
676
|
-
return /* @__PURE__ */ jsxs(
|
|
677
|
-
"div",
|
|
678
|
-
{
|
|
679
|
-
className,
|
|
680
|
-
"data-testid": "feedback-detail-error",
|
|
681
|
-
role: "alert",
|
|
682
|
-
children: [
|
|
683
|
-
/* @__PURE__ */ jsx("p", { className: "feedback-admin-detail__error", children: error ?? "Feedback item not found." }),
|
|
684
|
-
/* @__PURE__ */ jsx(
|
|
685
|
-
"button",
|
|
686
|
-
{
|
|
687
|
-
type: "button",
|
|
688
|
-
className: "feedback-admin-detail__back-btn",
|
|
689
|
-
onClick: () => onNavigate("/feedback"),
|
|
690
|
-
"data-testid": "feedback-detail-back-error",
|
|
691
|
-
children: "Back to list"
|
|
692
|
-
}
|
|
693
|
-
)
|
|
694
|
-
]
|
|
695
|
-
}
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
const handleUpdateItem = async (id, patch) => {
|
|
699
|
-
setItem((prev) => prev ? { ...prev, ...patch } : prev);
|
|
700
|
-
try {
|
|
701
|
-
const updated = await fetchItem(id);
|
|
702
|
-
setItem(updated);
|
|
703
|
-
} catch {
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
const formatDate2 = (isoString) => {
|
|
707
|
-
try {
|
|
708
|
-
return new Date(isoString).toLocaleString();
|
|
709
|
-
} catch {
|
|
710
|
-
return isoString;
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
return /* @__PURE__ */ jsxs(
|
|
714
|
-
"article",
|
|
715
|
-
{
|
|
716
|
-
className,
|
|
717
|
-
"data-testid": "feedback-detail",
|
|
718
|
-
"data-feedback-id": item.id,
|
|
719
|
-
children: [
|
|
720
|
-
/* @__PURE__ */ jsxs("header", { className: "feedback-admin-detail__header", children: [
|
|
721
|
-
/* @__PURE__ */ jsx("h1", { className: "feedback-admin-detail__title", children: item.content.length > 120 ? `${item.content.slice(0, 120)}…` : item.content }),
|
|
722
|
-
/* @__PURE__ */ jsxs("div", { className: "feedback-admin-detail__badges", children: [
|
|
340
|
+
),
|
|
723
341
|
/* @__PURE__ */ jsx(
|
|
724
|
-
|
|
342
|
+
EnumField,
|
|
725
343
|
{
|
|
726
|
-
|
|
727
|
-
|
|
344
|
+
label: "Scope",
|
|
345
|
+
options: SCOPE_OPTIONS,
|
|
346
|
+
value: scope,
|
|
347
|
+
onChange: setScope
|
|
728
348
|
}
|
|
729
349
|
),
|
|
730
350
|
/* @__PURE__ */ jsx(
|
|
731
|
-
|
|
351
|
+
EnumField,
|
|
732
352
|
{
|
|
733
|
-
|
|
734
|
-
|
|
353
|
+
label: "Size",
|
|
354
|
+
options: SIZE_OPTIONS,
|
|
355
|
+
value: size,
|
|
356
|
+
onChange: setSize
|
|
735
357
|
}
|
|
736
358
|
),
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
|
|
359
|
+
/* @__PURE__ */ jsx(
|
|
360
|
+
TextField,
|
|
361
|
+
{
|
|
362
|
+
label: "Assigned to",
|
|
363
|
+
value: assignedTo,
|
|
364
|
+
onChange: (e) => setAssignedTo(e.target.value),
|
|
365
|
+
placeholder: currentUser?.name ?? currentUser?.userId ?? "",
|
|
366
|
+
...currentUser ? { description: `You: ${currentUser.name ?? currentUser.userId}` } : {}
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
/* @__PURE__ */ jsx(
|
|
370
|
+
TextField,
|
|
739
371
|
{
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
item.priority
|
|
746
|
-
]
|
|
372
|
+
label: "Tags",
|
|
373
|
+
value: tags,
|
|
374
|
+
onChange: (e) => setTags(e.target.value),
|
|
375
|
+
placeholder: "Comma-separated tags",
|
|
376
|
+
description: "Separate multiple tags with commas"
|
|
747
377
|
}
|
|
748
378
|
)
|
|
749
|
-
] })
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
/* @__PURE__ */ jsx("dt", { children: "Reporters" }),
|
|
764
|
-
/* @__PURE__ */ jsx("dd", { "data-testid": "detail-reporter-count", children: item.reporterCount }),
|
|
765
|
-
item.assignedTo && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
766
|
-
/* @__PURE__ */ jsx("dt", { children: "Assigned to" }),
|
|
767
|
-
/* @__PURE__ */ jsx("dd", { "data-testid": "detail-assigned-to", children: item.assignedTo })
|
|
768
|
-
] }),
|
|
769
|
-
item.version && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
770
|
-
/* @__PURE__ */ jsx("dt", { children: "Version" }),
|
|
771
|
-
/* @__PURE__ */ jsx("dd", { "data-testid": "detail-version", children: item.version })
|
|
772
|
-
] }),
|
|
773
|
-
item.tags && item.tags.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
774
|
-
/* @__PURE__ */ jsx("dt", { children: "Tags" }),
|
|
775
|
-
/* @__PURE__ */ jsx("dd", { "data-testid": "detail-tags", children: item.tags.join(", ") })
|
|
776
|
-
] })
|
|
777
|
-
] })
|
|
778
|
-
}
|
|
779
|
-
),
|
|
780
|
-
/* @__PURE__ */ jsxs(
|
|
781
|
-
"section",
|
|
782
|
-
{
|
|
783
|
-
className: "feedback-admin-detail__description",
|
|
784
|
-
"aria-label": "Description",
|
|
785
|
-
children: [
|
|
786
|
-
/* @__PURE__ */ jsx("h2", { className: "feedback-admin-detail__section-heading", children: "Description" }),
|
|
787
|
-
/* @__PURE__ */ jsx(
|
|
788
|
-
"p",
|
|
789
|
-
{
|
|
790
|
-
className: "feedback-admin-detail__content",
|
|
791
|
-
"data-testid": "detail-content",
|
|
792
|
-
children: item.content
|
|
793
|
-
}
|
|
794
|
-
)
|
|
795
|
-
]
|
|
796
|
-
}
|
|
797
|
-
),
|
|
798
|
-
/* @__PURE__ */ jsxs(
|
|
799
|
-
"section",
|
|
800
|
-
{
|
|
801
|
-
className: "feedback-admin-detail__dialogue",
|
|
802
|
-
"aria-label": "Dialogue history",
|
|
803
|
-
children: [
|
|
804
|
-
/* @__PURE__ */ jsx("h2", { className: "feedback-admin-detail__section-heading", children: "Dialogue history" }),
|
|
805
|
-
/* @__PURE__ */ jsx(
|
|
806
|
-
DialogueHistory,
|
|
807
|
-
{
|
|
808
|
-
dialogue: item.dialogueHistory,
|
|
809
|
-
className: "feedback-admin-detail__dialogue-history"
|
|
810
|
-
}
|
|
811
|
-
)
|
|
812
|
-
]
|
|
813
|
-
}
|
|
814
|
-
),
|
|
815
|
-
/* @__PURE__ */ jsxs(
|
|
816
|
-
"section",
|
|
817
|
-
{
|
|
818
|
-
className: "feedback-admin-detail__screenshot",
|
|
819
|
-
"aria-label": "Screenshot",
|
|
820
|
-
children: [
|
|
821
|
-
/* @__PURE__ */ jsx("h2", { className: "feedback-admin-detail__section-heading", children: "Screenshot" }),
|
|
822
|
-
/* @__PURE__ */ jsx(
|
|
823
|
-
ScreenshotViewer,
|
|
824
|
-
{
|
|
825
|
-
...item.screenshotS3Key !== void 0 ? { screenshotS3Key: item.screenshotS3Key } : {},
|
|
826
|
-
...generateScreenshotUrl !== void 0 ? { generateScreenshotUrl } : {},
|
|
827
|
-
alt: `Screenshot for feedback ${item.id}`,
|
|
828
|
-
className: "feedback-admin-detail__screenshot-viewer"
|
|
829
|
-
}
|
|
830
|
-
)
|
|
831
|
-
]
|
|
832
|
-
}
|
|
833
|
-
),
|
|
834
|
-
/* @__PURE__ */ jsxs(
|
|
835
|
-
"section",
|
|
836
|
-
{
|
|
837
|
-
className: "feedback-admin-detail__context",
|
|
838
|
-
"aria-label": "Browser context",
|
|
839
|
-
children: [
|
|
840
|
-
/* @__PURE__ */ jsx("h2", { className: "feedback-admin-detail__section-heading", children: "Browser context" }),
|
|
841
|
-
/* @__PURE__ */ jsx(
|
|
842
|
-
BrowserContext,
|
|
843
|
-
{
|
|
844
|
-
context: item.context,
|
|
845
|
-
className: "feedback-admin-detail__browser-context"
|
|
846
|
-
}
|
|
847
|
-
)
|
|
848
|
-
]
|
|
849
|
-
}
|
|
850
|
-
),
|
|
851
|
-
/* @__PURE__ */ jsx(
|
|
852
|
-
QuickActions,
|
|
853
|
-
{
|
|
854
|
-
item,
|
|
855
|
-
updateItem: handleUpdateItem,
|
|
856
|
-
onNavigate,
|
|
857
|
-
...currentUser !== void 0 ? { currentUser } : {},
|
|
858
|
-
className: "feedback-admin-detail__quick-actions"
|
|
859
|
-
}
|
|
860
|
-
)
|
|
861
|
-
]
|
|
862
|
-
}
|
|
863
|
-
);
|
|
864
|
-
}
|
|
865
|
-
const ALLOWED_TRANSITIONS = {
|
|
866
|
-
open: ["approved", "deferred", "wontfix"],
|
|
867
|
-
approved: ["open", "resolved", "deferred"],
|
|
868
|
-
deferred: ["open", "approved", "wontfix"],
|
|
869
|
-
resolved: ["open", "approved"],
|
|
870
|
-
wontfix: ["open", "deferred"]
|
|
871
|
-
};
|
|
872
|
-
function useStatusTransition(currentStatus) {
|
|
873
|
-
const allowedTargets = ALLOWED_TRANSITIONS[currentStatus] ?? [];
|
|
874
|
-
return { allowedTargets };
|
|
875
|
-
}
|
|
876
|
-
const STATUS_LABELS = {
|
|
877
|
-
open: "Open",
|
|
878
|
-
approved: "Approved",
|
|
879
|
-
deferred: "Deferred",
|
|
880
|
-
resolved: "Resolved",
|
|
881
|
-
wontfix: "Won't fix"
|
|
882
|
-
};
|
|
883
|
-
const TYPE_LABELS = {
|
|
884
|
-
bug: "Bug",
|
|
885
|
-
feature: "Feature",
|
|
886
|
-
ux: "UX issue",
|
|
887
|
-
other: "Other"
|
|
888
|
-
};
|
|
889
|
-
const SCOPE_LABELS = {
|
|
890
|
-
isolated: "Isolated",
|
|
891
|
-
"cross-cutting": "Cross-cutting",
|
|
892
|
-
systemic: "Systemic"
|
|
893
|
-
};
|
|
894
|
-
const SIZE_LABELS = {
|
|
895
|
-
trivial: "Trivial",
|
|
896
|
-
small: "Small",
|
|
897
|
-
medium: "Medium",
|
|
898
|
-
large: "Large"
|
|
899
|
-
};
|
|
900
|
-
const ALL_TYPES = ["bug", "feature", "ux", "other"];
|
|
901
|
-
const ALL_SCOPES = ["isolated", "cross-cutting", "systemic"];
|
|
902
|
-
const ALL_SIZES = ["trivial", "small", "medium", "large"];
|
|
903
|
-
function StatusSelect({
|
|
904
|
-
currentStatus,
|
|
905
|
-
allowedTargets,
|
|
906
|
-
value,
|
|
907
|
-
onChange,
|
|
908
|
-
className
|
|
909
|
-
}) {
|
|
910
|
-
const id = "feedback-admin-status-select";
|
|
911
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
912
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Status" }),
|
|
913
|
-
/* @__PURE__ */ jsxs(
|
|
914
|
-
"select",
|
|
915
|
-
{
|
|
916
|
-
id,
|
|
917
|
-
value,
|
|
918
|
-
"aria-label": "Status",
|
|
919
|
-
onChange: (e) => onChange(e.target.value),
|
|
920
|
-
children: [
|
|
921
|
-
/* @__PURE__ */ jsx("option", { value: currentStatus, children: STATUS_LABELS[currentStatus] }),
|
|
922
|
-
allowedTargets.map((target) => /* @__PURE__ */ jsx("option", { value: target, children: STATUS_LABELS[target] }, target))
|
|
923
|
-
]
|
|
924
|
-
}
|
|
925
|
-
)
|
|
926
|
-
] });
|
|
927
|
-
}
|
|
928
|
-
function TypeSelect({
|
|
929
|
-
value,
|
|
930
|
-
onChange,
|
|
931
|
-
className
|
|
932
|
-
}) {
|
|
933
|
-
const id = "feedback-admin-type-select";
|
|
934
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
935
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Type" }),
|
|
936
|
-
/* @__PURE__ */ jsx(
|
|
937
|
-
"select",
|
|
938
|
-
{
|
|
939
|
-
id,
|
|
940
|
-
value,
|
|
941
|
-
"aria-label": "Type",
|
|
942
|
-
onChange: (e) => onChange(e.target.value),
|
|
943
|
-
children: ALL_TYPES.map((type) => /* @__PURE__ */ jsx("option", { value: type, children: TYPE_LABELS[type] }, type))
|
|
944
|
-
}
|
|
945
|
-
)
|
|
946
|
-
] });
|
|
947
|
-
}
|
|
948
|
-
function ScopeSelect({
|
|
949
|
-
value,
|
|
950
|
-
onChange,
|
|
951
|
-
className
|
|
952
|
-
}) {
|
|
953
|
-
const id = "feedback-admin-scope-select";
|
|
954
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
955
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Scope" }),
|
|
956
|
-
/* @__PURE__ */ jsxs(
|
|
957
|
-
"select",
|
|
958
|
-
{
|
|
959
|
-
id,
|
|
960
|
-
value: value ?? "",
|
|
961
|
-
"aria-label": "Scope",
|
|
962
|
-
onChange: (e) => {
|
|
963
|
-
const v = e.target.value;
|
|
964
|
-
onChange(v === "" ? void 0 : v);
|
|
965
|
-
},
|
|
966
|
-
children: [
|
|
967
|
-
/* @__PURE__ */ jsx("option", { value: "", children: "— not set —" }),
|
|
968
|
-
ALL_SCOPES.map((scope) => /* @__PURE__ */ jsx("option", { value: scope, children: SCOPE_LABELS[scope] }, scope))
|
|
969
|
-
]
|
|
970
|
-
}
|
|
971
|
-
)
|
|
972
|
-
] });
|
|
973
|
-
}
|
|
974
|
-
function SizeSelect({
|
|
975
|
-
value,
|
|
976
|
-
onChange,
|
|
977
|
-
className
|
|
978
|
-
}) {
|
|
979
|
-
const id = "feedback-admin-size-select";
|
|
980
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
981
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Size" }),
|
|
982
|
-
/* @__PURE__ */ jsxs(
|
|
983
|
-
"select",
|
|
984
|
-
{
|
|
985
|
-
id,
|
|
986
|
-
value: value ?? "",
|
|
987
|
-
"aria-label": "Size",
|
|
988
|
-
onChange: (e) => {
|
|
989
|
-
const v = e.target.value;
|
|
990
|
-
onChange(v === "" ? void 0 : v);
|
|
991
|
-
},
|
|
992
|
-
children: [
|
|
993
|
-
/* @__PURE__ */ jsx("option", { value: "", children: "— not set —" }),
|
|
994
|
-
ALL_SIZES.map((size) => /* @__PURE__ */ jsx("option", { value: size, children: SIZE_LABELS[size] }, size))
|
|
995
|
-
]
|
|
996
|
-
}
|
|
997
|
-
)
|
|
998
|
-
] });
|
|
999
|
-
}
|
|
1000
|
-
function AssigneeInput({
|
|
1001
|
-
value,
|
|
1002
|
-
onChange,
|
|
1003
|
-
currentUser,
|
|
1004
|
-
className
|
|
1005
|
-
}) {
|
|
1006
|
-
const id = "feedback-admin-assignee-input";
|
|
1007
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1008
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Assigned to" }),
|
|
1009
|
-
/* @__PURE__ */ jsx(
|
|
1010
|
-
"input",
|
|
1011
|
-
{
|
|
1012
|
-
id,
|
|
1013
|
-
type: "text",
|
|
1014
|
-
value: value ?? "",
|
|
1015
|
-
"aria-label": "Assigned to",
|
|
1016
|
-
onChange: (e) => {
|
|
1017
|
-
const v = e.target.value;
|
|
1018
|
-
onChange(v === "" ? void 0 : v);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
),
|
|
1022
|
-
currentUser !== void 0 && /* @__PURE__ */ jsx(
|
|
1023
|
-
"button",
|
|
1024
|
-
{
|
|
1025
|
-
type: "button",
|
|
1026
|
-
onClick: () => onChange(currentUser.userId),
|
|
1027
|
-
children: "Assign to me"
|
|
1028
|
-
}
|
|
1029
|
-
)
|
|
1030
|
-
] });
|
|
1031
|
-
}
|
|
1032
|
-
function TagsInput({
|
|
1033
|
-
value,
|
|
1034
|
-
onChange,
|
|
1035
|
-
className
|
|
1036
|
-
}) {
|
|
1037
|
-
const id = "feedback-admin-tags-input";
|
|
1038
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1039
|
-
/* @__PURE__ */ jsx("label", { htmlFor: id, children: "Tags" }),
|
|
1040
|
-
/* @__PURE__ */ jsx(
|
|
1041
|
-
"input",
|
|
1042
|
-
{
|
|
1043
|
-
id,
|
|
1044
|
-
type: "text",
|
|
1045
|
-
value: value.join(", "),
|
|
1046
|
-
"aria-label": "Tags",
|
|
1047
|
-
placeholder: "Comma-separated",
|
|
1048
|
-
onChange: (e) => {
|
|
1049
|
-
const parsed = e.target.value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
1050
|
-
onChange(parsed);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
)
|
|
1054
|
-
] });
|
|
1055
|
-
}
|
|
1056
|
-
function CorrectionNote({
|
|
1057
|
-
value,
|
|
1058
|
-
onChange,
|
|
1059
|
-
required,
|
|
1060
|
-
className
|
|
1061
|
-
}) {
|
|
1062
|
-
const id = "feedback-admin-correction-note";
|
|
1063
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1064
|
-
/* @__PURE__ */ jsxs("label", { htmlFor: id, children: [
|
|
1065
|
-
"Correction note",
|
|
1066
|
-
required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " *" })
|
|
1067
|
-
] }),
|
|
1068
|
-
/* @__PURE__ */ jsx(
|
|
1069
|
-
"textarea",
|
|
1070
|
-
{
|
|
1071
|
-
id,
|
|
1072
|
-
value,
|
|
1073
|
-
required,
|
|
1074
|
-
"aria-required": required,
|
|
1075
|
-
"aria-label": "Correction note",
|
|
1076
|
-
placeholder: "Describe why the classification is changing…",
|
|
1077
|
-
onChange: (e) => onChange(e.target.value)
|
|
1078
|
-
}
|
|
1079
|
-
)
|
|
1080
|
-
] });
|
|
1081
|
-
}
|
|
1082
|
-
const EditableFields = {
|
|
1083
|
-
StatusSelect,
|
|
1084
|
-
TypeSelect,
|
|
1085
|
-
ScopeSelect,
|
|
1086
|
-
SizeSelect,
|
|
1087
|
-
AssigneeInput,
|
|
1088
|
-
TagsInput,
|
|
1089
|
-
CorrectionNote
|
|
1090
|
-
};
|
|
1091
|
-
function FeedbackUpdatePage({
|
|
1092
|
-
feedbackId,
|
|
1093
|
-
fetchItem,
|
|
1094
|
-
updateItem,
|
|
1095
|
-
onNavigate,
|
|
1096
|
-
currentUser,
|
|
1097
|
-
className
|
|
1098
|
-
}) {
|
|
1099
|
-
const [item, setItem] = useState(null);
|
|
1100
|
-
const [loading, setLoading] = useState(true);
|
|
1101
|
-
const [status, setStatus] = useState("open");
|
|
1102
|
-
const [type, setType] = useState("bug");
|
|
1103
|
-
const [scope, setScope] = useState(void 0);
|
|
1104
|
-
const [size, setSize] = useState(void 0);
|
|
1105
|
-
const [assignedTo, setAssignedTo] = useState(void 0);
|
|
1106
|
-
const [tags, setTags] = useState([]);
|
|
1107
|
-
const [correctionNote, setCorrectionNote] = useState("");
|
|
1108
|
-
const [saving, setSaving] = useState(false);
|
|
1109
|
-
const { allowedTargets } = useStatusTransition(status);
|
|
1110
|
-
useEffect(() => {
|
|
1111
|
-
let cancelled = false;
|
|
1112
|
-
setLoading(true);
|
|
1113
|
-
fetchItem(feedbackId).then((loadedItem) => {
|
|
1114
|
-
if (cancelled) return;
|
|
1115
|
-
setItem(loadedItem);
|
|
1116
|
-
setStatus(loadedItem.status);
|
|
1117
|
-
setType(loadedItem.type);
|
|
1118
|
-
setScope(loadedItem.scope);
|
|
1119
|
-
setSize(loadedItem.size);
|
|
1120
|
-
setAssignedTo(loadedItem.assignedTo);
|
|
1121
|
-
setTags(loadedItem.tags ?? []);
|
|
1122
|
-
setCorrectionNote("");
|
|
1123
|
-
setLoading(false);
|
|
1124
|
-
});
|
|
1125
|
-
return () => {
|
|
1126
|
-
cancelled = true;
|
|
1127
|
-
};
|
|
1128
|
-
}, [feedbackId, fetchItem]);
|
|
1129
|
-
const classificationChanged = item !== null && (type !== item.type || scope !== item.scope || size !== item.size);
|
|
1130
|
-
const saveDisabled = saving || item === null || classificationChanged && correctionNote.trim() === "";
|
|
1131
|
-
function handleCancel() {
|
|
1132
|
-
onNavigate(`/feedback/${feedbackId}`);
|
|
1133
|
-
}
|
|
1134
|
-
async function handleSave() {
|
|
1135
|
-
if (item === null || saveDisabled) return;
|
|
1136
|
-
setSaving(true);
|
|
1137
|
-
try {
|
|
1138
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1139
|
-
const patch = {
|
|
1140
|
-
lastModifiedAt: now
|
|
1141
|
-
};
|
|
1142
|
-
if (status !== item.status) {
|
|
1143
|
-
patch.status = status;
|
|
1144
|
-
if (status === "resolved") {
|
|
1145
|
-
patch.resolvedAt = now;
|
|
1146
|
-
patch.resolvedBy = currentUser?.userId ?? "unknown";
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
if (type !== item.type) patch.type = type;
|
|
1150
|
-
if (scope !== item.scope) {
|
|
1151
|
-
if (scope !== void 0) {
|
|
1152
|
-
patch.scope = scope;
|
|
1153
|
-
} else {
|
|
1154
|
-
patch.scope = void 0;
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
if (size !== item.size) {
|
|
1158
|
-
if (size !== void 0) {
|
|
1159
|
-
patch.size = size;
|
|
1160
|
-
} else {
|
|
1161
|
-
patch.size = void 0;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
if (assignedTo !== item.assignedTo) {
|
|
1165
|
-
if (assignedTo !== void 0) {
|
|
1166
|
-
patch.assignedTo = assignedTo;
|
|
1167
|
-
} else {
|
|
1168
|
-
patch.assignedTo = void 0;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (JSON.stringify(tags) !== JSON.stringify(item.tags)) {
|
|
1172
|
-
patch.tags = tags;
|
|
1173
|
-
}
|
|
1174
|
-
if (classificationChanged) {
|
|
1175
|
-
const changedFields = [];
|
|
1176
|
-
const before = {};
|
|
1177
|
-
const after = {};
|
|
1178
|
-
if (type !== item.type) {
|
|
1179
|
-
changedFields.push("type");
|
|
1180
|
-
before.type = item.type;
|
|
1181
|
-
after.type = type;
|
|
1182
|
-
}
|
|
1183
|
-
if (scope !== item.scope) {
|
|
1184
|
-
changedFields.push("scope");
|
|
1185
|
-
before.scope = item.scope;
|
|
1186
|
-
after.scope = scope;
|
|
1187
|
-
}
|
|
1188
|
-
if (size !== item.size) {
|
|
1189
|
-
changedFields.push("size");
|
|
1190
|
-
before.size = item.size;
|
|
1191
|
-
after.size = size;
|
|
1192
|
-
}
|
|
1193
|
-
const correctionEntry = {
|
|
1194
|
-
field: changedFields.join(", "),
|
|
1195
|
-
before,
|
|
1196
|
-
after,
|
|
1197
|
-
correctedBy: currentUser?.userId ?? "unknown",
|
|
1198
|
-
correctedAt: now,
|
|
1199
|
-
reason: correctionNote
|
|
1200
|
-
};
|
|
1201
|
-
patch.corrections = [...item.corrections ?? [], correctionEntry];
|
|
379
|
+
] }),
|
|
380
|
+
classificationChanged && /* @__PURE__ */ jsx(
|
|
381
|
+
TextareaField,
|
|
382
|
+
{
|
|
383
|
+
label: "Correction note",
|
|
384
|
+
value: correctionNote,
|
|
385
|
+
onChange: (e) => setCorrectionNote(e.target.value),
|
|
386
|
+
required: true,
|
|
387
|
+
...!correctionNote ? { error: "Required when changing type, scope, or size" } : {},
|
|
388
|
+
placeholder: "Explain why this classification is being changed..."
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: item.tags.map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "outline", children: tag }, tag)) })
|
|
392
|
+
] })
|
|
1202
393
|
}
|
|
1203
|
-
|
|
1204
|
-
onNavigate(`/feedback/${feedbackId}`);
|
|
1205
|
-
} finally {
|
|
1206
|
-
setSaving(false);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
if (loading) {
|
|
1210
|
-
return /* @__PURE__ */ jsx("article", { "data-page": "feedback-update", className, children: /* @__PURE__ */ jsx("p", { "data-loading": "true", children: "Loading…" }) });
|
|
394
|
+
) });
|
|
1211
395
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1215
|
-
return /* @__PURE__ */ jsxs("article", { "data-page": "feedback-update", className, children: [
|
|
1216
|
-
/* @__PURE__ */ jsxs("header", { children: [
|
|
1217
|
-
/* @__PURE__ */ jsxs("h1", { children: [
|
|
1218
|
-
item.id,
|
|
1219
|
-
" — Edit"
|
|
1220
|
-
] }),
|
|
1221
|
-
/* @__PURE__ */ jsxs("nav", { children: [
|
|
1222
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => onNavigate(`/feedback/${feedbackId}`), children: "← Back to detail" }),
|
|
1223
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleCancel, children: "Cancel" })
|
|
1224
|
-
] })
|
|
1225
|
-
] }),
|
|
1226
|
-
/* @__PURE__ */ jsxs("section", { "data-section": "read-only-context", "aria-label": "Read-only context", children: [
|
|
1227
|
-
/* @__PURE__ */ jsx(StatusBadge, { status: item.status }),
|
|
1228
|
-
/* @__PURE__ */ jsx(TypeBadge, { type: item.type }),
|
|
1229
|
-
/* @__PURE__ */ jsx("div", { "data-field": "content", children: /* @__PURE__ */ jsx("p", { children: item.content }) }),
|
|
1230
|
-
/* @__PURE__ */ jsxs("div", { "data-field": "metadata", children: [
|
|
1231
|
-
/* @__PURE__ */ jsx("span", { "data-field": "submittedAt", children: item.submittedAt }),
|
|
1232
|
-
item.environment && /* @__PURE__ */ jsx("span", { "data-field": "environment", children: item.environment }),
|
|
1233
|
-
/* @__PURE__ */ jsx("span", { "data-field": "reporterCount", children: item.reporterCount })
|
|
1234
|
-
] })
|
|
1235
|
-
] }),
|
|
1236
|
-
/* @__PURE__ */ jsxs("section", { "data-section": "edit-form", children: [
|
|
1237
|
-
/* @__PURE__ */ jsx(
|
|
1238
|
-
EditableFields.StatusSelect,
|
|
1239
|
-
{
|
|
1240
|
-
currentStatus: item.status,
|
|
1241
|
-
allowedTargets,
|
|
1242
|
-
value: status,
|
|
1243
|
-
onChange: setStatus
|
|
1244
|
-
}
|
|
1245
|
-
),
|
|
1246
|
-
/* @__PURE__ */ jsx(
|
|
1247
|
-
EditableFields.TypeSelect,
|
|
1248
|
-
{
|
|
1249
|
-
value: type,
|
|
1250
|
-
onChange: setType
|
|
1251
|
-
}
|
|
1252
|
-
),
|
|
1253
|
-
/* @__PURE__ */ jsx(
|
|
1254
|
-
EditableFields.ScopeSelect,
|
|
1255
|
-
{
|
|
1256
|
-
value: scope,
|
|
1257
|
-
onChange: setScope
|
|
1258
|
-
}
|
|
1259
|
-
),
|
|
1260
|
-
/* @__PURE__ */ jsx(
|
|
1261
|
-
EditableFields.SizeSelect,
|
|
1262
|
-
{
|
|
1263
|
-
value: size,
|
|
1264
|
-
onChange: setSize
|
|
1265
|
-
}
|
|
1266
|
-
),
|
|
1267
|
-
/* @__PURE__ */ jsx(
|
|
1268
|
-
EditableFields.AssigneeInput,
|
|
1269
|
-
{
|
|
1270
|
-
value: assignedTo,
|
|
1271
|
-
onChange: setAssignedTo,
|
|
1272
|
-
...currentUser !== void 0 ? { currentUser } : {}
|
|
1273
|
-
}
|
|
1274
|
-
),
|
|
1275
|
-
/* @__PURE__ */ jsx(
|
|
1276
|
-
EditableFields.TagsInput,
|
|
1277
|
-
{
|
|
1278
|
-
value: tags,
|
|
1279
|
-
onChange: setTags
|
|
1280
|
-
}
|
|
1281
|
-
),
|
|
1282
|
-
classificationChanged && /* @__PURE__ */ jsx(
|
|
1283
|
-
EditableFields.CorrectionNote,
|
|
1284
|
-
{
|
|
1285
|
-
value: correctionNote,
|
|
1286
|
-
onChange: setCorrectionNote,
|
|
1287
|
-
required: true
|
|
1288
|
-
}
|
|
1289
|
-
)
|
|
1290
|
-
] }),
|
|
1291
|
-
/* @__PURE__ */ jsxs("footer", { children: [
|
|
1292
|
-
/* @__PURE__ */ jsx(
|
|
1293
|
-
"button",
|
|
1294
|
-
{
|
|
1295
|
-
type: "submit",
|
|
1296
|
-
disabled: saveDisabled,
|
|
1297
|
-
"aria-disabled": saveDisabled,
|
|
1298
|
-
onClick: () => {
|
|
1299
|
-
void handleSave();
|
|
1300
|
-
},
|
|
1301
|
-
children: saving ? "Saving…" : "Save changes"
|
|
1302
|
-
}
|
|
1303
|
-
),
|
|
1304
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: handleCancel, disabled: saving, children: "Cancel" })
|
|
1305
|
-
] })
|
|
1306
|
-
] });
|
|
1307
|
-
}
|
|
396
|
+
);
|
|
397
|
+
FeedbackUpdatePage.displayName = "FeedbackUpdatePage";
|
|
1308
398
|
export {
|
|
1309
399
|
FeedbackDetailPage,
|
|
1310
400
|
FeedbackListPage,
|
|
1311
|
-
FeedbackUpdatePage
|
|
401
|
+
FeedbackUpdatePage,
|
|
402
|
+
StatusBadge,
|
|
403
|
+
TypeBadge,
|
|
404
|
+
useStatusTransition
|
|
1312
405
|
};
|
|
1313
406
|
//# sourceMappingURL=index.js.map
|