Skip to content

Commit

Permalink
Merge branch 'main' into 13273-update-norwegian-version-of-gitea
Browse files Browse the repository at this point in the history
  • Loading branch information
mlqn authored Sep 12, 2024
2 parents c7ab0b9 + b96cae8 commit 2dd02f0
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 36 deletions.
30 changes: 15 additions & 15 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@
"process_editor.configuration_panel_custom_receipt_info": "Hvis du heller vil lage din egen kvittering, kan du opprette den her. Kvitteringen du lager selv vil overstyre standardkvitteringen.",
"process_editor.configuration_panel_custom_receipt_layout_set_name": "Navn på sidegruppe: ",
"process_editor.configuration_panel_custom_receipt_layout_set_name_validation": "Navnet må ha minst 2 tegn",
"process_editor.configuration_panel_custom_receipt_navigate_to_lage_button": "Gå til Lage",
"process_editor.configuration_panel_custom_receipt_navigate_to_lage_title": "Gå til Lage for å utforme kvitteringen din",
"process_editor.configuration_panel_custom_receipt_navigate_to_design_button": "Gå til Utforming",
"process_editor.configuration_panel_custom_receipt_navigate_to_design_title": "Gå til Utforming for å utforme kvitteringen din",
"process_editor.configuration_panel_custom_receipt_select_data_model_label": "Datamodellknytning",
"process_editor.configuration_panel_custom_receipt_spinner_title": "Laster inn kvittering",
"process_editor.configuration_panel_custom_receipt_textfield_label": "Navn på sidegruppe",
Expand Down Expand Up @@ -676,7 +676,7 @@
"process_editor.not_found_process_error_message": "Det finnes ingen prosess definert innenfor BPMN, Du kan sjekke om prosessen finnes i BPMN-filen.",
"process_editor.not_found_process_heading": "Det er ingen tilgjengelig prosess",
"process_editor.recommended_action.new_name": "Gi oppgaven et navn",
"process_editor.recommended_action.new_name_description": "Du finner lettere igjen oppgaven på Lage-siden, hvis du gir den et eget navn. Hvis du velger Hopp over, får oppgaven en tilfeldig navn. Du kan endre navnet senere.",
"process_editor.recommended_action.new_name_description": "Du finner lettere igjen oppgaven på Utformingssiden, hvis du gir den et eget navn. Hvis du velger Hopp over, får oppgaven et tilfeldig navn. Du kan endre navnet senere.",
"process_editor.recommended_action.new_name_label": "Navn på oppgaven",
"process_editor.save_bpmn_xml_error": "Noe gikk galt da prosessen skulle lagres.",
"process_editor.sequence_flow_configuration_add_new_rule": "Lag en ny logikkregel",
Expand Down Expand Up @@ -771,12 +771,12 @@
"right_menu.rules_calculations": "Regel for beregninger",
"right_menu.rules_calculations_add_alt": "Legg til regel for beregninger",
"right_menu.rules_calculations_deprecated_info": "Verktøyet er utdatert, så vi har tatt det bort. Det betyr at du ikke lenger kan legge til og redigere regler for beregninger i Studio, men du kan fortsatt lage dem i koden.",
"right_menu.rules_calculations_deprecated_info_title": "Vi har fjernet beregningsregler på Lage-siden",
"right_menu.rules_calculations_deprecated_info_title": "Vi har fjernet beregningsregler på Utforming-siden",
"right_menu.rules_calculations_edit_in_gitea": "Rediger beregninger direkte i Gitea",
"right_menu.rules_conditional_rendering": "Regel for vis/skjul felt",
"right_menu.rules_conditional_rendering_add_alt": "Legg til regel for vis/skjul felt",
"right_menu.rules_conditional_rendering_deprecated_info": "Verktøyet er utdatert, så vi har tatt det bort. Det betyr at du ikke lenger kan legge til og redigere regler for betinget visning i Studio. <0 href=\"{{expressionDocs}}\" >Vi anbefaler å bruke dynamiske uttrykk.</0>",
"right_menu.rules_conditional_rendering_deprecated_info_title": "Vi har fjernet regler for betinget visning på Lage-siden",
"right_menu.rules_conditional_rendering_deprecated_info_title": "Vi har fjernet regler for betinget visning på Utforming-siden",
"right_menu.rules_conditional_rendering_edit_in_gitea": "Rediger betingede visninger direkte i Gitea",
"right_menu.rules_empty": "Ingen regler lagt til...",
"right_menu.show_old_dynamics": "Vis gammelt verktøy for dynamikk",
Expand Down Expand Up @@ -1019,7 +1019,7 @@
"text_editor.variables_default_value": "<bold>Standardverdi:</bold> {{defaultValue}}",
"text_editor.variables_editing_not_supported": "Det, er ikke lagt til støtte for redigering av variabler i Studio.",
"top_menu.about": "Oversikt",
"top_menu.create": "Lage",
"top_menu.create": "Utforming",
"top_menu.dashboard": "Dashboard",
"top_menu.data_model": "Datamodell",
"top_menu.deploy": "Publiser",
Expand All @@ -1046,7 +1046,7 @@
"ux_editor.component_deletion_text": "Er du sikker på at du vil slette denne komponenten?",
"ux_editor.component_dropdown_set_preselected": "Sett forhåndsvalgt verdi for nedtrekksliste",
"ux_editor.component_group_deletion_text": "Er du sikker på at du vil slette denne gruppen?\nAlle komponenter i denne gruppen blir også slettet",
"ux_editor.component_help_text.Accordion": "Med Accordion-komponenten (trekkspilliste) kan du presentere mye innhold på liten plass i en eller flere rader. Brukerne kan klikke på hele raden, og åpne eller lukke visningen av innholdet under.",
"ux_editor.component_help_text.Accordion": "Med komponenten Trekkspilliste kan du presentere mye innhold på liten plass i en eller flere rader. Brukerne kan klikke på hele raden, og åpne eller lukke visningen av innholdet under.",
"ux_editor.component_help_text.AccordionGroup": "En samling med trekkspillister som vises vertikalt. Brukes for å gruppere lister som hører sammen.",
"ux_editor.component_help_text.ActionButton": "Knapp for å utløse en bestemt handling knyttet til det steget i prosessen som sluttbrukeren befinner seg på. Eksempler inkluderer 'sign', 'confirm', 'reject'.",
"ux_editor.component_help_text.Address": "Komponent for å fylle ut adresse. Poststedet blir slått opp automatisk, basert på postnummeret.",
Expand All @@ -1057,10 +1057,10 @@
"ux_editor.component_help_text.ButtonGroup": "En samling knapper som vises side om side horisontalt. Brukes for å gruppere knapper som hører sammen.",
"ux_editor.component_help_text.Checkboxes": "Du bruker avmerkingsbokser når brukeren skal kunne velge flere svar. Hvis brukeren bare skal velge ett av to alternativer, bruker du radioknapper.",
"ux_editor.component_help_text.Datepicker": "Datovelger som tilbyr en kalender brukeren kan velge dato fra.",
"ux_editor.component_help_text.Dropdown": "Bruk Nedtrekksliste når di vil at brukeren skal velge kun ett alternativ blant flere, for eksempel i en liste med stedsnavn. Du kan bruke radioknapper hvis bruken bare skal velge mellom to eller tre alternativer.",
"ux_editor.component_help_text.Dropdown": "Bruk Nedtrekksliste når du vil at brukeren skal velge kun ett alternativ blant flere, for eksempel i en liste med stedsnavn. Du kan bruke radioknapper hvis bruken bare skal velge mellom to eller tre alternativer.",
"ux_editor.component_help_text.FileUpload": "Komponent for å laste opp filer. Du kan angi hvilke filtyper som skal være tillatt, om brukeren skal kunne laste opp flere filer, samt spesifisere begrensing til fil-størrelse.",
"ux_editor.component_help_text.FileUploadWithTag": "Komponent for å laste opp filer med merking hentet fra en options-liste. Du kan angi hvilke filtyper som skal være tillatt, om brukeren skal kunne laste opp flere filer, samt spesifisere begrensing til fil-størrelse.",
"ux_editor.component_help_text.Grid": "Grid-komponenten brukes til å visuelt oppstille komponenter i en tabellvisning.",
"ux_editor.component_help_text.Grid": "Bruk Rutenett-komponenten til å ordne andre komponenter i en tabellvisning.",
"ux_editor.component_help_text.Group": "En samling av andre skjemakomponenter. Kan konfigureres til å være en repeterende gruppe.",
"ux_editor.component_help_text.Header": "Bruk titler konsistent for å etablere en tydelig hierarki i appen. H1 er brukt som tittel mens H2 og under kan brukes i appen for å strukturere innhold. Skriv alle titler med stor forbokstav.",
"ux_editor.component_help_text.IFrame": "IFrame-komponenten kan brukes til å rendre din egen HTML og CSS i en Altinn-app.",
Expand Down Expand Up @@ -1252,7 +1252,7 @@
"ux_editor.component_properties.triggers": "Feltet skal utløse:",
"ux_editor.component_properties.unit": "Enhet",
"ux_editor.component_properties.url": "Lenke (URL)",
"ux_editor.component_properties.useComponentGrid": "Bruk komponentens grid-oppsett",
"ux_editor.component_properties.useComponentGrid": "Bruk komponentens rutenettoppsett",
"ux_editor.component_properties.validFileEndings": "Skriv inn gyldige filtyper (Eksempel: .jpeg, .pdf, .png)",
"ux_editor.component_properties.validateOnBackward": "Validering ved navigering fremover",
"ux_editor.component_properties.validateOnForward": "Validering ved navigering bakover",
Expand All @@ -1266,8 +1266,8 @@
"ux_editor.component_properties_description.elements": "Hvilke elementer skal vises for instansinformasjonen",
"ux_editor.component_properties_description.pageBreak": "Valgfri sideskift før eller etter komponenten i PDF",
"ux_editor.component_properties_description.pagination": "Pagineringsvalg for repeterende gruppe",
"ux_editor.component_title.Accordion": "Accordion",
"ux_editor.component_title.AccordionGroup": "Accordion-gruppe",
"ux_editor.component_title.Accordion": "Trekkspilliste",
"ux_editor.component_title.AccordionGroup": "Nestet trekkspilliste",
"ux_editor.component_title.ActionButton": "Handlingsknapp",
"ux_editor.component_title.Address": "Adresse",
"ux_editor.component_title.AddressComponent": "Adresse",
Expand All @@ -1285,7 +1285,7 @@
"ux_editor.component_title.Dropdown": "Nedtrekksliste",
"ux_editor.component_title.FileUpload": "Vedlegg",
"ux_editor.component_title.FileUploadWithTag": "Vedlegg med merking",
"ux_editor.component_title.Grid": "Grid",
"ux_editor.component_title.Grid": "Rutenett",
"ux_editor.component_title.Group": "Gruppe",
"ux_editor.component_title.Header": "Tittel",
"ux_editor.component_title.IFrame": "IFrame",
Expand Down Expand Up @@ -1339,8 +1339,8 @@
"ux_editor.input_popover_label": "Gi nytt navn til siden",
"ux_editor.input_popover_save_button": "Lagre",
"ux_editor.latitude_label": "Latitude",
"ux_editor.loading_form_layout": "Laster inn formlayout",
"ux_editor.loading_page": "Laster inn lage siden",
"ux_editor.loading_form_layout": "Laster inn siden",
"ux_editor.loading_page": "Laster inn utforming",
"ux_editor.longitude_label": "Longitude",
"ux_editor.map_layer": "Kartlag",
"ux_editor.mobilePreview": "Mobilvisning",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
describe('RedirectToCreatePageButton', () => {
afterEach(() => jest.clearAllMocks());

it('Checks that the button to go to "Lage" page has the correct href', () => {
it('Checks that the button to go to "Utforming" page has the correct href', () => {
renderRedirectToCreatePageButton();

const navigationButton = screen.getByRole('link', {
name: textMock('process_editor.configuration_panel_custom_receipt_navigate_to_lage_button'),
name: textMock('process_editor.configuration_panel_custom_receipt_navigate_to_design_button'),
});
expect(navigationButton).toHaveAttribute('href', '/editor/testOrg/testApp/ui-editor');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export const RedirectToCreatePageButton = (): React.ReactElement => {
return (
<div className={classes.goToCreatePageWrapper}>
<RedirectBox
title={t('process_editor.configuration_panel_custom_receipt_navigate_to_lage_title')}
title={t('process_editor.configuration_panel_custom_receipt_navigate_to_design_title')}
>
<StudioButton asChild variant='primary' color='second' onClick={handleClick}>
<Link
href={packagesRouter.getPackageNavigationUrl('editorUiEditor')}
className={classes.link}
>
<PencilWritingIcon />
{t('process_editor.configuration_panel_custom_receipt_navigate_to_lage_button')}
{t('process_editor.configuration_panel_custom_receipt_navigate_to_design_button')}
</Link>
</StudioButton>
</RedirectBox>
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/shared/src/types/QueryKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum QueryKey {
DeployPermissions = 'DeployPermissions',
Environments = 'Environments',
FetchBpmn = 'FetchBpmn',
FetchTextResources = 'FetchTextResources',
FormComponent = 'FormComponent',
FormLayoutSettings = 'FormLayoutSettings',
FormLayouts = 'FormLayouts',
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/shared/src/types/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ILayoutSettings {
export interface IPagesSettings {
order?: string[];
excludeFromPdf?: string[];
pdfLayoutName?: string;
}

export interface IComponentsSettings {
Expand Down
12 changes: 6 additions & 6 deletions frontend/packages/ux-editor/src/AppContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
queryKey: ['formLayouts', mockSelectedFormLayoutSetName],
queryKey: ['FormLayouts', org, app, mockSelectedFormLayoutSetName],
}),
);
});
Expand All @@ -157,7 +157,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.resetQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.resetQueries).toHaveBeenCalledWith({
queryKey: ['formLayouts', mockSelectedFormLayoutSetName],
queryKey: ['FormLayouts', org, app, mockSelectedFormLayoutSetName],
}),
);
});
Expand All @@ -174,7 +174,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
queryKey: ['layoutSettings', mockSelectedFormLayoutSetName],
queryKey: ['FormLayoutSettings', org, app, mockSelectedFormLayoutSetName],
}),
);
});
Expand All @@ -191,7 +191,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.resetQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.resetQueries).toHaveBeenCalledWith({
queryKey: ['layoutSettings', mockSelectedFormLayoutSetName],
queryKey: ['FormLayoutSettings', org, app, mockSelectedFormLayoutSetName],
}),
);
});
Expand All @@ -208,7 +208,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.invalidateQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.invalidateQueries).toHaveBeenCalledWith({
queryKey: ['fetchTextResources', mockLanguage],
queryKey: ['FetchTextResources', org, app, mockLanguage],
}),
);
});
Expand All @@ -225,7 +225,7 @@ describe('AppContext', () => {
await waitFor(async () => expect(queryClient.resetQueries).toHaveBeenCalledTimes(1));
await waitFor(async () =>
expect(queryClient.resetQueries).toHaveBeenCalledWith({
queryKey: ['fetchTextResources', mockLanguage],
queryKey: ['FetchTextResources', org, app, mockLanguage],
}),
);
});
Expand Down
19 changes: 11 additions & 8 deletions frontend/packages/ux-editor/src/AppContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { MutableRefObject } from 'react';
import React, { useMemo, useRef, createContext, useCallback } from 'react';
import type { QueryClient, QueryKey } from '@tanstack/react-query';
import type { QueryClient, QueryKey as TanStackQueryKey } from '@tanstack/react-query';
import { useSelectedFormLayoutName, useSelectedFormLayoutSetName } from './hooks';
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams';
import { QueryKey } from 'app-shared/types/QueryKey';

