diff --git a/src/Components/CreateImageWizardV2/steps/TargetEnvironment/Gcp/index.tsx b/src/Components/CreateImageWizardV2/steps/TargetEnvironment/Gcp/index.tsx index 1047fa01..dc1fe456 100644 --- a/src/Components/CreateImageWizardV2/steps/TargetEnvironment/Gcp/index.tsx +++ b/src/Components/CreateImageWizardV2/steps/TargetEnvironment/Gcp/index.tsx @@ -15,7 +15,12 @@ import { ValidatedTextInput } from '../../../ValidatedTextInput'; import { isGcpEmailValid } from '../../../validators'; export type GcpShareMethod = 'withGoogle' | 'withInsights'; -export type GcpAccountTypes = 'google' | 'service' | 'group' | 'domain'; +export type GcpAccountType = + | 'google' + | 'service' + | 'group' + | 'domain' + | undefined; const Gcp = () => { const dispatch = useAppDispatch(); diff --git a/src/Components/CreateImageWizardV2/validators.ts b/src/Components/CreateImageWizardV2/validators.ts index 3623b845..d740673d 100644 --- a/src/Components/CreateImageWizardV2/validators.ts +++ b/src/Components/CreateImageWizardV2/validators.ts @@ -9,11 +9,11 @@ export const isAwsAccountIdValid = (awsAccountId: string | undefined) => { return false; }; -// TODO: this validator thinks asdf@asdf is a valid e-mail address, is that intentional or a bug? export const isGcpEmailValid = (gcpShareWithAccount: string | undefined) => { if ( gcpShareWithAccount !== undefined && - /^[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,}$/.test(gcpShareWithAccount) + /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,12}$/.test(gcpShareWithAccount) && + gcpShareWithAccount.length <= 253 ) { return true; } diff --git a/src/store/wizardSlice.ts b/src/store/wizardSlice.ts index 144f3370..44a7d6c4 100644 --- a/src/store/wizardSlice.ts +++ b/src/store/wizardSlice.ts @@ -7,7 +7,7 @@ import { V1ListSourceResponseItem, } from '../Components/CreateImageWizardV2/steps/TargetEnvironment/Aws'; import { - GcpAccountTypes as GcpAccountType, + GcpAccountType, GcpShareMethod, } from '../Components/CreateImageWizardV2/steps/TargetEnvironment/Gcp'; import { RHEL_9, X86_64 } from '../constants'; @@ -126,6 +126,14 @@ export const wizardSlice = createSlice({ state.aws.source = action.payload; }, changeGcpShareMethod: (state, action: PayloadAction) => { + switch (action.payload) { + case 'withInsights': + state.gcp.accountType = undefined; + state.gcp.email = undefined; + break; + case 'withGoogle': + state.gcp.accountType = 'google'; + } state.gcp.shareMethod = action.payload; }, changeGcpAccountType: (state, action: PayloadAction) => {