Sanity Studio v3.91.0: Modify documents when duplicating; Duplicate Releases; and fixes for unpublishing documents in structure form

New Features

Modify a document through a duplication action

Sometimes you want to omit certain fields or add certain information when duplicating documents. It's now possible to programmatically modify the created document when duplicating a document. This can be achieved by setting the mapDocument option when executing the duplicate document operation, or by passing a prop of the same name (mapDocument) to the system duplicate document action component.

mapDocument is a function that receives the duplicated document as its only parameter, and should return a new object representing the duplicated document that will be created.

Here's an example demonstrating how a custom duplicate document action could be used to omit a field (slug) from the duplicated document:

// sanity.config.js

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {schemaTypes} from './schemas'
import {createCustomDuplicateAction} from './actions'

export default defineConfig({
name: 'default',
projectId: '<project-id>',
dataset: 'production',

plugins: [
structureTool(),
],
document: {
actions: (actions) => actions.map((actionItem) =>
actionItem.action === 'duplicate'
? createCustomDuplicateAction(actionItem)
: actionItem
),
},
schema: {
types: schemaTypes,
},
})

import {type DuplicateDocumentActionComponent} from 'sanity'

export function createCustomDuplicateAction(
originalAction: DuplicateDocumentActionComponent,
): DuplicateDocumentActionComponent {
return function CustomDuplicateAction(props) {
return originalAction({
...props,
mapDocument: ({slug, ...document}) => document,
})
}
}

Duplicate a Content Release

Unknown block type "docsPaidFeature", specify a component for it in the `components.types` option

Sometimes you want to work iteratively on a Content Release and stage changes to the same set of documents. You can now duplicate a release from the overview page by clicking on the '...' button and select 'Duplicate release'.

This will create a new release copying the original release's title, description, release type and publish date. New versions of all documents in the original release will also be created.

Duplicating a locked and scheduled release will create a new active release, which can be rescheduled.

Unknown block type "muxVideo", specify a component for it in the `components.types` option

Manage Workspace Content Releases limit

The new releases.limit configuration option can be used to prevent Studio users creating releases if the number of active releases in the dataset has reached the configured limit. This is a purely client-side guard intended to help control release usage across an organisation.

🐛 Notable bugfixes

Fixes issue where a document location resolver state was incorrectly duplicated across multiple Presentation instances.

Fix for an issue where documents marked as to be unpublished in a release show an empty document form title preview. Now the document form will show the current title of that document.

Fixes an issue in where users with no dataset read permissions were seeing an error toast on load.

Fixes an issue in where the studio dev command will get blocked if using auto update in a non interactive environment.