export interface WindowWithQueryClient extends Window {
queryClient?: QueryClient;
Expand Down Expand Up @@ -36,14 +38,15 @@ export const AppContextProvider = ({
previewHasLoaded,
onLayoutSetNameChange,
}: AppContextProviderProps): React.JSX.Element => {
const { org, app } = useStudioEnvironmentParams();
const previewIframeRef = useRef<HTMLIFrameElement>(null);
const { selectedFormLayoutSetName, setSelectedFormLayoutSetName } =
useSelectedFormLayoutSetName();
const { selectedFormLayoutName, setSelectedFormLayoutName } =
useSelectedFormLayoutName(selectedFormLayoutSetName);

const refetch = useCallback(
async (queryKey: QueryKey, resetQueries: boolean = false): Promise<void> => {
async (queryKey: TanStackQueryKey, resetQueries: boolean = false): Promise<void> => {
const contentWindow: WindowWithQueryClient = previewIframeRef?.current?.contentWindow;

resetQueries
Expand All @@ -59,23 +62,23 @@ export const AppContextProvider = ({

const refetchLayouts = useCallback(
async (layoutSetName: string, resetQueries: boolean = false): Promise<void> => {
return await refetch(['formLayouts', layoutSetName], resetQueries);
return await refetch([QueryKey.FormLayouts, org, app, layoutSetName], resetQueries);
},
[refetch],
[refetch, org, app],
);

const refetchLayoutSettings = useCallback(
async (layoutSetName: string, resetQueries: boolean = false): Promise<void> => {
return await refetch(['layoutSettings', layoutSetName], resetQueries);
return await refetch([QueryKey.FormLayoutSettings, org, app, layoutSetName], resetQueries);
},
[refetch],
[refetch, org, app],
);

const refetchTexts = useCallback(
async (language: string, resetQueries: boolean = false): Promise<void> => {
return await refetch(['fetchTextResources', language], resetQueries);
return await refetch([QueryKey.FetchTextResources, org, app, language], resetQueries);
},
[refetch],
[refetch, org, app],
);

const value = useMemo(
Expand Down
40 changes: 40 additions & 0 deletions frontend/packages/ux-editor/src/classes/FormLayoutSettings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { FormLayoutSettings } from '@altinn/ux-editor/classes/FormLayoutSettings';
import { formLayoutSettingsMock } from '@altinn/ux-editor/testing/mocks';
import type { ILayoutSettings } from 'app-shared/types/global';

describe('FormLayoutSettings', () => {
describe('getPdfLayoutName', () => {
it('Should get pdfLayoutName as undefined from class when not set in object', () => {
const layoutSettings = setupFormLayoutSettings({
pages: { ...formLayoutSettingsMock.pages, pdfLayoutName: undefined },
});
const pdfLayoutName = layoutSettings.getPdfLayoutName();
expect(pdfLayoutName).toBeUndefined();
});

it('Should get pdfLayoutName as defined from class when set in object', () => {
const pdfLayoutNameMock = 'pdfLayoutNameMock';
const layoutSettings = setupFormLayoutSettings({
pages: { ...formLayoutSettingsMock.pages, pdfLayoutName: pdfLayoutNameMock },
});
const pdfLayoutName = layoutSettings.getPdfLayoutName();
expect(pdfLayoutName).toBe(pdfLayoutNameMock);
});
});
describe('setPdfLayoutName', () => {
it('Should set pdfLayoutName to new value when updated', () => {
const pdfLayoutNameMock = 'pdfLayoutNameMock';
const layoutSettings = setupFormLayoutSettings({
pages: { ...formLayoutSettingsMock.pages, pdfLayoutName: undefined },
});
layoutSettings.setPdfLayoutName(pdfLayoutNameMock);
expect(layoutSettings.getPdfLayoutName()).toBe(pdfLayoutNameMock);
});
});
});

const setupFormLayoutSettings = ({
...props
}: ILayoutSettings = formLayoutSettingsMock): FormLayoutSettings => {
return new FormLayoutSettings({ ...props });
};
22 changes: 22 additions & 0 deletions frontend/packages/ux-editor/src/classes/FormLayoutSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { ILayoutSettings } from 'app-shared/types/global';

export class FormLayoutSettings {
private readonly layoutSettings: ILayoutSettings;

constructor(layoutSettings: ILayoutSettings) {
this.layoutSettings = layoutSettings;
}

public getLayoutSettings(): ILayoutSettings {
return this.layoutSettings;
}

public setPdfLayoutName(layoutName: string): FormLayoutSettings {
this.layoutSettings.pages.pdfLayoutName = layoutName;
return this;
}

public getPdfLayoutName(): string {
return this.layoutSettings.pages.pdfLayoutName;
}
}
Loading

0 comments on commit 2dd02f0

Please sign in to comment.