@sanity/dashboard 3.0.0-v3-studio.5 → 3.0.0-v3-studio.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.
package/lib/cjs/index.js DELETED
@@ -1,998 +0,0 @@
1
- var $dyHF6$reactjsxruntime = require("react/jsx-runtime");
2
- var $dyHF6$react = require("react");
3
- var $dyHF6$sanity = require("sanity");
4
- var $dyHF6$sanityui = require("@sanity/ui");
5
- var $dyHF6$styledcomponents = require("styled-components");
6
- var $dyHF6$rxjs = require("rxjs");
7
- var $dyHF6$rxjsoperators = require("rxjs/operators");
8
- var $dyHF6$sanityicons = require("@sanity/icons");
9
- var $dyHF6$sanityimageurl = require("@sanity/image-url");
10
-
11
- function $parcel$export(e, n, v, s) {
12
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
- }
14
- function $parcel$exportWildcard(dest, source) {
15
- Object.keys(source).forEach(function(key) {
16
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
17
- return;
18
- }
19
-
20
- Object.defineProperty(dest, key, {
21
- enumerable: true,
22
- get: function get() {
23
- return source[key];
24
- }
25
- });
26
- });
27
-
28
- return dest;
29
- }
30
- function $parcel$interopDefault(a) {
31
- return a && a.__esModule ? a.default : a;
32
- }
33
-
34
- $parcel$export(module.exports, "dashboardTool", () => $329a1cedcedb1349$export$dd097bc0a3a5adbd);
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
- function $93c883afbea98073$export$3469e8c87b54056a(props) {
43
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Container), {
44
- width: 4,
45
- padding: 4,
46
- sizing: "border",
47
- style: {
48
- minHeight: "100%"
49
- },
50
- children: props.children
51
- });
52
- }
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
- const $57696b1483ff1ea5$export$3d9a716c82234f3d = /*#__PURE__*/ (0, $dyHF6$react.createContext)({
63
- widgets: []
64
- });
65
- function $57696b1483ff1ea5$export$f69a0df1904034e() {
66
- return (0, $dyHF6$react.useContext)($57696b1483ff1ea5$export$3d9a716c82234f3d);
67
- }
68
-
69
-
70
-
71
- function $eac9c79096489071$export$d320a48219c7c153(props) {
72
- const config = (0, $57696b1483ff1ea5$export$f69a0df1904034e)();
73
- const layout = (0, $dyHF6$react.useMemo)(()=>({
74
- ...props.layout || {},
75
- ...config.layout || {}
76
- }), [
77
- props.layout,
78
- config.layout
79
- ]);
80
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
81
- shadow: 1,
82
- "data-width": layout.width,
83
- "data-height": layout.height,
84
- children: /*#__PURE__*/ (0, $dyHF6$react.createElement)(props.component, {})
85
- });
86
- }
87
-
88
-
89
- const $0c9a17bfc268c430$var$media = {
90
- small: (...args)=>(0, $dyHF6$styledcomponents.css)`
91
- @media (min-width: ${({ theme: theme })=>theme.sanity.media[0]}px) {
92
- ${(0, $dyHF6$styledcomponents.css)(...args)}
93
- }
94
- `,
95
- medium: (...args)=>(0, $dyHF6$styledcomponents.css)`
96
- @media (min-width: ${({ theme: theme })=>theme.sanity.media[2]}px) {
97
- ${(0, $dyHF6$styledcomponents.css)(...args)}
98
- }
99
- `
100
- };
101
- const $0c9a17bfc268c430$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Grid))`
102
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
103
-
104
- & > div {
105
- overflow: hidden;
106
- }
107
-
108
- & > div[data-width='medium'] {
109
- ${$0c9a17bfc268c430$var$media.small`
110
- grid-column: span 2;
111
- `}
112
- }
113
-
114
- & > div[data-width='large'] {
115
- ${$0c9a17bfc268c430$var$media.small`
116
- grid-column: span 2;
117
- `}
118
-
119
- ${$0c9a17bfc268c430$var$media.medium`
120
- grid-column: span 3;
121
- `}
122
- }
123
-
124
- & > div[data-width='full'] {
125
- ${$0c9a17bfc268c430$var$media.small`
126
- grid-column: 1 / -1;
127
- `}
128
- }
129
-
130
- & > div[data-height='medium'] {
131
- ${$0c9a17bfc268c430$var$media.small`
132
- grid-row: span 2;
133
- `}
134
- }
135
-
136
- & > div[data-height='large'] {
137
- ${$0c9a17bfc268c430$var$media.small`
138
- grid-row: span 2;
139
- `}
140
-
141
- ${$0c9a17bfc268c430$var$media.medium`
142
- grid-row: span 3;
143
- `}
144
- }
145
-
146
- & > div[data-height='full'] {
147
- ${$0c9a17bfc268c430$var$media.medium`
148
- grid-row: 1 / -1;
149
- `}
150
- }
151
- `;
152
- const $0c9a17bfc268c430$var$NO_WIDGETS = [];
153
- const $0c9a17bfc268c430$var$NO_LAYOUT = {};
154
- function $0c9a17bfc268c430$export$606a10b16bce9144(props) {
155
- const { config: { layout: layout = $0c9a17bfc268c430$var$NO_LAYOUT , widgets: widgets = $0c9a17bfc268c430$var$NO_WIDGETS } , } = props;
156
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($0c9a17bfc268c430$var$Root, {
157
- autoFlow: "row dense",
158
- "data-width": layout.width || "auto",
159
- "data-height": layout.height || "auto",
160
- gap: 4,
161
- children: [
162
- widgets.length ? null : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
163
- padding: 4,
164
- shadow: 1,
165
- tone: "primary",
166
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
167
- align: "center",
168
- children: "Add some widgets to populate this space."
169
- })
170
- }),
171
- widgets.map((widgetConfig, index)=>{
172
- if (widgetConfig.type === "__experimental_group") return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($0c9a17bfc268c430$export$606a10b16bce9144, {
173
- config: widgetConfig
174
- }, index);
175
- if (widgetConfig.component) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $eac9c79096489071$export$d320a48219c7c153), {
176
- ...widgetConfig
177
- }, index);
178
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Box), {
179
- children: [
180
- widgetConfig.name,
181
- " is missing widget component"
182
- ]
183
- }, index);
184
- })
185
- ]
186
- });
187
- }
188
-
189
-
190
-
191
- function $91e9efa9de14badb$export$fe82a520fc33e5f4({ config: config }) {
192
- if (!config) return null;
193
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $57696b1483ff1ea5$export$3d9a716c82234f3d).Provider, {
194
- value: config,
195
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $93c883afbea98073$export$3469e8c87b54056a), {
196
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $0c9a17bfc268c430$export$606a10b16bce9144), {
197
- config: config
198
- })
199
- })
200
- });
201
- }
202
-
203
-
204
-
205
- var $4ba7065cde0cca68$exports = {};
206
-
207
-
208
- var $b40b76121260b241$exports = {};
209
-
210
- $parcel$export($b40b76121260b241$exports, "DashboardWidgetContainer", () => $b40b76121260b241$export$67b2e85605d868b2);
211
-
212
-
213
-
214
-
215
- const $b40b76121260b241$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
216
- display: flex;
217
- flex-direction: column;
218
- justify-content: stretch;
219
- height: 100%;
220
- box-sizing: border-box;
221
- position: relative;
222
- `;
223
- const $b40b76121260b241$var$Header = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
224
- position: sticky;
225
- top: 0;
226
- z-index: 2;
227
- border-top-left-radius: inherit;
228
- border-top-right-radius: inherit;
229
- `;
230
- const $b40b76121260b241$var$Footer = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
231
- position: sticky;
232
- overflow: hidden;
233
- bottom: 0;
234
- z-index: 2;
235
- border-bottom-right-radius: inherit;
236
- border-bottom-left-radius: inherit;
237
- margin-top: auto;
238
- `;
239
- const $b40b76121260b241$var$Content = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
240
- position: relative;
241
- z-index: 1;
242
- height: stretch;
243
- min-height: 21.5em;
244
-
245
- @media (min-width: ${({ theme: theme })=>theme.sanity.media[0]}px) {
246
- overflow-y: auto;
247
- outline: none;
248
- }
249
- `;
250
- const $b40b76121260b241$export$67b2e85605d868b2 = /*#__PURE__*/ (0, $dyHF6$react.forwardRef)(function DashboardWidgetContainer(props, ref) {
251
- const { header: header , children: children , footer: footer } = props;
252
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($b40b76121260b241$var$Root, {
253
- radius: 3,
254
- display: "flex",
255
- ref: ref,
256
- children: [
257
- header && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Header, {
258
- borderBottom: true,
259
- paddingX: 3,
260
- paddingY: 4,
261
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
262
- size: 1,
263
- textOverflow: "ellipsis",
264
- children: header
265
- })
266
- }),
267
- children && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Content, {
268
- children: children
269
- }),
270
- footer && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Footer, {
271
- borderTop: true,
272
- children: footer
273
- })
274
- ]
275
- });
276
- });
277
-
278
-
279
- var $3b85b98919e996ec$exports = {};
280
-
281
- $parcel$export($3b85b98919e996ec$exports, "projectInfoWidget", () => $3b85b98919e996ec$export$66362ea0e7ee12e);
282
-
283
-
284
-
285
-
286
- function $b707d8a93b21430e$export$270fde7c7e72cf26() {
287
- return (0, $dyHF6$sanity.useClient)({
288
- apiVersion: "1"
289
- });
290
- }
291
-
292
-
293
-
294
-
295
- function $7f8f68c82a66a1d7$var$isUrl(url) {
296
- return url && /^https?:\/\//.test(`${url}`);
297
- }
298
- function $7f8f68c82a66a1d7$var$getGraphQlUrl(projectId, dataset) {
299
- return `https://${projectId}.api.sanity.io/v1/graphql/${dataset}/default`;
300
- }
301
- function $7f8f68c82a66a1d7$var$getGroqUrl(projectId, dataset) {
302
- return `https://${projectId}.api.sanity.io/v1/groq/${dataset}`;
303
- }
304
- function $7f8f68c82a66a1d7$var$getManageUrl(projectId) {
305
- return `https://manage.sanity.io/projects/${projectId}`;
306
- }
307
- const $7f8f68c82a66a1d7$var$NO_EXPERIMENTAL = [];
308
- const $7f8f68c82a66a1d7$var$NO_DATA = [];
309
- function $7f8f68c82a66a1d7$export$a1c9a67310a2d004(props) {
310
- const { __experimental_before: __experimental_before = $7f8f68c82a66a1d7$var$NO_EXPERIMENTAL , data: data = $7f8f68c82a66a1d7$var$NO_DATA } = props;
311
- const [studioHost, setStudioHost] = (0, $dyHF6$react.useState)();
312
- const [graphqlApi, setGraphQlApi] = (0, $dyHF6$react.useState)();
313
- const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
314
- const { projectId: projectId = "unknown" , dataset: dataset = "unknown" } = versionedClient.config();
315
- (0, $dyHF6$react.useEffect)(()=>{
316
- const subscriptions = [];
317
- subscriptions.push(versionedClient.observable.request({
318
- uri: `/projects/${projectId}`
319
- }).subscribe({
320
- next: (result)=>{
321
- const { studioHost: host } = result;
322
- setStudioHost(host ? `https://${host}.sanity.studio` : undefined);
323
- },
324
- error: (error)=>{
325
- console.error("Error while looking for studioHost", error);
326
- setStudioHost({
327
- error: "Something went wrong while looking up studioHost. See console."
328
- });
329
- }
330
- }));
331
- // ping assumed graphql endpoint
332
- subscriptions.push(versionedClient.observable.request({
333
- method: "HEAD",
334
- uri: `/graphql/${dataset}/default`
335
- }).subscribe({
336
- next: ()=>setGraphQlApi($7f8f68c82a66a1d7$var$getGraphQlUrl(projectId, dataset)),
337
- error: (error)=>{
338
- if (error.statusCode === 404) setGraphQlApi(undefined);
339
- else {
340
- console.error("Error while looking for graphqlApi", error);
341
- setGraphQlApi({
342
- error: "Something went wrong while looking up graphqlApi. See console."
343
- });
344
- }
345
- }
346
- }));
347
- return ()=>{
348
- subscriptions.forEach((s)=>s.unsubscribe());
349
- };
350
- }, [
351
- dataset,
352
- projectId,
353
- versionedClient,
354
- setGraphQlApi,
355
- setStudioHost
356
- ]);
357
- const assembleTableRows = (0, $dyHF6$react.useMemo)(()=>{
358
- let result = [
359
- {
360
- title: "Sanity project",
361
- rows: [
362
- {
363
- title: "Project ID",
364
- value: projectId
365
- },
366
- {
367
- title: "Dataset",
368
- value: dataset
369
- },
370
- ]
371
- },
372
- ];
373
- // Handle any apps
374
- const apps = [
375
- studioHost ? {
376
- title: "Studio",
377
- value: studioHost
378
- } : null,
379
- ...data.filter((item)=>item.category === "apps"),
380
- ].filter((a)=>!!a);
381
- if (apps.length > 0) result = result.concat([
382
- {
383
- title: "Apps",
384
- rows: apps
385
- }
386
- ]);
387
- // Handle APIs
388
- result = result.concat([
389
- {
390
- title: "APIs",
391
- rows: [
392
- {
393
- title: "GROQ",
394
- value: $7f8f68c82a66a1d7$var$getGroqUrl(projectId, dataset)
395
- },
396
- {
397
- title: "GraphQL",
398
- value: (typeof graphqlApi === "object" ? "Error" : graphqlApi) ?? "Not deployed"
399
- },
400
- ]
401
- },
402
- ], data.filter((item)=>item.category === "apis"));
403
- // Handle whatever else there might be
404
- const otherStuff = {};
405
- data.forEach((item)=>{
406
- if (item.category && item.category !== "apps" && item.category !== "apis") {
407
- if (!otherStuff[item.category]) otherStuff[item.category] = [];
408
- otherStuff[item.category].push(item);
409
- }
410
- });
411
- Object.keys(otherStuff).forEach((category)=>{
412
- result.push({
413
- title: category,
414
- rows: otherStuff[category]
415
- });
416
- });
417
- return result;
418
- }, [
419
- graphqlApi,
420
- studioHost,
421
- projectId,
422
- dataset,
423
- data
424
- ]);
425
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
426
- children: [
427
- __experimental_before.map((widgetConfig, idx)=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $eac9c79096489071$export$d320a48219c7c153), {
428
- ...widgetConfig
429
- }, idx)),
430
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
431
- height: "fill",
432
- marginTop: __experimental_before?.length > 0 ? 4 : 0,
433
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
434
- footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
435
- style: {
436
- width: "100%"
437
- },
438
- paddingX: 2,
439
- paddingY: 4,
440
- mode: "bleed",
441
- tone: "primary",
442
- text: "Manage project",
443
- as: "a",
444
- href: $7f8f68c82a66a1d7$var$getManageUrl(projectId)
445
- }),
446
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
447
- paddingY: 4,
448
- radius: 2,
449
- role: "table",
450
- "aria-label": "Project info",
451
- "aria-describedby": "project_info_table",
452
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
453
- space: 4,
454
- children: [
455
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
456
- paddingX: 3,
457
- as: "header",
458
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
459
- size: 1,
460
- as: "h2",
461
- id: "project_info_table",
462
- children: "Project info"
463
- })
464
- }),
465
- assembleTableRows.map((item)=>{
466
- if (!item || !item.rows) return null;
467
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
468
- space: 3,
469
- children: [
470
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
471
- borderBottom: true,
472
- padding: 3,
473
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Label), {
474
- size: 0,
475
- muted: true,
476
- role: "columnheader",
477
- children: item.title
478
- })
479
- }),
480
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
481
- space: 4,
482
- paddingX: 3,
483
- role: "rowgroup",
484
- children: item.rows.map((row)=>{
485
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Grid), {
486
- columns: 2,
487
- role: "row",
488
- children: [
489
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
490
- weight: "medium",
491
- role: "rowheader",
492
- children: row.title
493
- }),
494
- typeof row.value === "object" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
495
- size: 1,
496
- children: row.value?.error
497
- }),
498
- typeof row.value === "string" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
499
- children: $7f8f68c82a66a1d7$var$isUrl(row.value) ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
500
- size: 1,
501
- role: "cell",
502
- style: {
503
- wordBreak: "break-word"
504
- },
505
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("a", {
506
- href: row.value,
507
- children: row.value
508
- })
509
- }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Code), {
510
- size: 1,
511
- role: "cell",
512
- style: {
513
- wordBreak: "break-word"
514
- },
515
- children: row.value
516
- })
517
- })
518
- ]
519
- }, row.title);
520
- })
521
- })
522
- ]
523
- }, item.title);
524
- })
525
- ]
526
- })
527
- })
528
- })
529
- })
530
- ]
531
- });
532
- }
533
-
534
-
535
- function $3b85b98919e996ec$export$66362ea0e7ee12e(config) {
536
- return {
537
- name: "project-info",
538
- component: (0, $7f8f68c82a66a1d7$export$a1c9a67310a2d004),
539
- layout: config?.layout ?? {
540
- width: "medium"
541
- }
542
- };
543
- }
544
-
545
-
546
- var $9f0f01baaf74f19a$exports = {};
547
-
548
- $parcel$export($9f0f01baaf74f19a$exports, "projectUsersWidget", () => $9f0f01baaf74f19a$export$5c0e62d7539f632);
549
-
550
-
551
-
552
-
553
-
554
-
555
-
556
-
557
-
558
-
559
- const $0a8433cdd42b1c75$var$AvatarWrapper = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
560
- box-sizing: border-box;
561
- border-radius: 50%;
562
- border-color: transparent;
563
- overflow: hidden;
564
- width: 100%;
565
- height: 100%;
566
-
567
- & > img {
568
- width: 100%;
569
- height: auto;
570
- }
571
- `;
572
- function $0a8433cdd42b1c75$var$getInviteUrl(projectId) {
573
- return `https://manage.sanity.io/projects/${projectId}/team/invite`;
574
- }
575
- function $0a8433cdd42b1c75$export$2500e0068175e4b9() {
576
- const [project, setProject] = (0, $dyHF6$react.useState)();
577
- const [users, setUsers] = (0, $dyHF6$react.useState)();
578
- const [error, setError] = (0, $dyHF6$react.useState)();
579
- const userStore = (0, $dyHF6$sanity.useUserStore)();
580
- const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
581
- const fetchData = (0, $dyHF6$react.useCallback)(()=>{
582
- const { projectId: projectId } = versionedClient.config();
583
- const subscription = versionedClient.observable.request({
584
- uri: `/projects/${projectId}`
585
- }).pipe((0, $dyHF6$rxjsoperators.switchMap)((_project)=>(0, $dyHF6$rxjs.from)(userStore.getUsers(_project.members.map((mem)=>mem.id))).pipe((0, $dyHF6$rxjsoperators.map)((_users)=>({
586
- project: _project,
587
- users: _users
588
- }))))).subscribe({
589
- next: ({ users: _users , project: _project })=>{
590
- setProject(_project);
591
- setUsers((Array.isArray(_users) ? _users : [
592
- _users
593
- ]).sort((userA, userB)=>$0a8433cdd42b1c75$var$sortUsersByRobotStatus(userA, userB, _project)));
594
- },
595
- error: (e)=>setError(e)
596
- });
597
- return ()=>subscription.unsubscribe();
598
- }, [
599
- userStore,
600
- versionedClient
601
- ]);
602
- (0, $dyHF6$react.useEffect)(()=>fetchData(), [
603
- fetchData
604
- ]);
605
- const handleRetryFetch = (0, $dyHF6$react.useCallback)(()=>fetchData(), [
606
- fetchData
607
- ]);
608
- const isLoading = !users || !project;
609
- if (error) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
610
- header: "Project users",
611
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
612
- padding: 4,
613
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
614
- children: [
615
- "Something went wrong while fetching data. You could",
616
- " ",
617
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("a", {
618
- onClick: handleRetryFetch,
619
- title: "Retry users fetch",
620
- style: {
621
- cursor: "pointer"
622
- },
623
- children: "retry"
624
- }),
625
- "..?"
626
- ]
627
- })
628
- })
629
- });
630
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $b40b76121260b241$export$67b2e85605d868b2), {
631
- header: "Project users",
632
- footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
633
- style: {
634
- width: "100%"
635
- },
636
- paddingX: 2,
637
- paddingY: 4,
638
- mode: "bleed",
639
- tone: "primary",
640
- text: "Invite members",
641
- as: "a",
642
- loading: isLoading,
643
- href: isLoading ? undefined : $0a8433cdd42b1c75$var$getInviteUrl(project.id)
644
- }),
645
- children: [
646
- isLoading && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
647
- paddingY: 5,
648
- paddingX: 2,
649
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
650
- space: 4,
651
- children: [
652
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
653
- align: "center",
654
- muted: true,
655
- size: 1,
656
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {})
657
- }),
658
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
659
- align: "center",
660
- size: 1,
661
- muted: true,
662
- children: "Loading items..."
663
- })
664
- ]
665
- })
666
- }),
667
- !isLoading && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
668
- space: 3,
669
- padding: 3,
670
- children: users?.map((user)=>{
671
- const membership = project.members.find((member)=>member.id === user.id);
672
- const media = membership?.isRobot ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
673
- size: 3,
674
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.RobotIcon), {})
675
- }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($0a8433cdd42b1c75$var$AvatarWrapper, {
676
- tone: "transparent",
677
- children: user?.imageUrl && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("img", {
678
- src: user.imageUrl,
679
- alt: user?.displayName
680
- })
681
- });
682
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
683
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanity.DefaultPreview), {
684
- title: user.displayName,
685
- subtitle: membership?.role,
686
- media: media
687
- })
688
- }, user.id);
689
- })
690
- })
691
- ]
692
- });
693
- }
694
- function $0a8433cdd42b1c75$var$sortUsersByRobotStatus(userA, userB, project) {
695
- const { members: members } = project;
696
- const membershipA = members.find((member)=>member.id === userA?.id);
697
- const membershipB = members.find((member)=>member.id === userB?.id);
698
- if (membershipA?.isRobot) return 1;
699
- if (membershipB?.isRobot) return -1;
700
- return 0;
701
- }
702
-
703
-
704
- function $9f0f01baaf74f19a$export$5c0e62d7539f632(config) {
705
- return {
706
- name: "project-info",
707
- component: (0, $0a8433cdd42b1c75$export$2500e0068175e4b9),
708
- layout: config?.layout
709
- };
710
- }
711
-
712
-
713
- var $1000d7b311eba884$exports = {};
714
-
715
- $parcel$export($1000d7b311eba884$exports, "sanityTutorialsWidget", () => $1000d7b311eba884$export$b3552e87a7c5c47b);
716
-
717
-
718
-
719
-
720
-
721
-
722
-
723
-
724
- const $f7904e4c8f3104b2$var$PlayIconBox = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
725
- position: absolute;
726
- top: 50%;
727
- left: 50%;
728
- transform: translate(-50%, -50%);
729
-
730
- &:before {
731
- content: '';
732
- position: absolute;
733
- top: 50%;
734
- left: 50%;
735
- transform: translate(-50%, -50%);
736
- width: 2.75em;
737
- height: 2.75em;
738
- border-radius: 50%;
739
- background: ${({ theme: theme })=>theme.sanity.color.card.enabled.bg};
740
- opacity: 0.75;
741
- }
742
- `;
743
- const $f7904e4c8f3104b2$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Flex))`
744
- &:hover {
745
- ${$f7904e4c8f3104b2$var$PlayIconBox} {
746
- &:before {
747
- opacity: 1;
748
- }
749
- }
750
- }
751
- `;
752
- const $f7904e4c8f3104b2$var$PosterCard = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
753
- width: 100%;
754
- padding-bottom: calc(9 / 16 * 100%);
755
- position: relative;
756
- `;
757
- const $f7904e4c8f3104b2$var$Poster = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).img`
758
- position: absolute;
759
- top: 0;
760
- left: 0;
761
- height: 100%;
762
- width: 100%;
763
- object-fit: cover;
764
- display: block;
765
-
766
- &:not([src]) {
767
- display: none;
768
- }
769
- `;
770
- function $f7904e4c8f3104b2$export$825b76de5f2b0345(props) {
771
- const { title: title , posterURL: posterURL , showPlayIcon: showPlayIcon , href: href , presenterName: presenterName , presenterSubtitle: presenterSubtitle } = props;
772
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$Root, {
773
- flex: 1,
774
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
775
- sizing: "border",
776
- flex: 1,
777
- padding: 2,
778
- radius: 2,
779
- as: "a",
780
- href: href,
781
- target: "_blank",
782
- rel: "noopener noreferrer",
783
- style: {
784
- position: "relative"
785
- },
786
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
787
- direction: "column",
788
- style: {
789
- height: "100%"
790
- },
791
- children: [
792
- posterURL && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($f7904e4c8f3104b2$var$PosterCard, {
793
- marginBottom: 1,
794
- children: [
795
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$Poster, {
796
- src: posterURL
797
- }),
798
- showPlayIcon && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$PlayIconBox, {
799
- display: "flex",
800
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
801
- align: "center",
802
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.PlayIcon), {})
803
- })
804
- })
805
- ]
806
- }),
807
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
808
- direction: "column",
809
- justify: "space-between",
810
- paddingY: 2,
811
- flex: 1,
812
- children: [
813
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
814
- as: "h3",
815
- size: 1,
816
- children: title
817
- }),
818
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
819
- marginTop: 4,
820
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
821
- space: 2,
822
- flex: 1,
823
- children: [
824
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
825
- size: 1,
826
- children: presenterName
827
- }),
828
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
829
- size: 0,
830
- style: {
831
- opacity: 0.7
832
- },
833
- children: presenterSubtitle
834
- })
835
- ]
836
- })
837
- })
838
- ]
839
- })
840
- ]
841
- })
842
- })
843
- });
844
- }
845
-
846
-
847
-
848
-
849
-
850
- const $03a20cc8653e0692$var$tutorialsProjectConfig = {
851
- projectId: "3do82whm",
852
- dataset: "next"
853
- };
854
- function $03a20cc8653e0692$export$144c6e577729d454() {
855
- const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
856
- return (0, $dyHF6$react.useMemo)(()=>({
857
- getFeed: (templateRepoId)=>{
858
- const uri = templateRepoId ? `/addons/dashboard?templateRepoId=${templateRepoId}` : "/addons/dashboard";
859
- return versionedClient.observable.request({
860
- uri: uri,
861
- withCredentials: false
862
- });
863
- },
864
- urlBuilder: (0, ($parcel$interopDefault($dyHF6$sanityimageurl)))($03a20cc8653e0692$var$tutorialsProjectConfig)
865
- }), [
866
- versionedClient
867
- ]);
868
- }
869
-
870
-
871
-
872
- function $9c397f58297d9297$var$createUrl(slug, type) {
873
- if (type === "tutorial") return `https://www.sanity.io/docs/tutorials/${slug.current}`;
874
- else if (type === "guide") return `https://www.sanity.io/docs/guides/${slug.current}`;
875
- return false;
876
- }
877
- function $9c397f58297d9297$export$5f156cc357b8467f(props) {
878
- const { templateRepoId: templateRepoId } = props;
879
- const [feedItems, setFeedItems] = (0, $dyHF6$react.useState)([]);
880
- const { getFeed: getFeed , urlBuilder: urlBuilder } = (0, $03a20cc8653e0692$export$144c6e577729d454)();
881
- (0, $dyHF6$react.useEffect)(()=>{
882
- const subscription = getFeed(templateRepoId).subscribe((response)=>{
883
- setFeedItems(response.items);
884
- });
885
- return ()=>{
886
- subscription.unsubscribe();
887
- };
888
- }, [
889
- setFeedItems,
890
- getFeed,
891
- templateRepoId
892
- ]);
893
- const title = "Learn about Sanity";
894
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
895
- header: title,
896
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
897
- as: "ul",
898
- overflow: "auto",
899
- align: "stretch",
900
- paddingY: 2,
901
- children: feedItems?.map((feedItem, index)=>{
902
- if (!feedItem.title || !feedItem.guideOrTutorial && !feedItem.externalLink) return null;
903
- const presenter = feedItem.presenter || feedItem.guideOrTutorial?.presenter || {};
904
- const subtitle = feedItem.category;
905
- const { guideOrTutorial: guideOrTutorial = {} } = feedItem;
906
- const href = (guideOrTutorial.slug ? $9c397f58297d9297$var$createUrl(guideOrTutorial.slug, guideOrTutorial._type) : feedItem.externalLink) || feedItem.externalLink;
907
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
908
- as: "li",
909
- paddingRight: index < feedItems?.length - 1 ? 1 : 3,
910
- paddingLeft: index === 0 ? 3 : 0,
911
- align: "stretch",
912
- style: {
913
- minWidth: 272,
914
- width: "30%"
915
- },
916
- children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f7904e4c8f3104b2$export$825b76de5f2b0345), {
917
- title: feedItem.title,
918
- href: href ?? "",
919
- presenterName: presenter.name,
920
- presenterSubtitle: subtitle,
921
- showPlayIcon: feedItem.hasVideo,
922
- posterURL: feedItem.poster ? urlBuilder.image(feedItem.poster).height(360).url() : undefined
923
- })
924
- }, feedItem._id);
925
- })
926
- })
927
- });
928
- }
929
-
930
-
931
- function $1000d7b311eba884$export$b3552e87a7c5c47b(config) {
932
- return {
933
- name: "sanity-tutorials",
934
- component: (0, $9c397f58297d9297$export$5f156cc357b8467f),
935
- layout: config?.layout ?? {
936
- width: "full"
937
- }
938
- };
939
- }
940
-
941
-
942
- const $329a1cedcedb1349$var$strokeStyle = {
943
- stroke: "currentColor",
944
- strokeWidth: 1.2
945
- };
946
- const $329a1cedcedb1349$var$DashboardIcon = ()=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("svg", {
947
- "data-sanity-icon": true,
948
- viewBox: "0 0 25 25",
949
- fill: "none",
950
- xmlns: "http://www.w3.org/2000/svg",
951
- preserveAspectRatio: "xMidYMid",
952
- width: "1em",
953
- height: "1em",
954
- children: [
955
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
956
- d: "M19.5 19.5H5.5V5.5H19.5V19.5Z",
957
- style: $329a1cedcedb1349$var$strokeStyle
958
- }),
959
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
960
- d: "M5.5 12.5H19.5",
961
- style: $329a1cedcedb1349$var$strokeStyle
962
- }),
963
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
964
- d: "M14.5 19.5V12.5M10.5 12.5V5.5",
965
- style: $329a1cedcedb1349$var$strokeStyle
966
- })
967
- ]
968
- });
969
- const $329a1cedcedb1349$export$dd097bc0a3a5adbd = (0, $dyHF6$sanity.createPlugin)((config = {})=>{
970
- const pluginConfig = {
971
- layout: config.defaultLayout ?? {},
972
- widgets: config.widgets ?? []
973
- };
974
- return {
975
- name: "dashboard",
976
- tools: (prev, context)=>{
977
- return [
978
- ...prev,
979
- {
980
- title: "Dashboard",
981
- name: "dashboard",
982
- icon: $329a1cedcedb1349$var$DashboardIcon,
983
- component: ()=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $91e9efa9de14badb$export$fe82a520fc33e5f4), {
984
- config: pluginConfig
985
- })
986
- },
987
- ];
988
- }
989
- };
990
- });
991
- $parcel$exportWildcard(module.exports, $4ba7065cde0cca68$exports);
992
- $parcel$exportWildcard(module.exports, $b40b76121260b241$exports);
993
- $parcel$exportWildcard(module.exports, $3b85b98919e996ec$exports);
994
- $parcel$exportWildcard(module.exports, $9f0f01baaf74f19a$exports);
995
- $parcel$exportWildcard(module.exports, $1000d7b311eba884$exports);
996
-
997
-
998
- //# sourceMappingURL=index.js.map