sanity-plugin-workflow 1.0.0-beta.4 → 1.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +0,0 @@
1
- import PropTypes from 'prop-types'
2
- import React from 'react'
3
- import {EyeOpenIcon} from '@sanity/icons'
4
-
5
- import {inferMetadataState, useWorkflowMetadata} from '../../lib/workflow'
6
- import RequestReviewWizard from '../../components/RequestReviewWizard'
7
-
8
- export function RequestReviewAction(props) {
9
- const [showWizardDialog, setShowWizardDialog] = React.useState(false)
10
- const metadata = useWorkflowMetadata(props.id, inferMetadataState(props))
11
- const {state} = metadata.data
12
-
13
- if (!props.draft || state === 'inReview' || state === 'approved') {
14
- return null
15
- }
16
-
17
- const onHandle = () => {
18
- if (!showWizardDialog) {
19
- setShowWizardDialog(true)
20
- }
21
- }
22
-
23
- const onSend = (assignees) => {
24
- setShowWizardDialog(false)
25
-
26
- if (assignees.length === 0) {
27
- metadata.clearAssignees()
28
- } else {
29
- metadata.setAssignees(assignees)
30
- }
31
-
32
- metadata.setState('inReview')
33
- props.onComplete()
34
- }
35
-
36
- const onClose = () => setShowWizardDialog(false)
37
-
38
- return {
39
- dialog: showWizardDialog && {
40
- type: 'popover',
41
- content: <RequestReviewWizard metadata={metadata.data} onClose={onClose} onSend={onSend} />,
42
- onClose: props.onComplete,
43
- },
44
- disabled: showWizardDialog,
45
- icon: EyeOpenIcon,
46
- label: 'Request review',
47
- onHandle,
48
- }
49
- }
50
-
51
- RequestReviewAction.propTypes = {
52
- draft: PropTypes.object,
53
- id: PropTypes.string,
54
- onComplete: PropTypes.func,
55
- }
@@ -1,21 +0,0 @@
1
- import {ApproveAction} from './ApproveAction'
2
- import {DeleteAction} from './DeleteAction'
3
- import {DiscardChangesAction} from './DiscardChangesAction'
4
- import {PublishAction} from './PublishAction'
5
- import {RequestChangesAction} from './RequestChangesAction'
6
- import {RequestReviewAction} from './RequestReviewAction'
7
- import {SyncAction} from './SyncAction'
8
- import {UnpublishAction} from './Unpublish'
9
-
10
- export function resolveWorkflowActions(/* docInfo */) {
11
- return [
12
- SyncAction,
13
- RequestReviewAction,
14
- ApproveAction,
15
- RequestChangesAction,
16
- PublishAction,
17
- UnpublishAction,
18
- DiscardChangesAction,
19
- DeleteAction,
20
- ]
21
- }