How to allow file deletion in Sanity using configuration settings
5 replies
Last updated: Feb 18, 2023
A
How can i allow files to be deleted from sanity? I currently can find the option from this area:
Feb 16, 2023, 3:11 PM
A
Thanks!
Feb 16, 2023, 3:11 PM
It looks like the delete document action has been removed. What does your config look like?
Feb 16, 2023, 7:04 PM
A
it looks like this:
Feb 16, 2023, 8:06 PM
A
import {defineConfig, isDev}from 'sanity' import {deskTool} from 'sanity/desk' import {visionTool} from '@sanity/vision' import deskStructure from './src/structure/deskStructure' import schemas from './schemas/schema' import {dashboardTool} from '@sanity/dashboard' import { netlifyWidget } from 'sanity-plugin-dashboard-widget-netlify' export default defineConfig({ name: 'default', title: 'Bex Day Shop', projectId: '#####################', dataset: 'production', plugins: [ dashboardTool({ widgets: [ netlifyWidget({ title: 'My Netlify deploys', description: "NOTE: Because these sites are static builds, they need to be re-deployed to see the changes when documents are published.", sites: [ { title: 'Bex Day Shop Studio', apiId: '#####################', buildHookId: '#####################', name:'bex-day-shop-studio', url: '<https://studioshop.bexday.com>', }, { title: 'Bex Day Shop', apiId: "#####################", buildHookId: "#####################", name: 'bex-day-shop', url: '<https://shop.bexday.com>', } ], }), ], }), deskTool({ structure: deskStructure, }), visionTool() ], tools: (prev) => { // :point_down: Uses environment variables set by Vite in development mode if (isDev) { return prev } return prev.filter((tool) => tool.name !== 'vision') }, schema: { types: schemas, }, document: { newDocumentOptions: (prev, {creationContext}) => { if (creationContext.type === 'global') { return prev.filter((templateItem) => templateItem.templateId != 'siteSettings','home') } return prev }, actions: (prev, {schema}) => { if (schema === 'siteSettings','home') { return prev.filter(({action}) => !['unpublish', 'delete', 'duplicate'].includes(action)) } return prev }, }, })
Feb 16, 2023, 8:06 PM
A
No worries! all solved!, Thanks
user M
Feb 18, 2023, 1:04 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.