Skip to content

feat: show snippet ID in editor and add trash and export-all options - #588

Open
faisalahammad wants to merge 1 commit into
codesnippetspro:core-betafrom
faisalahammad:feat/555-editor-id-and-export-options/core
Open

faisalahammad wants to merge 1 commit into
codesnippetspro:core-betafrom
faisalahammad:feat/555-editor-id-and-export-options/core

Conversation

@faisalahammad

Copy link
Copy Markdown

Summary

Adds the three improvements requested in #555: the snippet ID is shown in the editor sidebar, snippets in the Trash tab can be exported, and a new Export All button downloads every snippet in one file, including trashed ones.

Closes #555

Changes

Snippet ID in editor sidebar (new SnippetIdInfo.tsx)

Before: the ID was only visible in the page URL.
After: saved snippets show their numeric ID in the sidebar settings, next to a copy button. Hidden for unsaved snippets.
Why: users need a reliable way to reference a snippet ID without reading the URL.

Export from Trash (useApplyBulkAction.ts, RowActions.tsx, ManageSnippetCard.tsx)

Before: the Export row action, bulk action, and card menu item were all hidden in the Trash tab.
After: Export is available in the Trash tab in all three places. Table and card view behave the same.
Why: the existing export builder already writes trashed: true for trashed snippets and the importer ignores that field, so these exports stay import compatible and no PHP change is needed.

Export All (SnippetsTableControls.tsx)

Before: no way to export all snippets at once without selecting rows in every tab.
After: a new button in the list toolbar fetches all snippets through the existing REST endpoint (no pagination, all statuses) and downloads one snippets.code-snippets.json file.
Why: get_items with no query parameters already returns the full set including trashed snippets, so a client-side download reuses existing behavior with no new endpoint.

Exports are read only and do not modify snippet data.

Testing

Export All

  1. Open Snippets > All Snippets.
  2. Click Export All.
  3. The downloaded file contains active, inactive, and trashed snippets under snippets.code-snippets.json.

Export from Trash

  1. Trash a snippet.
  2. In the Trash tab, export it from its row actions.
  3. Select rows and use the Export bulk action for the same result.
  4. Both files contain the snippet with "trashed": true and import successfully.

Snippet ID

  1. Edit a saved snippet.
  2. The sidebar shows its ID with a copy button, matching the id query parameter in the URL.

Automated: added Playwright tests for all three flows in tests/e2e/code-snippets-edit.spec.ts, tests/e2e/code-snippets-list.spec.ts, and tests/e2e/helpers/SnippetsTestHelper.ts helper (trashSnippet). Full lint suite and webpack build pass.

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.

Show snippet IDs in the editor and expand export options

1 participant