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