diff --git a/src/altinn-app-frontend/__mocks__/formLayoutStateMock.ts b/src/altinn-app-frontend/__mocks__/formLayoutStateMock.ts index af4c5f04eb..601e3f11f6 100644 --- a/src/altinn-app-frontend/__mocks__/formLayoutStateMock.ts +++ b/src/altinn-app-frontend/__mocks__/formLayoutStateMock.ts @@ -1,4 +1,5 @@ import { ILayoutState } from '../src/features/form/layout/formLayoutSlice'; +import { getUiConfigStateMock } from './uiConfigStateMock'; export function getFormLayoutStateMock(customStates?: Partial): ILayoutState { const mockFormLayoutState: ILayoutState = { @@ -46,21 +47,7 @@ export function getFormLayoutStateMock(customStates?: Partial): IL ], }, error: null, - uiConfig: { - autoSave: true, - focus: null, - hiddenFields: [], - repeatingGroups: { - group: { - index: 1, - dataModelBinding: 'someGroup', - } - }, - fileUploadersWithTag: null, - currentView: 'FormLayout', - navigationConfig: {}, - layoutOrder: ['FormLayout'], - }, + uiConfig: getUiConfigStateMock(), layoutsets: null, }; diff --git a/src/altinn-app-frontend/__mocks__/initialStateMock.ts b/src/altinn-app-frontend/__mocks__/initialStateMock.ts index 30a4d6d228..21e82ec8cf 100644 --- a/src/altinn-app-frontend/__mocks__/initialStateMock.ts +++ b/src/altinn-app-frontend/__mocks__/initialStateMock.ts @@ -20,7 +20,9 @@ export const mockParty: IParty = { childParties: null, }; -export function getInitialStateMock(customStates?: Partial): IRuntimeState { +export function getInitialStateMock( + customStates?: Partial, +): IRuntimeState { const initialState: IRuntimeState = { applicationMetadata: { applicationMetadata: applicationMetadataMock, @@ -65,6 +67,7 @@ export function getInitialStateMock(customStates?: Partial): IRun }, language: { language: getLanguageFromCode('nb'), + selectedAppLanguage: '', error: null, }, organisationMetaData: { @@ -78,19 +81,14 @@ export function getInitialStateMock(customStates?: Partial): IRun logo: '', orgnr: '', homepage: '', - environments: [ - 'tt02', - 'production', - ], + environments: ['tt02', 'production'], }, }, error: null, }, party: { error: null, - parties: [ - mockParty, - ], + parties: [mockParty], selectedParty: mockParty, }, process: { @@ -108,7 +106,17 @@ export function getInitialStateMock(customStates?: Partial): IRun }, textResources: { resources: [ - { id: 'option.from.rep.group.label', value: 'The value from the group is: {0}', unparsedValue: 'The value from the group is: {0}', variables: [ { dataSource: 'dataModel.skjema', key: 'someGroup[{0}].labelField' }] } + { + id: 'option.from.rep.group.label', + value: 'The value from the group is: {0}', + unparsedValue: 'The value from the group is: {0}', + variables: [ + { + dataSource: 'dataModel.skjema', + key: 'someGroup[{0}].labelField', + }, + ], + }, ], error: null, language: 'nb', diff --git a/src/altinn-app-frontend/__mocks__/statelessAndAllowAnonymousMock.ts b/src/altinn-app-frontend/__mocks__/statelessAndAllowAnonymousMock.ts new file mode 100644 index 0000000000..cb3ae4709a --- /dev/null +++ b/src/altinn-app-frontend/__mocks__/statelessAndAllowAnonymousMock.ts @@ -0,0 +1,33 @@ +import { IApplicationMetadata } from 'src/shared/resources/applicationMetadata'; +import { IRuntimeState } from 'src/types'; +import { getInitialStateMock } from './initialStateMock'; + +export const statelessAndAllowAnonymousMock = (allowAnonymous: boolean | undefined) => { + const initialState = getInitialStateMock(); + const initialAppMetadata: IApplicationMetadata = { + ...initialState.applicationMetadata.applicationMetadata, + onEntry: { + show: 'stateless', + }, + }; + initialAppMetadata.dataTypes[0].appLogic.allowAnonymousOnStateless = allowAnonymous; + const mockInitialState: IRuntimeState = { + ...initialState, + applicationMetadata: { + applicationMetadata: initialAppMetadata, + error: null, + }, + formLayout: { + ...initialState.formLayout, + layoutsets: { + sets: [ + { + id: 'stateless', + dataType: 'test-data-model', + }, + ], + }, + }, + }; + return mockInitialState; +}; diff --git a/src/altinn-app-frontend/__mocks__/uiConfigStateMock.ts b/src/altinn-app-frontend/__mocks__/uiConfigStateMock.ts new file mode 100644 index 0000000000..9e24c5e0c9 --- /dev/null +++ b/src/altinn-app-frontend/__mocks__/uiConfigStateMock.ts @@ -0,0 +1,20 @@ +import { IUiConfig } from 'src/types'; + +export const getUiConfigStateMock = (customStates?: Partial): IUiConfig=>{ + return { + autoSave: true, + focus: null, + hiddenFields: [], + repeatingGroups: { + group: { + index: 1, + dataModelBinding: 'someGroup', + } + }, + fileUploadersWithTag: null, + currentView: 'FormLayout', + navigationConfig: {}, + layoutOrder: ['FormLayout'], + ...customStates + } +} diff --git a/src/altinn-app-frontend/src/components/base/DropdownComponent.tsx b/src/altinn-app-frontend/src/components/base/DropdownComponent.tsx index 56f37b0e9e..96be2ee041 100644 --- a/src/altinn-app-frontend/src/components/base/DropdownComponent.tsx +++ b/src/altinn-app-frontend/src/components/base/DropdownComponent.tsx @@ -1,15 +1,9 @@ import React from 'react'; -import cn from 'classnames'; -import { makeStyles } from '@material-ui/core'; - -import { AltinnAppTheme } from 'altinn-shared/theme'; import { useAppSelector, useHasChangedIgnoreUndefined } from 'src/common/hooks'; import { IComponentProps } from '..'; - -import '../../styles/shared.css'; import type { IMapping, IOptionSource } from 'src/types'; import { getOptionLookupKey } from 'src/utils/options'; -import { AltinnSpinner } from 'altinn-shared/components'; +import { AltinnSpinner, Select } from 'altinn-shared/components'; import { useGetOptions } from '../hooks'; export interface IDropdownProps extends IComponentProps { @@ -19,19 +13,6 @@ export interface IDropdownProps extends IComponentProps { source?: IOptionSource; } -const useStyles = makeStyles({ - select: { - fontSize: '1.6rem', - '&:focus': { - outline: `2px solid ${AltinnAppTheme.altinnPalette.primary.blueDark}`, - }, - }, -}); - -const optionStyle = { - display: 'none', -}; - function DropdownComponent({ optionsId, formData, @@ -44,7 +25,6 @@ function DropdownComponent({ mapping, source, }: IDropdownProps) { - const classes = useStyles(); const options = useGetOptions({ optionsId, mapping, source }); const fetchingOptions = useAppSelector( (state) => @@ -89,26 +69,23 @@ function DropdownComponent({ {fetchingOptions ? ( ) : ( - + value={formData?.simpleBinding} + disabled={readOnly} + error={!isValid} + options={ + options?.map((option) => ({ + label: getTextResourceAsString(option.label), + value: option.value, + })) || [] + } + /> )} ); } + export default DropdownComponent; diff --git a/src/altinn-app-frontend/src/components/presentation/CloseButton.tsx b/src/altinn-app-frontend/src/components/presentation/CloseButton.tsx new file mode 100644 index 0000000000..3742d75148 --- /dev/null +++ b/src/altinn-app-frontend/src/components/presentation/CloseButton.tsx @@ -0,0 +1,27 @@ +import { getLanguageFromKey } from 'altinn-shared/utils'; +import * as React from 'react'; +import { useAppSelector } from 'src/common/hooks'; + +interface CloseButtonProps { + handleClose: () => void; +}; + +export const CloseButton = ({ handleClose }: CloseButtonProps) => { + const language = useAppSelector(state => state.language.language || {}); + return