feat: Table actions - #246
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable per-table retention actions (archive/delete/purge) that can be edited in the CMS UI, exported/imported with table definitions, and executed daily via a scheduled job. It also adds a new “purge” capability to asset services/components to support permanent deletion of records and their owned resources (files/rows).
Changes:
- Add CMS editor UI + routes/controllers/models/enums for table retention actions and persist them in a new
cms_table_actionstable. - Export/import retention actions with table definitions (asset export version bump to 1.4.0) and harden exchange-table rebuild by dropping FK constraints on backup tables.
- Add “purge” support across asset services/components plus upload sharing support (
source_upload_id) to safely clean up files only when no longer referenced.
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Traits/Exchangeable.php | Bumps export version and includes table action + new allow flags in exports. |
| src/Services/Editor/TableActionsEditor.php | New CMS UI builder for listing/adding/editing retention actions. |
| src/Services/CmsExchange/TemplateExchangeService.php | Drops foreign keys on renamed backup tables during import rebuild. |
| src/Services/CmsExchange/TableExchangeService.php | Imports/exports table actions; adds allow flags; rebuilds cms_table_actions in import flow. |
| src/Services/CmsExchange/AbstractExchangeService.php | Adds helper to drop foreign keys from backup tables. |
| src/Services/Assets/TableService.php | Adds purge() to permanently remove a record, component-owned resources, and uploads. |
| src/Services/Assets/TableActionService.php | New service to execute retention actions against site tables. |
| src/Services/Assets/PageService.php | Adds purge() to permanently remove page-owned resources and strings. |
| src/Services/Assets/GlobalPageService.php | Adds purge() override that blocks purging global pages. |
| src/Services/Assets/Enums/TableActionType.php | New enum for action types (archive/delete/purge) + CMS labels. |
| src/Services/Assets/Enums/TableActionCondition.php | New enum for retention conditions + timestamp mapping + CMS labels. |
| src/Services/Assets/Components/ComponentVectorImage.php | Implements component-level purge() cleanup. |
| src/Services/Assets/Components/ComponentTimePicker.php | Implements no-op purge() (value stored in record). |
| src/Services/Assets/Components/ComponentText.php | Refactors upload folder usage; adds clone + purge handling for rich-text uploads. |
| src/Services/Assets/Components/ComponentTags.php | Adds purge() to remove record↔tag link rows. |
| src/Services/Assets/Components/ComponentTableSelect.php | Implements no-op purge() (shared referenced rows). |
| src/Services/Assets/Components/ComponentStaticValue.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentSlug.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentNumber.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentModelSelect.php | Implements no-op purge() (shared referenced rows). |
| src/Services/Assets/Components/ComponentImage.php | Makes file deletion resilient to missing sizes; adds purge() to delete generated images. |
| src/Services/Assets/Components/ComponentHeader.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentFilter.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentFile.php | Adds purge() and implements actual file deletion helper. |
| src/Services/Assets/Components/ComponentEditorLink.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentDropDown.php | Implements no-op purge() (shared referenced rows). |
| src/Services/Assets/Components/ComponentDescription.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentDefault.php | Implements no-op purge() fallback. |
| src/Services/Assets/Components/ComponentDateTimePicker.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentDatePicker.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentCustomSelect.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentContentBlocks.php | Adds purge() to remove content blocks and purge their target records. |
| src/Services/Assets/Components/ComponentCombobox.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentChildTable.php | Adds purge() to purge child rows (including previously deleted). |
| src/Services/Assets/Components/ComponentCheckbox.php | Implements no-op purge(). |
| src/Services/Assets/Components/ComponentButton.php | Implements no-op purge(). |
| src/Services/Assets/Components/AbstractComponent.php | Adds new required abstract purge() API for components. |
| src/Services/Assets/AbstractAssetService.php | Adds new required abstract purge() API for asset services. |
| src/Models/TableAction.php | New model for cms_table_actions with enum casts and relation to Table. |
| src/Models/Table.php | Adds actions() relation and adds purgeRecord() for hard deletes. |
| src/Models/FileUpload.php | Adds source_upload_id fillable/docs to support shared uploads across duplicates. |
| src/Jobs/RunTableActions.php | New queued job to run table retention actions daily (unique job). |
| src/Http/Controllers/CmsEditor/CmsEditorTableController.php | Adds the retention actions widget to the table editor page. |
| src/Http/Controllers/CmsEditor/CmsEditorTableActionController.php | New controller to create/read/update/delete retention actions. |
| src/FrameworkServiceProvider.php | Registers artisan command and daily schedule for running table actions. |
| routes/cms/editor.php | Adds editor routes for table actions under /action. |
| database/migrations/2026_07_23_000001_add_source_upload_id_to_cms_uploads_table.php | Adds source_upload_id to support shared-upload lifecycle. |
| database/migrations/2026_07_23_000000_create_cms_table_actions_table.php | Creates cms_table_actions table schema. |
Comments suppressed due to low confidence (2)
src/Services/Editor/TableActionsEditor.php:96
- $action is nullable in addInputs(), but
$action->days ?? 30will still throw when $action is null because it attempts to access a property on null. Use the nullsafe operator so new-action defaults work.
src/Services/Editor/TableActionsEditor.php:104 - $action is nullable in addInputs(), but
$action->action->value ?? ...will throw when $action is null. Use the nullsafe operator so the default action is selected when adding a new rule.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.