Skip to content

Add JSON response format to board publication toggle#2663

Open
robzolkos wants to merge 1 commit intobasecamp:mainfrom
robzolkos:json-board-publication
Open

Add JSON response format to board publication toggle#2663
robzolkos wants to merge 1 commit intobasecamp:mainfrom
robzolkos:json-board-publication

Conversation

@robzolkos
Copy link
Contributor

Summary

  • Adds respond_to blocks to Boards::PublicationsController for JSON support alongside existing Turbo Stream responses
  • Publishing returns 201 Created with the shareable key and public url
  • Unpublishing returns 204 No Content
  • Only board administrators can publish/unpublish (existing permission check unchanged)

Copilot AI review requested due to automatic review settings March 4, 2026 20:19
@robzolkos robzolkos marked this pull request as ready for review March 4, 2026 20:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds JSON support for publishing/unpublishing boards so API clients can toggle public access and receive a shareable link, alongside the existing Turbo Stream behavior.

Changes:

  • Add respond_to JSON branches in Boards::PublicationsController#create/destroy (201 w/ {key,url} on publish, 204 on unpublish).
  • Add integration tests for JSON publish/unpublish.
  • Document the new Board Publications endpoints in docs/API.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
app/controllers/boards/publications_controller.rb Adds JSON responses for publish/unpublish actions alongside Turbo Stream.
test/controllers/boards/publications_controller_test.rb Adds JSON request tests for publish/unpublish.
docs/API.md Documents Board Publications API endpoints and example responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Allows programmatic clients to publish and unpublish boards via
the API, returning the shareable key and URL on publish.
@robzolkos robzolkos force-pushed the json-board-publication branch from b8c0359 to eebb196 Compare March 4, 2026 20:29

respond_to do |format|
format.turbo_stream
format.json { head :no_content }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the default Rails response anyway? Can it be omitted?


respond_to do |format|
format.turbo_stream
format.json { render json: { key: @board.publication.key, url: published_board_url(@board) }, status: :created }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON response should typically be the entity created. Would add a partial for the board publication, include it in boards/_board (if published), and then choose whether to render the publication itself or the entire board in response here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants