Skip to content

Commit 854e81d

Browse files
authored
fix: url label changed to take correct value (#620)
1 parent a32c3b9 commit 854e81d

6 files changed

Lines changed: 21 additions & 14 deletions

File tree

admin/src/pages/HomePage/components/NavigationItemForm/components/PathField/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { generatePreviewPath } from '../../utils/properties';
1010
import { useConfig } from '../../../../hooks';
1111
import { NavigationItemFormSchema } from '../../utils/form';
1212
import { StrapiContentTypeItemSchema } from 'src/api/validators';
13-
import { isEmpty } from 'lodash';
1413

1514
type PathFieldProps = {
1615
contentTypeItems: StrapiContentTypeItemSchema[] | undefined;
@@ -35,9 +34,9 @@ export const PathField: React.FC<PathFieldProps> = ({
3534
values.type === 'INTERNAL'
3635
? values
3736
: {
38-
related: undefined,
39-
relatedType: undefined,
40-
};
37+
related: undefined,
38+
relatedType: undefined,
39+
};
4140

4241
const pathDefault = generatePreviewPath({
4342
currentPath: values.path,
@@ -53,7 +52,15 @@ export const PathField: React.FC<PathFieldProps> = ({
5352

5453
const disabled = !canUpdate || (values.autoSync && values.type === 'INTERNAL');
5554

56-
const [pathDefaultFieldsValue] = Object.values(configQuery.data?.pathDefaultFields ?? {}).flat();
55+
const pathDefaultFieldsValue = internalValues.relatedType
56+
? (configQuery.data?.pathDefaultFields?.[internalValues.relatedType] ?? [])
57+
: [];
58+
59+
const selectedEntity = contentTypeItems?.find(
60+
({ documentId }) => documentId === internalValues.related
61+
);
62+
63+
const validPathFieldName = pathDefaultFieldsValue.find((field) => selectedEntity?.[field]);
5764

5865
return (
5966
<Grid.Item alignItems="flex-start" key="title" col={12}>
@@ -65,13 +72,13 @@ export const PathField: React.FC<PathFieldProps> = ({
6572
formatMessage(getTrad(`popup.item.form.${pathSourceName}.placeholder`, 'e.g. Blog')),
6673
pathDefault
6774
? formatMessage(getTrad('popup.item.form.type.external.description'), {
68-
value: pathDefault,
69-
})
75+
value: pathDefault,
76+
})
7077
: '',
7178
disabled
7279
? formatMessage(getTrad('popup.item.form.type.internal.source'), {
73-
value: !isEmpty(pathDefaultFieldsValue) ? pathDefaultFieldsValue : 'id',
74-
})
80+
value: validPathFieldName || 'id',
81+
})
7582
: '',
7683
].join(' ')}
7784
>

admin/src/translations/ca.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ const ca = {
315315
pathDefaultFields: {
316316
label: 'Champs par défaut du chemin',
317317
placeholder:
318-
'Sélectionner au moins un ou laisser vide pour désactiver le remplissage du champ de chemin avec la valeur des attributs',
318+
'Selecciona almenys un o deixa-ho buit perquè s’utilitzi Id com a valor per defecte.',
319319
hint: "La valeur de l'attribut sélectionné sera la valeur par défaut pour le chemin interne",
320320
empty: "Ce type de contenu n'a pas d'attributs appropriés",
321321
},

admin/src/translations/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ const en = {
316316
pathDefaultFields: {
317317
label: 'Path default fields',
318318
placeholder:
319-
'Select at least one or leave it empty to disable populating path field with attributes value',
319+
'Select at least one or leave it empty to populate Id as default value',
320320
hint: 'Value of selected attribute will be a default value for internal path',
321321
empty: "This content type doesn't have any suitable attributes",
322322
},

admin/src/translations/es.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ const en = {
319319
pathDefaultFields: {
320320
label: 'Campos predeterminados de ruta',
321321
placeholder:
322-
'Selecciona al menos uno o déjalo vacío para deshabilitar la población de la ruta con valores de atributos',
322+
'Selecciona al menos uno o déjalo vacío para que Id se use como valor predeterminado.',
323323
hint: 'El valor del atributo seleccionado será el valor predeterminado para la ruta interna',
324324
empty: 'Este tipo de contenido no tiene atributos adecuados',
325325
},

admin/src/translations/fr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ const fr = {
319319
pathDefaultFields: {
320320
label: 'Champs par défaut du chemin',
321321
placeholder:
322-
'Sélectionner au moins un ou laisser vide pour désactiver le remplissage du champ de chemin avec la valeur des attributs',
322+
'Sélectionner au moins un ou laissez vide afin qu’Id soit utilisé comme valeur par défaut.',
323323
hint: "La valeur de l'attribut sélectionné sera la valeur par défaut pour le chemin interne",
324324
empty: "Ce type de contenu n'a pas d'attributs appropriés",
325325
},

admin/src/translations/tr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ const tr = {
317317
pathDefaultFields: {
318318
label: 'Varsayılan yol alanları',
319319
placeholder:
320-
'En az birini seçin veya yol alanını nitelik değeriyle doldurmayı devre dışı bırakın',
320+
'En az birini seçin veya boş bırakın; varsayılan değer olarak Id kullanılır',
321321
hint: 'Seçilen nitelik değeri, dahili yol için varsayılan değer olacaktır',
322322
empty: 'Bu içerik türünde uygun nitelikler bulunmuyor',
323323
},

0 commit comments

Comments
 (0)