fix(directory): keep failed owner actions in place#364
Conversation
Greptile SummaryThis PR fixes owner action regressions in the directory listing component by wrapping all three mutation handlers (
Confidence Score: 5/5Safe to merge — all three handlers now correctly preserve UI state on failure and the changes are well-covered by the new focused tests. The refactoring is mechanically sound: try/catch/finally is applied consistently across all three handlers, the responseError helper gracefully falls back when parsing fails, and error state is cleared at every transition point. The two regressions called out in the PR description are both directly exercised by the new tests. No unguarded state mutations or uncaught promise rejections remain in the changed code paths. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Owner Action Button Clicked] --> B{Action Type}
B -->|Edit| C[Clear error, set editing true]
B -->|Hide or Show| D[Clear error, set loading true]
B -->|Delete| E{confirm dialog}
E -->|Cancelled| F[return early]
E -->|Confirmed| G[Clear error, set loading true]
C --> H[Render Edit Form]
H -->|Submit| I[Clear error, set loading true]
H -->|Cancel| J[Clear error, set editing false]
I --> K[fetch PATCH]
D --> L[fetch PATCH status]
G --> M[fetch DELETE]
K -->|Network error| N[catch: setError Update failed]
K -->|not ok| O[setError from responseError]
K -->|ok| P[setEditing false + router.refresh]
L -->|Network error| Q[catch: setError Visibility update failed]
L -->|not ok| R[setError from responseError]
L -->|ok| S[router.refresh]
M -->|Network error| T[catch: setError Delete failed]
M -->|not ok| U[setError from responseError]
M -->|ok| V[router.push /directory]
N --> W[finally: setLoading false]
O --> W
P --> W
Q --> X[finally: setLoading false]
R --> X
S --> X
T --> Y[finally: setLoading false]
U --> Y
V --> Y
W --> Z[Show alert in Edit form]
X --> AA[Show alert in Owner Actions panel]
Y --> AA
Reviews (2): Last reviewed commit: "fix(directory): recover from edit networ..." | Re-trigger Greptile |
Summary
Paid task
https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e
Verification
pnpm exec vitest run 'src/app/directory/[id]/DirectoryOwnerActions.test.tsx'pnpm exec eslint 'src/app/directory/[id]/DirectoryOwnerActions.tsx' 'src/app/directory/[id]/DirectoryOwnerActions.test.tsx'git diff --check