feat(projects): edit existing registered projects#16
Merged
Conversation
Closes nathanwhit#15: projects could only be added or removed, with no way to edit a registered project's name, repo, fork, or base branch. Backend: - store.UpdateProject does a full UPDATE by id, setting every editable field explicitly so emptied fields actually clear (unlike UpsertProject, which is keyed by repo and preserves empty values) and the repo itself can change. Returns ErrNotFound when no row matches and a new ErrConflict when the new repo collides with another project (repo is UNIQUE). - PUT /api/projects/{id} -> updateProject handler (reuses upsertProjectReq; repo required -> 400). ErrNotFound -> 404, ErrConflict -> 409 via the existing httpStatusFor helper. - Go tests for the store update (success, field-clear, not-found, conflict) and the PUT endpoint (200, 404, 400). Frontend: - api.put mirroring api.post; an "edit" (square-pen) icon. - AddProjectModal refactored into a shared ProjectModal that pre-fills and PUTs when given a project ("Edit project") and POSTs otherwise ("Add project", unchanged). Each project row gains an Edit button next to Remove. Verification: - Playwright e2e (ui/e2e/projects.spec.ts) drives the full stack against a real orcha server (fake agents, in-memory SQLite): adds a project, edits its name and base branch, and asserts the change is reflected. Added @playwright/test, playwright.config.ts, and a test:e2e npm script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #15.
Previously you could only add or remove registered projects — there was no way to edit one in place. This adds a real edit flow, exposed in the UI and verified end-to-end with Playwright.
Backend (Go)
internal/store/projects.go— newUpdateProject(p): a fullUPDATEby id that sets every editable field explicitly, so emptied fields actually clear (unlike the repo-keyedUpsertProject, which preserves empty fields). Defaults an empty name to the repo, returnsErrNotFoundwhen no row matches (viaRowsAffected), and returns a conflict error on aUNIQUErepo collision instead of panicking.internal/store/store.go— newErrConflictsentinel for uniqueness violations.internal/api/api.go— registeredPUT /api/projects/{id}with anupdateProjecthandler (reusesupsertProjectReq; repo required → 400).ErrNotFound→ 404 andErrConflict→ 409 via the existinghttpStatusForhelper.TestUpdateProject(success, field-clear, not-found, conflict) andTestUpdateProject_Endpoint(200/404/400), following the existing test style.Frontend (React/TS)
ui/src/api.ts—put<T>helper mirroringpost.ui/src/icons.tsx— lucidesquare-penpath underedit.ui/src/pages/Projects.tsx— each project row gains an Edit button next to Remove.AddProjectModalis refactored into a sharedProjectModalthat pre-fills fields, titles itself "Edit project", andPUTs when given a project; otherwise it behaves exactly as before ("Add project",POST).Playwright verification
The issue explicitly asked to "make sure with playwright."
@playwright/test,playwright.config.ts, and atest:e2enpm script. The config'swebServerbuilds the UI and runs the Go server (-fake-agents -db :memory:) so the binary serves both the SPA and/apion one port.ui/e2e/projects.spec.tsdrives the full stack: adds a project, edits its name and base branch, and asserts the change is reflected (old values gone)..gitignoreupdated for Playwright artifacts.Verification
go build ./...,go vet ./...,go test ./...pass; the UI builds; and the Playwright e2e test passes locally.