Wizard: Add locale structure to store and mapper

This creates structure and actions for the locale customization in the wizardSlice and requestMapper.
This commit is contained in:
regexowl 2024-11-28 11:03:55 +01:00 committed by Lucas Garfield
parent cbe04c5f9a
commit e4e83d4417
2 changed files with 61 additions and 1 deletions

View file

@ -76,6 +76,8 @@ import {
selectFirstBootScript,
selectMetadata,
initialState,
selectLanguages,
selectKeyboard,
} from '../../../store/wizardSlice';
import { FileSystemConfigurationType } from '../steps/FileSystem';
import {
@ -290,6 +292,10 @@ function commonRequestToState(
repository: '' as PackageRepository,
package_list: [],
})) || [],
locale: {
languages: request.customizations.locale?.languages || [],
keyboard: request.customizations.locale?.keyboard || '',
},
services: {
enabled: request.customizations?.services?.enabled || [],
masked: request.customizations?.services?.masked || [],
@ -496,7 +502,7 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
: undefined,
groups: undefined,
timezone: undefined,
locale: undefined,
locale: getLocale(state),
firewall: undefined,
installation_device: undefined,
fdo: undefined,
@ -614,6 +620,20 @@ const getSubscription = (
}
};
const getLocale = (state: RootState) => {
const languages = selectLanguages(state);
const keyboard = selectKeyboard(state);
if (languages?.length === 0 && !keyboard) {
return undefined;
} else {
return {
languages: languages && languages.length > 0 ? languages : undefined,
keyboard: keyboard ? keyboard : undefined,
};
}
};
const getCustomRepositories = (state: RootState) => {
const customRepositories = selectCustomRepositories(state);
const recommendedRepositories = selectRecommendedRepositories(state);