Removing a document type from the "New document" dialog in Sanity Studio
17 replies
Last updated: Dec 19, 2022
Y
Hi ! I can’t find a way to remove a documentId from the “New document” dialog in the studio. I want to block my teammates from creating a new “Site settings” document .. Could you help me ? 🙂
Dec 18, 2022, 7:46 PM
H
deskTool({ name: 'content',
title: 'Content',
structure: (S) =>
S.list()
.title('Content')
.items([
S.documentTypeListItem('tools'),
S.documentTypeListItem('collections'),
S.divider(),
S.listItem()
.icon(MdInfo)
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
S.divider(),
S.documentTypeListItem('categories'),
S.documentTypeListItem('tags'),
]),
}),
title: 'Content',
structure: (S) =>
S.list()
.title('Content')
.items([
S.documentTypeListItem('tools'),
S.documentTypeListItem('collections'),
S.divider(),
S.listItem()
.icon(MdInfo)
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
S.divider(),
S.documentTypeListItem('categories'),
S.documentTypeListItem('tags'),
]),
}),
Dec 18, 2022, 8:35 PM
H
This can be done in your deskTool! The «About» list item is the way ive done it
Dec 18, 2022, 8:36 PM
Y
Are you sure it’s going to remove the document type from the “New document” dialog in the top left corner of the studio ?
Dec 18, 2022, 8:36 PM
H
Can you take a screenshot?
Dec 18, 2022, 8:40 PM
Y
Sure I want to remove it from here
Dec 18, 2022, 8:42 PM
H
Can’t recall to see a icon there on a single page!
Dec 18, 2022, 8:43 PM
H
But give it a try
Dec 18, 2022, 8:43 PM
H
S.listItem() .icon(MdInfo)
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
.title('About')
.child(S.editor().schemaType('about').documentId('about')),
Dec 18, 2022, 8:44 PM
H
This is what you need
Dec 18, 2022, 8:44 PM
Y
Let me try
Dec 18, 2022, 8:46 PM
Y
I did it it’s not changing anything .. 😕
Dec 18, 2022, 8:47 PM
H
:/ Well currently not on a computer, but there is probably some people that can help! Monday tomorrow so Sanity people is back :saluting_face:
Dec 18, 2022, 8:52 PM
M
Dec 19, 2022, 12:50 AM
M
In the sanity.config.json
document: { newDocumentOptions: (prev, { creationContext }) => { if (creationContext.type === 'global') { return prev.filter((templateItem) => templateItem.templateId != 'settings') } return prev }, actions: (prev, { schemaType }) => { if (schemaType === 'settings') { return prev.filter(({ action }) => !['unpublish', 'delete','duplicate'].includes(action)) } return prev }, }
Dec 19, 2022, 12:51 AM
Y
Thanks for your help, I’ll try it !
Dec 19, 2022, 9:21 AM
Y
Works perfectly. It was quite hidden in the docs to be honest
Dec 19, 2022, 9:25 AM
M
Yeah I know, found it by chance as well haha
Dec 19, 2022, 2:56 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.