sanity-plugin-workflow 1.0.0-beta.1 → 1.0.0-beta.4
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.
- package/LICENSE +1 -1
- package/README.md +73 -12
- package/lib/{src/index.d.ts → index.d.ts} +3 -3
- package/lib/index.esm.js +1800 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1813 -1
- package/lib/index.js.map +1 -1
- package/package.json +51 -40
- package/src/actions/AssignWorkflow.tsx +48 -0
- package/src/actions/BeginWorkflow.tsx +68 -0
- package/src/actions/CompleteWorkflow.tsx +41 -0
- package/src/actions/RequestReviewAction.js +1 -7
- package/src/actions/UpdateWorkflow.tsx +142 -0
- package/src/badges/AssigneesBadge.tsx +52 -0
- package/src/badges/{index.tsx → StateBadge.tsx} +4 -8
- package/src/components/DocumentCard/AvatarGroup.tsx +12 -8
- package/src/components/DocumentCard/CompleteButton.tsx +53 -0
- package/src/components/DocumentCard/EditButton.tsx +3 -2
- package/src/components/DocumentCard/Field.tsx +38 -0
- package/src/components/DocumentCard/ValidationStatus.tsx +37 -0
- package/src/components/DocumentCard/core/DraftStatus.tsx +32 -0
- package/src/components/DocumentCard/core/PublishedStatus.tsx +39 -0
- package/src/components/DocumentCard/core/TimeAgo.tsx +11 -0
- package/src/components/DocumentCard/index.tsx +156 -50
- package/src/components/DocumentList.tsx +122 -0
- package/src/components/Filters.tsx +168 -0
- package/src/components/FloatingCard.tsx +29 -0
- package/src/components/StateTitle/Status.tsx +27 -0
- package/src/components/StateTitle/index.tsx +73 -0
- package/src/components/UserAssignment.tsx +57 -75
- package/src/components/UserAssignmentInput.tsx +27 -0
- package/src/components/UserDisplay.tsx +57 -0
- package/src/components/Validators.tsx +229 -0
- package/src/components/WorkflowTool.tsx +302 -163
- package/src/constants/index.ts +31 -0
- package/src/helpers/arraysContainMatchingString.ts +6 -0
- package/src/helpers/filterItemsAndSort.ts +41 -0
- package/src/helpers/initialRank.ts +13 -0
- package/src/hooks/useWorkflowDocuments.tsx +62 -70
- package/src/hooks/useWorkflowMetadata.tsx +0 -1
- package/src/index.ts +38 -58
- package/src/schema/workflow/workflow.metadata.ts +68 -0
- package/src/tools/index.ts +15 -0
- package/src/types/index.ts +27 -6
- package/src/actions/DemoteAction.tsx +0 -62
- package/src/actions/PromoteAction.tsx +0 -62
- package/src/components/Mutate.tsx +0 -54
- package/src/components/StateTimeline.tsx +0 -98
- package/src/components/UserSelectInput.tsx +0 -43
- package/src/schema/workflow/metadata.ts +0 -38
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
> This is a **Sanity Studio v3** plugin.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install sanity-plugin-workflow
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
# Sanity Workflow Demo Plugin Example
|
|
10
|
+
|
|
11
|
+
With Sanity Studio you can [customize your content tools to support arbitrary workflows like assignment and content pipelines](https://www.sanity.io/docs/custom-workflows).
|
|
12
|
+
|
|
13
|
+
This plugin is distributed as a **reference implementation** of these customization APIs and is not considered to be a feature-complete implementation of what workflow management requires in production. It is a starting point intended to be forked and customized to the needs of your organization and content creators.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
This work demonstrates how a single plugin can define:
|
|
20
|
+
|
|
21
|
+
- A unique schema to handle workflow metadata
|
|
22
|
+
- Document Actions to promote and demote documents through the workflow
|
|
23
|
+
- Document Badges for visual feedback about the current state of a document
|
|
24
|
+
- A custom Tool for drag-and-drop updating of a document's state
|
|
4
25
|
|
|
5
26
|
## Installation
|
|
6
27
|
|
|
7
28
|
```
|
|
8
|
-
npm install --save sanity-plugin-workflow
|
|
29
|
+
npm install --save sanity-plugin-workflow@beta
|
|
9
30
|
```
|
|
10
31
|
|
|
11
32
|
or
|
|
12
33
|
|
|
13
34
|
```
|
|
14
|
-
yarn add sanity-plugin-workflow
|
|
35
|
+
yarn add sanity-plugin-workflow@beta
|
|
15
36
|
```
|
|
16
37
|
|
|
17
38
|
## Usage
|
|
@@ -26,25 +47,65 @@ Add it as a plugin in sanity.config.ts (or .js):
|
|
|
26
47
|
// all other settings ...
|
|
27
48
|
plugins: [
|
|
28
49
|
workflow({
|
|
29
|
-
// Required
|
|
50
|
+
// Required, list of document type names
|
|
51
|
+
// schemaTypes: ['article', 'product'],
|
|
30
52
|
schemaTypes: [],
|
|
31
|
-
// Optional
|
|
53
|
+
// Optional, see below
|
|
32
54
|
states: [],
|
|
33
55
|
})
|
|
34
56
|
]
|
|
35
57
|
})
|
|
36
58
|
```
|
|
37
59
|
|
|
38
|
-
##
|
|
60
|
+
## Configuring "States"
|
|
61
|
+
|
|
62
|
+
The plugin comes with a default set of "States". These are tracked by the plugin creating a separate "metadata" document for each document that has begun the Workflow.
|
|
63
|
+
|
|
64
|
+
Documents can be promoted and demoted in the Workflow with the provided Document Actions as well as a drag-and-drop custom Tool. The settings below are not enforced by the API, custom access control rules could be used to do so.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
{
|
|
68
|
+
// Required configuration
|
|
69
|
+
id: 'inReview',
|
|
70
|
+
title: 'In Review',
|
|
71
|
+
// Optional settings:
|
|
72
|
+
// Used for the color of the Document Badge
|
|
73
|
+
color: 'success',
|
|
74
|
+
// Will enable document actions and drag-and-drop for only users with these Role
|
|
75
|
+
roles: ['publisher', 'administrator'],
|
|
76
|
+
// Requires the user to be "assigned" in order to update to this State
|
|
77
|
+
requireAssignment: true,
|
|
78
|
+
// Defines which States a document can be moved to from this one
|
|
79
|
+
transitions: ['changesRequested', 'approved']
|
|
80
|
+
}
|
|
81
|
+
```
|
|
39
82
|
|
|
40
|
-
|
|
41
|
-
See LICENSE
|
|
83
|
+
### Intended content operations with this plugin
|
|
42
84
|
|
|
85
|
+
A content creator composes a new document of one of the configured Schema types. The document is a "Draft", but not automatically added to the Workflow.
|
|
43
86
|
|
|
44
|
-
|
|
87
|
+
The creator clicks the "Begin Workflow" Document Action to create a new "metadata" document and add the document to the first State in the Workflow. Using the default States, the document is now "In Review".
|
|
88
|
+
|
|
89
|
+
The document is now visible in the Workflow Tool. The creator can drag and drop the document to the next State in the Workflow, "Changes Requested". Other users may be "assigned" to the document. In the default State configuration, only an assigned user can move the document into the final "Approved" state.
|
|
90
|
+
|
|
91
|
+
An administrator can move the document into Changes Requested or Approved.
|
|
92
|
+
|
|
93
|
+
With the document now Approved, a user may also return to the document and Publish it, by whatever means that make sense to your use case. Such as scheduled publishing or migrating it to a new dataset.
|
|
45
94
|
|
|
46
|
-
|
|
95
|
+
Once the Workflow is complete, the metadata can be removed by using the "Complete Workflow" document action.
|
|
96
|
+
|
|
97
|
+
### Differences from the Sanity Studio v2 Workflow Demo
|
|
98
|
+
|
|
99
|
+
This plugin is largely based on the original Workflow Demo built into a Sanity Studio v2 project. The major differences are:
|
|
100
|
+
|
|
101
|
+
* This plugin can be more easily installed and configured, not just code examples built into a Studio project
|
|
102
|
+
* Documents must "opt-in" to and removed from the Workflow, in the previous version all documents were in the workflow which would fill up the interface
|
|
103
|
+
* User Roles and Assignments can affect the Workflow. Set rules to enforce which States documents can move between and if being assigned to a document is required to move it to a new State
|
|
104
|
+
* Ability to filter Schema types and assigned Users
|
|
105
|
+
|
|
106
|
+
## License
|
|
47
107
|
|
|
108
|
+
[MIT](LICENSE) © Sanity.io
|
|
48
109
|
|
|
49
110
|
## Develop & test
|
|
50
111
|
|
|
@@ -52,11 +113,11 @@ This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
|
52
113
|
with default configuration for build & watch scripts.
|
|
53
114
|
|
|
54
115
|
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
55
|
-
on how to run this plugin with
|
|
116
|
+
on how to run this plugin with hot reload in the studio.
|
|
56
117
|
|
|
57
118
|
### Release new version
|
|
58
119
|
|
|
59
120
|
Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-workflow/actions/workflows/main.yml).
|
|
60
121
|
Make sure to select the main branch and check "Release new version".
|
|
61
122
|
|
|
62
|
-
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
123
|
+
Semantic release will only release on configured branches, so it is safe to run the release on any branch.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {Plugin as Plugin_2} from 'sanity'
|
|
2
|
-
import {default as React_2} from 'react'
|
|
3
2
|
|
|
4
3
|
declare type State = {
|
|
5
4
|
id: string
|
|
5
|
+
transitions: string[]
|
|
6
6
|
title: string
|
|
7
|
-
|
|
7
|
+
roles?: string[]
|
|
8
|
+
requireAssignment?: boolean
|
|
8
9
|
color?: 'primary' | 'success' | 'warning' | 'danger'
|
|
9
|
-
icon?: React_2.ReactNode | React_2.ComponentType
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export declare const workflow: Plugin_2<WorkflowConfig>
|