createImageWizard: change the default name of bllueprint
this commit change the default name to different format
<release>-<arch>-<date>-<time>
const dateString = `${day}${month}${year}`;
const timeString = `${hours}`;
This commit is contained in:
parent
be8a00d186
commit
047ae0111c
2 changed files with 12 additions and 16 deletions
|
|
@ -18,7 +18,6 @@ import {
|
|||
selectBlueprintDescription,
|
||||
selectBlueprintName,
|
||||
selectDistribution,
|
||||
selectImageTypes,
|
||||
} from '../../../../store/wizardSlice';
|
||||
import { generateDefaultName } from '../../utilities/generateDefaultName';
|
||||
import { useDetailsValidation } from '../../utilities/useValidation';
|
||||
|
|
@ -30,15 +29,10 @@ const DetailsStep = () => {
|
|||
const blueprintDescription = useAppSelector(selectBlueprintDescription);
|
||||
const distribution = useAppSelector(selectDistribution);
|
||||
const arch = useAppSelector(selectArchitecture);
|
||||
const targetEnvironments = useAppSelector(selectImageTypes);
|
||||
|
||||
useEffect(() => {
|
||||
if (!blueprintName) {
|
||||
dispatch(
|
||||
changeBlueprintName(
|
||||
generateDefaultName(distribution, arch, targetEnvironments)
|
||||
)
|
||||
);
|
||||
dispatch(changeBlueprintName(generateDefaultName(distribution, arch)));
|
||||
}
|
||||
// This useEffect hook should run *only* on mount and therefore has an empty
|
||||
// dependency array. eslint's exhaustive-deps rule does not support this use.
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { ImageTypes } from '../../../store/imageBuilderApi';
|
||||
import { Distributions, ImageRequest } from '../../../store/imageBuilderApi';
|
||||
|
||||
export const generateDefaultName = (
|
||||
distribution: string,
|
||||
arch: string,
|
||||
targetEnvironments: ImageTypes[]
|
||||
distribution: Distributions,
|
||||
arch: ImageRequest['architecture']
|
||||
) => {
|
||||
const date = new Date();
|
||||
const day = date.getDate().toString().padStart(2, '0');
|
||||
const month = date.toLocaleString('en-US', { month: 'long' });
|
||||
const year = date.getFullYear();
|
||||
return `${distribution} ${arch} ${targetEnvironments.join(
|
||||
' '
|
||||
)} ${day} ${month} ${year}`;
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||
const year = date.getFullYear().toString();
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
|
||||
const dateTimeString = `${month}${day}${year}-${hours}${minutes}`;
|
||||
|
||||
return `${distribution}-${arch}-${dateTimeString}`;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue