Skip to content

feat(widget): render the CMS-authored report-issue form from sy-atlas-config #216

Description

@Ardnived

Blocked by: sydevs/SahajCloud#813 — reportIssueForm does not exist on sy-atlas-config, and pnpm types:cms cannot pull it, until sydevs/SahajCloud#823 merges to main (was: Proposed)

Summary

Report-an-issue fails in production. sendReport posts a contact row that names no form, and SahajCloud refuses it with a 400 on form. #213 moved the call onto POST /api/user-submissions but could not fix this, because the CMS rule was still undecided. sydevs/SahajCloud#823 decides it the other way: the form-less row stays refused. The CMS now names an authored contact form on sy-atlas-config.reportIssueForm. The widget must read that form, render its fields, and post a contact row that names it.

Approach

  1. Types. Once feat(sy-atlas-config): name the atlas report-issue form on the config global SahajCloud#823 is on main, run pnpm types:cms. SyAtlasConfig gains reportIssueForm?: (number | null) | Form.
  2. Read the form id. getAtlasConfig (src/config/api/fetch.ts:720) selects only availableLocales. Add reportIssueForm: true to the select. Keep depth: 0 so the value stays a bare id, and extend AtlasConfigSchema to accept number | null.
  3. Fetch the form. Add a forms read by id, with an explicit select, because an API-client read must send one. Select only what the renderer needs: fields, submitButtonLabel, confirmationType/confirmationMessage. Never select recipient or client. feat(sy-atlas-config): name the atlas report-issue form on the config global SahajCloud#823 locks both to managers, but the widget must not rely on that lock. The forms read is already open to the atlas key, so no CMS role change is needed.
  4. Render the authored fields. ReportIssueForm (src/components/organisms/ReportIssueForm/ReportIssueForm.tsx) hard-codes an optional email, a message, and ReportSchema. Replace these with fields and validation derived from the form's fields. Support the form-builder block types a contact form can hold, at least text, email, textarea, select, checkbox, message. Keep REFUSAL_MESSAGE_KEYS, Turnstile, the honest thank-you screen, and networkMode exactly as they are.
  5. Post against the form. sendReport (src/config/api/mutate.ts:309) adds form: <id> and sends each authored field as a { field: <name>, value } pair. The CMS allows the authored names plus the base and contact keys (allowedSubmissionKeys in SahajCloud src/collections/UserSubmissions/submissionData.ts). So subject and the auto-attached context (path, hostUrl, locale, userAgent, error) can ride along unchanged. An unknown key is a 400 submission_data_invalid. Keep leaving out context.client.
  6. Unset form. The CMS field says an empty value hides the report-issue path entirely. Gate every entry point on it: Fallbacks.tsx, SettingsMenu.tsx, CompactEmbedView.tsx, and the modal mount in App.tsx:245.
  7. Docs. Update the sendReport bullet in docs/rules/data-layer.md:215, and remove the SahajCloud#813 blocker breadcrumbs that feat(api): migrate widget intakes to unified form-submissions #213 left in mutate.ts and data-layer.md.

Acceptance criteria

  • With reportIssueForm set, the modal renders that form's authored fields and labels, not hard-coded ones.
  • A submit creates a contact row whose form is the configured id. The message reaches that form's recipient, or CONTACT_EMAIL if the form has none.
  • Every refusal code still maps to its specific copy, and the thank-you screen still appears only on a resolved mutation.
  • With reportIssueForm empty, the widget shows no "Report an issue" affordance anywhere, and nothing throws.
  • No request from the widget selects or receives recipient or client off forms.
  • If the form cannot be fetched, the widget degrades and does not crash, per the "atlas reads must degrade" rule.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.

Verification checklist

  • pnpm types:cms, then grep -n reportIssueForm src/types/payload/payload-types.ts shows the field.
  • Set up a contact form with a recipient on SahajCloud (the PR preview or staging), and name it on /admin/globals/sy-atlas-config.
  • Open "Report an issue" on the branch preview and submit. The network tab shows POST /api/user-submissions → 201 with form in the body. The row appears in /admin/collections/user-submissions, and the email reaches the recipient.
  • Clear reportIssueForm, reload, and confirm that the Settings menu and the error fallbacks show no report affordance.
  • Check the GET /api/forms/<id> response in the network tab. It contains no recipient or client key.
  • ReportIssueForm.submit.test.tsx asserts that form is in the posted body, and fails when it is removed.

Open questions

  • Fetch timing. The form is mostly reached from error fallbacks, which appear after something already failed, often the network. Should it be prefetched at boot with the config, or fetched on open, with a fallback if that fails? Prefetching is recommended, so a network failure does not also take out the only way to report it.
  • Hiding when unset. Should an unset form hide the affordance inside the error fallbacks too, or should those keep a mailto: to the contact address? The CMS description says "hide … entirely".
  • Sender address. Which authored field is the sender's address? Should the first email-type field be mapped to senderEmail, or should a field name be fixed by convention?
  • Copy. Are the form-builder labels localized on SahajCloud? If not, a non-English viewer sees English labels while the rest of the modal is translated.

Notes

Activity

  1. added theissue type on Sep 18, 2026
  2. sydevs-bot commented on Sep 18, 2026

    @sydevs-bot
    Contributor

    @Ardnived unblocked: every blocker is closed. Say @sydevs-bot implement to start.

    🤖 sydevs dispatcher

  3. Ardnived commented on Sep 21, 2026

    @Ardnived
    ContributorAuthor

    @sydevs-bot implement

  4. added
    bot:working
    and removed on Sep 21, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Sep 21, 2026
  6. sydevs-bot commented on Sep 21, 2026

    @sydevs-bot
    Contributor

    🤖 no session running

    recent dispatches
    • 18:00Z implement · attempt 1 · session · done
    • 18:00Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  7. removed
    bot:working
    on Sep 21, 2026
  8. added a commit that references this issue on Oct 1, 2026
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

    No labels
    No labels

    Fields

    Priority

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions