In one of our project we have a News List page with the  limitation of one content type that could be created under. There are no subpages and containers structure so after a while a list become really huge. We decided to hide news list children and display the them in a different way. But then it was not possible to remove news, because “Move to trash” command is available only in page tree item context menu. I tried to add additional Move to Trash command under page tools menu.
Additional trash icon

Move to trash is available under content context menu. It’s implemented in “epi-cms/command/DeleteContent“. We could prepare our own delete command implementation which will just execute delete API action from Content Store, but built in command support many scenarios related with custom providers like – if content supports deletation or if command support waste basked.

Move to trash menu

The child context menu is not available so we had to move command somewhere on the child page edit.

New list hidden in tree

We prepared new module with module.config, module initializer and command provider with additional Move to Trash command.

additional trash command solution

In module.config we defined module initializer – additionalTrashButton.commandsInitializer.

The initializer is responsible for registering new command provider. The command will be registered under page Tools menu represented by “epi.cms.contentdetailsmenu” key.

The most difficult part is the commands provider. By default Delete command is used in page context menu. The context menu requires two implementations – clipboard and item selection. The clipboard is not used, but it has to be defined. We could simply use new Clipboard type instance.
The Selection is used to determinate which item will be removed. When the command is used in tools menu, the selection will always contains currently edited page.

The model for Delete command could be a ContentTreeStoreModel. But using this type directly we won’t get delete confirmation.
Deleting article - confirmation dialog
That’s why we need to use ContentTreeModelConfirmation wrapper: new ContentTreeModelConfirmation(new ContentTreeStoreModel())

After running the application Move to Trash command appeared in the tools menu.

Move to trash command

Because we don’t want to show command for pages other than News we need to set command availability based on current content type. In updateCommandModel we set isAvailable property.

Now for all other pages the command won’t be shown.
Other pages without command