Skip to content

Commit 3be6358

Browse files
committed
added thumbnail selection and fixed problem with multiple languages
Multiple languages can't be obtained via the documents API of strapi. Only one is possible, so the language is mandatory to select in the sitemap
1 parent b0a0104 commit 3be6358

File tree

177 files changed

+24873
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+24873
-17
lines changed

admin/src/components/CollectionTypeModal.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export default function CollectionTypeModal({
3434
const [priority, setPriority] = useState('');
3535
const [frequency, setFrequency] = useState('');
3636
const [lastModified, setLastModified] = useState('false');
37+
const [thumbnail, setThumbnail] = useState('');
38+
const [possibleThumbnailFields, setPossibleThumbnailFields] = useState<any[]>([]);
3739

3840
const [collectionTypes, setCollectionTypes] = useState<CollectionType[]>([]);
3941
const [locales, setLocales] = useState<any[]>([]);
@@ -45,6 +47,7 @@ export default function CollectionTypeModal({
4547
const priorityRef = useRef<HTMLInputElement>(null);
4648
const frequencyRef = useRef<HTMLInputElement>(null);
4749
const lastModifiedRef = useRef<HTMLInputElement>(null);
50+
const thumbnailRef = useRef<HTMLInputElement>(null);
4851

4952
const { get, put, post } = getFetchClient();
5053

@@ -87,6 +90,7 @@ export default function CollectionTypeModal({
8790
priority,
8891
frequency,
8992
lastModified,
93+
thumbnail,
9094
id: editID,
9195
});
9296
} else {
@@ -97,6 +101,7 @@ export default function CollectionTypeModal({
97101
priority,
98102
lastModified,
99103
frequency,
104+
thumbnail,
100105
});
101106
}
102107

@@ -108,6 +113,7 @@ export default function CollectionTypeModal({
108113
setPriority('');
109114
setFrequency('');
110115
setLastModified('false');
116+
setThumbnail('');
111117
setEditID('');
112118
setTypeToEdit('');
113119
setModalOpen(false);
@@ -125,13 +131,15 @@ export default function CollectionTypeModal({
125131
setPriority(typeToEdit.priority?.toString() || '');
126132
setFrequency(typeToEdit.frequency || '');
127133
setLastModified(typeToEdit.lastModified || 'false');
134+
setThumbnail(typeToEdit.thumbnail || '');
128135
} else {
129136
setType('');
130137
setLangcode('');
131138
setPattern('');
132139
setPriority('');
133140
setFrequency('');
134141
setLastModified('false');
142+
setThumbnail('');
135143
setEditID('');
136144
}
137145
}, [typeToEdit]);
@@ -163,6 +171,7 @@ export default function CollectionTypeModal({
163171
if (type) {
164172
const getAllowedFields = async () => {
165173
const { data } = await get(`/${PLUGIN_ID}/admin-allowed-fields?type=${type}`);
174+
setPossibleThumbnailFields(data.allowedFields);
166175

167176
setPatternHint('Possible fields: ' + data.allowedFields.map((field: string) => `[${field}]`).join(', '));
168177
if (pattern === '') {
@@ -203,10 +212,10 @@ export default function CollectionTypeModal({
203212
</Field.Root>
204213
</Grid.Item>
205214
<Grid.Item>
206-
<Field.Root required width='100%' hint="Select a language or leave empty for all languages">
215+
<Field.Root required width='100%' hint="Select a language or leave empty for the default language">
207216
<Field.Label>Lang Code</Field.Label>
208217
<SingleSelect name="langcode" onChange={handleSelectChange(setLangcode)} ref={langcodeRef} value={langcode} placeholder="Select Langcode" disabled={type === ''}>
209-
<SingleSelectOption value="-">None</SingleSelectOption>
218+
<SingleSelectOption value="-">Default Language</SingleSelectOption>
210219
{locales.map((locale) => (
211220
<SingleSelectOption key={locale.id} value={locale.code}>{locale.code}</SingleSelectOption>
212221
))}
@@ -264,6 +273,18 @@ export default function CollectionTypeModal({
264273
<Field.Hint />
265274
</Field.Root>
266275
</Grid.Item>
276+
<Grid.Item>
277+
<Field.Root width='100%' hint="Optional thumbnail image">
278+
<Field.Label>Thumbnail</Field.Label>
279+
<SingleSelect name="thumbnail" onChange={handleSelectChange(setThumbnail)} ref={thumbnailRef} value={thumbnail} placeholder="Select Thumbnail" disabled={type === ''}>
280+
<SingleSelectOption value="-">None</SingleSelectOption>
281+
{possibleThumbnailFields.map((field) => (
282+
<SingleSelectOption key={field} value={field}>{field}</SingleSelectOption>
283+
))}
284+
</SingleSelect>
285+
<Field.Hint />
286+
</Field.Root>
287+
</Grid.Item>
267288
</Grid.Root>
268289
</Modal.Body>
269290
<Modal.Footer>

admin/src/pages/Settings.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ const Settings = () => {
215215
<Th>
216216
<Typography variant="sigma">Add last modification date</Typography>
217217
</Th>
218+
<Th>
219+
<Typography variant="sigma">Thumbnail</Typography>
220+
</Th>
218221
<Th>
219222
<VisuallyHidden>Actions</VisuallyHidden>
220223
</Th>
@@ -241,6 +244,9 @@ const Settings = () => {
241244
<Td>
242245
<Typography variant="sigma">{collectionType.lastModified}</Typography>
243246
</Td>
247+
<Td>
248+
<Typography variant="sigma">{collectionType.thumbnail}</Typography>
249+
</Td>
244250
<Td>
245251
</Td>
246252
<Td>

dist/_chunks/Settings-3plHLk_S.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/_chunks/Settings-3plHLk_S.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)