sanity-plugin-vercel-deploy icon indicating copy to clipboard operation
sanity-plugin-vercel-deploy copied to clipboard

Disabling deletion in production also disables it in development environment

Open tomaszter opened this issue 10 months ago • 2 comments

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 avatar Apr 18 '24 14:04 tomaszter

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 avatar Apr 18 '24 20:04 tomaszter

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!

Great! that worked for me, deleted a stuck project from the dashboard.

loayawad avatar Aug 28 '24 10:08 loayawad