@nocode-factory/sanity-kit 2.24.0 → 2.26.0
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/{componentDefaults-BY3hQ6aD.js → componentDefaults-2eWjLLBf.js} +6 -6
- package/dist/componentDefaults-2eWjLLBf.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +467 -367
- package/dist/index.js.map +1 -1
- package/dist/schema.js +1 -1
- package/dist/web-server.js +2 -2
- package/dist/web-server.js.map +1 -1
- package/dist/web.js +9 -9
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/PropagatePublish.tsx +14 -14
- package/src/actions/RemoveFromSite.tsx +9 -9
- package/src/config/defaults.ts +7 -7
- package/src/config/resolve.ts +1 -1
- package/src/config/validate.ts +24 -24
- package/src/context/BoardLayoutContext.tsx +1 -1
- package/src/context/KitContext.tsx +1 -1
- package/src/context/PreviewTargetContext.tsx +1 -1
- package/src/form/LanguageMismatch.tsx +85 -0
- package/src/form/OverrideInput.tsx +5 -5
- package/src/form/SlugUrlInput.tsx +2 -2
- package/src/form/TranslationTodoInput.tsx +2 -2
- package/src/hooks/useHistory.ts +5 -5
- package/src/hooks/useOccurrences.ts +1 -1
- package/src/hooks/useOpenOnline.ts +4 -4
- package/src/index.ts +7 -5
- package/src/lib/grouping.ts +2 -2
- package/src/lib/overrides.ts +10 -10
- package/src/lib/pages.ts +3 -3
- package/src/lib/previewLocale.ts +17 -0
- package/src/lib/service.ts +5 -5
- package/src/lib/status.ts +3 -3
- package/src/lib/studioLinks.ts +6 -6
- package/src/schema/boardLayout.ts +32 -32
- package/src/schema/componentDefaults.ts +5 -5
- package/src/schema/translationTodo.ts +6 -6
- package/src/tools/components/BlockCard.tsx +3 -3
- package/src/tools/components/ComponentsTool.tsx +17 -17
- package/src/tools/components/map/SectionNode.tsx +1 -1
- package/src/tools/components/map/SectionsMap.tsx +10 -10
- package/src/tools/designSystem/DesignSystemTool.tsx +3 -3
- package/src/tools/history/DiffPanel.tsx +23 -23
- package/src/tools/history/HistoryTool.tsx +21 -23
- package/src/tools/more/MoreTool.tsx +1 -1
- package/src/tools/navbar/KitUpdate.tsx +8 -8
- package/src/tools/navbar/PreviewLauncher.tsx +6 -6
- package/src/tools/navbar/ToolButtons.tsx +2 -2
- package/src/tools/pages/ColumnHeader.tsx +18 -18
- package/src/tools/pages/ColumnVisibility.tsx +10 -10
- package/src/tools/pages/FieldValue.tsx +9 -9
- package/src/tools/pages/PagesTable.tsx +11 -11
- package/src/tools/pages/PagesTool.tsx +19 -19
- package/src/tools/pages/PagesToolbar.tsx +3 -3
- package/src/tools/pages/PathCell.tsx +1 -1
- package/src/tools/pages/PreviewTarget.tsx +10 -10
- package/src/tools/pages/SharePreview.tsx +19 -20
- package/src/tools/pages/TagCell.tsx +2 -2
- package/src/tools/pages/ViewTabs.tsx +4 -4
- package/src/tools/pages/board/BoardView.tsx +11 -11
- package/src/tools/pages/board/PageNode.tsx +5 -5
- package/src/tools/pages/board/PagePanel.tsx +10 -10
- package/src/tools/presentation/PreviewHeader.tsx +1 -1
- package/src/tools/shared/AnnotationNode.tsx +3 -3
- package/src/ui/ActorName.tsx +1 -1
- package/src/ui/ConfigIssues.tsx +3 -3
- package/src/ui/PreviewOriginsNotice.tsx +3 -3
- package/src/ui/ProjectStatusNotice.tsx +7 -7
- package/src/ui/QueryError.tsx +2 -2
- package/src/ui/ToolPlaceholder.tsx +2 -2
- package/src/ui/formatDate.ts +1 -1
- package/src/version.ts +1 -1
- package/src/web/PreviewBanner.tsx +9 -9
- package/src/web/draftModeToggle.ts +1 -1
- package/src/web/previewGrant.ts +5 -5
- package/dist/componentDefaults-BY3hQ6aD.js.map +0 -1
|
@@ -18,7 +18,7 @@ export function BoardLayoutProvider(props: {children: ReactNode}) {
|
|
|
18
18
|
export function useBoardLayout(): BoardLayoutState {
|
|
19
19
|
const value = useContext(BoardLayoutContext)
|
|
20
20
|
if (!value) {
|
|
21
|
-
throw new Error('useBoardLayout
|
|
21
|
+
throw new Error('useBoardLayout must be called inside BoardLayoutProvider.')
|
|
22
22
|
}
|
|
23
23
|
return value
|
|
24
24
|
}
|
|
@@ -22,7 +22,7 @@ export function KitProvider(props: KitProviderProps) {
|
|
|
22
22
|
export function useKitContext(): KitContextValue {
|
|
23
23
|
const value = useContext(KitContext)
|
|
24
24
|
if (!value) {
|
|
25
|
-
throw new Error('useKitContext
|
|
25
|
+
throw new Error('useKitContext must be called inside a tool of the @nocode-factory/sanity-kit plugin.')
|
|
26
26
|
}
|
|
27
27
|
return value
|
|
28
28
|
}
|
|
@@ -21,7 +21,7 @@ export function PreviewTargetProvider(props: {children: ReactNode}) {
|
|
|
21
21
|
export function usePreviewTarget(): PreviewTargetState {
|
|
22
22
|
const value = useContext(PreviewTargetContext)
|
|
23
23
|
if (!value) {
|
|
24
|
-
throw new Error('usePreviewTarget
|
|
24
|
+
throw new Error('usePreviewTarget must be called inside PreviewTargetProvider.')
|
|
25
25
|
}
|
|
26
26
|
return value
|
|
27
27
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {createElement, useEffect, useState, type ComponentType} from 'react'
|
|
2
|
+
import {useFormValue, type InputProps} from 'sanity'
|
|
3
|
+
import {usePresentationNavigate, usePresentationParams} from 'sanity/presentation'
|
|
4
|
+
import {Button, Card, Flex, Stack, Text} from '@sanity/ui'
|
|
5
|
+
import type {ResolvedKitConfig} from '../config/types'
|
|
6
|
+
import {useKitClient} from '../hooks/useKitClient'
|
|
7
|
+
import {localeOfPreview} from '../lib/previewLocale'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Presentation : le panneau d'édition DOIT montrer la langue de l'aperçu. Si le
|
|
11
|
+
* document édité n'est pas dans la langue de la page affichée (ex. aperçu EN, panneau
|
|
12
|
+
* FR), un bandeau le dit en haut du formulaire, avec un bouton qui ouvre la bonne
|
|
13
|
+
* version. Évite de modifier le français en croyant modifier l'anglais.
|
|
14
|
+
* Structure stable : le formulaire garde sa place, que le bandeau soit là ou non.
|
|
15
|
+
*/
|
|
16
|
+
export function withLanguageMismatch(Inner: ComponentType<InputProps>, config: ResolvedKitConfig): ComponentType<InputProps> {
|
|
17
|
+
const i18n = config.i18n
|
|
18
|
+
function LanguageMismatch(props: InputProps) {
|
|
19
|
+
const inner = createElement(Inner, props)
|
|
20
|
+
if (!i18n || props.path.length > 0) return inner
|
|
21
|
+
return (
|
|
22
|
+
<Stack gap={4}>
|
|
23
|
+
<MismatchCheck />
|
|
24
|
+
{inner}
|
|
25
|
+
</Stack>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function MismatchCheck() {
|
|
30
|
+
const params = usePresentationParams(false)
|
|
31
|
+
const language = useFormValue([i18n?.field ?? 'language']) as string | undefined
|
|
32
|
+
const shown = localeOfPreview(params?.preview, i18n)
|
|
33
|
+
if (!params || !language || !shown || language === shown) return null
|
|
34
|
+
return <MismatchBanner editing={language} shown={shown} />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function MismatchBanner(props: {editing: string; shown: string}) {
|
|
38
|
+
const {editing, shown} = props
|
|
39
|
+
const navigate = usePresentationNavigate()
|
|
40
|
+
const client = useKitClient()
|
|
41
|
+
const id = (useFormValue(['_id']) as string | undefined)?.replace(/^drafts\./, '')
|
|
42
|
+
const type = useFormValue(['_type']) as string | undefined
|
|
43
|
+
const [target, setTarget] = useState<string | null | undefined>(undefined)
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!id) return
|
|
47
|
+
let alive = true
|
|
48
|
+
client
|
|
49
|
+
.fetch<string | null>(
|
|
50
|
+
`*[_type == "translation.metadata" && references($id)][0].translations[_key == $lang || language == $lang][0].value._ref`,
|
|
51
|
+
{id, lang: shown},
|
|
52
|
+
)
|
|
53
|
+
.then((ref) => alive && setTarget(ref ?? null))
|
|
54
|
+
.catch(() => alive && setTarget(null))
|
|
55
|
+
return () => {
|
|
56
|
+
alive = false
|
|
57
|
+
}
|
|
58
|
+
}, [client, id, shown])
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Card tone="caution" padding={3} radius={2} border>
|
|
62
|
+
<Flex align="center" gap={3} wrap="wrap">
|
|
63
|
+
<Text size={1} weight="semibold" style={{flex: 1, minWidth: 200}}>
|
|
64
|
+
You are editing the {editing.toUpperCase()} version. The preview shows {shown.toUpperCase()}.
|
|
65
|
+
</Text>
|
|
66
|
+
{target && type ? (
|
|
67
|
+
<Button
|
|
68
|
+
tone="caution"
|
|
69
|
+
fontSize={1}
|
|
70
|
+
padding={2}
|
|
71
|
+
text={`Edit the ${shown.toUpperCase()} version`}
|
|
72
|
+
onClick={() => navigate(undefined, {type, id: target})}
|
|
73
|
+
/>
|
|
74
|
+
) : target === null ? (
|
|
75
|
+
<Text size={1} muted>
|
|
76
|
+
No {shown.toUpperCase()} version of this document yet.
|
|
77
|
+
</Text>
|
|
78
|
+
) : null}
|
|
79
|
+
</Flex>
|
|
80
|
+
</Card>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return LanguageMismatch
|
|
85
|
+
}
|
|
@@ -102,7 +102,7 @@ export function createOverrideInput(config: ResolvedKitConfig): ComponentType<In
|
|
|
102
102
|
{inherits && placeholder === null && (
|
|
103
103
|
<Box marginTop={2}>
|
|
104
104
|
<Text size={0} muted>
|
|
105
|
-
|
|
105
|
+
Component default value: {describeValue(inherited)}
|
|
106
106
|
</Text>
|
|
107
107
|
</Box>
|
|
108
108
|
)}
|
|
@@ -135,7 +135,7 @@ const BLUE = 'var(--card-badge-primary-dot-color, #2276fc)'
|
|
|
135
135
|
|
|
136
136
|
function OverrideDot(props: {hasDefault: boolean; full: string; short: string; onClick: () => void}) {
|
|
137
137
|
const [hover, setHover] = useState(false)
|
|
138
|
-
const label = props.hasDefault ? `↺ ${props.short}` : '
|
|
138
|
+
const label = props.hasDefault ? `↺ ${props.short}` : 'No default value'
|
|
139
139
|
return (
|
|
140
140
|
<Tooltip
|
|
141
141
|
portal
|
|
@@ -144,8 +144,8 @@ function OverrideDot(props: {hasDefault: boolean; full: string; short: string; o
|
|
|
144
144
|
<Box padding={2} style={{maxWidth: 280}}>
|
|
145
145
|
<Text size={1}>
|
|
146
146
|
{props.hasDefault
|
|
147
|
-
? `
|
|
148
|
-
: '
|
|
147
|
+
? `Different from the component default value (${props.full}). Click to go back to the default value: the field will follow it, even if it changes.`
|
|
148
|
+
: 'This component has no default value for this field. Click to set it (Components: default values).'}
|
|
149
149
|
</Text>
|
|
150
150
|
</Box>
|
|
151
151
|
}
|
|
@@ -157,7 +157,7 @@ function OverrideDot(props: {hasDefault: boolean; full: string; short: string; o
|
|
|
157
157
|
onMouseLeave={() => setHover(false)}
|
|
158
158
|
onFocus={() => setHover(true)}
|
|
159
159
|
onBlur={() => setHover(false)}
|
|
160
|
-
aria-label={props.hasDefault ? `
|
|
160
|
+
aria-label={props.hasDefault ? `Go back to the component default value: ${props.full}` : 'Set the component default value'}
|
|
161
161
|
style={{
|
|
162
162
|
marginTop: 9,
|
|
163
163
|
flex: 'none',
|
|
@@ -39,8 +39,8 @@ export function createSlugUrlInput(config: ResolvedKitConfig): ComponentType<Inp
|
|
|
39
39
|
<Text size={1} muted style={{flex: 1, minWidth: 0, wordBreak: 'break-all'}}>
|
|
40
40
|
{url}
|
|
41
41
|
</Text>
|
|
42
|
-
<Button mode="ghost" fontSize={1} padding={2} text={copied ? '
|
|
43
|
-
<Button as="a" href={url} target="_blank" rel="noopener noreferrer" mode="ghost" fontSize={1} padding={2} text="
|
|
42
|
+
<Button mode="ghost" fontSize={1} padding={2} text={copied ? 'Copied' : 'Copy'} onClick={copy} />
|
|
43
|
+
<Button as="a" href={url} target="_blank" rel="noopener noreferrer" mode="ghost" fontSize={1} padding={2} text="Open" />
|
|
44
44
|
</Flex>
|
|
45
45
|
</Card>
|
|
46
46
|
)}
|
|
@@ -35,9 +35,9 @@ export function withTranslationTodo(Inner: ComponentType<InputProps>, config: Re
|
|
|
35
35
|
<Card tone="caution" padding={2} radius={2} border>
|
|
36
36
|
<Flex align="center" gap={2}>
|
|
37
37
|
<Text size={1} style={{flex: 1}}>
|
|
38
|
-
|
|
38
|
+
To translate: changed in the {(todo?.sourceLanguage ?? '').toUpperCase()} version.
|
|
39
39
|
</Text>
|
|
40
|
-
<Button mode="ghost" fontSize={1} padding={2} text="
|
|
40
|
+
<Button mode="ghost" fontSize={1} padding={2} text="Mark as translated" disabled={busy} onClick={done} />
|
|
41
41
|
</Flex>
|
|
42
42
|
</Card>
|
|
43
43
|
)}
|
package/src/hooks/useHistory.ts
CHANGED
|
@@ -16,11 +16,11 @@ export interface HistoryState {
|
|
|
16
16
|
function explain(error: unknown): string {
|
|
17
17
|
const code = error instanceof Error ? error.message : String(error)
|
|
18
18
|
if (code === 'bad_key')
|
|
19
|
-
return "
|
|
19
|
+
return "The read key is not recognized: run `npx ncf-kit setup` again in the studio folder, then redeploy it."
|
|
20
20
|
if (code === 'project_inactive')
|
|
21
|
-
return "
|
|
22
|
-
if (code === 'missing_key') return '
|
|
23
|
-
return "
|
|
21
|
+
return "The log is not enabled for this project at NoCode Factory: `npx ncf-kit setup` enables it, or contact NoCode Factory."
|
|
22
|
+
if (code === 'missing_key') return 'No read key configured.'
|
|
23
|
+
return "The log could not be loaded."
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -42,7 +42,7 @@ export function useHistory(documentId?: string): HistoryState {
|
|
|
42
42
|
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
if (!history) {
|
|
45
|
-
setError('
|
|
45
|
+
setError('No read key configured.')
|
|
46
46
|
return undefined
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ export function useOccurrences(): OccurrencesState {
|
|
|
52
52
|
map.set(id, {
|
|
53
53
|
id,
|
|
54
54
|
type: doc._type,
|
|
55
|
-
title: (typeof title === 'string' ? title.trim() : '') || '
|
|
55
|
+
title: (typeof title === 'string' ? title.trim() : '') || 'Untitled',
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
return map
|
|
@@ -50,9 +50,9 @@ export function useOpenOnline() {
|
|
|
50
50
|
const tab = window.open('about:blank', '_blank')
|
|
51
51
|
if (!tab) return
|
|
52
52
|
tab.opener = null
|
|
53
|
-
tab.document.title = '
|
|
53
|
+
tab.document.title = 'Opening the preview…'
|
|
54
54
|
tab.document.body.innerHTML =
|
|
55
|
-
'<p style="font:15px/1.6 system-ui,sans-serif;color:#57534e;padding:2rem">
|
|
55
|
+
'<p style="font:15px/1.6 system-ui,sans-serif;color:#57534e;padding:2rem">Opening the preview…</p>'
|
|
56
56
|
|
|
57
57
|
try {
|
|
58
58
|
const {projectId, dataset, token} = client.config()
|
|
@@ -81,8 +81,8 @@ export function useOpenOnline() {
|
|
|
81
81
|
// On le dit dans l'onglet ouvert, plutôt que de laisser une page blanche
|
|
82
82
|
// ou d'envoyer sur la page de refus sans explication.
|
|
83
83
|
const message = explainGrantError(cause)
|
|
84
|
-
tab.document.title = '
|
|
85
|
-
tab.document.body.innerHTML = `<main style="font:15px/1.6 system-ui,sans-serif;color:#1c1917;padding:2rem;max-width:32rem"><h1 style="font-size:18px">
|
|
84
|
+
tab.document.title = 'Preview unavailable'
|
|
85
|
+
tab.document.body.innerHTML = `<main style="font:15px/1.6 system-ui,sans-serif;color:#1c1917;padding:2rem;max-width:32rem"><h1 style="font-size:18px">Unable to open the preview</h1><p style="color:#57534e"></p></main>`
|
|
86
86
|
const paragraph = tab.document.querySelector('p')
|
|
87
87
|
if (paragraph) paragraph.textContent = message
|
|
88
88
|
}
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ import {RemoveFromSiteAction} from './actions/RemoveFromSite'
|
|
|
45
45
|
import {createSlugUrlInput, isSlugInput} from './form/SlugUrlInput'
|
|
46
46
|
import {withTranslationTodo} from './form/TranslationTodoInput'
|
|
47
47
|
import {withPublishedHint} from './form/PublishedHint'
|
|
48
|
+
import {withLanguageMismatch} from './form/LanguageMismatch'
|
|
48
49
|
import {withPropagation} from './actions/PropagatePublish'
|
|
49
50
|
|
|
50
51
|
/** Champs du formulaire : adresse sous le Slug d'une page, pastille sur les sections. */
|
|
@@ -56,7 +57,8 @@ function createKitInput(config: Parameters<typeof createOverrideInput>[0]): Comp
|
|
|
56
57
|
}
|
|
57
58
|
// Traductions : pastille « À traduire » sur les champs modifiés dans la version principale.
|
|
58
59
|
// Vue « Published » : « Switch to Drafts to edit » au survol d'un champ.
|
|
59
|
-
|
|
60
|
+
// Presentation : bandeau si le document édité n'est pas dans la langue de l'aperçu.
|
|
61
|
+
return withPublishedHint(config.i18n ? withLanguageMismatch(withTranslationTodo(KitInput, config), config) : KitInput)
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
export const ncfKit = definePlugin<NcfKitConfig>((options) => {
|
|
@@ -83,11 +85,11 @@ export const ncfKit = definePlugin<NcfKitConfig>((options) => {
|
|
|
83
85
|
name: 'components',
|
|
84
86
|
tool: {
|
|
85
87
|
name: NCF_COMPONENTS_TOOL,
|
|
86
|
-
title: '
|
|
88
|
+
title: 'Components',
|
|
87
89
|
icon: ComponentIcon,
|
|
88
90
|
component: createToolComponent({
|
|
89
91
|
name: 'components',
|
|
90
|
-
title: '
|
|
92
|
+
title: 'Components',
|
|
91
93
|
config,
|
|
92
94
|
issues,
|
|
93
95
|
Component: ComponentsTool,
|
|
@@ -98,11 +100,11 @@ export const ncfKit = definePlugin<NcfKitConfig>((options) => {
|
|
|
98
100
|
name: 'history',
|
|
99
101
|
tool: {
|
|
100
102
|
name: NCF_HISTORY_TOOL,
|
|
101
|
-
title: '
|
|
103
|
+
title: 'History',
|
|
102
104
|
icon: ClockIcon,
|
|
103
105
|
component: createToolComponent({
|
|
104
106
|
name: 'history',
|
|
105
|
-
title: '
|
|
107
|
+
title: 'History',
|
|
106
108
|
config,
|
|
107
109
|
issues,
|
|
108
110
|
Component: HistoryTool,
|
package/src/lib/grouping.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface RowGroup {
|
|
|
15
15
|
rows: PageRow[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const UNSET_LABEL = '
|
|
18
|
+
export const UNSET_LABEL = 'Not set'
|
|
19
19
|
|
|
20
20
|
export interface GroupOptions {
|
|
21
21
|
/** Disposition enregistrée, qui porte étiquettes et champs internes. */
|
|
@@ -47,7 +47,7 @@ function describe(
|
|
|
47
47
|
if (!value) return {label: UNSET_LABEL}
|
|
48
48
|
if (groupBy === 'status') return {label: STATUS_LABELS[row_status(value)].label}
|
|
49
49
|
if (groupBy === 'indexation') {
|
|
50
|
-
return value === 'noindex' ? {label: '
|
|
50
|
+
return value === 'noindex' ? {label: 'Not indexable'} : {label: 'Indexable'}
|
|
51
51
|
}
|
|
52
52
|
if (groupBy === 'tag') {
|
|
53
53
|
const tag = options.tags.find((t) => t.id === value)
|
package/src/lib/overrides.ts
CHANGED
|
@@ -129,20 +129,20 @@ export function sameValue(a: unknown, b: unknown): boolean {
|
|
|
129
129
|
|
|
130
130
|
/** Valeur par défaut lisible, pour la bulle de la pastille. */
|
|
131
131
|
export function describeValue(value: unknown): string {
|
|
132
|
-
if (isEmptyValue(value)) return '
|
|
133
|
-
if (typeof value === 'string') return value.length > 60 ?
|
|
134
|
-
if (typeof value === 'boolean') return value ? '
|
|
132
|
+
if (isEmptyValue(value)) return 'empty (design system value)'
|
|
133
|
+
if (typeof value === 'string') return value.length > 60 ? `"${value.slice(0, 57)}…"` : `"${value}"`
|
|
134
|
+
if (typeof value === 'boolean') return value ? 'Yes' : 'No'
|
|
135
135
|
if (typeof value === 'number') return String(value)
|
|
136
|
-
if (Array.isArray(value)) return `${value.length}
|
|
136
|
+
if (Array.isArray(value)) return `${value.length} item${value.length > 1 ? 's' : ''}`
|
|
137
137
|
if (value && typeof value === 'object') {
|
|
138
138
|
const v = value as Record<string, unknown>
|
|
139
|
-
if (typeof v.token === 'string') return `
|
|
140
|
-
if (typeof v.customHex === 'string') return `
|
|
141
|
-
if (typeof v.label === 'string') return
|
|
142
|
-
if (v.asset) return '
|
|
143
|
-
if (typeof v._ref === 'string') return '
|
|
139
|
+
if (typeof v.token === 'string') return `color ${v.token}`
|
|
140
|
+
if (typeof v.customHex === 'string') return `color ${v.customHex}`
|
|
141
|
+
if (typeof v.label === 'string') return `"${v.label}"`
|
|
142
|
+
if (v.asset) return 'an image'
|
|
143
|
+
if (typeof v._ref === 'string') return 'a document'
|
|
144
144
|
}
|
|
145
|
-
return '
|
|
145
|
+
return 'a value'
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
package/src/lib/pages.ts
CHANGED
|
@@ -44,8 +44,8 @@ export function formatDocumentValue(
|
|
|
44
44
|
type: 'text' | 'boolean' | 'number',
|
|
45
45
|
invert = false,
|
|
46
46
|
): string {
|
|
47
|
-
if (value === null || value === undefined) return type === 'boolean' && invert ? '
|
|
48
|
-
if (type === 'boolean') return (invert ? !value : Boolean(value)) ? '
|
|
47
|
+
if (value === null || value === undefined) return type === 'boolean' && invert ? 'Yes' : ''
|
|
48
|
+
if (type === 'boolean') return (invert ? !value : Boolean(value)) ? 'Yes' : 'No'
|
|
49
49
|
if (type === 'number') return typeof value === 'number' ? String(value) : ''
|
|
50
50
|
if (typeof value === 'string') return value.trim()
|
|
51
51
|
if (typeof value === 'number' || typeof value === 'boolean') return String(value)
|
|
@@ -73,7 +73,7 @@ export function buildPageRows(
|
|
|
73
73
|
return {
|
|
74
74
|
id: merged.id,
|
|
75
75
|
type: doc._type,
|
|
76
|
-
title: doc.ncfTitle?.trim() || '
|
|
76
|
+
title: doc.ncfTitle?.trim() || 'Untitled',
|
|
77
77
|
path,
|
|
78
78
|
url: toUrl(config.previewUrl, path),
|
|
79
79
|
locale: doc.ncfLocale ?? null,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {ResolvedI18n} from '../config/types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Langue de la page affichée dans l'aperçu, d'après son adresse : premier segment
|
|
5
|
+
* s'il est une langue autre que la principale (/en/...), sinon la langue principale.
|
|
6
|
+
*/
|
|
7
|
+
export function localeOfPreview(preview: string | null | undefined, i18n: ResolvedI18n | null): string | null {
|
|
8
|
+
if (!i18n || !preview) return null
|
|
9
|
+
let pathname: string
|
|
10
|
+
try {
|
|
11
|
+
pathname = new URL(preview, 'http://preview.local').pathname
|
|
12
|
+
} catch {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
const first = pathname.split('/').filter(Boolean)[0]
|
|
16
|
+
return first && first !== i18n.defaultLocale && i18n.locales.includes(first) ? first : i18n.defaultLocale
|
|
17
|
+
}
|
package/src/lib/service.ts
CHANGED
|
@@ -115,10 +115,10 @@ export async function requestPreviewGrant(
|
|
|
115
115
|
export function explainGrantError(error: unknown): string {
|
|
116
116
|
const code = error instanceof Error ? error.message : String(error)
|
|
117
117
|
if (code === 'missing_sanity_token') {
|
|
118
|
-
return "
|
|
118
|
+
return "Your Sanity session exposes no token: unable to prove your access to the project."
|
|
119
119
|
}
|
|
120
|
-
if (code === 'no_project_access') return "
|
|
121
|
-
if (code === 'project_inactive') return "
|
|
122
|
-
if (code === 'unknown_project') return "
|
|
123
|
-
return "
|
|
120
|
+
if (code === 'no_project_access') return "Your account has no access to this Sanity project."
|
|
121
|
+
if (code === 'project_inactive') return "This project is not active at NoCode Factory."
|
|
122
|
+
if (code === 'unknown_project') return "This project is not registered at NoCode Factory."
|
|
123
|
+
return "The link could not be created."
|
|
124
124
|
}
|
package/src/lib/status.ts
CHANGED
|
@@ -116,7 +116,7 @@ export function mergeVersions<T extends VersionedDoc>(docs: readonly T[]): Merge
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export const STATUS_LABELS: Record<PageStatus, {label: string; tone: 'positive' | 'caution' | 'default'; help: string}> = {
|
|
119
|
-
published: {label: '
|
|
120
|
-
modified: {label: '
|
|
121
|
-
draft: {label: '
|
|
119
|
+
published: {label: 'Published', tone: 'positive', help: 'Live, up to date'},
|
|
120
|
+
modified: {label: 'Modified', tone: 'caution', help: 'Live, with unpublished changes'},
|
|
121
|
+
draft: {label: 'Not published', tone: 'default', help: 'Not on the site: never published, or removed from the site (content kept in the draft)'},
|
|
122
122
|
}
|
package/src/lib/studioLinks.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type {NcfEnvironment} from '../config/types'
|
|
|
10
10
|
export type PreviewPerspective = 'drafts' | 'published'
|
|
11
11
|
|
|
12
12
|
export const PERSPECTIVES: {id: PreviewPerspective; label: string; hint: string}[] = [
|
|
13
|
-
{id: 'drafts', label: '
|
|
14
|
-
{id: 'published', label: '
|
|
13
|
+
{id: 'drafts', label: 'Drafts', hint: 'What will go live after publishing'},
|
|
14
|
+
{id: 'published', label: 'Published', hint: 'What the public sees today'},
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
/** Retire le slash final, pour ne pas produire d'URL à double slash. */
|
|
@@ -67,13 +67,13 @@ export interface PreviewTargetEntry {
|
|
|
67
67
|
export function previewTargets(environments: readonly NcfEnvironment[], previewUrl: string | null | undefined): PreviewTargetEntry[] {
|
|
68
68
|
const previews = environments.filter((e) => !isPublicEnvironment(e, previewUrl))
|
|
69
69
|
const publics = environments.filter((e) => isPublicEnvironment(e, previewUrl))
|
|
70
|
-
const name = (e: NcfEnvironment) => (e.id === 'preprod' ? '
|
|
70
|
+
const name = (e: NcfEnvironment) => (e.id === 'preprod' ? 'Staging' : e.label)
|
|
71
71
|
return [
|
|
72
72
|
...previews.flatMap((environment): PreviewTargetEntry[] => [
|
|
73
|
-
{environment, perspective: 'drafts', label: `${name(environment)} ·
|
|
74
|
-
{environment, perspective: 'published', label: `${name(environment)} ·
|
|
73
|
+
{environment, perspective: 'drafts', label: `${name(environment)} · Drafts`, hint: 'What will go live after publishing', tone: 'draft'},
|
|
74
|
+
{environment, perspective: 'published', label: `${name(environment)} · Published`, hint: 'The published content, on the test version of the site', tone: 'live'},
|
|
75
75
|
]),
|
|
76
|
-
...publics.map((environment): PreviewTargetEntry => ({environment, perspective: 'published', label: 'Prod ·
|
|
76
|
+
...publics.map((environment): PreviewTargetEntry => ({environment, perspective: 'published', label: 'Prod · Published', hint: 'The public site, as visitors see it', tone: 'prod'})),
|
|
77
77
|
]
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -16,26 +16,26 @@ export const NCF_HIDDEN_TYPES = [BOARD_LAYOUT_TYPE, TRANSLATION_TODO_TYPE] as co
|
|
|
16
16
|
|
|
17
17
|
const boardNodeType = defineType({
|
|
18
18
|
name: BOARD_NODE_TYPE,
|
|
19
|
-
title: '
|
|
19
|
+
title: 'Page position',
|
|
20
20
|
type: 'object',
|
|
21
21
|
fields: [
|
|
22
22
|
defineField({name: 'documentId', title: 'Document', type: 'string'}),
|
|
23
23
|
defineField({name: 'x', title: 'X', type: 'number'}),
|
|
24
24
|
defineField({name: 'y', title: 'Y', type: 'number'}),
|
|
25
25
|
// Taille choisie à la main ; absente tant que le nœud garde sa taille.
|
|
26
|
-
defineField({name: 'width', title: '
|
|
27
|
-
defineField({name: 'height', title: '
|
|
28
|
-
defineField({name: 'tag', title: '
|
|
26
|
+
defineField({name: 'width', title: 'Width', type: 'number'}),
|
|
27
|
+
defineField({name: 'height', title: 'Height', type: 'number'}),
|
|
28
|
+
defineField({name: 'tag', title: 'Tracking tag', type: 'string'}),
|
|
29
29
|
defineField({
|
|
30
30
|
name: 'fields',
|
|
31
|
-
title: '
|
|
31
|
+
title: 'Internal management',
|
|
32
32
|
type: 'array',
|
|
33
33
|
of: [{type: NODE_FIELD_TYPE}],
|
|
34
34
|
}),
|
|
35
35
|
],
|
|
36
36
|
preview: {
|
|
37
37
|
select: {title: 'documentId', x: 'x', y: 'y'},
|
|
38
|
-
prepare: ({title, x, y}) => ({title: title ?? '
|
|
38
|
+
prepare: ({title, x, y}) => ({title: title ?? 'No document', subtitle: `${x ?? 0} × ${y ?? 0}`}),
|
|
39
39
|
},
|
|
40
40
|
})
|
|
41
41
|
|
|
@@ -45,7 +45,7 @@ const annotationType = defineType({
|
|
|
45
45
|
title: 'Annotation',
|
|
46
46
|
type: 'object',
|
|
47
47
|
fields: [
|
|
48
|
-
defineField({name: 'id', title: '
|
|
48
|
+
defineField({name: 'id', title: 'ID', type: 'string'}),
|
|
49
49
|
defineField({
|
|
50
50
|
name: 'scope',
|
|
51
51
|
title: 'Canvas',
|
|
@@ -54,28 +54,28 @@ const annotationType = defineType({
|
|
|
54
54
|
}),
|
|
55
55
|
defineField({
|
|
56
56
|
name: 'kind',
|
|
57
|
-
title: '
|
|
57
|
+
title: 'Kind',
|
|
58
58
|
type: 'string',
|
|
59
|
-
options: {list: [{title: '
|
|
59
|
+
options: {list: [{title: 'Text', value: 'text'}, {title: 'Shape', value: 'rect'}]},
|
|
60
60
|
}),
|
|
61
61
|
defineField({name: 'x', type: 'number'}),
|
|
62
62
|
defineField({name: 'y', type: 'number'}),
|
|
63
63
|
defineField({name: 'width', type: 'number'}),
|
|
64
64
|
defineField({name: 'height', type: 'number'}),
|
|
65
|
-
defineField({name: 'text', title: '
|
|
66
|
-
defineField({name: 'color', title: '
|
|
65
|
+
defineField({name: 'text', title: 'Text', type: 'string'}),
|
|
66
|
+
defineField({name: 'color', title: 'Color', type: 'string'}),
|
|
67
67
|
],
|
|
68
68
|
preview: {select: {title: 'text', subtitle: 'scope'}},
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
const columnOptionType = defineType({
|
|
72
72
|
name: COLUMN_OPTION_TYPE,
|
|
73
|
-
title: '
|
|
73
|
+
title: 'Choice',
|
|
74
74
|
type: 'object',
|
|
75
75
|
fields: [
|
|
76
|
-
defineField({name: 'id', title: '
|
|
77
|
-
defineField({name: 'label', title: '
|
|
78
|
-
defineField({name: 'color', title: '
|
|
76
|
+
defineField({name: 'id', title: 'ID', type: 'string'}),
|
|
77
|
+
defineField({name: 'label', title: 'Label', type: 'string'}),
|
|
78
|
+
defineField({name: 'color', title: 'Color', type: 'string'}),
|
|
79
79
|
],
|
|
80
80
|
preview: {select: {title: 'label', subtitle: 'id'}},
|
|
81
81
|
})
|
|
@@ -87,29 +87,29 @@ const columnOptionType = defineType({
|
|
|
87
87
|
*/
|
|
88
88
|
const columnType = defineType({
|
|
89
89
|
name: COLUMN_TYPE,
|
|
90
|
-
title: '
|
|
90
|
+
title: 'Internal management column',
|
|
91
91
|
type: 'object',
|
|
92
92
|
fields: [
|
|
93
|
-
defineField({name: 'id', title: '
|
|
94
|
-
defineField({name: 'label', title: '
|
|
93
|
+
defineField({name: 'id', title: 'ID', type: 'string'}),
|
|
94
|
+
defineField({name: 'label', title: 'Name', type: 'string'}),
|
|
95
95
|
defineField({
|
|
96
96
|
name: 'type',
|
|
97
97
|
title: 'Type',
|
|
98
98
|
type: 'string',
|
|
99
|
-
options: {list: [{title: '
|
|
99
|
+
options: {list: [{title: 'Text', value: 'text'}, {title: 'List', value: 'select'}]},
|
|
100
100
|
}),
|
|
101
|
-
defineField({name: 'options', title: '
|
|
101
|
+
defineField({name: 'options', title: 'Choices', type: 'array', of: [{type: COLUMN_OPTION_TYPE}]}),
|
|
102
102
|
],
|
|
103
103
|
preview: {select: {title: 'label', subtitle: 'type'}},
|
|
104
104
|
})
|
|
105
105
|
|
|
106
106
|
const nodeFieldType = defineType({
|
|
107
107
|
name: NODE_FIELD_TYPE,
|
|
108
|
-
title: '
|
|
108
|
+
title: 'Internal management field',
|
|
109
109
|
type: 'object',
|
|
110
110
|
fields: [
|
|
111
|
-
defineField({name: 'fieldId', title: '
|
|
112
|
-
defineField({name: 'value', title: '
|
|
111
|
+
defineField({name: 'fieldId', title: 'Field', type: 'string'}),
|
|
112
|
+
defineField({name: 'value', title: 'Value', type: 'string'}),
|
|
113
113
|
],
|
|
114
114
|
preview: {
|
|
115
115
|
select: {title: 'fieldId', subtitle: 'value'},
|
|
@@ -118,16 +118,16 @@ const nodeFieldType = defineType({
|
|
|
118
118
|
|
|
119
119
|
const sectionNodeType = defineType({
|
|
120
120
|
name: SECTION_NODE_TYPE,
|
|
121
|
-
title: '
|
|
121
|
+
title: 'Section position',
|
|
122
122
|
type: 'object',
|
|
123
123
|
fields: [
|
|
124
|
-
defineField({name: 'blockName', title: '
|
|
124
|
+
defineField({name: 'blockName', title: 'Block type', type: 'string'}),
|
|
125
125
|
defineField({name: 'x', title: 'X', type: 'number'}),
|
|
126
126
|
defineField({name: 'y', title: 'Y', type: 'number'}),
|
|
127
127
|
],
|
|
128
128
|
preview: {
|
|
129
129
|
select: {title: 'blockName', x: 'x', y: 'y'},
|
|
130
|
-
prepare: ({title, x, y}) => ({title: title ?? '
|
|
130
|
+
prepare: ({title, x, y}) => ({title: title ?? 'No block', subtitle: `${x ?? 0} × ${y ?? 0}`}),
|
|
131
131
|
},
|
|
132
132
|
})
|
|
133
133
|
|
|
@@ -137,7 +137,7 @@ const sectionNodeType = defineType({
|
|
|
137
137
|
*/
|
|
138
138
|
const boardLayoutType = defineType({
|
|
139
139
|
name: BOARD_LAYOUT_TYPE,
|
|
140
|
-
title: '
|
|
140
|
+
title: 'Board layout (NCF)',
|
|
141
141
|
type: 'document',
|
|
142
142
|
fields: [
|
|
143
143
|
defineField({
|
|
@@ -154,26 +154,26 @@ const boardLayoutType = defineType({
|
|
|
154
154
|
}),
|
|
155
155
|
defineField({
|
|
156
156
|
name: 'columns',
|
|
157
|
-
title: '
|
|
157
|
+
title: 'Internal management columns',
|
|
158
158
|
type: 'array',
|
|
159
159
|
of: [{type: COLUMN_TYPE}],
|
|
160
160
|
}),
|
|
161
161
|
// Distingue « jamais réglé » de « volontairement vidé ».
|
|
162
|
-
defineField({name: 'columnsSet', title: '
|
|
162
|
+
defineField({name: 'columnsSet', title: 'Columns set', type: 'boolean'}),
|
|
163
163
|
defineField({
|
|
164
164
|
name: 'sections',
|
|
165
|
-
title: '
|
|
165
|
+
title: 'Section positions',
|
|
166
166
|
type: 'array',
|
|
167
167
|
of: [{type: SECTION_NODE_TYPE}],
|
|
168
168
|
}),
|
|
169
169
|
defineField({
|
|
170
170
|
name: 'updatedBy',
|
|
171
|
-
title: '
|
|
171
|
+
title: 'Modified by',
|
|
172
172
|
type: 'string',
|
|
173
173
|
readOnly: true,
|
|
174
174
|
}),
|
|
175
175
|
],
|
|
176
|
-
preview: {prepare: () => ({title: '
|
|
176
|
+
preview: {prepare: () => ({title: 'Board layout (NCF)'})},
|
|
177
177
|
})
|
|
178
178
|
|
|
179
179
|
export const kitSchemaTypes = [
|