Wizard: Add Hostname functionality
This adds a validated hostname input and new tests.
This commit is contained in:
parent
c98b7d9997
commit
5a514d1d04
7 changed files with 153 additions and 4 deletions
|
|
@ -80,6 +80,7 @@ import {
|
|||
selectNtpServers,
|
||||
selectLanguages,
|
||||
selectKeyboard,
|
||||
selectHostname,
|
||||
} from '../../../store/wizardSlice';
|
||||
import { FileSystemConfigurationType } from '../steps/FileSystem';
|
||||
import {
|
||||
|
|
@ -310,6 +311,7 @@ function commonRequestToState(
|
|||
timezone: request.customizations.timezone?.timezone || '',
|
||||
ntpservers: request.customizations.timezone?.ntpservers || [],
|
||||
},
|
||||
hostname: request.customizations.hostname || '',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -502,7 +504,7 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
|
|||
filesystem: getFileSystem(state),
|
||||
users: undefined,
|
||||
services: getServices(state),
|
||||
hostname: undefined,
|
||||
hostname: selectHostname(state) || undefined,
|
||||
kernel: selectKernel(state).append
|
||||
? { append: selectKernel(state).append }
|
||||
: undefined,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import {
|
|||
selectUseLatest,
|
||||
selectActivationKey,
|
||||
selectRegistrationType,
|
||||
selectHostname,
|
||||
} from '../../../store/wizardSlice';
|
||||
import {
|
||||
getDuplicateMountPoints,
|
||||
|
|
@ -25,6 +26,7 @@ import {
|
|||
isBlueprintDescriptionValid,
|
||||
isMountpointMinSizeValid,
|
||||
isSnapshotValid,
|
||||
isHostnameValid,
|
||||
} from '../validators';
|
||||
|
||||
export type StepValidation = {
|
||||
|
|
@ -38,12 +40,14 @@ export function useIsBlueprintValid(): boolean {
|
|||
const registration = useRegistrationValidation();
|
||||
const filesystem = useFilesystemValidation();
|
||||
const snapshot = useSnapshotValidation();
|
||||
const hostname = useHostnameValidation();
|
||||
const firstBoot = useFirstBootValidation();
|
||||
const details = useDetailsValidation();
|
||||
return (
|
||||
!registration.disabledNext &&
|
||||
!filesystem.disabledNext &&
|
||||
!snapshot.disabledNext &&
|
||||
!hostname.disabledNext &&
|
||||
!firstBoot.disabledNext &&
|
||||
!details.disabledNext
|
||||
);
|
||||
|
|
@ -133,6 +137,20 @@ export function useFirstBootValidation(): StepValidation {
|
|||
};
|
||||
}
|
||||
|
||||
export function useHostnameValidation(): StepValidation {
|
||||
const hostname = useAppSelector(selectHostname);
|
||||
|
||||
if (!isHostnameValid(hostname)) {
|
||||
return {
|
||||
errors: {
|
||||
hostname: 'Invalid hostname',
|
||||
},
|
||||
disabledNext: true,
|
||||
};
|
||||
}
|
||||
return { errors: {}, disabledNext: false };
|
||||
}
|
||||
|
||||
export function useDetailsValidation(): StepValidation {
|
||||
const name = useAppSelector(selectBlueprintName);
|
||||
const description = useAppSelector(selectBlueprintDescription);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue