Skip to content

Conversation

@alecgeatches
Copy link
Contributor

@alecgeatches alecgeatches commented Sep 17, 2024

Description

Adds a "This status requires a review" toggle on statuses in the VIP Workflow editor:

workflow-edit-modal

This is the first step in adding this feature. Currently, this is only the checkbox and persistence. The approve/reject dialog on steps that require approval will come in a separate PR.

Made a couple of other small changes:

  1. Changed default data to set review required on the "Pending Review" default status. To test, delete the "Pending Review" status, then run wp option delete vip_workflow_custom_status_options, then refresh the workflow page. You should see a new "Pending Review" status with the review required toggle enabled by default.

  2. Added a divider, and moved action buttons to the right side of the modal as pictured above. This felt more right, and I checked to see that other modals in Gutenberg used the same layout. This one can be viewed by editing a block in the editor, clicking the "..." dropdown in the floating toolbar, and clicking "Create Pattern":

    create-pattern-modal

    The <HStack> used in our code to right-align the buttons is the same used from the above modal in Gutenberg core. Although it's labeled as "experimental", it's been around for a few years and it's used extensively in Gutenberg as well.

Steps to test

  1. Check out this PR.
  2. Create a new status with the review required toggle enabled, and ensure it persists properly after saving.
  3. Modify existing statuses and ensure that the review required toggle persists correctly.
  4. Try the wp option delete vip_workflow_custom_status_options steps mentioned above, and ensure that the "Pending Review" status is created with the toggle default on.

@alecgeatches alecgeatches requested a review from a team as a code owner September 17, 2024 19:03
@alecgeatches alecgeatches self-assigned this Sep 17, 2024
$args_to_encode = [];
$args_to_encode['description'] = $args['description'] ?? $old_status->description;
$args_to_encode['position'] = $args['position'] ?? $old_status->position;
$args_to_encode['is_review_required'] = $args['is_review_required'] ?? $old_status->is_review_required ?? false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this double null coalescing operator is pretty nifty.

@alecgeatches
Copy link
Contributor Author

Also added some REST tests that test CRUD operations for custom statuses and reordering over REST. Somewhat related to this PR as we also test the new is_review_required flag is saved properly. Merging!

@alecgeatches alecgeatches merged commit a487a73 into trunk Sep 18, 2024
@alecgeatches alecgeatches deleted the add/approve-reject-workflow-setting branch September 18, 2024 21:32
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