Skip to content

Commit

Permalink
feat(test-studio): add custom restore document action
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 committed May 17, 2024
1 parent 8e5ca31 commit a0c5f79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {RocketIcon} from '@sanity/icons'
import {type DocumentActionComponent} from 'sanity'

export const TestCustomRestoreAction: (
action: DocumentActionComponent,
) => DocumentActionComponent = (restoreAction) => {
const action: DocumentActionComponent = (props) => ({
...restoreAction(props),
label: 'Custom restore',
tone: 'positive',
icon: RocketIcon,
})

action.action = 'restore'
return action
}
9 changes: 8 additions & 1 deletion dev/test-studio/documentActions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {type DocumentActionsResolver} from 'sanity'

import {TestConfirmDialogAction} from './actions/TestConfirmDialogAction'
import {TestCustomComponentAction} from './actions/TestCustomComponentAction'
import {TestCustomRestoreAction} from './actions/TestCustomRestoreAction'
import {TestModalDialogAction} from './actions/TestModalDialogAction'
import {TestPopoverDialogAction} from './actions/TestPopoverDialogAction'

Expand All @@ -13,7 +14,13 @@ export const resolveDocumentActions: DocumentActionsResolver = (prev, {schemaTyp
TestPopoverDialogAction,
TestCustomComponentAction,
...prev,
]
].map((action) => {
if (action.action === 'restore') {
return TestCustomRestoreAction(action)
}

return action
})
}

return prev
Expand Down

0 comments on commit a0c5f79

Please sign in to comment.