silverstripe / silverstripe-admin

Silverstripe Admin Component
BSD 3-Clause "New" or "Revised" License
25 stars 91 forks source link

Unlinking a record gives a "Are you sure you want to delete this record?" message #1697

Open lekoala opened 4 months ago

lekoala commented 4 months ago

Module version(s) affected

5.1.x

Description

Currently, when you unlink a record, you get a warning message saying "Are you sure you want to delete this record?"

image

This is obviously NOT the case since you only UNLINK the record.

The toast message says "deleted" afterwards

How to reproduce

In model admin Have a record with a has_many relation Unlink a record Get the message and see the toast

Possible Solution

This seems to be done on the js side of things

https://github.com/silverstripe/silverstripe-admin/blob/0c5de61469e6ae732f50a04264fc776f93fdc40a/client/src/legacy/GridField.js#L562-L564

I would rather have some kind of data attribute that can be set on the button itself. In general, having "confirmable" actions handled at core level would be great, but that's another topic...

This way, the button can provide the message itself or even make it user configurable if needed. Much better than hardcoded in js.

Toasts message should rely on X-Status instead

Additional Context

No response

Validations

GuySartorelli commented 4 months ago

Thanks for reporting this. If you'd like to raise a PR to resolve this I'd be very grateful. This almost certainly affects CMS 4 as well, so please target 1.13 if you do open a PR to resolve this.