Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/app/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
const checkPubliccodeYmlVersion = useCallback((publicCode: PublicCode) => {
const { publiccodeYmlVersion } = publicCode;
setPubliccodeYmlVersion(publiccodeYmlVersion);
}, []);

Check warning on line 228 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has a missing dependency: 'setPubliccodeYmlVersion'. Either include it or remove the dependency array

Check warning on line 228 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has a missing dependency: 'setPubliccodeYmlVersion'. Either include it or remove the dependency array

const checkItCountryExtensionVersion = useCallback(
(publicCode: PublicCode) => {
Expand All @@ -245,7 +245,7 @@

setShowCountryExtensionVersion(countryExtensionVersionVisible);
},
[]

Check warning on line 248 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has a missing dependency: 'setShowCountryExtensionVersion'. Either include it or remove the dependency array

Check warning on line 248 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has a missing dependency: 'setShowCountryExtensionVersion'. Either include it or remove the dependency array
);

useFormPersist("form-values", {
Expand All @@ -257,7 +257,7 @@
checkPubliccodeYmlVersion(pc);
checkItCountryExtensionVersion(pc);
},
[setLanguages]

Check warning on line 260 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has missing dependencies: 'checkItCountryExtensionVersion' and 'checkPubliccodeYmlVersion'. Either include them or remove the dependency array

Check warning on line 260 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has missing dependencies: 'checkItCountryExtensionVersion' and 'checkPubliccodeYmlVersion'. Either include them or remove the dependency array
),
storage: window?.localStorage, // default window.sessionStorage
exclude: [],
Expand Down Expand Up @@ -346,7 +346,8 @@
};

const setFormDataAfterImport = async (
fetchData: () => Promise<PublicCode | null>
fetchData: () => Promise<PublicCode | null>,
removedFields: string[] = []
) => {
try {
const publicCode = await fetchData().then((publicCode) => {
Expand Down Expand Up @@ -374,12 +375,24 @@
setIsPublicCodeImported(true);

const res = await checkWarnings(publicCode);
setWarnings(
Array.from(res.warnings).map(([key, { message }]) => ({
const warningsFromValidator = Array.from(res.warnings).map(
([key, { message }]) => ({
key,
message,
}))
})
);

const autofixWarning =
removedFields.length > 0
? [
{
key: t("editor.form.validate.info.title"),
message: removedFields.join(", "),
},
]
: [];

setWarnings([...warningsFromValidator, ...autofixWarning]);
} catch (error: unknown) {
notify("Import error", (error as Error).message, {
dismissable: true,
Expand All @@ -401,22 +414,8 @@
});
const sanitized = linter(adapted);
const removed = collectRemovedKeys(raw, sanitized);
if (removed.length > 0) {
const body = (
<List className="it-list">
{removed.map((k) => (
<ListItem key={k}>
<span className="text">{k}</span>
</ListItem>
))}
</List>
);
notify(t("editor.form.validate.info.title"), body, {
state: "info",
dismissable: true,
});
}
await setFormDataAfterImport(async () => adapted as PublicCode);

await setFormDataAfterImport(async () => adapted as PublicCode, removed);
} catch {
// fall back to standard flow on any error
await setFormDataAfterImport(async () => raw as PublicCode);
Expand Down Expand Up @@ -458,7 +457,7 @@
yamlLoadEventBus.off("loadRemoteYaml", loadRemoteYamlHandler);
yamlLoadEventBus.off("loadFileYaml", loadFileYamlHandler);
};
}, []);

Check warning on line 460 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'loadFileYamlHandler' and 'loadRemoteYamlHandler'. Either include them or remove the dependency array

Check warning on line 460 in src/app/components/Editor.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'loadFileYamlHandler' and 'loadRemoteYamlHandler'. Either include them or remove the dependency array

return (
<div className="content__editor-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"notification_title": "Validierungsfehler",
"notification_text": "Überprüfen Sie die Felder des Formulars",
"info": {
"title": "Unbekannte Felder entfernt"
"title": "Automatische Korrekturen auf die folgenden Felder angewendet"
},
"button": "Validieren"
},
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"text": "Check form fields"
},
"info": {
"title": "Unknown fields removed"
"title": "Automatic corrections applied to the following fields"
},
"button": "Validate"
},
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"text": "Check form fields"
},
"info": {
"title": "Champs inconnus supprimés"
"title": "Corrections automatiques appliquées aux champs suivants"
},
"button": "Validate"
},
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"text": "Controlla i campi della form"
},
"info": {
"title": "Campi sconosciuti rimossi"
"title": "Correzioni automatiche applicate sui seguenti campi"
},
"button": "Valida"
},
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"text": "Controleer formuliervelden"
},
"info": {
"title": "Onbekende velden verwijderd"
"title": "Automatische correcties toegepast op de volgende velden"
},
"button": "Valideren"
},
Expand Down
Loading