Skip to content

[8571] Disable staging target on initial publish#4903

Open
jvega190 wants to merge 3 commits into
craftercms:developfrom
jvega190:bugfix/8571
Open

[8571] Disable staging target on initial publish#4903
jvega190 wants to merge 3 commits into
craftercms:developfrom
jvega190:bugfix/8571

Conversation

@jvega190

@jvega190 jvega190 commented Jun 26, 2026

Copy link
Copy Markdown
Member

craftercms/craftercms#8571

Summary by CodeRabbit

  • Bug Fixes
    • Improved how the publishing target is chosen when opening the publish dialog, so first-time publishing now defaults to the most appropriate available target.
    • Updated target availability rules to better reflect publish vs. promote flows.
    • Clarified the staging option label when it can’t be selected on first publish.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@jvega190, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 23 minutes and 54 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7c424aa3-6061-4140-a35c-6ab3ceba5820

📥 Commits

Reviewing files that changed from the base of the PR and between 05dd91e and e67f8eb.

📒 Files selected for processing (1)
  • ui/app/src/components/PublishDialog/PublishDialogContainer.tsx

Walkthrough

The publish dialog now selects the initial publishing target based on published status, and the publishing target options update their disabled state and labels to reflect staging behavior on first publish.

Changes

Publish dialog target behavior

Layer / File(s) Summary
Target defaulting and option state
ui/app/src/components/PublishDialog/PublishDialogContainer.tsx, ui/app/src/components/PublishDialog/PublishDialogForm.tsx
publishingTarget now defaults differently for published versus unpublished content, and the publishing target radios now use published status to adjust disabled states and labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • rart
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: disabling the staging target on initial publish.
Description check ✅ Passed The description satisfies the template by providing the related ticket reference as the PR description.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/src/components/PublishDialog/PublishDialogContainer.tsx`:
- Around line 122-124: The target selection logic in PublishDialogContainer
should not default to a disabled staging option on first publish. Update the
branch that sets `target` so it uses `published` only to allow staging, but when
`published` is false it selects the first non-`staging` entry from
`publishingTargets` and leaves the value empty if no other target exists. Use
the existing `publishingTargets` lookup and `PublishDialogForm` behavior to
ensure `state.publishingTarget` is not prefilled with a disabled option.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bba03b3f-3dcb-4b4c-a6d1-afe8beec8234

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8ec52 and 05dd91e.

📒 Files selected for processing (2)
  • ui/app/src/components/PublishDialog/PublishDialogContainer.tsx
  • ui/app/src/components/PublishDialog/PublishDialogForm.tsx

Comment thread ui/app/src/components/PublishDialog/PublishDialogContainer.tsx Outdated
@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf "\n== Changed files ==\n"
git diff --name-only origin/develop...HEAD || git diff --name-only HEAD~1...HEAD

printf "\n== PublishDialogContainer outline ==\n"
ast-grep outline ui/app/src/components/PublishDialog/PublishDialogContainer.tsx --view expanded || true

printf "\n== PublishDialogForm outline ==\n"
ast-grep outline ui/app/src/components/PublishDialog/PublishDialogForm.tsx --view expanded || true

printf "\n== Diff for changed files ==\n"
git diff --unified=80 origin/develop...HEAD -- \
  ui/app/src/components/PublishDialog/PublishDialogContainer.tsx \
  ui/app/src/components/PublishDialog/PublishDialogForm.tsx || \
git diff --unified=80 HEAD~1...HEAD -- \
  ui/app/src/components/PublishDialog/PublishDialogContainer.tsx \
  ui/app/src/components/PublishDialog/PublishDialogForm.tsx

printf "\n== Relevant snippets: publishing target logic and messages ==\n"
rg -n -C4 'publishingTarget|publishingTargets|isPromote|published|staging|Publishing Target' \
  ui/app/src/components/PublishDialog/PublishDialogContainer.tsx \
  ui/app/src/components/PublishDialog/PublishDialogForm.tsx \
  ui/app/src/components/PublishDialog -g '!**/*.test.*' || true

Length of output: 88397



@jvega190 I took a final pass over the changes, and this looks good to hand off for human review.

What I checked:

  • Initial publish no longer auto-selects staging in ui/app/src/components/PublishDialog/PublishDialogContainer.tsx around Line 122.
  • staging is explicitly disabled for first publish in ui/app/src/components/PublishDialog/PublishDialogForm.tsx around Line 318.
  • The UI label clearly communicates that behavior at ui/app/src/components/PublishDialog/PublishDialogForm.tsx around Line 332.
  • The existing guard that prevents submit without a valid target is still in place in ui/app/src/components/PublishDialog/PublishDialogContainer.tsx at Line 211.

I didn’t find any blocking issues in the updated flow.
Only tiny nit: the comment near ui/app/src/components/PublishDialog/PublishDialogContainer.tsx Lines 120-121 still mentions defaulting to staging, which no longer matches the new behavior.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@jvega190 I’ll do one more fresh end-to-end pass before you hand this off for human review.

✅ Action performed

Full review finished.

@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai, the last commit hasn't been reviewed. Please review and report findings.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== PR branch HEAD commit =="
git log --oneline -n 5

echo
echo "== Files changed in last commit =="
git diff --name-only HEAD~1..HEAD

echo
echo "== Last commit diff =="
git diff --unified=80 HEAD~1..HEAD -- \
  ui/app/src/components/PublishDialog/PublishDialogContainer.tsx \
  ui/app/src/components/PublishDialog/PublishDialogForm.tsx

echo
echo "== AST outline: PublishDialogContainer =="
ast-grep outline ui/app/src/components/PublishDialog/PublishDialogContainer.tsx --view expanded || true

echo
echo "== AST outline: PublishDialogForm =="
ast-grep outline ui/app/src/components/PublishDialog/PublishDialogForm.tsx --view expanded || true

echo
echo "== PublishDialogContainer relevant slice =="
sed -n '100,250p' ui/app/src/components/PublishDialog/PublishDialogContainer.tsx

echo
echo "== PublishDialogForm relevant slice =="
sed -n '260,380p' ui/app/src/components/PublishDialog/PublishDialogForm.tsx

echo
echo "== Search for publishing target submit validation and initial value usage =="
rg -n -C3 'publishingTarget|setFieldValue|onSubmit|validationSchema|disabled:|isPromote|published' \
  ui/app/src/components/PublishDialog/PublishDialogContainer.tsx \
  ui/app/src/components/PublishDialog/PublishDialogForm.tsx

Length of output: 50798



@jvega190 I reviewed the last commit (e67f8eb15) specifically.

Findings: no new issues from that commit.

What I verified:

  • The last commit only updates the comment in ui/app/src/components/PublishDialog/PublishDialogContainer.tsx around Lines 120-121.
  • That comment now matches the current behavior much better:
    • already-published content prefers staging
    • first publish avoids preselecting staging
  • The form logic is still consistent with that behavior in ui/app/src/components/PublishDialog/PublishDialogForm.tsx around Lines 318-333, where staging is disabled and labeled accordingly on first publish.
  • The submit guard is still intact in ui/app/src/components/PublishDialog/PublishDialogContainer.tsx at Line 211, so the dialog cannot submit without a valid target.

So from this final pass, I don’t have any remaining findings on the latest commit. This looks good to hand over for human review.

@jvega190 jvega190 marked this pull request as ready for review June 26, 2026 14:22
@jvega190 jvega190 requested a review from rart as a code owner June 26, 2026 14:22
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.

1 participant