sanity 6.4.0-next.21 → 6.4.0-next.23
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/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +1 -1
- package/lib/_chunks-es/CalendarFilter.js +3 -1
- package/lib/_chunks-es/CalendarFilter.js.map +1 -1
- package/lib/_chunks-es/CommentsInspector.js +58 -1
- package/lib/_chunks-es/CommentsInspector.js.map +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +9 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -1
- package/lib/_chunks-es/ReleasesStudioLayout.js +58 -1
- package/lib/_chunks-es/ReleasesStudioLayout.js.map +1 -1
- package/lib/_chunks-es/ReleasesTool.js +68 -1
- package/lib/_chunks-es/ReleasesTool.js.map +1 -1
- package/lib/_chunks-es/StructureToolProvider.js +4 -1
- package/lib/_chunks-es/StructureToolProvider.js.map +1 -1
- package/lib/_chunks-es/Table.js +2 -1
- package/lib/_chunks-es/Table.js.map +1 -1
- package/lib/_chunks-es/TasksDocumentInputLayout.js +58 -1
- package/lib/_chunks-es/TasksDocumentInputLayout.js.map +1 -1
- package/lib/_chunks-es/TasksFooterOpenTasks.js +59 -1
- package/lib/_chunks-es/TasksFooterOpenTasks.js.map +1 -1
- package/lib/_chunks-es/TasksStudioActiveToolLayout.js +58 -1
- package/lib/_chunks-es/TasksStudioActiveToolLayout.js.map +1 -1
- package/lib/_chunks-es/TasksStudioLayout.js +58 -1
- package/lib/_chunks-es/TasksStudioLayout.js.map +1 -1
- package/lib/_chunks-es/TasksStudioNavbar.js +58 -1
- package/lib/_chunks-es/TasksStudioNavbar.js.map +1 -1
- package/lib/_chunks-es/Tool.js +7 -1
- package/lib/_chunks-es/Tool.js.map +1 -1
- package/lib/_chunks-es/VariantsStudioNavbar.js +58 -1
- package/lib/_chunks-es/VariantsStudioNavbar.js.map +1 -1
- package/lib/_chunks-es/VariantsTool.js +59 -1
- package/lib/_chunks-es/VariantsTool.js.map +1 -1
- package/lib/_chunks-es/index2.js +98 -1
- package/lib/_chunks-es/index2.js.map +1 -1
- package/lib/_chunks-es/index3.js +58 -1
- package/lib/_chunks-es/index3.js.map +1 -1
- package/lib/_chunks-es/index4.js +3 -1
- package/lib/_chunks-es/index4.js.map +1 -1
- package/lib/_chunks-es/index5.js +3 -1
- package/lib/_chunks-es/index5.js.map +1 -1
- package/lib/_chunks-es/index6.js +60 -1
- package/lib/_chunks-es/index6.js.map +1 -1
- package/lib/_chunks-es/index7.js +58 -1
- package/lib/_chunks-es/index7.js.map +1 -1
- package/lib/_chunks-es/index8.js +59 -1
- package/lib/_chunks-es/index8.js.map +1 -1
- package/lib/_chunks-es/index9.js +8 -1
- package/lib/_chunks-es/index9.js.map +1 -1
- package/lib/_chunks-es/inputResolver.js +2 -1
- package/lib/_chunks-es/inputResolver.js.map +1 -1
- package/lib/_chunks-es/presentation.js +7 -1
- package/lib/_chunks-es/presentation.js.map +1 -1
- package/lib/_chunks-es/resources2.js +58 -1
- package/lib/_chunks-es/resources2.js.map +1 -1
- package/lib/_chunks-es/resources3.js +58 -1
- package/lib/_chunks-es/resources3.js.map +1 -1
- package/lib/_chunks-es/resources4.js +58 -1
- package/lib/_chunks-es/resources4.js.map +1 -1
- package/lib/_chunks-es/resources5.js +58 -1
- package/lib/_chunks-es/resources5.js.map +1 -1
- package/lib/_chunks-es/resources6.js +58 -1
- package/lib/_chunks-es/resources6.js.map +1 -1
- package/lib/_chunks-es/resources7.js +58 -1
- package/lib/_chunks-es/resources7.js.map +1 -1
- package/lib/_chunks-es/structureTool.js +47 -1
- package/lib/_chunks-es/structureTool.js.map +1 -1
- package/lib/_chunks-es/version.js +2 -2
- package/lib/desk.js +4 -1
- package/lib/desk.js.map +1 -1
- package/lib/index.js +15 -1
- package/lib/index.js.map +1 -1
- package/lib/structure.js +3 -1
- package/lib/structure.js.map +1 -1
- package/package.json +11 -11
|
@@ -13,19 +13,24 @@ import "@sanity/client/csm";
|
|
|
13
13
|
import "quick-lru";
|
|
14
14
|
import "lodash-es/throttle.js";
|
|
15
15
|
import "lodash-es/isEqual.js";
|
|
16
|
-
import "@sanity/icons";
|
|
16
|
+
import "@sanity/icons/Document";
|
|
17
|
+
import "@sanity/icons/Image";
|
|
17
18
|
import "@sanity/uuid";
|
|
18
19
|
import "@sanity/color";
|
|
19
20
|
import "color2k";
|
|
20
21
|
import "styled-components";
|
|
21
22
|
import "lodash-es/isString.js";
|
|
23
|
+
import "@sanity/icons/Copy";
|
|
22
24
|
import "react-i18next";
|
|
25
|
+
import "@sanity/icons/Clipboard";
|
|
23
26
|
import "./createAgentBundlesStore.js";
|
|
24
27
|
import "@sanity/telemetry/react";
|
|
25
28
|
import "@portabletext/editor";
|
|
26
29
|
import "@sanity/util/paths";
|
|
27
30
|
import { Dialog } from "./index.js";
|
|
28
31
|
import "@sanity/types";
|
|
32
|
+
import "@sanity/icons/ChevronRight";
|
|
33
|
+
import "@sanity/icons/Revert";
|
|
29
34
|
import "@sanity/diff-match-patch";
|
|
30
35
|
import "lodash-es/flatten.js";
|
|
31
36
|
import "lodash-es/orderBy.js";
|
|
@@ -33,18 +38,29 @@ import "lodash-es/uniq.js";
|
|
|
33
38
|
import "lodash-es/xor.js";
|
|
34
39
|
import "@sanity/diff-patch";
|
|
35
40
|
import "./version.js";
|
|
41
|
+
import "@sanity/icons/ErrorOutline";
|
|
36
42
|
import "@sanity/id-utils";
|
|
37
43
|
import "sanity/router";
|
|
44
|
+
import "@sanity/icons/ChevronDown";
|
|
45
|
+
import "@sanity/icons/InfoOutline";
|
|
38
46
|
import "date-fns/addHours";
|
|
39
47
|
import "date-fns/startOfHour";
|
|
48
|
+
import "@sanity/icons/Bolt";
|
|
49
|
+
import "@sanity/icons/Clock";
|
|
50
|
+
import "@sanity/icons/Dot";
|
|
51
|
+
import "@sanity/icons/EarthGlobe";
|
|
40
52
|
import "date-fns/format";
|
|
41
53
|
import "date-fns/isValid";
|
|
42
54
|
import "date-fns/parse";
|
|
43
55
|
import "@sanity/util/legacyDateFormat";
|
|
56
|
+
import "@sanity/icons/Search";
|
|
44
57
|
import "@sanity/ui/theme";
|
|
58
|
+
import "@sanity/icons/Sync";
|
|
45
59
|
import "lodash-es/pick.js";
|
|
46
60
|
import "react-fast-compare";
|
|
61
|
+
import "@sanity/icons/AccessDenied";
|
|
47
62
|
import "lodash-es/startCase.js";
|
|
63
|
+
import "@sanity/icons/Close";
|
|
48
64
|
import "react-focus-lock";
|
|
49
65
|
import "lodash-es/debounce.js";
|
|
50
66
|
import "date-fns/differenceInDays";
|
|
@@ -54,8 +70,19 @@ import "date-fns/differenceInMonths";
|
|
|
54
70
|
import "date-fns/differenceInSeconds";
|
|
55
71
|
import "date-fns/differenceInWeeks";
|
|
56
72
|
import "date-fns/differenceInYears";
|
|
73
|
+
import "@sanity/icons/AddCircle";
|
|
74
|
+
import "@sanity/icons/Calendar";
|
|
75
|
+
import "@sanity/icons/Circle";
|
|
76
|
+
import "@sanity/icons/Edit";
|
|
77
|
+
import "@sanity/icons/Publish";
|
|
78
|
+
import "@sanity/icons/Timeline";
|
|
79
|
+
import "@sanity/icons/Trash";
|
|
80
|
+
import "@sanity/icons/Unpublish";
|
|
57
81
|
import "@sanity/diff";
|
|
58
82
|
import "mendoza";
|
|
83
|
+
import "@sanity/icons/ArrowDown";
|
|
84
|
+
import "@sanity/icons/ArrowRight";
|
|
85
|
+
import "@sanity/icons/WarningOutline";
|
|
59
86
|
import "@portabletext/sanity-bridge";
|
|
60
87
|
import "motion/react";
|
|
61
88
|
import "lodash-es/get.js";
|
|
@@ -74,6 +101,7 @@ import "lodash-es/toLower.js";
|
|
|
74
101
|
import "lodash-es/union.js";
|
|
75
102
|
import "lodash-es/words.js";
|
|
76
103
|
import "lodash-es/isFinite.js";
|
|
104
|
+
import "@sanity/icons/Add";
|
|
77
105
|
import "observable-callback";
|
|
78
106
|
import "@sanity/util/content";
|
|
79
107
|
import "lodash-es/isPlainObject.js";
|
|
@@ -81,6 +109,8 @@ import "@sanity/insert-menu";
|
|
|
81
109
|
import "@tanstack/react-virtual";
|
|
82
110
|
import "speakingurl";
|
|
83
111
|
import "@sanity/asset-utils";
|
|
112
|
+
import "@sanity/icons/HelpCircle";
|
|
113
|
+
import "@sanity/icons/Launch";
|
|
84
114
|
import "@sanity/image-url";
|
|
85
115
|
import "nanoid";
|
|
86
116
|
import "lodash-es/castArray.js";
|
|
@@ -88,8 +118,13 @@ import "rxjs-mergemap-array";
|
|
|
88
118
|
import "@sanity/mutator";
|
|
89
119
|
import "@portabletext/react";
|
|
90
120
|
import "lodash-es/findIndex.js";
|
|
121
|
+
import "@sanity/icons/EyeOpen";
|
|
122
|
+
import "@sanity/icons/Feedback";
|
|
91
123
|
import "@xstate/react";
|
|
92
124
|
import "xstate";
|
|
125
|
+
import "@sanity/icons/FaceHappy";
|
|
126
|
+
import "@sanity/icons/FaceIndifferent";
|
|
127
|
+
import "@sanity/icons/FaceSad";
|
|
93
128
|
import "@sentry/react";
|
|
94
129
|
import "@sanity/schema";
|
|
95
130
|
import "@sanity/util/client";
|
|
@@ -99,14 +134,29 @@ import "json-reduce";
|
|
|
99
134
|
import "rxjs-exhaustmap-with-trailing";
|
|
100
135
|
import "date-fns/isBefore";
|
|
101
136
|
import "date-fns/startOfMinute";
|
|
137
|
+
import "@sanity/icons/Documents";
|
|
138
|
+
import "@sanity/icons/Unknown";
|
|
102
139
|
import "@portabletext/toolkit";
|
|
140
|
+
import "@sanity/icons/CheckmarkCircle";
|
|
141
|
+
import "@sanity/icons/User";
|
|
142
|
+
import "@sanity/icons/Link";
|
|
143
|
+
import "@sanity/icons/ChevronLeft";
|
|
103
144
|
import "polished";
|
|
104
145
|
import "@sanity/client";
|
|
146
|
+
import "@sanity/icons/Reset";
|
|
105
147
|
import "react-is";
|
|
106
148
|
import "exif-component";
|
|
107
149
|
import "lodash-es/pickBy.js";
|
|
108
150
|
import "swr";
|
|
151
|
+
import "@sanity/icons/Download";
|
|
152
|
+
import "@sanity/icons/Upload";
|
|
153
|
+
import "@sanity/icons/BinaryDocument";
|
|
154
|
+
import "@sanity/icons/Lock";
|
|
155
|
+
import "@sanity/icons/AddDocument";
|
|
156
|
+
import "@sanity/icons/InsertAbove";
|
|
157
|
+
import "@sanity/icons/InsertBelow";
|
|
109
158
|
import "use-hot-module-reload";
|
|
159
|
+
import "@sanity/icons/EllipsisHorizontal";
|
|
110
160
|
import "lodash-es/memoize.js";
|
|
111
161
|
import "lodash-es/sortedIndex.js";
|
|
112
162
|
import "lodash-es/difference.js";
|
|
@@ -121,11 +171,18 @@ import "groq-js";
|
|
|
121
171
|
import "use-sync-external-store/with-selector";
|
|
122
172
|
import "is-network-error";
|
|
123
173
|
import "lodash-es/escapeRegExp.js";
|
|
174
|
+
import "@sanity/icons/Desktop";
|
|
175
|
+
import "@sanity/icons/Moon";
|
|
176
|
+
import "@sanity/icons/Sun";
|
|
124
177
|
import "lodash-es/isEmpty.js";
|
|
125
178
|
import "react-dom/server";
|
|
126
179
|
import "lodash-es/capitalize.js";
|
|
127
180
|
import "lodash-es/last.js";
|
|
128
181
|
import "react-dom/client";
|
|
182
|
+
import "@sanity/icons/ArrowLeft";
|
|
183
|
+
import "@sanity/icons/AddUser";
|
|
184
|
+
import "@sanity/icons/Cog";
|
|
185
|
+
import "@sanity/icons/Checkmark";
|
|
129
186
|
import "date-fns/addWeeks";
|
|
130
187
|
import "date-fns/isAfter";
|
|
131
188
|
import "semver";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReleasesStudioLayout.js","sources":["../../src/core/releases/components/dialog/ReleaseLimitsMisconfigurationDialog.tsx","../../src/core/releases/contexts/upsell/fetchReleaseLimits.ts","../../src/core/releases/store/useOrgActiveReleaseCount.ts","../../src/core/releases/store/useReleaseLimits.ts","../../src/core/releases/contexts/upsell/ReleasesUpsellProvider.tsx","../../src/core/releases/plugin/ReleasesStudioLayout.tsx"],"sourcesContent":["import {Stack, Text} from '@sanity/ui'\nimport {useCallback} from 'react'\n\nimport {Dialog} from '../../../../ui-components'\nimport {useTranslation} from '../../../i18n'\n\ninterface ReleaseLimitsMisconfigurationDialogProps {\n onClose: () => void\n}\n\nexport function ReleaseLimitsMisconfigurationDialog(\n props: ReleaseLimitsMisconfigurationDialogProps,\n) {\n const {onClose} = props\n const {t} = useTranslation()\n\n const handleContactSupport = useCallback(() => {\n window.open('https://www.sanity.io/contact/support', '_blank', 'noopener,noreferrer')\n onClose()\n }, [onClose])\n\n return (\n <Dialog\n id=\"releases-misconfiguration-dialog\"\n header={t('releases.upsell.misconfiguration.header')}\n width={1}\n onClose={onClose}\n footer={{\n confirmButton: {\n text: t('releases.upsell.misconfiguration.contact-support'),\n onClick: handleContactSupport,\n tone: 'primary',\n },\n }}\n >\n <Stack space={4}>\n <Text>{t('releases.upsell.misconfiguration.message')}</Text>\n </Stack>\n </Dialog>\n )\n}\n","import {type ClientError, type SanityClient} from '@sanity/client'\nimport {catchError, map, type Observable, of} from 'rxjs'\n\nexport interface ReleaseLimits {\n // count of all active releases (including content releases and scheduled drafts)\n orgActiveReleaseCount: number\n // counts all content releases that contribute towards reaching the org active release limit\n // excludes scheduled drafts (cardinality `one` releases)\n orgMeteredActiveReleaseCount: number\n datasetReleaseLimit: number\n // internal server error has no fallback number - it uses null\n orgActiveReleaseLimit: number | null\n}\n\ninterface ReleaseLimitsResponse {\n data: ReleaseLimits\n}\n\nfunction isErrorAtLimits(error: ClientError) {\n return (\n error.statusCode === 403 &&\n typeof error.response.body !== 'string' &&\n 'data' in error.response.body\n )\n}\n\n/**\n * @internal\n * fetches subscriptions for this project\n */\nexport function fetchReleaseLimits(\n client: SanityClient,\n storeOrigin: string,\n): Observable<ReleaseLimits> {\n const {projectId} = client.config()\n\n // This endpoint is prone to optimisation and further work\n // it will never live within a versions API and will always be on vX\n // until it goes away - there is graceful handling in `catchError`\n // for when this endpoint is no longer available and limits are fetched\n // some other way\n const clientX = client.withConfig({apiVersion: 'vX'})\n\n return clientX.observable\n .request<ReleaseLimitsResponse>({\n uri: `projects/${projectId}/new-content-release-allowed`,\n /**\n * In a particular case when both releaseLimits\n * and orgActiveReleaseCount stores are empty, 2 fetch calls are made\n * to guard the create/archive/revert actions - browsers behave differently.\n *\n * Chromium based browsers will stall the second network request until the first\n * resolves by attaching the store name to the tag, this spoofs 2 unique requests\n * allowing both the fire in parallel.\n */\n tag: `new-content-release-allowed-${storeOrigin}`,\n })\n .pipe(\n catchError((error: ClientError) => {\n console.error(error)\n\n if (isErrorAtLimits(error)) {\n // body will still contain the limits and current count (if available)\n // so still want to return these and just silently log the error\n return of(error.response.body as ReleaseLimitsResponse)\n }\n\n // for internal server errors, or as a fallback\n // propagate up the error\n throw error\n }),\n map(({data}) => data),\n )\n}\n","import {type SanityClient} from '@sanity/client'\nimport {useMemo} from 'react'\nimport {BehaviorSubject, catchError, map, type Observable, of, switchMap, tap, timer} from 'rxjs'\n\nimport {useClient} from '../../hooks/useClient'\nimport {useResourceCache} from '../../store/ResourceCacheProvider'\nimport {fetchReleaseLimits, type ReleaseLimits} from '../contexts/upsell/fetchReleaseLimits'\nimport {useActiveReleases} from './useActiveReleases'\n\ninterface OrgActiveReleaseCountStore {\n orgActiveReleaseCount$: Observable<ReleaseLimits['orgActiveReleaseCount']>\n}\n\nconst STATE_TTL_MS = 60_000\nconst ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE = 'orgActiveReleaseCount'\n\nfunction createOrgActiveReleaseCountStore(\n client: SanityClient,\n activeReleasesCount: number,\n): OrgActiveReleaseCountStore {\n const latestFetchState = new BehaviorSubject<number | null>(null)\n const staleFlag$ = new BehaviorSubject<boolean>(false)\n const activeReleaseCountAtFetch = new BehaviorSubject<number | null>(null)\n\n const orgActiveReleaseCount$ = latestFetchState.pipe(\n switchMap((state) => {\n if (\n state === null ||\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n staleFlag$.getValue() === true ||\n activeReleaseCountAtFetch.getValue() !== activeReleasesCount\n ) {\n staleFlag$.next(false)\n\n return fetchReleaseLimits(client, 'orgActiveReleaseCount').pipe(\n tap(() => activeReleaseCountAtFetch.next(activeReleasesCount)),\n map((data) => data.orgMeteredActiveReleaseCount),\n catchError((error) => {\n console.error('Failed to fetch org release count', error)\n\n if (!state) throw error\n\n // return the last state if it exists\n return of(state)\n }),\n switchMap((nextState) => {\n latestFetchState.next(nextState)\n\n timer(STATE_TTL_MS).subscribe(() => {\n staleFlag$.next(true)\n activeReleaseCountAtFetch.next(null)\n })\n\n return of(nextState)\n }),\n )\n }\n\n return of(state)\n }),\n )\n\n return {\n orgActiveReleaseCount$,\n }\n}\n\n/**\n * @internal\n *\n * Returns a shared observable to a cache of the org's active release count.\n *\n * This cache expires after a TTL or whenever the active releases in the\n * count of active releases in the dataset changes.\n *\n * @returns An Observable of the cached value for org's active release count.\n */\nexport const useOrgActiveReleaseCount = () => {\n const resourceCache = useResourceCache()\n const {data: activeReleases} = useActiveReleases()\n const client = useClient({apiVersion: 'v2025-02-19'})\n\n const activeReleasesCount = activeReleases?.length || 0\n\n // dependencies must be objects not primitives, so nesting activeReleasesCount in an object\n const count = useMemo(() => ({activeReleasesCount}), [activeReleasesCount])\n\n return useMemo(() => {\n const releaseLimitsStore =\n resourceCache.get<OrgActiveReleaseCountStore>({\n dependencies: [client, count],\n namespace: ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE,\n }) || createOrgActiveReleaseCountStore(client, count.activeReleasesCount)\n\n resourceCache.set({\n namespace: ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE,\n value: releaseLimitsStore,\n dependencies: [client, count],\n })\n\n return releaseLimitsStore\n }, [client, count, resourceCache])\n}\n","import {type SanityClient} from '@sanity/client'\nimport {useMemo} from 'react'\nimport {catchError, map, type Observable, of, shareReplay} from 'rxjs'\n\nimport {useClient} from '../../hooks/useClient'\nimport {useResourceCache} from '../../store/ResourceCacheProvider'\nimport {fetchReleaseLimits, type ReleaseLimits} from '../contexts/upsell/fetchReleaseLimits'\n\ninterface ReleaseLimitsStore {\n releaseLimits$: Observable<Omit<\n ReleaseLimits,\n 'orgActiveReleaseCount' | 'orgMeteredActiveReleaseCount'\n > | null>\n}\n\nconst RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE = 'ReleaseLimits'\n\nfunction createReleaseLimitsStore(client: SanityClient): ReleaseLimitsStore {\n const releaseLimits$ = fetchReleaseLimits(client, 'releaseLimits').pipe(\n map((data) => ({\n datasetReleaseLimit: data.datasetReleaseLimit,\n orgActiveReleaseLimit: data.orgActiveReleaseLimit,\n })),\n shareReplay(1),\n catchError((error) => {\n console.error('Failed to fetch release limits', error)\n\n return of(null)\n }),\n )\n\n return {\n releaseLimits$,\n }\n}\n\n/**\n * @internal\n *\n * Returns a shared observable to a cache of the release limits for the current project.\n *\n * This cache is shared across all instances of this hook, and will only be fetched once.\n * It will never expire as the limits are not expected to change during the lifetime of the render cycle.\n *\n * @returns An Observable of the cached value for the release limits\n */\nexport const useReleaseLimits: () => ReleaseLimitsStore = () => {\n const resourceCache = useResourceCache()\n const client = useClient({apiVersion: 'v2025-02-19'})\n\n return useMemo(() => {\n const releaseLimitsStore =\n resourceCache.get<ReleaseLimitsStore>({\n dependencies: [client],\n namespace: RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE,\n }) || createReleaseLimitsStore(client)\n\n resourceCache.set({\n namespace: RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE,\n value: releaseLimitsStore,\n dependencies: [client],\n })\n\n return releaseLimitsStore\n }, [client, resourceCache])\n}\n","import {useToast} from '@sanity/ui'\nimport {useCallback, useMemo, useState} from 'react'\nimport {firstValueFrom, tap} from 'rxjs'\nimport {ReleasesUpsellContext} from 'sanity/_singletons'\n\nimport {useFeatureEnabled} from '../../../hooks'\nimport {FEATURES} from '../../../hooks/useFeatureEnabled'\nimport {useUpsellData} from '../../../hooks/useUpsellData'\nimport {useTranslation} from '../../../i18n'\nimport {type UpsellDialogViewedInfo} from '../../../studio/upsell/__telemetry__/upsell.telemetry'\nimport {UpsellDialog} from '../../../studio/upsell/UpsellDialog'\nimport {isCardinalityOneRelease} from '../../../util/releaseUtils'\nimport {ReleaseLimitsMisconfigurationDialog} from '../../components/dialog/ReleaseLimitsMisconfigurationDialog'\nimport {useActiveReleases} from '../../store/useActiveReleases'\nimport {useOrgActiveReleaseCount} from '../../store/useOrgActiveReleaseCount'\nimport {useReleaseLimits} from '../../store/useReleaseLimits'\nimport {type ReleasesUpsellContextValue} from './types'\n\nclass StudioReleaseLimitExceededError extends Error {\n details: {type: 'releaseLimitExceededError'}\n\n constructor() {\n super('StudioReleaseLimitExceeded')\n this.name = 'StudioReleaseLimitExceededError'\n this.details = {\n type: 'releaseLimitExceededError',\n }\n }\n}\n\n/**\n * @beta\n * @hidden\n */\nexport function ReleasesUpsellProvider(props: {children: React.ReactNode}) {\n const [upsellDialogOpen, setUpsellDialogOpen] = useState(false)\n const {data: allActiveReleases} = useActiveReleases()\n const {enabled: isReleasesFeatureEnabled} = useFeatureEnabled(FEATURES.contentReleases)\n const {upsellData, telemetryLogs, hasError} = useUpsellData({\n dataUri: '/journey/content-releases',\n feature: 'content-releases',\n })\n const toast = useToast()\n const {t} = useTranslation()\n\n const meteredActiveReleases = useMemo(\n () => allActiveReleases.filter((release) => !isCardinalityOneRelease(release)),\n [allActiveReleases],\n )\n\n const mode = useMemo(() => {\n /**\n * upsell if:\n * plan is free, ie releases is not feature enabled\n */\n if (!isReleasesFeatureEnabled) {\n return 'upsell'\n }\n return 'default'\n }, [isReleasesFeatureEnabled])\n\n const handlePrimaryButtonClick = useCallback(() => {\n telemetryLogs.dialogPrimaryClicked()\n }, [telemetryLogs])\n\n const handleSecondaryButtonClick = useCallback(() => {\n telemetryLogs.dialogSecondaryClicked()\n }, [telemetryLogs])\n\n const handleClose = useCallback(() => {\n setUpsellDialogOpen(false)\n telemetryLogs.dialogDismissed()\n }, [telemetryLogs])\n\n const [releaseLimit, setReleaseLimit] = useState<number | null>(null)\n const [showMisconfigurationDialog, setShowMisconfigurationDialog] = useState(false)\n\n const handleOpenDialog = useCallback(\n (source: UpsellDialogViewedInfo['source'] = 'navbar') => {\n if (hasError) {\n toast.push({\n status: 'error',\n title: t('errors.unable-to-perform-action'),\n closable: true,\n })\n return\n }\n\n setUpsellDialogOpen(true)\n\n telemetryLogs.dialogViewed(source)\n },\n [hasError, toast, t, telemetryLogs],\n )\n\n const {releaseLimits$} = useReleaseLimits()\n const {orgActiveReleaseCount$} = useOrgActiveReleaseCount()\n\n const guardWithReleaseLimitUpsell = useCallback(\n async (\n cb: () => void,\n throwError: boolean = false,\n whenResolved?: (hasPassed: boolean) => void,\n ) => {\n const doUpsell = (): false => {\n handleOpenDialog()\n if (throwError) {\n throw new StudioReleaseLimitExceededError()\n }\n return false\n }\n\n if (mode === 'upsell') {\n whenResolved?.(false)\n return doUpsell()\n }\n\n const fetchLimitsCount = async () => {\n try {\n // if either fails then catch the error\n return await Promise.all([\n firstValueFrom(orgActiveReleaseCount$),\n firstValueFrom(\n releaseLimits$.pipe(\n tap((limit) => setReleaseLimit(limit?.orgActiveReleaseLimit || null)),\n ),\n ),\n ])\n } catch (e) {\n console.error('Error fetching release limits and org count for upsell:', e)\n\n return null\n }\n }\n\n const result = await fetchLimitsCount()\n\n // silently fail and allow pass through guard\n if (result === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const [orgMeteredActiveReleaseCount, releaseLimits] = result\n\n if (releaseLimits === null || orgMeteredActiveReleaseCount === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const {orgActiveReleaseLimit, datasetReleaseLimit} = releaseLimits\n\n // Misconfiguration is when the content release feature is enabled\n // but the quota is set to 0\n if (orgActiveReleaseLimit === 0) {\n whenResolved?.(false)\n setShowMisconfigurationDialog(true)\n if (throwError) {\n throw new StudioReleaseLimitExceededError()\n }\n return false\n }\n\n // orgMeteredActiveReleaseCount might be missing due to internal server error\n // allow pass through guard in that case\n if (orgMeteredActiveReleaseCount === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const meteredActiveReleaseCount = meteredActiveReleases?.length || 0\n const allActiveReleaseCount = allActiveReleases?.length || 0\n\n // scheduled drafts and content releases contribute towards reaching the dataset limit\n const isCurrentDatasetAtAboveDatasetLimit = allActiveReleaseCount >= datasetReleaseLimit\n\n // only metered content releases contribute towards reaching the org limit\n const isCurrentDatasetAtAboveOrgLimit =\n orgActiveReleaseLimit !== null && meteredActiveReleaseCount >= orgActiveReleaseLimit\n const isOrgAtAboveOrgLimit =\n orgActiveReleaseLimit !== null && orgMeteredActiveReleaseCount >= orgActiveReleaseLimit\n\n const shouldShowDialog =\n isCurrentDatasetAtAboveDatasetLimit ||\n isCurrentDatasetAtAboveOrgLimit ||\n isOrgAtAboveOrgLimit\n\n if (shouldShowDialog) {\n whenResolved?.(false)\n return doUpsell()\n }\n\n whenResolved?.(true)\n return cb()\n },\n [\n meteredActiveReleases.length,\n handleOpenDialog,\n allActiveReleases.length,\n mode,\n releaseLimits$,\n orgActiveReleaseCount$,\n ],\n )\n\n const onReleaseLimitReached = useCallback(\n (limit: number) => {\n setReleaseLimit(limit)\n handleOpenDialog()\n },\n [handleOpenDialog],\n )\n\n const ctxValue = useMemo<ReleasesUpsellContextValue>(\n () => ({\n mode,\n upsellDialogOpen,\n guardWithReleaseLimitUpsell,\n onReleaseLimitReached,\n telemetryLogs,\n upsellData,\n handleOpenDialog,\n }),\n [\n mode,\n upsellDialogOpen,\n guardWithReleaseLimitUpsell,\n onReleaseLimitReached,\n telemetryLogs,\n upsellData,\n handleOpenDialog,\n ],\n )\n\n const interpolation = useMemo(\n () => (releaseLimit === null ? undefined : {releaseLimit: releaseLimit}),\n [releaseLimit],\n )\n\n const dialogProps = useMemo(\n () => ({\n data: upsellData,\n open: upsellDialogOpen,\n interpolation,\n onClose: handleClose,\n onPrimaryClick: handlePrimaryButtonClick,\n onSecondaryClick: handleSecondaryButtonClick,\n }),\n [\n upsellData,\n upsellDialogOpen,\n interpolation,\n handleClose,\n handlePrimaryButtonClick,\n handleSecondaryButtonClick,\n ],\n )\n\n return (\n <ReleasesUpsellContext.Provider value={ctxValue}>\n {props.children}\n {showMisconfigurationDialog ? (\n <ReleaseLimitsMisconfigurationDialog onClose={() => setShowMisconfigurationDialog(false)} />\n ) : (\n <UpsellDialog {...dialogProps} />\n )}\n </ReleasesUpsellContext.Provider>\n )\n}\n","import {type LayoutProps} from '../../config'\nimport {useReleasesToolAvailable} from '../../schedules/hooks/useReleasesToolAvailable'\nimport {ReleasesMetadataProvider} from '../contexts/ReleasesMetadataProvider'\nimport {ReleasesUpsellProvider} from '../contexts/upsell/ReleasesUpsellProvider'\n\nexport function ReleasesStudioLayout(props: LayoutProps) {\n const releasesToolAvailable = useReleasesToolAvailable()\n\n if (!releasesToolAvailable) {\n return props.renderDefault(props)\n }\n\n return (\n <ReleasesUpsellProvider>\n <ReleasesMetadataProvider>{props.renderDefault(props)}</ReleasesMetadataProvider>\n </ReleasesUpsellProvider>\n )\n}\n"],"names":["ReleaseLimitsMisconfigurationDialog","props","$","_c","onClose","t","useTranslation","t0","window","open","handleContactSupport","t1","t2","t3","confirmButton","text","onClick","tone","t4","t5","t6","isErrorAtLimits","error","statusCode","response","body","fetchReleaseLimits","client","storeOrigin","projectId","config","withConfig","apiVersion","observable","request","uri","tag","pipe","catchError","console","of","map","data","STATE_TTL_MS","ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE","createOrgActiveReleaseCountStore","activeReleasesCount","latestFetchState","BehaviorSubject","staleFlag$","activeReleaseCountAtFetch","orgActiveReleaseCount$","switchMap","state","getValue","next","tap","orgMeteredActiveReleaseCount","nextState","timer","subscribe","useOrgActiveReleaseCount","resourceCache","useResourceCache","activeReleases","useActiveReleases","for","useClient","length","count","releaseLimitsStore","get","dependencies","namespace","set","value","RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE","createReleaseLimitsStore","releaseLimits$","datasetReleaseLimit","orgActiveReleaseLimit","shareReplay","useReleaseLimits","StudioReleaseLimitExceededError","Error","constructor","name","details","type","ReleasesUpsellProvider","upsellDialogOpen","setUpsellDialogOpen","useState","allActiveReleases","enabled","isReleasesFeatureEnabled","useFeatureEnabled","FEATURES","contentReleases","dataUri","feature","upsellData","telemetryLogs","hasError","useUpsellData","toast","useToast","filter","_temp","meteredActiveReleases","bb0","mode","dialogPrimaryClicked","handlePrimaryButtonClick","dialogSecondaryClicked","handleSecondaryButtonClick","dialogDismissed","handleClose","releaseLimit","setReleaseLimit","showMisconfigurationDialog","setShowMisconfigurationDialog","t7","source","undefined","push","status","title","closable","dialogViewed","handleOpenDialog","cb","t8","whenResolved","throwError","doUpsell","result","Promise","all","firstValueFrom","limit","t9","e","releaseLimits","meteredActiveReleaseCount","isCurrentDatasetAtAboveDatasetLimit","isCurrentDatasetAtAboveOrgLimit","isOrgAtAboveOrgLimit","guardWithReleaseLimitUpsell","limit_0","onReleaseLimitReached","ctxValue","t10","interpolation","t11","onPrimaryClick","onSecondaryClick","dialogProps","t12","t13","children","release","isCardinalityOneRelease","ReleasesStudioLayout","useReleasesToolAvailable","renderDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAAA,oCAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAGL;AAAA,IAAAC;AAAAA,EAAAA,IAAkBH,OAClB;AAAA,IAAAI;AAAAA,EAAAA,IAAYC,eAAAA;AAAgB,MAAAC;AAAAL,WAAAE,WAEaG,KAAAA,MAAA;AACvCC,WAAMC,KAAM,yCAAyC,UAAU,qBAAqB,GACpFL,QAAAA;AAAAA,EAAS,GACVF,OAAAE,SAAAF,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAHD,QAAAQ,uBAA6BH;A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K,cAAepK,KAAK,GAACC,OAAAD,OAAAC,OAAAK,OAAAA,MAAAL,EAAA,CAAA,GAA1BK;AAAAA,EAA0B;AAClC,MAAAA;AAAAL,WAAAD,SAI8BM,KAAAN,MAAKoK,cAAepK,KAAK,GAACC,OAAAD,OAAAC,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAAA,MAAAS;AAAA,SAAAT,SAAAK,MADvDI,KAAA,oBAAC,wBAAA,EACC,UAAA,oBAAC,0BAAA,EAA0BJ,UAAAA,IAA2B,EAAA,CACxD,GAAyBL,OAAAK,IAAAL,OAAAS,MAAAA,KAAAT,EAAA,CAAA,GAFzBS;AAEyB;"}
|
|
1
|
+
{"version":3,"file":"ReleasesStudioLayout.js","sources":["../../src/core/releases/components/dialog/ReleaseLimitsMisconfigurationDialog.tsx","../../src/core/releases/contexts/upsell/fetchReleaseLimits.ts","../../src/core/releases/store/useOrgActiveReleaseCount.ts","../../src/core/releases/store/useReleaseLimits.ts","../../src/core/releases/contexts/upsell/ReleasesUpsellProvider.tsx","../../src/core/releases/plugin/ReleasesStudioLayout.tsx"],"sourcesContent":["import {Stack, Text} from '@sanity/ui'\nimport {useCallback} from 'react'\n\nimport {Dialog} from '../../../../ui-components'\nimport {useTranslation} from '../../../i18n'\n\ninterface ReleaseLimitsMisconfigurationDialogProps {\n onClose: () => void\n}\n\nexport function ReleaseLimitsMisconfigurationDialog(\n props: ReleaseLimitsMisconfigurationDialogProps,\n) {\n const {onClose} = props\n const {t} = useTranslation()\n\n const handleContactSupport = useCallback(() => {\n window.open('https://www.sanity.io/contact/support', '_blank', 'noopener,noreferrer')\n onClose()\n }, [onClose])\n\n return (\n <Dialog\n id=\"releases-misconfiguration-dialog\"\n header={t('releases.upsell.misconfiguration.header')}\n width={1}\n onClose={onClose}\n footer={{\n confirmButton: {\n text: t('releases.upsell.misconfiguration.contact-support'),\n onClick: handleContactSupport,\n tone: 'primary',\n },\n }}\n >\n <Stack space={4}>\n <Text>{t('releases.upsell.misconfiguration.message')}</Text>\n </Stack>\n </Dialog>\n )\n}\n","import {type ClientError, type SanityClient} from '@sanity/client'\nimport {catchError, map, type Observable, of} from 'rxjs'\n\nexport interface ReleaseLimits {\n // count of all active releases (including content releases and scheduled drafts)\n orgActiveReleaseCount: number\n // counts all content releases that contribute towards reaching the org active release limit\n // excludes scheduled drafts (cardinality `one` releases)\n orgMeteredActiveReleaseCount: number\n datasetReleaseLimit: number\n // internal server error has no fallback number - it uses null\n orgActiveReleaseLimit: number | null\n}\n\ninterface ReleaseLimitsResponse {\n data: ReleaseLimits\n}\n\nfunction isErrorAtLimits(error: ClientError) {\n return (\n error.statusCode === 403 &&\n typeof error.response.body !== 'string' &&\n 'data' in error.response.body\n )\n}\n\n/**\n * @internal\n * fetches subscriptions for this project\n */\nexport function fetchReleaseLimits(\n client: SanityClient,\n storeOrigin: string,\n): Observable<ReleaseLimits> {\n const {projectId} = client.config()\n\n // This endpoint is prone to optimisation and further work\n // it will never live within a versions API and will always be on vX\n // until it goes away - there is graceful handling in `catchError`\n // for when this endpoint is no longer available and limits are fetched\n // some other way\n const clientX = client.withConfig({apiVersion: 'vX'})\n\n return clientX.observable\n .request<ReleaseLimitsResponse>({\n uri: `projects/${projectId}/new-content-release-allowed`,\n /**\n * In a particular case when both releaseLimits\n * and orgActiveReleaseCount stores are empty, 2 fetch calls are made\n * to guard the create/archive/revert actions - browsers behave differently.\n *\n * Chromium based browsers will stall the second network request until the first\n * resolves by attaching the store name to the tag, this spoofs 2 unique requests\n * allowing both the fire in parallel.\n */\n tag: `new-content-release-allowed-${storeOrigin}`,\n })\n .pipe(\n catchError((error: ClientError) => {\n console.error(error)\n\n if (isErrorAtLimits(error)) {\n // body will still contain the limits and current count (if available)\n // so still want to return these and just silently log the error\n return of(error.response.body as ReleaseLimitsResponse)\n }\n\n // for internal server errors, or as a fallback\n // propagate up the error\n throw error\n }),\n map(({data}) => data),\n )\n}\n","import {type SanityClient} from '@sanity/client'\nimport {useMemo} from 'react'\nimport {BehaviorSubject, catchError, map, type Observable, of, switchMap, tap, timer} from 'rxjs'\n\nimport {useClient} from '../../hooks/useClient'\nimport {useResourceCache} from '../../store/ResourceCacheProvider'\nimport {fetchReleaseLimits, type ReleaseLimits} from '../contexts/upsell/fetchReleaseLimits'\nimport {useActiveReleases} from './useActiveReleases'\n\ninterface OrgActiveReleaseCountStore {\n orgActiveReleaseCount$: Observable<ReleaseLimits['orgActiveReleaseCount']>\n}\n\nconst STATE_TTL_MS = 60_000\nconst ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE = 'orgActiveReleaseCount'\n\nfunction createOrgActiveReleaseCountStore(\n client: SanityClient,\n activeReleasesCount: number,\n): OrgActiveReleaseCountStore {\n const latestFetchState = new BehaviorSubject<number | null>(null)\n const staleFlag$ = new BehaviorSubject<boolean>(false)\n const activeReleaseCountAtFetch = new BehaviorSubject<number | null>(null)\n\n const orgActiveReleaseCount$ = latestFetchState.pipe(\n switchMap((state) => {\n if (\n state === null ||\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n staleFlag$.getValue() === true ||\n activeReleaseCountAtFetch.getValue() !== activeReleasesCount\n ) {\n staleFlag$.next(false)\n\n return fetchReleaseLimits(client, 'orgActiveReleaseCount').pipe(\n tap(() => activeReleaseCountAtFetch.next(activeReleasesCount)),\n map((data) => data.orgMeteredActiveReleaseCount),\n catchError((error) => {\n console.error('Failed to fetch org release count', error)\n\n if (!state) throw error\n\n // return the last state if it exists\n return of(state)\n }),\n switchMap((nextState) => {\n latestFetchState.next(nextState)\n\n timer(STATE_TTL_MS).subscribe(() => {\n staleFlag$.next(true)\n activeReleaseCountAtFetch.next(null)\n })\n\n return of(nextState)\n }),\n )\n }\n\n return of(state)\n }),\n )\n\n return {\n orgActiveReleaseCount$,\n }\n}\n\n/**\n * @internal\n *\n * Returns a shared observable to a cache of the org's active release count.\n *\n * This cache expires after a TTL or whenever the active releases in the\n * count of active releases in the dataset changes.\n *\n * @returns An Observable of the cached value for org's active release count.\n */\nexport const useOrgActiveReleaseCount = () => {\n const resourceCache = useResourceCache()\n const {data: activeReleases} = useActiveReleases()\n const client = useClient({apiVersion: 'v2025-02-19'})\n\n const activeReleasesCount = activeReleases?.length || 0\n\n // dependencies must be objects not primitives, so nesting activeReleasesCount in an object\n const count = useMemo(() => ({activeReleasesCount}), [activeReleasesCount])\n\n return useMemo(() => {\n const releaseLimitsStore =\n resourceCache.get<OrgActiveReleaseCountStore>({\n dependencies: [client, count],\n namespace: ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE,\n }) || createOrgActiveReleaseCountStore(client, count.activeReleasesCount)\n\n resourceCache.set({\n namespace: ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE,\n value: releaseLimitsStore,\n dependencies: [client, count],\n })\n\n return releaseLimitsStore\n }, [client, count, resourceCache])\n}\n","import {type SanityClient} from '@sanity/client'\nimport {useMemo} from 'react'\nimport {catchError, map, type Observable, of, shareReplay} from 'rxjs'\n\nimport {useClient} from '../../hooks/useClient'\nimport {useResourceCache} from '../../store/ResourceCacheProvider'\nimport {fetchReleaseLimits, type ReleaseLimits} from '../contexts/upsell/fetchReleaseLimits'\n\ninterface ReleaseLimitsStore {\n releaseLimits$: Observable<Omit<\n ReleaseLimits,\n 'orgActiveReleaseCount' | 'orgMeteredActiveReleaseCount'\n > | null>\n}\n\nconst RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE = 'ReleaseLimits'\n\nfunction createReleaseLimitsStore(client: SanityClient): ReleaseLimitsStore {\n const releaseLimits$ = fetchReleaseLimits(client, 'releaseLimits').pipe(\n map((data) => ({\n datasetReleaseLimit: data.datasetReleaseLimit,\n orgActiveReleaseLimit: data.orgActiveReleaseLimit,\n })),\n shareReplay(1),\n catchError((error) => {\n console.error('Failed to fetch release limits', error)\n\n return of(null)\n }),\n )\n\n return {\n releaseLimits$,\n }\n}\n\n/**\n * @internal\n *\n * Returns a shared observable to a cache of the release limits for the current project.\n *\n * This cache is shared across all instances of this hook, and will only be fetched once.\n * It will never expire as the limits are not expected to change during the lifetime of the render cycle.\n *\n * @returns An Observable of the cached value for the release limits\n */\nexport const useReleaseLimits: () => ReleaseLimitsStore = () => {\n const resourceCache = useResourceCache()\n const client = useClient({apiVersion: 'v2025-02-19'})\n\n return useMemo(() => {\n const releaseLimitsStore =\n resourceCache.get<ReleaseLimitsStore>({\n dependencies: [client],\n namespace: RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE,\n }) || createReleaseLimitsStore(client)\n\n resourceCache.set({\n namespace: RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE,\n value: releaseLimitsStore,\n dependencies: [client],\n })\n\n return releaseLimitsStore\n }, [client, resourceCache])\n}\n","import {useToast} from '@sanity/ui'\nimport {useCallback, useMemo, useState} from 'react'\nimport {firstValueFrom, tap} from 'rxjs'\nimport {ReleasesUpsellContext} from 'sanity/_singletons'\n\nimport {useFeatureEnabled} from '../../../hooks'\nimport {FEATURES} from '../../../hooks/useFeatureEnabled'\nimport {useUpsellData} from '../../../hooks/useUpsellData'\nimport {useTranslation} from '../../../i18n'\nimport {type UpsellDialogViewedInfo} from '../../../studio/upsell/__telemetry__/upsell.telemetry'\nimport {UpsellDialog} from '../../../studio/upsell/UpsellDialog'\nimport {isCardinalityOneRelease} from '../../../util/releaseUtils'\nimport {ReleaseLimitsMisconfigurationDialog} from '../../components/dialog/ReleaseLimitsMisconfigurationDialog'\nimport {useActiveReleases} from '../../store/useActiveReleases'\nimport {useOrgActiveReleaseCount} from '../../store/useOrgActiveReleaseCount'\nimport {useReleaseLimits} from '../../store/useReleaseLimits'\nimport {type ReleasesUpsellContextValue} from './types'\n\nclass StudioReleaseLimitExceededError extends Error {\n details: {type: 'releaseLimitExceededError'}\n\n constructor() {\n super('StudioReleaseLimitExceeded')\n this.name = 'StudioReleaseLimitExceededError'\n this.details = {\n type: 'releaseLimitExceededError',\n }\n }\n}\n\n/**\n * @beta\n * @hidden\n */\nexport function ReleasesUpsellProvider(props: {children: React.ReactNode}) {\n const [upsellDialogOpen, setUpsellDialogOpen] = useState(false)\n const {data: allActiveReleases} = useActiveReleases()\n const {enabled: isReleasesFeatureEnabled} = useFeatureEnabled(FEATURES.contentReleases)\n const {upsellData, telemetryLogs, hasError} = useUpsellData({\n dataUri: '/journey/content-releases',\n feature: 'content-releases',\n })\n const toast = useToast()\n const {t} = useTranslation()\n\n const meteredActiveReleases = useMemo(\n () => allActiveReleases.filter((release) => !isCardinalityOneRelease(release)),\n [allActiveReleases],\n )\n\n const mode = useMemo(() => {\n /**\n * upsell if:\n * plan is free, ie releases is not feature enabled\n */\n if (!isReleasesFeatureEnabled) {\n return 'upsell'\n }\n return 'default'\n }, [isReleasesFeatureEnabled])\n\n const handlePrimaryButtonClick = useCallback(() => {\n telemetryLogs.dialogPrimaryClicked()\n }, [telemetryLogs])\n\n const handleSecondaryButtonClick = useCallback(() => {\n telemetryLogs.dialogSecondaryClicked()\n }, [telemetryLogs])\n\n const handleClose = useCallback(() => {\n setUpsellDialogOpen(false)\n telemetryLogs.dialogDismissed()\n }, [telemetryLogs])\n\n const [releaseLimit, setReleaseLimit] = useState<number | null>(null)\n const [showMisconfigurationDialog, setShowMisconfigurationDialog] = useState(false)\n\n const handleOpenDialog = useCallback(\n (source: UpsellDialogViewedInfo['source'] = 'navbar') => {\n if (hasError) {\n toast.push({\n status: 'error',\n title: t('errors.unable-to-perform-action'),\n closable: true,\n })\n return\n }\n\n setUpsellDialogOpen(true)\n\n telemetryLogs.dialogViewed(source)\n },\n [hasError, toast, t, telemetryLogs],\n )\n\n const {releaseLimits$} = useReleaseLimits()\n const {orgActiveReleaseCount$} = useOrgActiveReleaseCount()\n\n const guardWithReleaseLimitUpsell = useCallback(\n async (\n cb: () => void,\n throwError: boolean = false,\n whenResolved?: (hasPassed: boolean) => void,\n ) => {\n const doUpsell = (): false => {\n handleOpenDialog()\n if (throwError) {\n throw new StudioReleaseLimitExceededError()\n }\n return false\n }\n\n if (mode === 'upsell') {\n whenResolved?.(false)\n return doUpsell()\n }\n\n const fetchLimitsCount = async () => {\n try {\n // if either fails then catch the error\n return await Promise.all([\n firstValueFrom(orgActiveReleaseCount$),\n firstValueFrom(\n releaseLimits$.pipe(\n tap((limit) => setReleaseLimit(limit?.orgActiveReleaseLimit || null)),\n ),\n ),\n ])\n } catch (e) {\n console.error('Error fetching release limits and org count for upsell:', e)\n\n return null\n }\n }\n\n const result = await fetchLimitsCount()\n\n // silently fail and allow pass through guard\n if (result === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const [orgMeteredActiveReleaseCount, releaseLimits] = result\n\n if (releaseLimits === null || orgMeteredActiveReleaseCount === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const {orgActiveReleaseLimit, datasetReleaseLimit} = releaseLimits\n\n // Misconfiguration is when the content release feature is enabled\n // but the quota is set to 0\n if (orgActiveReleaseLimit === 0) {\n whenResolved?.(false)\n setShowMisconfigurationDialog(true)\n if (throwError) {\n throw new StudioReleaseLimitExceededError()\n }\n return false\n }\n\n // orgMeteredActiveReleaseCount might be missing due to internal server error\n // allow pass through guard in that case\n if (orgMeteredActiveReleaseCount === null) {\n whenResolved?.(true)\n return cb()\n }\n\n const meteredActiveReleaseCount = meteredActiveReleases?.length || 0\n const allActiveReleaseCount = allActiveReleases?.length || 0\n\n // scheduled drafts and content releases contribute towards reaching the dataset limit\n const isCurrentDatasetAtAboveDatasetLimit = allActiveReleaseCount >= datasetReleaseLimit\n\n // only metered content releases contribute towards reaching the org limit\n const isCurrentDatasetAtAboveOrgLimit =\n orgActiveReleaseLimit !== null && meteredActiveReleaseCount >= orgActiveReleaseLimit\n const isOrgAtAboveOrgLimit =\n orgActiveReleaseLimit !== null && orgMeteredActiveReleaseCount >= orgActiveReleaseLimit\n\n const shouldShowDialog =\n isCurrentDatasetAtAboveDatasetLimit ||\n isCurrentDatasetAtAboveOrgLimit ||\n isOrgAtAboveOrgLimit\n\n if (shouldShowDialog) {\n whenResolved?.(false)\n return doUpsell()\n }\n\n whenResolved?.(true)\n return cb()\n },\n [\n meteredActiveReleases.length,\n handleOpenDialog,\n allActiveReleases.length,\n mode,\n releaseLimits$,\n orgActiveReleaseCount$,\n ],\n )\n\n const onReleaseLimitReached = useCallback(\n (limit: number) => {\n setReleaseLimit(limit)\n handleOpenDialog()\n },\n [handleOpenDialog],\n )\n\n const ctxValue = useMemo<ReleasesUpsellContextValue>(\n () => ({\n mode,\n upsellDialogOpen,\n guardWithReleaseLimitUpsell,\n onReleaseLimitReached,\n telemetryLogs,\n upsellData,\n handleOpenDialog,\n }),\n [\n mode,\n upsellDialogOpen,\n guardWithReleaseLimitUpsell,\n onReleaseLimitReached,\n telemetryLogs,\n upsellData,\n handleOpenDialog,\n ],\n )\n\n const interpolation = useMemo(\n () => (releaseLimit === null ? undefined : {releaseLimit: releaseLimit}),\n [releaseLimit],\n )\n\n const dialogProps = useMemo(\n () => ({\n data: upsellData,\n open: upsellDialogOpen,\n interpolation,\n onClose: handleClose,\n onPrimaryClick: handlePrimaryButtonClick,\n onSecondaryClick: handleSecondaryButtonClick,\n }),\n [\n upsellData,\n upsellDialogOpen,\n interpolation,\n handleClose,\n handlePrimaryButtonClick,\n handleSecondaryButtonClick,\n ],\n )\n\n return (\n <ReleasesUpsellContext.Provider value={ctxValue}>\n {props.children}\n {showMisconfigurationDialog ? (\n <ReleaseLimitsMisconfigurationDialog onClose={() => setShowMisconfigurationDialog(false)} />\n ) : (\n <UpsellDialog {...dialogProps} />\n )}\n </ReleasesUpsellContext.Provider>\n )\n}\n","import {type LayoutProps} from '../../config'\nimport {useReleasesToolAvailable} from '../../schedules/hooks/useReleasesToolAvailable'\nimport {ReleasesMetadataProvider} from '../contexts/ReleasesMetadataProvider'\nimport {ReleasesUpsellProvider} from '../contexts/upsell/ReleasesUpsellProvider'\n\nexport function ReleasesStudioLayout(props: LayoutProps) {\n const releasesToolAvailable = useReleasesToolAvailable()\n\n if (!releasesToolAvailable) {\n return props.renderDefault(props)\n }\n\n return (\n <ReleasesUpsellProvider>\n <ReleasesMetadataProvider>{props.renderDefault(props)}</ReleasesMetadataProvider>\n </ReleasesUpsellProvider>\n )\n}\n"],"names":["ReleaseLimitsMisconfigurationDialog","props","$","_c","onClose","t","useTranslation","t0","window","open","handleContactSupport","t1","t2","t3","confirmButton","text","onClick","tone","t4","t5","t6","isErrorAtLimits","error","statusCode","response","body","fetchReleaseLimits","client","storeOrigin","projectId","config","withConfig","apiVersion","observable","request","uri","tag","pipe","catchError","console","of","map","data","STATE_TTL_MS","ORG_ACTIVE_RELEASE_COUNT_RESOURCE_CACHE_NAMESPACE","createOrgActiveReleaseCountStore","activeReleasesCount","latestFetchState","BehaviorSubject","staleFlag$","activeReleaseCountAtFetch","orgActiveReleaseCount$","switchMap","state","getValue","next","tap","orgMeteredActiveReleaseCount","nextState","timer","subscribe","useOrgActiveReleaseCount","resourceCache","useResourceCache","activeReleases","useActiveReleases","for","useClient","length","count","releaseLimitsStore","get","dependencies","namespace","set","value","RELEASE_LIMITS_RESOURCE_CACHE_NAMESPACE","createReleaseLimitsStore","releaseLimits$","datasetReleaseLimit","orgActiveReleaseLimit","shareReplay","useReleaseLimits","StudioReleaseLimitExceededError","Error","constructor","name","details","type","ReleasesUpsellProvider","upsellDialogOpen","setUpsellDialogOpen","useState","allActiveReleases","enabled","isReleasesFeatureEnabled","useFeatureEnabled","FEATURES","contentReleases","dataUri","feature","upsellData","telemetryLogs","hasError","useUpsellData","toast","useToast","filter","_temp","meteredActiveReleases","bb0","mode","dialogPrimaryClicked","handlePrimaryButtonClick","dialogSecondaryClicked","handleSecondaryButtonClick","dialogDismissed","handleClose","releaseLimit","setReleaseLimit","showMisconfigurationDialog","setShowMisconfigurationDialog","t7","source","undefined","push","status","title","closable","dialogViewed","handleOpenDialog","cb","t8","whenResolved","throwError","doUpsell","result","Promise","all","firstValueFrom","limit","t9","e","releaseLimits","meteredActiveReleaseCount","isCurrentDatasetAtAboveDatasetLimit","isCurrentDatasetAtAboveOrgLimit","isOrgAtAboveOrgLimit","guardWithReleaseLimitUpsell","limit_0","onReleaseLimitReached","ctxValue","t10","interpolation","t11","onPrimaryClick","onSecondaryClick","dialogProps","t12","t13","children","release","isCardinalityOneRelease","ReleasesStudioLayout","useReleasesToolAvailable","renderDefault"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAAA,oCAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,EAAA,GAGL;AAAA,IAAAC;AAAAA,EAAAA,IAAkBH,OAClB;AAAA,IAAAI;AAAAA,EAAAA,IAAYC,eAAAA;AAAgB,MAAAC;AAAAL,WAAAE,WAEaG,KAAAA,MAAA;AACvCC,WAAMC,KAAM,yCAAyC,UAAU,qBAAqB,GACpFL,QAAAA;AAAAA,EAAS,GACVF,OAAAE,SAAAF,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAHD,QAAAQ,uBAA6BH;AAGhB,MAAAI;AAAAT,WAAAG,KAKDM,KAAAN,EAAE,yCAAyC,GAACH,OAAAG,GAAAH,OAAAS,MAAAA,KAAAT,EAAA,CAAA;AAAA,MAAAU;AAAAV,WAAAG,KAK1CO,KAAAP,EAAE,kDAAkD,GAACH,OAAAG,GAAAH,OAAAU,MAAAA,KAAAV,EAAA,CAAA;AAAA,MAAAW;AAAAX,IAAA,CAAA,MAAAQ,wBAAAR,SAAAU,MAFvDC,KAAA;AAAA,IAAAC,eACS;AAAA,MAAAC,MACPH;AAAAA,MAAqDI,SAClDN;AAAAA,MAAoBO,MACvB;AAAA,IAAA;AAAA,EACR,GACDf,OAAAQ,sBAAAR,OAAAU,IAAAV,OAAAW,MAAAA,KAAAX,EAAA,CA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ment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
3
|
import { IntentLink, useRouter, RouterContext } from "sanity/router";
|
|
4
|
-
import {
|
|
4
|
+
import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
5
5
|
import { Card, Text, Flex, Stack, Box, useToast, useClickOutsideEvent, Spinner, TabList, Container, Checkbox, MenuDivider, Menu, Button as Button$1, LayerProvider, PortalProvider, Skeleton, Label, Badge, Inline, useMediaIndex } from "@sanity/ui";
|
|
6
6
|
import { motion, AnimatePresence } from "motion/react";
|
|
7
7
|
import { forwardRef, memo, useRef, useMemo, useEffect, useState } from "react";
|
|
@@ -15,18 +15,24 @@ import { getPublishedId, getVersionFromId, getVersionId } from "@sanity/client/c
|
|
|
15
15
|
import "quick-lru";
|
|
16
16
|
import "lodash-es/throttle.js";
|
|
17
17
|
import isEqual from "lodash-es/isEqual.js";
|
|
18
|
+
import "@sanity/icons/Document";
|
|
19
|
+
import "@sanity/icons/Image";
|
|
18
20
|
import "@sanity/uuid";
|
|
19
21
|
import "@sanity/color";
|
|
20
22
|
import "color2k";
|
|
21
23
|
import { styled } from "styled-components";
|
|
22
24
|
import "lodash-es/isString.js";
|
|
25
|
+
import { CopyIcon } from "@sanity/icons/Copy";
|
|
23
26
|
import "react-i18next";
|
|
27
|
+
import "@sanity/icons/Clipboard";
|
|
24
28
|
import "./createAgentBundlesStore.js";
|
|
25
29
|
import { useTelemetry } from "@sanity/telemetry/react";
|
|
26
30
|
import "@portabletext/editor";
|
|
27
31
|
import { toString } from "@sanity/util/paths";
|
|
28
32
|
import { Button, Popover, Tab, Tooltip, Dialog, MenuItem, MenuButton } from "./index.js";
|
|
29
33
|
import "@sanity/types";
|
|
34
|
+
import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
|
|
35
|
+
import "@sanity/icons/Revert";
|
|
30
36
|
import "@sanity/diff-match-patch";
|
|
31
37
|
import "lodash-es/flatten.js";
|
|
32
38
|
import "lodash-es/orderBy.js";
|
|
@@ -42,16 +48,35 @@ import "date-fns/differenceInMonths";
|
|
|
42
48
|
import "date-fns/differenceInSeconds";
|
|
43
49
|
import "date-fns/differenceInWeeks";
|
|
44
50
|
import "date-fns/differenceInYears";
|
|
51
|
+
import "@sanity/icons/AddCircle";
|
|
52
|
+
import { CalendarIcon } from "@sanity/icons/Calendar";
|
|
53
|
+
import "@sanity/icons/Circle";
|
|
54
|
+
import { CloseIcon } from "@sanity/icons/Close";
|
|
55
|
+
import "@sanity/icons/Edit";
|
|
56
|
+
import { PublishIcon } from "@sanity/icons/Publish";
|
|
57
|
+
import "@sanity/icons/Timeline";
|
|
58
|
+
import { TrashIcon } from "@sanity/icons/Trash";
|
|
59
|
+
import { UnpublishIcon } from "@sanity/icons/Unpublish";
|
|
45
60
|
import "@sanity/diff";
|
|
46
61
|
import "mendoza";
|
|
62
|
+
import "@sanity/icons/ArrowDown";
|
|
63
|
+
import "@sanity/icons/ArrowRight";
|
|
64
|
+
import { InfoOutlineIcon } from "@sanity/icons/InfoOutline";
|
|
65
|
+
import { WarningOutlineIcon } from "@sanity/icons/WarningOutline";
|
|
47
66
|
import "@portabletext/sanity-bridge";
|
|
48
67
|
import "@sanity/id-utils";
|
|
68
|
+
import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
|
|
49
69
|
import "date-fns/addHours";
|
|
50
70
|
import "date-fns/startOfHour";
|
|
71
|
+
import "@sanity/icons/Bolt";
|
|
72
|
+
import { ClockIcon } from "@sanity/icons/Clock";
|
|
73
|
+
import "@sanity/icons/Dot";
|
|
74
|
+
import { EarthGlobeIcon } from "@sanity/icons/EarthGlobe";
|
|
51
75
|
import { format } from "date-fns/format";
|
|
52
76
|
import { isValid } from "date-fns/isValid";
|
|
53
77
|
import { parse } from "date-fns/parse";
|
|
54
78
|
import "@sanity/util/legacyDateFormat";
|
|
79
|
+
import "@sanity/icons/Search";
|
|
55
80
|
import "react-fast-compare";
|
|
56
81
|
import "lodash-es/pick.js";
|
|
57
82
|
import "lodash-es/get.js";
|
|
@@ -70,6 +95,7 @@ import "lodash-es/toLower.js";
|
|
|
70
95
|
import "lodash-es/union.js";
|
|
71
96
|
import "lodash-es/words.js";
|
|
72
97
|
import "lodash-es/isFinite.js";
|
|
98
|
+
import { AddIcon } from "@sanity/icons/Add";
|
|
73
99
|
import "observable-callback";
|
|
74
100
|
import "@sanity/util/content";
|
|
75
101
|
import "lodash-es/isPlainObject.js";
|
|
@@ -78,6 +104,9 @@ import { useVirtualizer } from "@tanstack/react-virtual";
|
|
|
78
104
|
import "lodash-es/startCase.js";
|
|
79
105
|
import "speakingurl";
|
|
80
106
|
import "@sanity/asset-utils";
|
|
107
|
+
import "@sanity/icons/AccessDenied";
|
|
108
|
+
import "@sanity/icons/HelpCircle";
|
|
109
|
+
import "@sanity/icons/Launch";
|
|
81
110
|
import "@sanity/image-url";
|
|
82
111
|
import "nanoid";
|
|
83
112
|
import "lodash-es/castArray.js";
|
|
@@ -85,14 +114,25 @@ import "rxjs-mergemap-array";
|
|
|
85
114
|
import "@sanity/mutator";
|
|
86
115
|
import "@portabletext/react";
|
|
87
116
|
import "lodash-es/findIndex.js";
|
|
117
|
+
import "@sanity/icons/EyeOpen";
|
|
118
|
+
import "@sanity/icons/Feedback";
|
|
88
119
|
import "@xstate/react";
|
|
89
120
|
import "xstate";
|
|
121
|
+
import "@sanity/icons/FaceHappy";
|
|
122
|
+
import "@sanity/icons/FaceIndifferent";
|
|
123
|
+
import "@sanity/icons/FaceSad";
|
|
90
124
|
import "@sentry/react";
|
|
91
125
|
import { isBefore } from "date-fns/isBefore";
|
|
92
126
|
import { startOfMinute } from "date-fns/startOfMinute";
|
|
127
|
+
import "@sanity/icons/Documents";
|
|
128
|
+
import "@sanity/icons/Unknown";
|
|
93
129
|
import "@portabletext/toolkit";
|
|
94
130
|
import "lodash-es/debounce.js";
|
|
131
|
+
import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle";
|
|
132
|
+
import "@sanity/icons/User";
|
|
95
133
|
import "react-focus-lock";
|
|
134
|
+
import { LinkIcon } from "@sanity/icons/Link";
|
|
135
|
+
import "@sanity/icons/ChevronLeft";
|
|
96
136
|
import "polished";
|
|
97
137
|
import "@sanity/schema";
|
|
98
138
|
import "@sanity/util/client";
|
|
@@ -101,11 +141,21 @@ import "lodash-es/uniqBy.js";
|
|
|
101
141
|
import "json-reduce";
|
|
102
142
|
import "rxjs-exhaustmap-with-trailing";
|
|
103
143
|
import "@sanity/client";
|
|
144
|
+
import "@sanity/icons/Reset";
|
|
145
|
+
import "@sanity/icons/Sync";
|
|
104
146
|
import "react-is";
|
|
105
147
|
import "exif-component";
|
|
106
148
|
import "lodash-es/pickBy.js";
|
|
107
149
|
import "swr";
|
|
150
|
+
import "@sanity/icons/Download";
|
|
151
|
+
import "@sanity/icons/Upload";
|
|
152
|
+
import "@sanity/icons/BinaryDocument";
|
|
153
|
+
import { LockIcon } from "@sanity/icons/Lock";
|
|
154
|
+
import "@sanity/icons/AddDocument";
|
|
155
|
+
import "@sanity/icons/InsertAbove";
|
|
156
|
+
import "@sanity/icons/InsertBelow";
|
|
108
157
|
import "use-hot-module-reload";
|
|
158
|
+
import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
|
|
109
159
|
import "lodash-es/memoize.js";
|
|
110
160
|
import "lodash-es/sortedIndex.js";
|
|
111
161
|
import "lodash-es/difference.js";
|
|
@@ -120,20 +170,37 @@ import "groq-js";
|
|
|
120
170
|
import "use-sync-external-store/with-selector";
|
|
121
171
|
import "is-network-error";
|
|
122
172
|
import "lodash-es/escapeRegExp.js";
|
|
173
|
+
import "@sanity/icons/Desktop";
|
|
174
|
+
import "@sanity/icons/Moon";
|
|
175
|
+
import "@sanity/icons/Sun";
|
|
123
176
|
import "lodash-es/isEmpty.js";
|
|
124
177
|
import "react-dom/server";
|
|
125
178
|
import "lodash-es/capitalize.js";
|
|
126
179
|
import "lodash-es/last.js";
|
|
127
180
|
import "react-dom/client";
|
|
181
|
+
import "@sanity/icons/ArrowLeft";
|
|
182
|
+
import "@sanity/icons/AddUser";
|
|
183
|
+
import "@sanity/icons/Cog";
|
|
184
|
+
import "@sanity/icons/Checkmark";
|
|
128
185
|
import "date-fns/addWeeks";
|
|
129
186
|
import "date-fns/isAfter";
|
|
130
187
|
import "semver";
|
|
131
188
|
import "lodash-es/isObject.js";
|
|
189
|
+
import { PinIcon } from "@sanity/icons/Pin";
|
|
190
|
+
import { PinFilledIcon } from "@sanity/icons/PinFilled";
|
|
132
191
|
import { addDays } from "date-fns/addDays";
|
|
192
|
+
import { RestoreIcon } from "@sanity/icons/Restore";
|
|
193
|
+
import { CloseCircleIcon } from "@sanity/icons/CloseCircle";
|
|
194
|
+
import { ArchiveIcon } from "@sanity/icons/Archive";
|
|
195
|
+
import { UnarchiveIcon } from "@sanity/icons/Unarchive";
|
|
196
|
+
import { ShareIcon } from "@sanity/icons/Share";
|
|
197
|
+
import { TargetIcon } from "@sanity/icons/Target";
|
|
198
|
+
import { TextIcon } from "@sanity/icons/Text";
|
|
133
199
|
import { Headers, Table } from "./Table.js";
|
|
134
200
|
import { isSameDay } from "date-fns/isSameDay";
|
|
135
201
|
import { CalendarDay, CalendarFilter } from "./CalendarFilter.js";
|
|
136
202
|
import { useReleasesMetadataProvider } from "./ReleasesMetadataProvider.js";
|
|
203
|
+
import { FilterIcon } from "@sanity/icons/Filter";
|
|
137
204
|
import { isPast } from "date-fns/isPast";
|
|
138
205
|
import { endOfDay } from "date-fns/endOfDay";
|
|
139
206
|
import { startOfDay } from "date-fns/startOfDay";
|