sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
21 lines (18 loc) • 488 B
text/typescript
import {type DocumentFieldActionNode} from '../../../config'
export function filterActions(actions: DocumentFieldActionNode[]): DocumentFieldActionNode[] {
return actions
.filter(Boolean)
.filter((node) => {
if ('hidden' in node) return node.hidden !== true
return true
})
.map((node) => {
if (node.type === 'group') {
return {
...node,
children: filterActions(node.children),
}
}
return node
})
}