Skip to content

Prompts: edit/delete a prompt in place via a dialog instead of jumping to the brand page #484

Closed

Description

@gkhngyk

Problem

Each row on the All Prompts tab (web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx) has an edit (pencil) button — but it just links to the top of /dashboard/brands/[id]/prompts, with no reference to the prompt that was clicked. The user has to find the same prompt again in a different list to change anything. Editing where you see the list is the same baseline expectation that motivated #460's Add prompt dialog.

Fix

Replace the pencil link with an Edit Prompt dialog, the sibling of the Add Prompt dialog from #483:

  • Fields pre-filled from the row's prompt: text, topic (Select over the brand's topics), the grouped Platform & Models picker (plan-filtered, chatgpt-shopping hidden unless the brand opted in — same rules as the Add dialog), and an active/paused toggle.
  • A Delete button inside the dialog with an inline confirm step, calling the existing deletePrompt.
  • Save calls the existing updatePrompt(id, { text, category, platforms, models, isActive }) (web/src/lib/actions/prompt.ts) — it already handles topic resolution, plan filtering and shopping stripping, so no backend changes are needed.
  • On success: close, refresh the list, toast.

Reuse, don't fork

The Add Prompt dialog (#483) already contains the exact form pieces (text input, topic select, grouped platform/model picker with badge chips). Extract the shared parts into a common component (or a shared form body) rather than copy-pasting — the two dialogs must not drift apart.

Role gate

The pencil currently renders for every role. Hide it (like the Add button) for members without write access — canManage from useUserRole.

Behavior note

Editing the text keeps the prompt's id, so its tracking history stays attached — this matches the existing behavior of the brand page's inline text editing. No migration or data handling needed.

Acceptance criteria

  • Clicking the pencil opens the dialog pre-filled with the prompt's current text, topic, platforms/models, and active state; saving updates the row in place.
  • The prompt can be deleted from the dialog after an explicit confirm; the row disappears from the list.
  • Platform/model options follow the same plan/shopping visibility rules as the Add dialog; saving with no engine selected is blocked.
  • Members without write access see no pencil button.
  • Shared form pieces are factored out of the Add dialog, not duplicated.
  • yarn lint, yarn typecheck, yarn format:check pass from web/.

Getting started

Depends on #483 (the Add Prompt dialog whose form pieces this reuses) — start after it merges. See CONTRIBUTING.md for setup. Comment here to claim the issue before opening a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions