There are many situations when the solution works on Development and Test environments, but there are some problems with Production. Few times I had to create test page, check how system behaves and then delete the page. There is no Permanent Delete option for single content, so I had to empty whole trash or leave the test page. That’s why I tried to prepare functionality of deleting single file from trash.
extended trash component

Replacing Trash view

Trash view is represented by “epi-cms/component/Trash” component. Widget class is returned by CmsContentContextResolver service. It’s not a configurable option, so I had to change the implementation of service. Registering new implementation for IUriContextResolver interface is quite difficult, because CmsContentContextResolver has internal constructor and all methods are non-virtual, so inheritance won’t work. Moreover, there is a second implementation – ProjectContextResolver so I had to change exactly CmsContentContextResolver instance.
Fortunately, developer can intercept existing services from EPiServer 9.10. Whenever ServiceLocator will ask for CmsContentContextResolver instance I will return custom implementation with extended trash view.
In AssignCustomTrashComponent method I replacing “epi-cms/component/Trash” with “customTrash/Trash”.

Implementing REST controller

When restoring content or emptying trash, the WasteBasketStore API controller methods are executed. I had to create new controller with PermanentDelete method.

The REST store has to be registered on client side using module initializer.

And then module initializer has to be set in module.config.

Extending trash view

The trash component is a standard context based view. It has updateView method executed when the context has changed. View contains one main widget “epi-cms/widget/Trash”. To replace it with extended version I changed the templateString property and set “customTrash/TrashWidget” for data-dojo-type attribute.

In extended trash widget I added “Delete permanently” link. Link has to be created for each data grid row. It will be displayed next to Restore link. To add the link I replaced formatter for action column (trashItemListWidget._grid.columns.action.formatter). It’s a hack, but it was the easiest way that I found.

Then I assigned click event using “.epi-gridDeleteAction:click” selector. In click event the PermanentDelete method of ExtendedWastebasketStore is executed, and trash is updated.

Before deleting item, the Confirmation dialog is displayed. Window was implemented using “epi/shell/widget/dialog/Confirmation”.

delete confirmation

Below is full widget source code.

uing extended trash component

The source code is available on Gist