-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tatt i bruk det nye endepunktet og startet på utvikling av meny for valg av spraak. * Legg til språk dropdown * Oppdaterte appLanguages til et dictionary. * Add language select with label * Fix tests after adding language combobox * Language combobx rename variables * Endret på visning av backArrow og closeButton * Rebase language branch fixes * Show error when app language has errors * Update snapshot in test * Fix from review * Renamed the schema-description from showLanguageDropdown to showLanguageSelector * Applied the requested changes * Added the missing attributes and removed the unused ones * REU-466; Fiks after review * REU-466; Fix after rebase * Application language fix back button test and run app language saga when the latest layoutsettings is fullfilled * App language remove error when fetch fails. Will only remove app language Select instead * Tatt i bruk det nye endepunktet og startet på utvikling av meny for valg av spraak. * Legg til språk dropdown * Oppdaterte appLanguages til et dictionary. * Add language select with label * Fix tests after adding language combobox * Language combobx rename variables * Endret på visning av backArrow og closeButton * Rebase language branch fixes * Show error when app language has errors * Update snapshot in test * Fix from review * Renamed the schema-description from showLanguageDropdown to showLanguageSelector * Applied the requested changes * Added the missing attributes and removed the unused ones * REU-466; Fiks after review * REU-466; Fix after rebase * Application language fix back button test and run app language saga when the latest layoutsettings is fullfilled * App language remove error when fetch fails. Will only remove app language Select instead * Added the workaround for rendering missing variables in text resources when chaning language * Reverted the workaround * AppLanguage: Update to redux toolkit * Language selector: Combine selector with allowAnonymous and revert unchanged files * App language: Fiks and write tests * App language: Fix after review * App language; merge from master and add test for navigation Co-authored-by: Truls Gunnerød <[email protected]> Co-authored-by: laklov <[email protected]> Co-authored-by: Lasse Klovstad <[email protected]>
- Loading branch information
1 parent
c53a978
commit 2db4ae2
Showing
36 changed files
with
765 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/altinn-app-frontend/__mocks__/statelessAndAllowAnonymousMock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IUiConfig } from 'src/types'; | ||
|
||
export const getUiConfigStateMock = (customStates?: Partial<IUiConfig>): IUiConfig=>{ | ||
return { | ||
autoSave: true, | ||
focus: null, | ||
hiddenFields: [], | ||
repeatingGroups: { | ||
group: { | ||
index: 1, | ||
dataModelBinding: 'someGroup', | ||
} | ||
}, | ||
fileUploadersWithTag: null, | ||
currentView: 'FormLayout', | ||
navigationConfig: {}, | ||
layoutOrder: ['FormLayout'], | ||
...customStates | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/altinn-app-frontend/src/components/presentation/CloseButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <button | ||
type='button' | ||
className='a-modal-close a-js-tabable-popover ml-1' | ||
aria-label={getLanguageFromKey('general.close_schema', language)} | ||
onClick={handleClose} | ||
> | ||
<span className='ai-stack'> | ||
<i | ||
className='ai-stack-1x ai ai-exit a-modal-close-icon' | ||
aria-hidden='true' | ||
/> | ||
</span> | ||
<span className='sr-only'> | ||
{getLanguageFromKey('general.close_schema', language)} | ||
</span> | ||
</button>; | ||
}; |
54 changes: 54 additions & 0 deletions
54
src/altinn-app-frontend/src/components/presentation/LanguageSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { getTextFromAppOrDefault } from 'src/utils/textResource'; | ||
import { AltinnSpinner, Select } from 'altinn-shared/components'; | ||
import { Box } from '@material-ui/core'; | ||
import * as React from 'react'; | ||
import { useAppSelector } from 'src/common/hooks'; | ||
import { useGetAppLanguageQuery } from 'src/services/LanguageApi'; | ||
import { LanguageActions } from 'src/shared/resources/language/languageSlice'; | ||
import { useDispatch } from 'react-redux'; | ||
import { appLanguageStateSelector } from 'src/selectors/appLanguageStateSelector'; | ||
|
||
export const LanguageSelector = () => { | ||
const language = useAppSelector(state => state.language.language || {}); | ||
const { isSuccess, data, isLoading } = useGetAppLanguageQuery(); | ||
const selectedAppLanguage = useAppSelector( | ||
appLanguageStateSelector, | ||
); | ||
|
||
const textResources = useAppSelector(state => state.textResources.resources); | ||
const dispatch = useDispatch(); | ||
const handleAppLanguageChange = (languageCode: string) => { | ||
dispatch(LanguageActions.updateSelectedAppLanguage({ selected: languageCode })); | ||
}; | ||
|
||
|
||
return <Box display='flex' flexDirection='column' className='mb-1'> | ||
{isLoading && <AltinnSpinner />} | ||
{isSuccess && <> | ||
<label className='a-form-label' htmlFor='app-language-select'> | ||
{getTextFromAppOrDefault( | ||
'language.selector.label', | ||
textResources, | ||
language, | ||
null, | ||
true, | ||
)} | ||
</label> | ||
<Select | ||
options={data.map((l) => ({ | ||
value: l.language, | ||
label: getTextFromAppOrDefault( | ||
'language.full_name.' + l.language, | ||
textResources, | ||
language, | ||
null, | ||
true, | ||
), | ||
}))} | ||
onChange={(ev) => handleAppLanguageChange(ev.target.value)} | ||
value={selectedAppLanguage} | ||
id='app-language-select' | ||
/> | ||
</>} | ||
</Box>; | ||
}; |
Oops, something went wrong.