Skip to content

[GT-1290] - Allow updating page filename and reordering pages#2016

Open
wjames111 wants to merge 8 commits into
masterfrom
GT-1290
Open

[GT-1290] - Allow updating page filename and reordering pages#2016
wjames111 wants to merge 8 commits into
masterfrom
GT-1290

Conversation

@wjames111

Copy link
Copy Markdown

Summary

  • PagesController#update now permits filename (alongside structure), so the admin tool can rename a page without direct database access. Duplicate filenames are rejected by the existing model validation (400).
  • New POST /resources/:resource_id/pages/reorder endpoint takes the complete ordered list of page ids and atomically renumbers positions 0..n-1 in a transaction. The id set must exactly match the resource's pages (else 400). A two-pass update (park at negative positions, then assign final order) avoids collisions with the (position, resource_id) unique index; validation happens inside the transaction with a row lock.
  • PageSerializer now serializes position, so clients can sort pages without relying on the API's default ordering.

Supports the admin-side UI in the companion mobile-content-admin PR (drag-and-drop reorder + inline rename), which depends on this change.

Test Plan

  • Acceptance specs: rename success + duplicate rejection, reorder success (persisted order + positions + response body) + mismatched-ids rejection, auth required on both endpoints (spec/acceptance/pages_controller_spec.rb — 15 examples, 0 failures)
  • Full suite green except 4 pre-existing global-activity-analytics failures that also fail on master
  • standardrb clean

🤖 Generated with Claude Code

@stage-branch-merger

Copy link
Copy Markdown

I see you added the "On Staging" label, I'll get this merged to the staging branch!

Patch-level lockfile bumps for concurrent-ruby, crass, faraday, json,
loofah, msgpack, net-imap, nokogiri, rails-html-sanitizer, and
websocket-driver. New advisories published 2026-07-17 fail the CI lint
job on any branch, including master.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stage-branch-merger

Copy link
Copy Markdown

Merge conflict attempting to merge this into staging. Please fix manually.

brakeman --ensure-latest fails CI now that 8.0.5 is out; the update also
surfaces a new Rails 7.2 EOL warning (2026-08-09), recorded in
config/brakeman.ignore the same way the previous Rails 7.1 EOL warning
was, replacing that now-obsolete entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stage-branch-merger

Copy link
Copy Markdown

Merge conflict attempting to merge this into staging. Please fix manually.

Comment thread config/routes.rb Outdated
Comment thread app/controllers/pages_controller.rb
wjames111 and others added 2 commits July 20, 2026 15:05
Group pages reorder route with the other pages routes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Allow updating page position directly via pages#update

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stage-branch-merger

Copy link
Copy Markdown

Merge conflict attempting to merge this into staging. Please fix manually.

@wjames111
wjames111 requested a review from frett July 21, 2026 13:57
@wjames111 wjames111 changed the title GT-1290 Allow updating page filename and reordering pages [GT-1290] - Allow updating page filename and reordering pages Jul 21, 2026
Comment thread config/routes.rb
resources :drafts, only: [:index, :show, :create, :destroy]
resources :translations, only: [:index, :show]
resources :pages, only: [:create, :update, :show]
post "resources/:resource_id/pages/reorder", to: "pages#reorder"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I forgot that the normal pages endpoint wasn't nested under resources like it should have been :(

Renaming or repositioning an existing page ran UsesCrowdinValidator and
400'd for any resource without a crowdin_project_id, even though page
saves never push to Crowdin. Scope the validator to creation so existing
pages stay editable while page creation on non-Crowdin resources stays
blocked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wjames111

Copy link
Copy Markdown
Author

90eaa52 scopes UsesCrowdinValidator to on: :create: renaming/repositioning an existing page was 400ing with "Resource Does not use Crowdin." for the 30 staging resources without a crowdin_project_id, even though page saves never push to Crowdin (CrowdinService only pulls at publish). Creation on non-Crowdin resources stays blocked.

Note this also unblocks structure edits on non-Crowdin resources (previously blocked by the same validation) — @frett flagging in case that block was intentional.

🤖 Generated with Claude Code

Comment thread app/models/page.rb
validates :position, presence: true, uniqueness: {scope: :resource}
validates :resource, presence: true
validates_with UsesCrowdinValidator
validates_with UsesCrowdinValidator, on: :create

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we even need this validator still?

the API used to upload phrases to OneSky (pre-Crowdin) to provide the new phrases for translators. This process was buggy and ended up paving over quite a few translations so we disabled it ~10 years ago and removed the upload entirely a couple years ago. I'm not sure what the UsesCrowdinValidator actually is doing for the Page model, but it might be unnecessary code

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants