@nocode-factory/sanity-kit 2.15.0 → 2.16.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/index.d.ts +1 -1
- package/dist/index.js +36 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/pages.ts +2 -1
- package/src/tools/pages/PagesTool.tsx +35 -4
- package/src/tools/pages/PagesToolbar.tsx +5 -5
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/lib/pages.ts
CHANGED
|
@@ -184,7 +184,8 @@ export function filterRows(rows: readonly PageRow[], filters: PageFilters): Page
|
|
|
184
184
|
return rows.filter((row) => {
|
|
185
185
|
if (filters.types?.length && !filters.types.includes(row.type)) return false
|
|
186
186
|
if (filters.statuses?.length && !filters.statuses.includes(row.status)) return false
|
|
187
|
-
|
|
187
|
+
// Un document sans langue vaut pour toutes : il reste visible quel que soit le filtre.
|
|
188
|
+
if (filters.locales?.length && row.locale && !filters.locales.includes(row.locale)) return false
|
|
188
189
|
if (search) {
|
|
189
190
|
const haystack = `${normalize(row.title)} ${normalize(row.path ?? '')}`
|
|
190
191
|
if (!haystack.includes(search)) return false
|
|
@@ -9,7 +9,7 @@ import {useDocumentColumns} from '../../hooks/useDocumentColumns'
|
|
|
9
9
|
import {usePreviewTarget} from '../../context/PreviewTargetContext'
|
|
10
10
|
import {PreviewTarget} from './PreviewTarget'
|
|
11
11
|
import {SharePreview} from './SharePreview'
|
|
12
|
-
import {filterRows, sortRows, type PageRow, type SortDirection, type SortKey} from '../../lib/pages'
|
|
12
|
+
import {filterRows, localesInRows, sortRows, type PageRow, type SortDirection, type SortKey} from '../../lib/pages'
|
|
13
13
|
import {groupPageRows, type GroupBy} from '../../lib/grouping'
|
|
14
14
|
import {resolveColorBy, type ColorBy} from '../../lib/colors'
|
|
15
15
|
import * as columnOps from '../../lib/columns'
|
|
@@ -35,6 +35,8 @@ export function PagesTool() {
|
|
|
35
35
|
|
|
36
36
|
const [view, setView] = useState<PagesView>('list')
|
|
37
37
|
const [search, setSearch] = useState('')
|
|
38
|
+
// Langue affichée : '' = toutes.
|
|
39
|
+
const [locale, setLocale] = useState('')
|
|
38
40
|
const [groupBy, setGroupBy] = useState<GroupBy>('none')
|
|
39
41
|
const [rawColorBy, setColorBy] = useState<ColorBy>('tag')
|
|
40
42
|
// L'ordre du Studio par défaut : aucune colonne n'est marquée triée tant
|
|
@@ -64,12 +66,19 @@ export function PagesTool() {
|
|
|
64
66
|
|
|
65
67
|
const colorBy = resolveColorBy(rawColorBy, columns)
|
|
66
68
|
|
|
69
|
+
// Langues proposées : celles déclarées dans la config i18n, sinon celles des
|
|
70
|
+
// documents. Le sélecteur n'apparaît qu'à partir de deux langues.
|
|
71
|
+
const locales = useMemo(
|
|
72
|
+
() => (config.i18n?.locales.length ? config.i18n.locales : localesInRows(rows)),
|
|
73
|
+
[config.i18n, rows],
|
|
74
|
+
)
|
|
75
|
+
|
|
67
76
|
const visible = useMemo(
|
|
68
77
|
() =>
|
|
69
|
-
sortRows(filterRows(rows, {search}), sortKey, sortDirection, {
|
|
78
|
+
sortRows(filterRows(rows, {search, locales: locale ? [locale] : undefined}), sortKey, sortDirection, {
|
|
70
79
|
typeOrder: config.pageTypeNames,
|
|
71
80
|
}),
|
|
72
|
-
[rows, search, sortKey, sortDirection, config.pageTypeNames],
|
|
81
|
+
[rows, search, locale, sortKey, sortDirection, config.pageTypeNames],
|
|
73
82
|
)
|
|
74
83
|
|
|
75
84
|
// Un filtre qui réduit la liste ne doit pas laisser l'utilisateur sur une
|
|
@@ -182,6 +191,28 @@ export function PagesTool() {
|
|
|
182
191
|
</Box>
|
|
183
192
|
)}
|
|
184
193
|
|
|
194
|
+
{locales.length > 1 && (
|
|
195
|
+
<Box style={{width: 120, flex: 'none'}}>
|
|
196
|
+
<FieldLabel>Langue</FieldLabel>
|
|
197
|
+
<Select
|
|
198
|
+
fontSize={1}
|
|
199
|
+
radius={2}
|
|
200
|
+
value={locale}
|
|
201
|
+
onChange={(event) => {
|
|
202
|
+
setLocale(event.currentTarget.value)
|
|
203
|
+
setPage(0)
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
<option value="">Toutes</option>
|
|
207
|
+
{locales.map((code) => (
|
|
208
|
+
<option key={code} value={code}>
|
|
209
|
+
{code.toUpperCase()}
|
|
210
|
+
</option>
|
|
211
|
+
))}
|
|
212
|
+
</Select>
|
|
213
|
+
</Box>
|
|
214
|
+
)}
|
|
215
|
+
|
|
185
216
|
{view === 'list' && (
|
|
186
217
|
<Box style={{width: 168, flex: 'none'}}>
|
|
187
218
|
<FieldLabel>Grouper par</FieldLabel>
|
|
@@ -259,7 +290,7 @@ export function PagesTool() {
|
|
|
259
290
|
<Text size={1} muted align="center">
|
|
260
291
|
{rows.length === 0
|
|
261
292
|
? `Le kit suit les types ${config.pageTypeNames.join(', ')}.`
|
|
262
|
-
: 'Essaie un autre terme, ou vide la recherche.'}
|
|
293
|
+
: 'Essaie un autre terme ou une autre langue, ou vide la recherche.'}
|
|
263
294
|
</Text>
|
|
264
295
|
</Stack>
|
|
265
296
|
</Box>
|
|
@@ -12,12 +12,12 @@ export interface PagesToolbarProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Recherche et rafraîchissement
|
|
15
|
+
* Recherche et rafraîchissement.
|
|
16
16
|
*
|
|
17
|
-
* Les filtres par type
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Les filtres par type et statut restent absents : le regroupement rend ces
|
|
18
|
+
* distinctions visibles sans rien masquer. La langue, elle, a son propre
|
|
19
|
+
* sélecteur (PagesTool) : sur un site multilingue, l'éditeur travaille une
|
|
20
|
+
* langue à la fois et le regroupement ne suffit pas à alléger la liste.
|
|
21
21
|
*/
|
|
22
22
|
export function PagesToolbar(props: PagesToolbarProps) {
|
|
23
23
|
return (
|
package/src/version.ts
CHANGED