@nocode-factory/sanity-kit 2.1.0 → 2.1.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.
- package/dist/index.d.ts +8 -1
- package/dist/index.js +34 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/usePreviewTarget.ts +12 -0
- package/src/tools/pages/PagesTool.tsx +1 -0
- package/src/tools/pages/PreviewTarget.tsx +8 -2
- package/src/tools/pages/SharePreview.tsx +24 -1
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1030,6 +1030,13 @@ interface PreviewTargetState {
|
|
|
1030
1030
|
pathFor: (url: string | null) => string | null;
|
|
1031
1031
|
/** URL de la page sur l'environnement choisi, pour l'ouvrir hors du Studio. */
|
|
1032
1032
|
siteUrlFor: (url: string | null) => string | null;
|
|
1033
|
+
/**
|
|
1034
|
+
* L'environnement choisi est-il le site public ?
|
|
1035
|
+
*
|
|
1036
|
+
* Il n'y a rien à y prévisualiser : le bandeau s'y masque et le mode
|
|
1037
|
+
* brouillon y est refusé. Partager un lien vers lui ne montrerait rien.
|
|
1038
|
+
*/
|
|
1039
|
+
isProduction: boolean;
|
|
1033
1040
|
}
|
|
1034
1041
|
export declare function usePreviewTarget(): PreviewTargetState;
|
|
1035
1042
|
/**
|
|
@@ -1191,7 +1198,7 @@ export declare function ActorName(props: {
|
|
|
1191
1198
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1192
1199
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1193
1200
|
*/
|
|
1194
|
-
export declare const KIT_VERSION = "2.1.
|
|
1201
|
+
export declare const KIT_VERSION = "2.1.1";
|
|
1195
1202
|
/**
|
|
1196
1203
|
* Données de la page proposées comme colonnes.
|
|
1197
1204
|
*
|
package/dist/index.js
CHANGED
|
@@ -1081,6 +1081,7 @@ function usePreviewTargetState() {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
}, [environment]);
|
|
1083
1083
|
return {
|
|
1084
|
+
isProduction: !!(environment && config.previewUrl && environment.url === config.previewUrl),
|
|
1084
1085
|
environments: allEnvironments,
|
|
1085
1086
|
customUrl,
|
|
1086
1087
|
setCustomUrl,
|
|
@@ -1239,7 +1240,7 @@ function explainGrantError(error) {
|
|
|
1239
1240
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1240
1241
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1241
1242
|
*/
|
|
1242
|
-
const KIT_VERSION = "2.1.
|
|
1243
|
+
const KIT_VERSION = "2.1.1";
|
|
1243
1244
|
/**
|
|
1244
1245
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1245
1246
|
*
|
|
@@ -1908,7 +1909,7 @@ const TABULAR = { fontVariantNumeric: "tabular-nums" }, MONO = {
|
|
|
1908
1909
|
* menu à une entrée occupe la place sans rien offrir.
|
|
1909
1910
|
*/
|
|
1910
1911
|
function PreviewTarget(props) {
|
|
1911
|
-
let { environments, environmentId, perspective, onEnvironment, onPerspective } = props, { onCustomUrl, customUrl } = props, current = environments.find((environment) => environment.id === environmentId);
|
|
1912
|
+
let { environments, environmentId, perspective, onEnvironment, onPerspective } = props, { onCustomUrl, customUrl, productionUrl } = props, current = environments.find((environment) => environment.id === environmentId);
|
|
1912
1913
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1913
1914
|
style: { flex: "none" },
|
|
1914
1915
|
children: [/* @__PURE__ */ jsx(FieldLabel, { children: "Aperçu" }), /* @__PURE__ */ jsxs(Flex, {
|
|
@@ -1953,6 +1954,7 @@ function PreviewTarget(props) {
|
|
|
1953
1954
|
environments.map((environment) => /* @__PURE__ */ jsx(EnvironmentRow, {
|
|
1954
1955
|
environment,
|
|
1955
1956
|
selected: environment.id === environmentId,
|
|
1957
|
+
isProduction: !!productionUrl && environment.url === productionUrl,
|
|
1956
1958
|
onSelect: () => {
|
|
1957
1959
|
onEnvironment(environment.id), close();
|
|
1958
1960
|
},
|
|
@@ -2011,7 +2013,7 @@ function EnvironmentRow(props) {
|
|
|
2011
2013
|
size: 0,
|
|
2012
2014
|
muted: !0,
|
|
2013
2015
|
textOverflow: "ellipsis",
|
|
2014
|
-
children: hostOf(props.environment.url)
|
|
2016
|
+
children: props.isProduction ? "site public — pas de préversion" : hostOf(props.environment.url)
|
|
2015
2017
|
})]
|
|
2016
2018
|
}),
|
|
2017
2019
|
props.onForget && /* @__PURE__ */ jsx(Button, {
|
|
@@ -2105,7 +2107,7 @@ const hostOf = (url) => {
|
|
|
2105
2107
|
* vérifie auprès de Sanity, il ne croit pas le Studio sur parole.
|
|
2106
2108
|
*/
|
|
2107
2109
|
function SharePreview() {
|
|
2108
|
-
let config = useKitConfig(), client = useKitClient(), { environment } = usePreviewTarget(), [link, setLink] = useState(null), [expiresAt, setExpiresAt] = useState(null), [busy, setBusy] = useState(!1), [error, setError] = useState(null), [copied, setCopied] = useState(!1), [label, setLabel] = useState(""), endpoint = config.serviceEndpoint, { projectId, dataset, token } = client.config(), issue = useCallback(async (days) => {
|
|
2110
|
+
let config = useKitConfig(), client = useKitClient(), { environment, isProduction } = usePreviewTarget(), [link, setLink] = useState(null), [expiresAt, setExpiresAt] = useState(null), [busy, setBusy] = useState(!1), [error, setError] = useState(null), [copied, setCopied] = useState(!1), [label, setLabel] = useState(""), endpoint = config.serviceEndpoint, { projectId, dataset, token } = client.config(), issue = useCallback(async (days) => {
|
|
2109
2111
|
if (endpoint && projectId && dataset && environment) {
|
|
2110
2112
|
setBusy(!0), setError(null), setCopied(!1);
|
|
2111
2113
|
try {
|
|
@@ -2148,10 +2150,33 @@ function SharePreview() {
|
|
|
2148
2150
|
title: "Créer un lien que n'importe qui peut ouvrir, sans compte",
|
|
2149
2151
|
onClick: toggle
|
|
2150
2152
|
}),
|
|
2151
|
-
children: () => /* @__PURE__ */
|
|
2153
|
+
children: () => /* @__PURE__ */ jsx(Stack, {
|
|
2152
2154
|
gap: 3,
|
|
2153
2155
|
padding: 2,
|
|
2154
|
-
children:
|
|
2156
|
+
children: isProduction ? /* @__PURE__ */ jsxs(Stack, {
|
|
2157
|
+
gap: 3,
|
|
2158
|
+
children: [
|
|
2159
|
+
/* @__PURE__ */ jsx(Text, {
|
|
2160
|
+
size: 1,
|
|
2161
|
+
weight: "semibold",
|
|
2162
|
+
children: "Rien à partager sur le site public"
|
|
2163
|
+
}),
|
|
2164
|
+
/* @__PURE__ */ jsx(Text, {
|
|
2165
|
+
size: 0,
|
|
2166
|
+
muted: !0,
|
|
2167
|
+
children: "La production n'affiche jamais les brouillons — c'est ce qui protège votre contenu non publié. Un lien vers elle ne montrerait rien de plus qu'une visite ordinaire."
|
|
2168
|
+
}),
|
|
2169
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
2170
|
+
size: 0,
|
|
2171
|
+
muted: !0,
|
|
2172
|
+
children: [
|
|
2173
|
+
"Choisissez d'abord une ",
|
|
2174
|
+
/* @__PURE__ */ jsx("b", { children: "préversion" }),
|
|
2175
|
+
" dans le sélecteur d'environnement, à gauche : une préproduction déclarée, ou l'adresse d'un déploiement de branche que vous y collez."
|
|
2176
|
+
]
|
|
2177
|
+
})
|
|
2178
|
+
]
|
|
2179
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2155
2180
|
/* @__PURE__ */ jsxs(Text, {
|
|
2156
2181
|
size: 0,
|
|
2157
2182
|
muted: !0,
|
|
@@ -2248,7 +2273,7 @@ function SharePreview() {
|
|
|
2248
2273
|
})
|
|
2249
2274
|
]
|
|
2250
2275
|
})
|
|
2251
|
-
]
|
|
2276
|
+
] })
|
|
2252
2277
|
})
|
|
2253
2278
|
}) : null;
|
|
2254
2279
|
}
|
|
@@ -4843,7 +4868,8 @@ function PagesTool() {
|
|
|
4843
4868
|
onEnvironment: preview.setEnvironment,
|
|
4844
4869
|
onPerspective: preview.setPerspective,
|
|
4845
4870
|
onCustomUrl: preview.setCustomUrl,
|
|
4846
|
-
customUrl: preview.customUrl
|
|
4871
|
+
customUrl: preview.customUrl,
|
|
4872
|
+
productionUrl: config.previewUrl
|
|
4847
4873
|
}),
|
|
4848
4874
|
/* @__PURE__ */ jsx(Box, {
|
|
4849
4875
|
style: {
|