@sanity/dashboard 2.30.2-shopify.2 → 3.0.0-studio-v3.1

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