Skip to content

Bulk and single action handlers for Trash tab#392

Open
louiswol94 wants to merge 2 commits into
core-betafrom
bulk-actions-handlers-trash-tab
Open

Bulk and single action handlers for Trash tab#392
louiswol94 wants to merge 2 commits into
core-betafrom
bulk-actions-handlers-trash-tab

Conversation

@louiswol94
Copy link
Copy Markdown
Contributor

@louiswol94 louiswol94 commented May 19, 2026

Summary

Restores working bulk and single-row actions for the Trash tab on the Manage Snippets screen. After the React rewrite these were either no-ops or wired to the wrong code paths, so this PR re-introduces the legacy behaviour with the new React/REST stack.

Changes

Bulk actions on the Trash tab (SnippetsListTable.tsx)

  • The bulk-action dropdown on the Trash tab now exposes only Restore and Delete Permanently, matching the legacy UI.
  • Both actions iterate the selected snippets and call the REST API (restore / delete) per item, then refresh the list.
  • The pool of snippets the action looks up by ID is now the snippets visible on the current tab (snippetsByStatus.get(currentStatus)), instead of snippetsByStatus.get('all'). Trashed snippets are only stored in the 'trashed' bucket by partitionSnippetsByStatus, so filtering against 'all' silently produced zero targets, which is why Apply appeared to do nothing.

Single row actions on the Trash tab (TableColumns.tsx)

  • Removed the Export link from the row actions for trashed snippets. Trashed rows now show only Restore | Delete Permanently, matching the legacy UI.
  • Restore already worked. Delete Permanently is fixed by the server-side change below.

Permanent delete via REST (Snippets_REST_Controller.php)

  • delete_item previously decided "trash vs permanent delete" from $item->trashed on the request body. The client never sends that flag on a DELETE, so permanent deletes silently re-trashed already-trashed snippets (a no-op).
  • It now loads the snippet from the database via get_snippet() and uses its real trashed state to choose between trash_snippet() and delete_snippet(). As a side benefit, clients can no longer override the server's view of the snippet state.

Test plan

  • Trash tab: select one or more snippets, choose Restore → snippets leave the trash and reappear in their original status.
  • Trash tab: select one or more snippets, choose Delete Permanently → snippets are permanently removed and the trash counts decrement.
  • Trash tab single row: Restore link restores the snippet.
  • Trash tab single row: Delete Permanently link removes the snippet (with confirmation dialog).
  • Trash tab single row: Export link is no longer shown.
  • Non-trash tabs: existing bulk actions (Activate / Deactivate / Clone / Export / Download / Trash) still work.

@louiswol94 louiswol94 added the run-tests Trigger automated tests label May 19, 2026
@louiswol94 louiswol94 requested a review from a team May 19, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-tests Trigger automated tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant