Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/7.2/14545.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/14545

* https://github.com/WordPress/gutenberg/pull/85186
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected function get_action_schema() {
'context' => array(
'description' => __( 'The context the action is limited to, such as `list` for the lists of items. Without it, the action shows everywhere.', 'gutenberg' ),
'type' => 'string',
'enum' => array( 'list', 'single' ),
'enum' => array( 'list' ),
),
'modalHeader' => array(
'description' => __( 'The header of the modal of the action.', 'gutenberg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class WP_Entity_Actions_Registry {
* @var array<string, string[]>
*/
const SUPPORTED_VALUES = array(
'context' => array( 'list', 'single' ),
'context' => array( 'list' ),
'modalSize' => array( 'small', 'medium', 'large', 'fill' ),
);

Expand Down Expand Up @@ -214,8 +214,8 @@ public function register( $origin, $kind, $name, $actions, $script_module = null
* _doing_it_wrong().
*
* A value DataViews does not support is otherwise silent: an action
* whose `context` is not `list` or `single` shows on no screen. Such a
* value is kept, like the field types the fields registry reports.
* whose `context` is not `list` shows on no screen. Such a value is
* kept, like the field types the fields registry reports.
* `callback`, `RenderModal`, and `isEligible` are functions and
* components, which only a script module can provide: a value set on
* the server would be called on the client and fail, so it is removed.
Expand Down
4 changes: 4 additions & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- Remove `single` from the values of the `context` of an action, which no screen supported ([#85186](https://github.com/WordPress/gutenberg/pull/85186)).

## 21.0.0 (2026-10-20)

### Breaking Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,11 @@ Whether the action is disabled.

### `context`

Where this action would be visible.
The context the action is limited to: `list` for the lists of items. Without it, the action shows everywhere. DataViews does not filter the actions by context: the consumer does, before passing them.

- Type: `string`
- Optional
- One of: `list`, `single`
- One of: `list`

### `callback`

Expand Down
7 changes: 4 additions & 3 deletions packages/dataviews/src/types/dataviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,11 @@ interface ActionBase< Item > {
supportsBulk?: boolean;

/**
* The context in which the action is visible.
* This is only a "meta" information for now.
* The context the action is limited to: `list` for the lists of items.
* Without it, the action shows everywhere. DataViews does not filter
* the actions by context: the consumer does, before passing them.
*/
context?: 'list' | 'single';
context?: 'list';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions phpunit/entity-actions-api-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public function test_registering_an_action_with_invalid_values_is_reported() {
array(
'id' => 'archive',
'label' => 'Archive',
'context' => 'lists',
'context' => 'single',
'isEligible' => true,
),
array(
Expand All @@ -599,12 +599,12 @@ public function test_registering_an_action_with_invalid_values_is_reported() {

$this->assertSame( array( 'feature', 'archive', 'export' ), $registered, 'The actions are registered anyway.' );
$actions = array_column( wp_get_registered_entity_actions( 'postType', 'page' ), null, 'id' );
$this->assertSame( 'lists', $actions['archive']['context'], 'A value DataViews does not support is kept.' );
$this->assertSame( 'single', $actions['archive']['context'], 'A value DataViews does not support is kept.' );
$this->assertSame( 'huge', $actions['export']['modalSize'], 'A value DataViews does not support is kept.' );
$this->assertArrayNotHasKey( 'isEligible', $actions['archive'], 'A property only a script module can provide is removed.' );
$this->assertCount( 1, $reported );
$this->assertStringContainsString( 'postType "page"', $reported[0], 'The notice names the entity.' );
$this->assertStringContainsString( ': archive (context is not one of list and single.)', $reported[0], 'The notice names the action and its value DataViews does not support.' );
$this->assertStringContainsString( ': archive (context is not one of list.)', $reported[0], 'The notice names the action and its value DataViews does not support.' );
$this->assertStringContainsString( 'archive (isEligible can only come from a script module', $reported[0], 'The notice names the property that is removed.' );
$this->assertStringContainsString( 'export (modalSize is not one of small, medium, large, and fill.)', $reported[0], 'The notice names every value DataViews does not support.' );
$this->assertStringNotContainsString( 'feature', $reported[0], 'The other actions of the call are not reported.' );
Expand Down
Loading