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

Can't remove items from media library #11

Closed
patrickdaley opened this issue Feb 21, 2020 · 25 comments
Closed

Can't remove items from media library #11

patrickdaley opened this issue Feb 21, 2020 · 25 comments
Labels

Comments

@patrickdaley
Copy link

It looks like the draft that contains the interface for removing items blocks the removal action:

"The mutation(s) failed: Document "b430b968-9037-44ab-9878-28376fb86d08" cannot be deleted as there are references to it from "drafts.b32572a0-8c4f-43f5-acc1-edf0f6ac9b64""

@kmelve
Copy link
Member

kmelve commented Feb 24, 2020

Thanks for reporting @patrickdaley! This is probably a “not a bug, but a feature”. The backend doesn't let you remove documents with incoming (strong) references. This is to prevent you from unintentionally breaking something in another document that might rely on the asset existing.

Did you remove the video reference from the drafts.b32572a0-8c4f-43f5-acc1-edf0f6ac9b64 document?

@patrickdaley
Copy link
Author

Hi @kmelve! That reference is the active draft. Because you need to be in the interface for adding the asset to remove it, it's counted as referenced by the same draft you're trying to use to remove it. Hope that makes sense!

@israelroldan
Copy link
Contributor

+1 that currently open draft is preventing the item from being removed

@kfrederix
Copy link

I can also confim that this makes it kind of impossible to remove a video from the studio interface.

@KimPaow
Copy link
Contributor

KimPaow commented Jan 5, 2021

I would also like to bump this. Is there a timeframe for when we can expect this to be fixed or does anyone have a workaround?

Edit: You also can't remove the credentials, leaving the fields empty doesn't remove the data.

@KimPaow
Copy link
Contributor

KimPaow commented Jan 7, 2021

I needed this for a client asap so I published a fork to npm with some updates. Rush-job so not 100% tested yet but seems to work so far. I added the new sanity ui components and fixed some visual bugs too (checkbox labels not visible etc).

If you're reading this and are in the same situation - please feel free to try it out by running sanity install @kimpaow/sanity-plugin-mux-video-input. Hopefully the official version gets an update soon though!

@mornir
Copy link

mornir commented Mar 3, 2021

@KimPaow Thanks for the fork! Working great so far! 😃 Also love the refactor to Sanity UI! Could you maybe open a pull request?

@gristleism
Copy link

Struggling with this today, client can't remove a video from their page so I had to go into the frontend codebase and disable it manually, very frustrating.

@dylanjha
Copy link
Collaborator

dylanjha commented Oct 5, 2021

@gristleism what version of the plugin are you on? I believe this was added back since v1.0.0

@gristleism
Copy link

My package.json file says it should be loading ^1.0.1.

@KimPaow
Copy link
Contributor

KimPaow commented Oct 5, 2021

Yep, this was added since v1.0.0.

@gristleism could you also share what version of the studio you have?

@gristleism
Copy link

@KimPaow happy to! Would you mind letting me know where I can find which version of the studio I'm using?

@KimPaow
Copy link
Contributor

KimPaow commented Oct 5, 2021

@gristleism you can run sanity versions in the terminal and share the output or check your @sanity deps from package.json

@gristleism
Copy link

Results from initial run:

@sanity/cli             2.18.0 (latest: 2.20.0)
@sanity/base            2.18.0 (latest: 2.20.0)
@sanity/cli             2.18.0 (latest: 2.20.0)
@sanity/components      2.14.0 (up to date)
@sanity/core            2.18.0 (latest: 2.20.0)
@sanity/default-layout  2.18.0 (latest: 2.20.0)
@sanity/default-login   2.18.0 (latest: 2.19.0)
@sanity/desk-tool       2.18.0 (latest: 2.20.0)
@sanity/vision          2.17.2 (latest: 2.20.0)

I then ran sanity upgrade and afterwards here are the versions:

@sanity/cli             2.18.0 (latest: 2.20.0)
@sanity/base            2.20.0 (up to date)
@sanity/cli             2.20.0 (up to date)
@sanity/components      2.14.0 (up to date)
@sanity/core            2.20.0 (up to date)
@sanity/default-layout  2.20.0 (up to date)
@sanity/default-login   2.19.0 (up to date)
@sanity/desk-tool       2.20.0 (up to date)
@sanity/vision          2.20.0 (up to date)

Running again locally, I attempted to delete a video file again and received the following error:

the mutation(s) failed: Document "d1a72d5b-e897-4ad9-9cb3-7df4c8709afc" cannot be deleted as there are references to it from "frequentlyAskedQuestions"

@KimPaow
Copy link
Contributor

KimPaow commented Oct 5, 2021

@gristleism I just tried running this with the same dependencies you listed here and am unable to reproduce it. Maybe try deleting node-modules and lock files and then reinstall all packages.

@JulienDesmettre
Copy link

Same "not a bug" issue, but the problem is that i don't anymore have access to the drafts.xxxxxxxxxx, as i made mutations that deleted the schema of this object/document that refers to the other document i want to delete. So it doesn't exist anymore in my Sanity Studio. Is there anyway to access it via url and its id drafts.xxxxx ?

@geball
Copy link

geball commented Apr 9, 2022

@JulienDesmettre You can access the document directly by running sanity documents create --watch --replace --id 'drafts.xxxxx' from the terminal.

@JulienDesmettre
Copy link

@JulienDesmettre You can access the document directly by running sanity documents create --watch --replace --id 'drafts.xxxxx' from the terminal.

Thanks for your answer geball. Yes i found it on Sanity CLI doc just few minutes after my question here.

@jimmi-joensson
Copy link

jimmi-joensson commented Jun 19, 2022

Ran into this issue as well. The issue happens when the mux.video on any of my draft pages. I know that the video is only used in the place I'm trying to delete it, so what should happen in my opinion is the following:

  1. Remove reference on selected field
  2. Try to delete the asset
    a. Success - Video asset is deleted
    b. Error, Video is used in another place - Show current error popup

Currently I have no way of deleting my video assets

Here is a small screen recording for reference:
https://user-images.githubusercontent.com/15996198/174471561-bdd56ce4-755c-4795-ba74-e4be88d1dc99.mp4

@jjjuulliiaann
Copy link

I have the same issue. As described by @jimmi-joensson it is impossible to delete videos inside the studio, because they have to be added to a document to access the delete button (and therefore can't be deleted as there are references to it).

Maybe it would be a good idea to have a delete button inside the browse/select grid (just like we have inside the image select grid)

Bildschirmfoto 2022-07-13 um 09 40 26

@MichaelPrecel
Copy link

Did anyone manage to find a way through this? Multiple versions later and this is still a problem, totally unable to remove a video from a field. Seems to be a very core functionality that bugs out and certainly getting in the way of using Mux in this project.

@rylanharper
Copy link

rylanharper commented Nov 10, 2022

Just checking in to see if anyone figured out a solution to this?

I am in the same boat as others above... The plugin still does not allow a video to be removed and when I create a separate module/page section containing a mux component, the plugin breaks with a Mutation(s) failed with 1 error(s) Client Error:

POST https://*studio-code*.api.sanity.io/v2021-05-17/data/mutate/production?tag=sanity.studio&returnIds=true&returnDocuments=true&visibility=sync 409

On top of this, if I delete a video within the Mux dashboard the videos are not updated within the Select Videos tab. Unfortunately this means that instead of using Mux for a client, I am going with Vimeo most likely (which isn't bad, but not ideal).

@kmelve is there any timeframe on this fix? This is the only breaking change that is really holding myself and many developers back from using this plugin/going with Mux over another video service.

@kwanso-nadeem
Copy link

Facing the exact same issue on my end as well. Unable to remove a video. Looking for a fix.

@jjjuulliiaann
Copy link

It does seem to work in the new Sanity Studio v3 using version 2.0.2 of the plugin. The videos in the select grid have a delete option where you can delete the video from the dataset and also from Mux.

@hdoro
Copy link
Collaborator

hdoro commented Feb 20, 2024

Closing this issue as deleting assets is now fully supported and respects strong references being used.

Thank you all for showing up, keeping track of updates and helping debug 🙏

@hdoro hdoro closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests