Page MenuHomePhabricator

Add button to delete template in the context menu
Closed, ResolvedPublic5 Estimated Story Points

Description

Background
In T272482: Show/hide advanced toolbar when multi-part content is present the toolbar is hidden when editing a single template. There is a trashcan there which currently lets you delete a template from within the dialog. There is also a trashcan button which shows next to the template name in the main dialog when the sidebar is expanded. Both are removed or inaccessible by the new implementation. This means that the possibility of deleting the template within the dialog is changing from difficult to do to not possible. Instead, we will provide users the possibility of deleting when clicking on the template from editing the article (currently possible by clicking 'backspace/delete' on keyboard).

Requirements

  • Implement behind a feature flag with T272354: Add back button to VE TemplateDialog and T272355: Add unsaved changes warning message to VE TemplateDialog
  • Remove trash can next to template name in main dialog (if still there)
  • Use OOUI component: ButtonGroupWidget (destructive and progressive ButtonWidget) to add a second button with 'Delete' label which removes the template (same as clicking the delete or backspace button when template is selected). This button set-up should match the context menu for tables in VE, which also has a destructive and progressive button group.
  • Ensure that CTRL-Z still works as an undo to bring the template back (currently functions)

Mock

Context menu.png (106×426 px, 9 KB)

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedWMDE-Fisch
ResolvedWMDE-Fisch
OpenNone
ResolvedWMDE-Fisch
Resolvedawight
DeclinedNone
ResolvedNone
InvalidNone
Resolvedthiemowmde
Resolvedlilients_WMDE
InvalidNone
Resolvedthiemowmde
ResolvedAndrew-WMDE
ResolvedAndrew-WMDE
ResolvedNone
ResolvedNone
Resolvedthiemowmde
ResolvedAndrew-WMDE
ResolvedWMDE-Fisch
ResolvedLena_WMDE
ResolvedNone
Resolvedawight
ResolvedAndrew-WMDE
InvalidNone
Resolvedthiemowmde
ResolvedBUG REPORTWMDE-Fisch
ResolvedBUG REPORTthiemowmde
ResolvedBUG REPORTthiemowmde
ResolvedWMDE-Fisch
OpenBUG REPORTNone
ResolvedECohen_WMDE
OpenNone
OpenNone
ResolvedWMDE-Fisch
ResolvedAndrew-WMDE
ResolvedWMDE-Fisch
ResolvedAndrew-WMDE
ResolvedBUG REPORTawight
OpenNone

Event Timeline

ECohen_WMDE renamed this task from Add button to delete template in the context menu to DRAFT: Add button to delete template in the context menu.Feb 9 2021, 3:32 PM
ECohen_WMDE created this task.
ECohen_WMDE updated the task description. (Show Details)
ECohen_WMDE updated the task description. (Show Details)
ECohen_WMDE set the point value for this task to 5.
Lena_WMDE renamed this task from DRAFT: Add button to delete template in the context menu to Add button to delete template in the context menu.Mar 10 2021, 2:34 PM

For what it's worth, you shouldn't need to do any direct work to add a button. There's already code for having a standardized delete button on context items, it's just restricted to the MobileContext. If you look up ve.ui.MobileContext.static.showDeleteButton you can trace through how its display is triggered.

It'd be really easy to go big and just enable delete buttons on all non-mobile context items.

It'd also be simple to just override isDeletable on MWTransclusionContextItem -- check out TableContextItem for an example. So long as that's returning true, a delete button will show.

Change 691162 had a related patch set uploaded (by Andrew-WMDE; author: Andrew-WMDE):

[mediawiki/extensions/VisualEditor@master] Show a delete button only in the transclusion context menu

https://gerrit.wikimedia.org/r/691162

For what it's worth, you shouldn't need to do any direct work to add a button. There's already code for having a standardized delete button on context items, it's just restricted to the MobileContext. If you look up ve.ui.MobileContext.static.showDeleteButton you can trace through how its display is triggered.

It'd be really easy to go big and just enable delete buttons on all non-mobile context items.

It'd also be simple to just override isDeletable on MWTransclusionContextItem -- check out TableContextItem for an example. So long as that's returning true, a delete button will show.

@DLynch Thanks, this was very helpful!

@ECohen_WMDE I want to double-check that we intend to:

  • Remove trash can next to template name in main dialog (if still there)

even for multi-template transclusions? The new button has this effect for these entities:

image.png (141×532 px, 16 KB)

Clicking "Delete" will remove both templates. Now the main dialog is lacking delete buttons, and aren't we getting rid of the sidebar tool buttons which provided the last remaining template delete action?

Change 692284 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/VisualEditor@master] Introduce feature flag for template dialog sidebar changes

https://gerrit.wikimedia.org/r/692284

Change 692284 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Introduce feature flag for template dialog sidebar changes

https://gerrit.wikimedia.org/r/692284

Change 691162 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Show a delete button only in the transclusion context menu

https://gerrit.wikimedia.org/r/691162

@awight hopefully I've understood your question, but for mutlipart transclusions, the toolbar at the bottom of the sidebar (which includes a trashcan) will remain visible within an active editing session, until the changes are saved and closed. Therefore, it remains possible to delete (all) parts of a multipart transclusion from within the dialog, but via the toolbar not the trash icon next to the template name. Those requirements are listed in T272482: Show/hide advanced toolbar when multi-part content is present

As discussed in the daily this morning, I have updated the requirement related to the feature flag in this ticket. This should be moved to be behind a feature flag with T272354: Add back button to VE TemplateDialog and T272355: Add unsaved changes warning message to VE TemplateDialog, so that it can be deployed earlier, together with those changes. Thank you!

Change 693137 had a related patch set uploaded (by Andrew-WMDE; author: Andrew-WMDE):

[mediawiki/extensions/VisualEditor@master] Update the delete button's feature flag in the tranclusion context menu

https://gerrit.wikimedia.org/r/693137

Change 693137 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update the delete button's feature flag in the tranclusion context menu

https://gerrit.wikimedia.org/r/693137