Skip to content

Web 4461 save and publish button - #32

Open
boulch wants to merge 1 commit into
mainfrom
WEB-4461_save_and_publish_button
Open

Web 4461 save and publish button#32
boulch wants to merge 1 commit into
mainfrom
WEB-4461_save_and_publish_button

Conversation

@boulch

@boulch boulch commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added a configurable Save and publish button to add and edit forms.
    • The button appears only when publishing is supported and permitted.
    • Added publishing for newly created and edited content.
  • Bug Fixes
    • Prevented publishing when submissions contain validation errors.
    • Added warnings for unsuccessful publishing transitions.
  • Documentation
    • Updated the changelog with the new Save and publish functionality.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10a83efb-e870-47f1-8a79-d664bd93a378

📥 Commits

Reviewing files that changed from the base of the PR and between 754dbd7 and c23bb07.

📒 Files selected for processing (1)
  • src/imio/smartweb/common/behaviors/publish.py

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

Adds an opt-in Save and publish behavior. Add and edit forms save valid content, then apply an allowed transition to published. Tests cover visibility, ordering, permissions, transitions, validation errors, and warning messages.

Changes

Save and publish

Layer / File(s) Summary
Publishing behavior and workflow helpers
src/imio/smartweb/common/behaviors/*, src/imio/smartweb/common/profiles/testing/types/Document.xml, src/imio/smartweb/common/tests/test_publish.py
Defines the opt-in behavior and publishing helpers. The helpers check behavior, workflow transitions, type configuration, permissions, and workflow errors.
Add and edit form actions
src/imio/smartweb/common/browser/forms.py, src/imio/smartweb/common/tests/test_forms.py, CHANGES.rst
Adds conditional Save and publish actions to add and edit forms. The forms preserve inherited controls, save content, publish valid objects, and retain validation errors. Tests and the changelog cover the new action.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to c23bb

This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant Form
  participant PublishingHelpers
  participant Workflow
  Browser->>Form: Submit Save and publish
  Form->>Form: Save valid content
  Form->>PublishingHelpers: Find and apply published transition
  PublishingHelpers->>Workflow: Apply allowed transition
  Workflow-->>Browser: Return published result or warning
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a Save and publish button, and includes the related issue number.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WEB-4461_save_and_publish_button

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md`:
- Around line 42-43: Update the documented publish API and edit-form example to
include the required request argument used by publish in the implementation.
Ensure every shown invocation passes request alongside obj and transition so
copied examples do not raise TypeError.
- Around line 137-143: Update the documented minimum-coverage test module
reference from tests/test_save_and_publish.py to
src/imio/smartweb/common/tests/test_publish.py, preserving the listed test
scenarios.

In `@src/imio/smartweb/common/behaviors/configure.zcml`:
- Around line 22-27: Update the behavior metadata in the plone:behavior
declaration for imio.smartweb.save_and_publish to use the message factory from
imio.smartweb.locales for both title and description instead of literal strings,
preserving their current meanings and translation keys.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17ada98e-8202-45a3-965e-18cf04f832fd

📥 Commits

Reviewing files that changed from the base of the PR and between b325053 and e3ca7a2.

📒 Files selected for processing (8)
  • CHANGES.rst
  • docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md
  • src/imio/smartweb/common/behaviors/configure.zcml
  • src/imio/smartweb/common/behaviors/publish.py
  • src/imio/smartweb/common/browser/forms.py
  • src/imio/smartweb/common/profiles/testing/types/Document.xml
  • src/imio/smartweb/common/tests/test_forms.py
  • src/imio/smartweb/common/tests/test_publish.py

Comment thread docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md
Comment on lines +137 to +143
`tests/test_save_and_publish.py`, couverture minimale 90 % :

- bouton présent sur un `Document` privé avec le behavior actif ;
- bouton absent sur un type sans le behavior (`Folder`) ;
- bouton absent sur un contenu déjà publié ;
- le bouton publie effectivement, depuis le formulaire d'édition ;
- le bouton crée puis publie, depuis le formulaire d'ajout.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented test module path.

The implemented test module is src/imio/smartweb/common/tests/test_publish.py. Replace tests/test_save_and_publish.py so the specification points to the test file in this PR.

🧰 Tools
🪛 LanguageTool

[typographical] ~140-~140: Caractère d’apostrophe incorrect.
Context: ...ton absent sur un type sans le behavior (Folder) ; - bouton absent sur un conten...

(APOS_INCORRECT)

🤖 Prompt for 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.

In `@docs/superpowers/specs/2026-08-07-save-and-publish-button-design.md` around
lines 137 - 143, Update the documented minimum-coverage test module reference
from tests/test_save_and_publish.py to
src/imio/smartweb/common/tests/test_publish.py, preserving the listed test
scenarios.

Comment on lines +22 to +27
<plone:behavior
name="imio.smartweb.save_and_publish"
title="Save and publish"
description="Add a 'Save and publish' button on add and edit forms."
provides=".publish.ISaveAndPublish"
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use message-factory-backed behavior metadata.

Lines 24-25 add user-facing behavior labels as literal strings. Use messages from imio.smartweb.locales for the title and description so the behavior picker can translate them.

As per coding guidelines, use “the message factory from imio.smartweb.locales for all user-facing strings in Plone views and components.”

🤖 Prompt for 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.

In `@src/imio/smartweb/common/behaviors/configure.zcml` around lines 22 - 27,
Update the behavior metadata in the plone:behavior declaration for
imio.smartweb.save_and_publish to use the message factory from
imio.smartweb.locales for both title and description instead of literal strings,
preserving their current meanings and translation keys.

Source: Coding guidelines

@boulch
boulch force-pushed the main branch 2 times, most recently from c03c564 to 06eea6b Compare August 11, 2026 09:13
@boulch
boulch force-pushed the WEB-4461_save_and_publish_button branch from e3ca7a2 to 754dbd7 Compare August 19, 2026 07:13
@boulch
boulch force-pushed the WEB-4461_save_and_publish_button branch from 754dbd7 to c23bb07 Compare August 19, 2026 07:15
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