-
Notifications
You must be signed in to change notification settings - Fork 395
/
deskStructure.js
127 lines (118 loc) · 3.93 KB
/
deskStructure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React from 'react'
import S from '@sanity/desk-tool/structure-builder'
import RefreshIcon from 'part:@sanity/base/sync-icon'
import JsonDocumentDump from './components/JsonDocumentDump'
// For testing. Bump the timeout to introduce som lag
const delay = val => new Promise(resolve => setTimeout(resolve, 10, val))
export default () =>
S.list()
.id('root')
.title('Content')
.items([
S.documentListItem()
.id('foo-bar')
.title('Singleton author')
.schemaType('author'),
S.divider(),
S.listItem()
.title('Anything with a title')
.icon(() => <span style={{fontSize: '2em'}}>T</span>)
.child(() =>
delay(
S.documentList({
id: 'title-list',
title: 'Titles!',
options: {
filter: 'defined(title)'
}
})
)
),
S.listItem()
.title('Singleton?')
.child(delay(S.editor({id: 'editor', options: {id: 'circular', type: 'referenceTest'}})))
.showIcon(false),
S.documentListItem()
.id('grrm')
.schemaType('author')
.child(
S.component()
.component(JsonDocumentDump)
.menuItems([
S.menuItem()
.title('Reload')
.action('reload')
.icon(RefreshIcon)
.showAsAction(true)
])
),
S.listItem()
.title('Deep')
.child(
S.list()
.title('Deeper')
.items([
S.documentTypeListItem('book').title('Books'),
S.documentTypeListItem('author').title('Authors')
])
),
S.listItem()
.title('Deep panes')
.child(
S.list()
.title('Depth 1')
.items([
S.listItem()
.title('Deeper')
.child(
S.list()
.title('Depth 2')
.items([
S.listItem()
.title('Even deeper')
.child(
S.list()
.title('Depth 3')
.items([
S.listItem()
.title('Keep digging')
.child(
S.list()
.title('Depth 4')
.items([
S.listItem()
.title('Dig into the core of the earth')
.child(
S.list()
.title('Depth 5')
.items([
S.documentListItem()
.id('grrm')
.schemaType('author')
])
)
])
)
])
)
])
)
])
),
S.listItem({
id: 'books-by-author',
title: 'Books by author',
schemaType: 'book',
child: () =>
S.documentTypeList('author').child(authorId =>
S.documentTypeList('book')
.title('Books by author')
.filter('_type == $type && author._ref == $authorId')
.params({type: 'book', authorId})
.child(S.editorWithInitialValueTemplate('book-by-author', {authorId}))
.canHandleIntent(S.documentTypeList('book').getCanHandleIntent())
)
}),
S.divider(),
...S.documentTypeListItems()
])