Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: custom node deletion text #3294

Merged
merged 8 commits into from
Feb 22, 2023

Conversation

pKallert
Copy link
Contributor

@pKallert pKallert commented Dec 13, 2022

What I did
Sometimes when deleting a node Editors should be warned that they should look out for certain things.
For example, when using an nodetype as a reference, editors should be warned that they are potentially deleting an important element.

How I did it
To show a custom delete confirm message I added a new option for the ui: deleteConfirmation. This message will be shown in the Delete Popup

How to verify it
For any node type add deleteConfirmation in the ui section

'Neos.Demo:Content.Headline':
  ui:
    deleteConfirmation: 
        message: 'Deleting the headline has a bad SEO impact.'

Bildschirmfoto 2022-12-22 um 18 15 00
Bildschirmfoto 2022-12-22 um 18 20 57

TBD

  1. Should we use a different key in the yaml-file so that we can add other messages later on?
  2. Should we hide the "original" message if there is a custom delete message?

@Sebobo
Copy link
Member

Sebobo commented Dec 13, 2022

In your first example for referenced nodes it wouldn't really help so much IMO, as the editor doesn't know if there is one.
I wrote a UI plugin that shows references in each element for some customers. So it would be cool to have the option for some datasource that would respond with a more meaningful warning that could actually contain the number of references or similar. Wdyt? Of course this increase complexity a bit, but just messages which always appear don't help so much I think.

@pKallert pKallert changed the title Feature: Custom Confirm delete note text Feature: custom node deletion text Dec 13, 2022
@pKallert
Copy link
Contributor Author

Perhaps the reference stuff was not the best example.
Another use case would be using the https://github.com/punktDe/nodereplicator .
When deleting Nodes across all dimensions warning the unsuspecting Editor would be nice.

@Sebobo
Copy link
Member

Sebobo commented Dec 14, 2022

Either way, it would be great to somehow have be possible to have a custom check.

If you define the deleteConfirmation as an object and for now only implement the message and support i18n as value it would be extendable later on. Then in the next step we could allow something like a datasource f.e. that would be called to fill the details of the dialog.

But when deleting lots of nodes this could quickly become a complicated dialog 😉

@markusguenther markusguenther added UI & UX Feature Label to mark the change as feature 8.3 labels Dec 14, 2022
@pKallert
Copy link
Contributor Author

pKallert commented Dec 22, 2022

Configuration and Labels are adjusted (see updated PR description).

I am not sure how to make the message translatable with i18n, is there any documentation or good example I could have a look at?

@Sebobo
Copy link
Member

Sebobo commented Jan 11, 2023

You can use the i18nRegistry which is already injected like this:

i18nRegistry.translate(value, fallback)

This should then already work with shorthand translation strings like this Neos.NodeTypes:NodeTypes.Headline:ui.deleteConfirmation.message.

To allow the i18n value you have to adjust the NodeTypeConfigurationEnrichmentAspect in Neos.Neos to convert the i18n string to the label matching the node and its package. So this would be a second PR.

Would be great if you could implement the first part though.

@Sebobo
Copy link
Member

Sebobo commented Jan 31, 2023

Markus asked me and I just realised that you used the I18n component which should do the shorthand translation already.
So if it works it's fine for me.

On thing about this component is that in my opinion it creates a lot of React overhead and you already have the I18nRegistry in your component which you can use directly instead of using the component.

@markusguenther markusguenther changed the title Feature: custom node deletion text FEATURE: custom node deletion text Feb 22, 2023
@markusguenther markusguenther merged commit 0e65a93 into neos:8.3 Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.3 Feature Label to mark the change as feature UI & UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants