From 1860f7dada7b02d4ac311386e1702fec7f124780 Mon Sep 17 00:00:00 2001 From: andreastanderen <71079896+standeren@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:47:59 +0100 Subject: [PATCH] fix: isolate code list editor text keys (#14051) --- frontend/language/src/en.json | 1 - frontend/language/src/nb.json | 49 ++++++++----------- .../config/editModal/EditOptions.test.tsx | 2 +- .../config/editModal/EditOptions.tsx | 2 +- .../EditOptions/EditOptions.test.tsx | 12 ++--- .../EditManualOptionsWithEditor.test.tsx | 4 +- .../EditManualOptionsWithEditor.tsx | 2 +- .../EditOptionListReference.test.tsx | 2 +- .../EditOptionListReference.tsx | 4 +- .../EditOptionList/OptionListEditor.test.tsx | 4 +- .../EditOptionList/OptionListEditor.tsx | 2 +- .../EditOptions/OptionTabs/OptionTabs.tsx | 4 +- .../hooks/useOptionListEditorTexts.ts | 33 ++++++------- 13 files changed, 54 insertions(+), 67 deletions(-) diff --git a/frontend/language/src/en.json b/frontend/language/src/en.json index 7789f97cd38..bf00d62fbf2 100644 --- a/frontend/language/src/en.json +++ b/frontend/language/src/en.json @@ -983,7 +983,6 @@ "ux_editor.no_text": "No text", "ux_editor.radios_description_add": "Add descrption", "ux_editor.radios_description_placeholder": "No description", - "ux_editor.radios_error_DuplicateValues": "All values must be unique.", "ux_editor.radios_error_NoOptions": "There must be at least one radio button.", "ux_editor.radios_legend_add": "Add title", "ux_editor.radios_legend_placeholder": "Title is missing", diff --git a/frontend/language/src/nb.json b/frontend/language/src/nb.json index d4e9f09400f..d534e2dc7a0 100644 --- a/frontend/language/src/nb.json +++ b/frontend/language/src/nb.json @@ -108,6 +108,21 @@ "app_release.release_title": "Appen bygges basert på", "app_release.release_title_link": "siste endringstransaksjon til master", "app_release.release_version": "Versjon:", + "code_list_editor.add_option": "Legg til alternativ", + "code_list_editor.column_title_delete": "Slett", + "code_list_editor.column_title_description": "Beskrivelse", + "code_list_editor.column_title_help_text": "Hjelpetekst", + "code_list_editor.column_title_label": "Ledetekst", + "code_list_editor.column_title_value": "Verdi", + "code_list_editor.delete_code_list_item": "Slett alternativ {{number}}", + "code_list_editor.description_item": "Beskrivelse for alternativ {{number}}", + "code_list_editor.duplicate_values_error": "Alle verdier må være unike.", + "code_list_editor.empty": "Kodelisten er tom.", + "code_list_editor.general_error": "Kan ikke lagre kodelisten, den inneholder feil.", + "code_list_editor.help_text_item": "Hjelpetekst for alternativ {{number}}", + "code_list_editor.label_item": "Ledetekst for alternativ {{number}}", + "code_list_editor.legend": "Kodeliste", + "code_list_editor.value_item": "Verdi for alternativ {{number}}", "contact.email.content": "Du kan skrive en e-post til Altinn servicedesk hvis du har spørsmål om å opprette organisasjoner eller miljøer, opplever tekniske problemer eller har spørsmål om dokumentasjonen eller andre ting.", "contact.email.heading": "Send e-post", "contact.github_issue.content": "Hvis du har behov for funksjonalitet eller ser feil og mangler i Studio som vi må fikse, kan du opprette en sak i Github, så ser vi på den.", @@ -1475,7 +1490,7 @@ "ux_editor.longitude_label": "Longitude", "ux_editor.map_layer": "Kartlag", "ux_editor.mobilePreview": "Mobilvisning", - "ux_editor.modal_add_options_codelist": "Kodeliste", + "ux_editor.modal_add_options_code_list": "Kodeliste", "ux_editor.modal_add_options_manual": "Manuelt", "ux_editor.modal_check_box_add_label": "Legg til tekst", "ux_editor.modal_check_box_increment": "Avmerkingsboks", @@ -1509,17 +1524,9 @@ "ux_editor.modal_new_option": "Legg til alternativ", "ux_editor.modal_properties_add_radio_button_options": "Hvordan vil du legge til radioknapper?", "ux_editor.modal_properties_code_list_custom_list": "Egendefinert kodeliste", - "ux_editor.modal_properties_code_list_delete_item": "Slett alternativ {{number}}", - "ux_editor.modal_properties_code_list_empty": "Kodelisten er tom.", "ux_editor.modal_properties_code_list_filename_error": "Filnavnet er ugyldig. Du kan bruke tall, understrek, punktum, bindestrek, og store/små bokstaver fra det norske alfabetet. Filnavnet må starte med en engelsk bokstav.", - "ux_editor.modal_properties_code_list_general_error": "Kan ikke lagre kodelisten, den inneholder feil.", "ux_editor.modal_properties_code_list_helper": "Velg kodeliste", "ux_editor.modal_properties_code_list_id": "Kodeliste-ID", - "ux_editor.modal_properties_code_list_item_description": "Beskrivelse for alternativ {{number}}", - "ux_editor.modal_properties_code_list_item_helpText": "Hjelpetekst for alternativ {{number}}", - "ux_editor.modal_properties_code_list_item_help_text": "Hjelpetekst for alternativ {{number}}", - "ux_editor.modal_properties_code_list_item_label": "Ledetekst for alternativ {{number}}", - "ux_editor.modal_properties_code_list_item_value": "Verdi for alternativ {{number}}", "ux_editor.modal_properties_code_list_open_editor": "Åpne redigeringsverktøy", "ux_editor.modal_properties_code_list_read_more": "<0 href=\"{{optionsDocs}}\" >Les mer om kodelister", "ux_editor.modal_properties_code_list_read_more_dynamic": "<0 href=\"{{optionsDocs}}\" >Les mer om dynamiske kodelister", @@ -1668,26 +1675,13 @@ "ux_editor.no_components_selected": "Velg en side for å se forhåndsvisningen", "ux_editor.no_text": "Ingen tekst", "ux_editor.open_preview": "Åpne forhåndsvisning", - "ux_editor.options.codelist_create_info.heading": "Steg for å skrive inn kodelister manuelt", - "ux_editor.options.codelist_create_info.step1": "Gå til Gitea for å lage ny kodeliste.", - "ux_editor.options.codelist_create_info.step2": "Klikk på \"Add file\", deretter \"Ny fil\" for å åpne fileditoren.", - "ux_editor.options.codelist_create_info.step3": "Filen må ligge i mappen \"App/options\". Sørg for at den blir plassert der ved å oppgi denne stien i opplastingsfeltet. Når du skriver \"App/options/\", blir feltet automatisk oppdatert med mappesti.", - "ux_editor.options.codelist_create_info.step4": "Skriv inn kodelisten i tekstfeltet midt på siden. Kodelisten må være i JSON-format.", - "ux_editor.options.codelist_create_info.step5": "Velg \"Commit endringer\".", - "ux_editor.options.codelist_create_info.step6": "Du er nå ferdig i Gitea for denne gang. Gå tilbake til Altinn Studio-fanen, eller klikk på Altinn-logoen øverst til venstre i Gitea for å komme tilbake til Altinn Studio.", - "ux_editor.options.codelist_only": "Denne komponenten støtter bare oppsett med forhåndsdefinerte kodelister.", - "ux_editor.options.codelist_referenceId.description": "Her kan du legge til en referanse-ID til en dynamisk kodeliste som er satt opp i koden.", - "ux_editor.options.codelist_referenceId.description_details": "Du bruker dynamiske kodelister for å tilpasse alternativer for brukerne. Det kan for eksempel være tilpasninger ut fra geografisk plassering, eller valg brukeren gjør tidligere i skjemaet.", - "ux_editor.options.codelist_upload_info.heading": "Steg for å laste opp kodelister manuelt", - "ux_editor.options.codelist_upload_info.step1": "Gå til Gitea for å laste opp kodeliste.", - "ux_editor.options.codelist_upload_info.step2": "Klikk på \"Add file\", deretter \"Last opp fil\" og last opp kodelisten.", - "ux_editor.options.codelist_upload_info.step3": "Filen må ligge i mappen \"App/options\". Sørg for at den blir plassert der ved å oppgi denne stien i opplastingsfeltet. Når du skriver \"App/options/\", blir feltet automatisk oppdatert med mappesti.", - "ux_editor.options.codelist_upload_info.step4": "Velg \"Commit endringer\".", - "ux_editor.options.codelist_upload_info.step5": "Du er nå ferdig i Gitea for denne gang. Gå tilbake til Altinn Studio-fanen, eller klikk på Altinn-logoen øverst til venstre i Gitea for å komme tilbake til Altinn Studio.", + "ux_editor.options.code_list_only": "Denne komponenten støtter bare oppsett med forhåndsdefinerte kodelister.", + "ux_editor.options.code_list_referenceId.description": "Her kan du legge til en referanse-ID til en dynamisk kodeliste som er satt opp i koden.", + "ux_editor.options.code_list_referenceId.description_details": "Du bruker dynamiske kodelister for å tilpasse alternativer for brukerne. Det kan for eksempel være tilpasninger ut fra geografisk plassering, eller valg brukeren gjør tidligere i skjemaet.", "ux_editor.options.multiple": "{{value}} alternativer", "ux_editor.options.section_heading": "Valg for kodelister", "ux_editor.options.single": "{{value}} alternativ", - "ux_editor.options.tab_codelist": "Velg kodeliste", + "ux_editor.options.tab_code_list": "Velg kodeliste", "ux_editor.options.tab_manual": "Sett opp egne alternativer", "ux_editor.options.tab_referenceId": "Angi referanse-ID", "ux_editor.page": "Side", @@ -1736,8 +1730,6 @@ "ux_editor.properties_panel.images.upload_image_file_size_limit": "Største tillate filstørrelse er {{maxSize}} MB", "ux_editor.properties_panel.images.validating_image_url_error": "Kunne ikke validere bildeadressen.", "ux_editor.properties_panel.images.validating_image_url_pending": "Validerer bildeadressen …", - "ux_editor.properties_panel.options.codelist_switch_to_custom": "Bytt til egendefinert kodeliste", - "ux_editor.properties_panel.options.codelist_switch_to_static": "Bytt til statisk kodeliste", "ux_editor.properties_panel.options.use_code_list_label": "Bruk kodeliste", "ux_editor.properties_panel.subform_table_columns.add_column": "Legg til kolonne", "ux_editor.properties_panel.subform_table_columns.cell_content_default_label": "Default", @@ -1753,7 +1745,6 @@ "ux_editor.properties_panel.texts.no_properties": "Det er ingen tekster å konfigurere for denne komponenten.", "ux_editor.properties_panel.texts.sub_title_images": "Valg for bilde", "ux_editor.properties_panel.texts.sub_title_texts": "Tekster", - "ux_editor.radios_error_DuplicateValues": "Alle verdier må være unike.", "ux_editor.radios_error_NoOptions": "Det må være minst én radioknapp.", "ux_editor.radios_option": "Radioknapp {{optionNumber}}", "ux_editor.search_text_resources_close": "Lukk tekstsøk", diff --git a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.test.tsx index e8c3f6dcfca..20a8b0a5564 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.test.tsx @@ -45,7 +45,7 @@ describe('EditOptions', () => { it('should show code list input by default when neither options nor optionId are set', async () => { await render(); - expect(screen.getByText(textMock('ux_editor.modal_add_options_codelist'))).toBeInTheDocument(); + expect(screen.getByText(textMock('ux_editor.modal_add_options_code_list'))).toBeInTheDocument(); }); it('should show manual input when component has options defined', async () => { diff --git a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.tsx b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.tsx index 6b2c4ed862a..8b34b87468f 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditOptions.tsx @@ -113,7 +113,7 @@ export function EditOptions({ size='small' > - {t('ux_editor.modal_add_options_codelist')} + {t('ux_editor.modal_add_options_code_list')} {t('ux_editor.modal_add_options_manual')} diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/EditOptions.test.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/EditOptions.test.tsx index a2d7f107634..a82e1194efc 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/EditOptions.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/EditOptions.test.tsx @@ -67,7 +67,7 @@ describe('EditOptions', () => { }); expect( await screen.findByRole('tab', { - name: textMock('ux_editor.options.tab_codelist'), + name: textMock('ux_editor.options.tab_code_list'), selected: true, }), ).toBeInTheDocument(); @@ -121,7 +121,7 @@ describe('EditOptions', () => { expect( await screen.findByRole('tab', { - name: textMock('ux_editor.options.tab_codelist'), + name: textMock('ux_editor.options.tab_code_list'), selected: true, }), ).toBeInTheDocument(); @@ -160,18 +160,18 @@ describe('EditOptions', () => { expect( screen.queryByRole('tab', { - name: textMock('ux_editor.options.tab_codelist'), + name: textMock('ux_editor.options.tab_code_list'), selected: true, }), ).not.toBeInTheDocument(); const codelistTabElement = await screen.findByRole('tab', { - name: textMock('ux_editor.options.tab_codelist'), + name: textMock('ux_editor.options.tab_code_list'), }); await waitFor(() => user.click(codelistTabElement)); expect( screen.getByRole('tab', { - name: textMock('ux_editor.options.tab_codelist'), + name: textMock('ux_editor.options.tab_code_list'), selected: true, }), ).toBeInTheDocument(); @@ -217,7 +217,7 @@ describe('EditOptions', () => { }); await waitFor(() => user.click(manualTabElement)); - expect(screen.getByText(textMock('ux_editor.options.codelist_only'))).toBeInTheDocument(); + expect(screen.getByText(textMock('ux_editor.options.code_list_only'))).toBeInTheDocument(); }); it('should show error message if query fails', async () => { diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.test.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.test.tsx index 6ff9f1af430..28fca9f1305 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.test.tsx @@ -135,7 +135,7 @@ describe('EditManualOptionsWithEditor', () => { await user.click(modalButton); const addNewButton = screen.getByRole('button', { - name: textMock('ux_editor.modal_new_option'), + name: textMock('code_list_editor.add_option'), }); await user.click(addNewButton); @@ -163,7 +163,7 @@ describe('EditManualOptionsWithEditor', () => { await user.click(modalButton); const addNewButton = screen.getByRole('button', { - name: textMock('ux_editor.modal_new_option'), + name: textMock('code_list_editor.add_option'), }); await user.click(addNewButton); diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.tsx index 77a05cdb52a..dbb8c0d896f 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditManualOptionsWithEditor/EditManualOptionsWithEditor.tsx @@ -38,7 +38,7 @@ export function EditManualOptionsWithEditor({ className={classes.manualTabDialog} contentClassName={classes.content} closeButtonTitle={t('general.close')} - heading={t('ux_editor.modal_add_options_codelist')} + heading={t('ux_editor.modal_add_options_code_list')} > { it('should render', () => { renderEditOptionListReference(); expect( - screen.getByText(textMock('ux_editor.options.codelist_referenceId.description')), + screen.getByText(textMock('ux_editor.options.code_list_referenceId.description')), ).toBeInTheDocument(); }); diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionListReference.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionListReference.tsx index 17a6ba6ebdc..30b2db4b75d 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionListReference.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionListReference.tsx @@ -25,10 +25,10 @@ export function EditOptionListReference({ return (
- {t('ux_editor.options.codelist_referenceId.description')} + {t('ux_editor.options.code_list_referenceId.description')} - {t('ux_editor.options.codelist_referenceId.description_details')} + {t('ux_editor.options.code_list_referenceId.description_details')} { await openModal(user); const textBox = screen.getByRole('textbox', { - name: textMock('ux_editor.modal_properties_code_list_item_description', { number: 2 }), + name: textMock('code_list_editor.description_item', { number: 2 }), }); await user.type(textBox, 'test'); @@ -106,7 +106,7 @@ describe('OptionListEditor', () => { await openModal(user); const textBox = screen.getByRole('textbox', { - name: textMock('ux_editor.modal_properties_code_list_item_description', { number: 2 }), + name: textMock('code_list_editor.description_item', { number: 2 }), }); await user.type(textBox, 'test'); diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/OptionListEditor.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/OptionListEditor.tsx index 7b89510492d..8642850f67a 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/OptionListEditor.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/OptionListEditor.tsx @@ -82,7 +82,7 @@ function OptionListEditorModal({ className={classes.editOptionTabModal} contentClassName={classes.content} closeButtonTitle={t('general.close')} - heading={t('ux_editor.modal_add_options_codelist')} + heading={t('ux_editor.modal_add_options_code_list')} onBeforeClose={handleClose} onInteractOutside={handleClose} > diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/OptionTabs.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/OptionTabs.tsx index 427f43a4479..fd4bdf17960 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/OptionTabs.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/OptionTabs.tsx @@ -52,7 +52,7 @@ export const OptionTabs = ({ > - {t('ux_editor.options.tab_codelist')} + {t('ux_editor.options.tab_code_list')} {t('ux_editor.options.tab_manual')} @@ -102,7 +102,7 @@ const RenderManualOptions = ({ if (areLayoutOptionsSupported === false) { return ( - {t('ux_editor.options.codelist_only')} + {t('ux_editor.options.code_list_only')} ); } diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/hooks/useOptionListEditorTexts.ts b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/hooks/useOptionListEditorTexts.ts index 469582e34de..c56f5f583aa 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/hooks/useOptionListEditorTexts.ts +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/hooks/useOptionListEditorTexts.ts @@ -5,25 +5,22 @@ export const useOptionListEditorTexts = (): CodeListEditorTexts => { const { t } = useTranslation(); return { - add: t('ux_editor.modal_new_option'), - codeList: t('ux_editor.modal_add_options_codelist'), - delete: t('general.delete'), - deleteItem: (number: number) => - t('ux_editor.modal_properties_code_list_delete_item', { number }), - description: t('general.description'), - emptyCodeList: t('ux_editor.modal_properties_code_list_empty'), + add: t('code_list_editor.add_option'), + delete: t('code_list_editor.column_title_delete'), + value: t('code_list_editor.column_title_value'), + label: t('code_list_editor.column_title_label'), + description: t('code_list_editor.column_title_description'), + helpText: t('code_list_editor.column_title_help_text'), + deleteItem: (number: number) => t('code_list_editor.delete_code_list_item', { number }), + itemValue: (number: number) => t('code_list_editor.value_item', { number }), + itemLabel: (number: number) => t('code_list_editor.label_item', { number }), + itemDescription: (number: number) => t('code_list_editor.description_item', { number }), + itemHelpText: (number: number) => t('code_list_editor.help_text_item', { number }), + codeList: t('code_list_editor.legend'), + emptyCodeList: t('code_list_editor.empty'), valueErrors: { - duplicateValue: t('ux_editor.radios_error_DuplicateValues'), + duplicateValue: t('code_list_editor.duplicate_values_error'), }, - generalError: t('ux_editor.modal_properties_code_list_general_error'), - helpText: t('ux_editor.modal_properties_textResourceBindings_help'), - itemDescription: (number: number) => - t('ux_editor.modal_properties_code_list_item_description', { number }), - itemHelpText: (number: number) => - t('ux_editor.modal_properties_code_list_item_helpText', { number }), - itemLabel: (number: number) => t('ux_editor.modal_properties_code_list_item_label', { number }), - itemValue: (number: number) => t('ux_editor.modal_properties_code_list_item_value', { number }), - label: t('ux_editor.modal_properties_textResourceBindings_title'), - value: t('general.value'), + generalError: t('code_list_editor.general_error'), }; };