sanity icon indicating copy to clipboard operation
sanity copied to clipboard

Improve unpublish/delete error when referenced somewhere

Open zanedev opened this issue 5 years ago • 7 comments

Is your feature request related to a problem? Please describe. Unpublish and delete a doc can fail with a vague error about being possibly linked somewhere.

Describe the solution you'd like We should be able to unpublish or delete anything (with a warning/confirmation) and the other linked item should have a graceful fallback if it is deleted or unpublished. This is how Contentful handles it. The reason is a user may need to remove a page from the live site and they are basically stuck at that point if they can't unpublish or delete it.

Also, one basic rule of User Interfaces is you never leave your user hanging with nowhere to go. The message is not user friendly. At a minimum the message should at least tell you exactly what is linking to it in a friendly way and easily allow you to discover those associations and remove them to resolve the problem.

This is a real problem for me right now because I am building a workflow where documents are approved (+ published automatically) or disapproved (+ unpublished automatically) and basically a user is going to disapprove a doc and run into this error because it might be already used on the site and there is no good way around it for them.

Describe alternatives you've considered Using a published at field is a hack around the system and is not intuitive to the published/draft model. If I set a published at field to the future for instance to get around this issue it will show the doc was published message fly in which is confusion, it was disapproved but published?

Additional context image

zanedev avatar Apr 23 '20 05:04 zanedev

Can we at least set the publishedAt field to null in the meantime? I tried doing that and it said invalid value for dateTime. Now I need to filter all future dates from rendering in all my page datas? 😢

zanedev avatar Apr 23 '20 06:04 zanedev

"Weak" references might help here. https://www.sanity.io/docs/reference-type#example-weak-reference-f45f659e7b28

tkdave avatar Apr 23 '20 17:04 tkdave

Thanks @tkdave I'll look into that! Is there any drawback to making everything a weak reference?

Even with using a weak reference I still feel the UI could use a better way for a regular user to resolve this and not being stuck.

zanedev avatar Apr 23 '20 18:04 zanedev

Hi Zane – that dialogue should link to the documents doing the referencing so the user can go remediate it. Marking the references as weak will allow deletion, but will leave you with dangling references.

We'll look into why this dialogue isn't more helpful. Thank you for bringing it to our attention.

evenwestvang avatar May 01 '20 00:05 evenwestvang

In this case, how am I supposed to delete the documents that are preventing me deleting another document?

D-Pagey avatar Jun 11 '21 15:06 D-Pagey

great question @D-Pagey

sebbean avatar Sep 01 '22 19:09 sebbean

I do have the same issue as @D-Pagey asked. I already deleted the document that had the reference and now I'm actually trying to delete the Reference itself and I'm getting an error that it still linked to the one that was already deleted. Is there a way to improve this binding?

tailanedebrito avatar Sep 15 '22 16:09 tailanedebrito

Getting this same error myself. Something to do with a draft preview referring to it.

image

Screenshot 2022-11-07 at 22 47 04

JayBox325 avatar Nov 07 '22 22:11 JayBox325

@D-Pagey @tailanedebrito @JayBox325

Anyone found a fix for this?

ansmlc avatar Dec 22 '22 14:12 ansmlc

Thanks for reporting! This should be fixed in newer versions of Sanity Studio.

CleanShot 2023-01-12 at 19 31 06@2x

kmelve avatar Jan 12 '23 18:01 kmelve

Thanks for reporting! This should be fixed in newer versions of Sanity Studio.

CleanShot 2023-01-12 at 19 31 06@2x

This is still happening to me, @sanity/cli version 3.9.1

guillemsrr avatar Apr 27 '23 17:04 guillemsrr

Thanks for reporting! This should be fixed in newer versions of Sanity Studio.

CleanShot 2023-01-12 at 19 31 06@2x

Still happening. The prompt you posted does appear, but after clicking "Delete anyway", it still shows the error:

An error occurred while attempting to delete this document. This usually means that there are other documents that refers to it. Details Mutation(s) failed with 1 error(s)

dbettini avatar May 12 '23 23:05 dbettini

image

We are getting something similar on 3.49; the details didn't list the places to go, and different users got a different presentation (some had the elaborate UI, some got this toast notification).

vincentjflorio avatar Jul 12 '24 15:07 vincentjflorio