Skip to content

Conversation

@louiswol94
Copy link
Contributor

No description provided.

@louiswol94 louiswol94 requested a review from sheabunge October 16, 2025 06:57
@code-snippets-bot code-snippets-bot changed the base branch from core to core-beta October 16, 2025 12:05
@imantsk imantsk requested a review from Copilot October 16, 2025 13:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a soft delete (trash) feature for code snippets, changing the delete behavior from permanent deletion to moving snippets to a trashed state that can be restored.

  • Implements soft delete functionality using an active status of -1 to mark snippets as trashed
  • Adds restore functionality to recover trashed snippets back to inactive state
  • Updates UI components to distinguish between "Delete" (soft delete) and "Delete Permanently" actions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/php/views/partials/list-table-notices.php Updates notice messages to use "trashed" instead of "deleted" and adds new messages for permanent deletion and restoration
src/php/snippet-ops.php Adds soft_delete_snippet() and restore_snippet() functions for trash functionality
src/php/rest-api/class-snippets-rest-controller.php Updates REST API delete endpoint to use soft delete instead of permanent deletion
src/php/class-snippet.php Adds is_trashed() method and logic to handle trashed state in snippet processing
src/php/class-list-table.php Implements trash view, filtering, and action handling in the snippets list table
src/js/components/EditorSidebar/actions/DeleteButton.tsx Updates delete button dialog text to reflect soft delete behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@sheabunge sheabunge left a comment

Choose a reason for hiding this comment

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

Great work!


case 'active':
return ( is_bool( $value ) ? $value : (bool) $value ) && ! $this->is_condition();
return ( is_bool( $value ) ? $value : (bool) $value ) && ! $this->is_condition() && (int) $value != -1;
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth changing the type of active entirely from string to int given we're using the full breadth of values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sheabunge Can we maybe do this in another PR. It started looking like a big scary change 🫣

@louiswol94
Copy link
Contributor Author

@sheabunge @imantsk

  • I addressed the code feedback.
  • Added "Undo" for both single and bulk actions.
  • Renamed the "Delete" labels to "Trash" in the List table and Bulk dropdown (as discussed to make the feature more visible).
  • Synced with file based feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants