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

Disabling deletion in production also disables it in development environment #58

Open
tomaszter opened this issue Apr 18, 2024 · 1 comment

Comments

@tomaszter
Copy link

tomaszter commented Apr 18, 2024

Activating the option "Disable the 'Delete' action for this item in production" prevents me from deleting the webhook item in the development environment too.

I encountered this issue after transferring the project to a new team on Vercel. I'm unable to customize the entire webhook element due to a validation error indicating that the token is not configured with the new project environment.

How should I proceed to delete the element?

@tomaszter
Copy link
Author

tomaszter commented Apr 18, 2024

Got a workaround. Display all documents of the type "webhook_deploy" in Vision. Determine the ID of the document and delete it with the mutateDocs script. For example:

import { getCliClient } from 'sanity/cli';

const client = getCliClient().withConfig({ apiVersion: '2021-10-21' });
const query = `*[_id == "vercel-deploy.uoUdDC87h2XkZuHCVFcTa"]`

const mutateDocs = async (query) => {
  const docsToMutate = await client.fetch(query, {})
  for (const doc of docsToMutate) {
        console.log('uploading')
        client
        .delete(doc._id) // Document ID to delete
        .then((updatedDoc) => {
          console.log('Hurray, the doc is deleted!')
        })
        .catch((err) => {
          console.error('Oh no, the update failed: ', err.responseBody)
        })
    }
}

mutateDocs(query)

sanity exec utils/deleteField.js --withUserToken

However, a deletion function that is always available in the development environment would be more practical.
Thank you!

@tomaszter tomaszter changed the title Cannot delete old deployments Disabling deletion in production also disables it in development environment Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant