Wizard: Add timezone structure to store and mapper
This creates structure and actions for the timezone customization in the wizardSlice and requestMapper.
This commit is contained in:
parent
696cc4f4bf
commit
ab446c2a36
2 changed files with 60 additions and 1 deletions
|
|
@ -76,6 +76,8 @@ import {
|
|||
selectFirstBootScript,
|
||||
selectMetadata,
|
||||
initialState,
|
||||
selectTimezone,
|
||||
selectNtpServers,
|
||||
selectLanguages,
|
||||
selectKeyboard,
|
||||
} from '../../../store/wizardSlice';
|
||||
|
|
@ -304,6 +306,10 @@ function commonRequestToState(
|
|||
kernel: {
|
||||
append: request.customizations?.kernel?.append || '',
|
||||
},
|
||||
timezone: {
|
||||
timezone: request.customizations.timezone?.timezone || '',
|
||||
ntpservers: request.customizations.timezone?.ntpservers || [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -501,7 +507,7 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
|
|||
? { append: selectKernel(state).append }
|
||||
: undefined,
|
||||
groups: undefined,
|
||||
timezone: undefined,
|
||||
timezone: getTimezone(state),
|
||||
locale: getLocale(state),
|
||||
firewall: undefined,
|
||||
installation_device: undefined,
|
||||
|
|
@ -586,6 +592,20 @@ const getPackages = (state: RootState) => {
|
|||
}
|
||||
};
|
||||
|
||||
const getTimezone = (state: RootState) => {
|
||||
const timezone = selectTimezone(state);
|
||||
const ntpservers = selectNtpServers(state);
|
||||
|
||||
if (!timezone && ntpservers?.length === 0) {
|
||||
return undefined;
|
||||
} else {
|
||||
return {
|
||||
timezone: timezone ? timezone : undefined,
|
||||
ntpservers: ntpservers && ntpservers.length > 0 ? ntpservers : undefined,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const getSubscription = (
|
||||
state: RootState,
|
||||
orgID: string
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import type {
|
|||
ImageTypes,
|
||||
Locale,
|
||||
Repository,
|
||||
Timezone,
|
||||
} from './imageBuilderApi';
|
||||
import type { ActivationKeys } from './rhsmApi';
|
||||
|
||||
|
|
@ -112,6 +113,7 @@ export type wizardState = {
|
|||
blueprintName: string;
|
||||
blueprintDescription: string;
|
||||
};
|
||||
timezone: Timezone;
|
||||
metadata?: {
|
||||
parent_id: string | null;
|
||||
exported_at: string;
|
||||
|
|
@ -187,6 +189,10 @@ export const initialState: wizardState = {
|
|||
blueprintName: '',
|
||||
blueprintDescription: '',
|
||||
},
|
||||
timezone: {
|
||||
timezone: '',
|
||||
ntpservers: [],
|
||||
},
|
||||
firstBoot: { script: '' },
|
||||
};
|
||||
|
||||
|
|
@ -357,6 +363,14 @@ export const selectFirstBootScript = (state: RootState) => {
|
|||
return state.wizard.firstBoot?.script;
|
||||
};
|
||||
|
||||
export const selectTimezone = (state: RootState) => {
|
||||
return state.wizard.timezone.timezone;
|
||||
};
|
||||
|
||||
export const selectNtpServers = (state: RootState) => {
|
||||
return state.wizard.timezone.ntpservers;
|
||||
};
|
||||
|
||||
export const wizardSlice = createSlice({
|
||||
name: 'wizard',
|
||||
initialState,
|
||||
|
|
@ -717,6 +731,27 @@ export const wizardSlice = createSlice({
|
|||
changeKernelAppend: (state, action: PayloadAction<string>) => {
|
||||
state.kernel.append = action.payload;
|
||||
},
|
||||
changeTimezone: (state, action: PayloadAction<string>) => {
|
||||
state.timezone.timezone = action.payload;
|
||||
},
|
||||
addNtpServer: (state, action: PayloadAction<string>) => {
|
||||
if (
|
||||
!state.timezone.ntpservers?.some((server) => server === action.payload)
|
||||
) {
|
||||
state.timezone.ntpservers?.push(action.payload);
|
||||
}
|
||||
},
|
||||
removeNtpServer: (state, action: PayloadAction<string>) => {
|
||||
state.timezone.ntpservers?.splice(
|
||||
state.timezone.ntpservers.findIndex(
|
||||
(server) => server === action.payload
|
||||
),
|
||||
1
|
||||
);
|
||||
},
|
||||
clearNtpServers: (state) => {
|
||||
state.timezone.ntpservers = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -780,5 +815,9 @@ export const {
|
|||
changeMaskedServices,
|
||||
changeDisabledServices,
|
||||
changeKernelAppend,
|
||||
changeTimezone,
|
||||
addNtpServer,
|
||||
removeNtpServer,
|
||||
clearNtpServers,
|
||||
} = wizardSlice.actions;
|
||||
export default wizardSlice.reducer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue