Skip to content

Commit

Permalink
Merge pull request #1213 from yaacov/dont-let-user-edit-empty-vddk-im…
Browse files Browse the repository at this point in the history
…age-without-empty-vddk-flag

🐞 Don't let user edit empty vddk image without empty flag
  • Loading branch information
yaacov authored Jun 16, 2024
2 parents d98bec6 + e0ec7cb commit 1f7364e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { validateVDDKImage } from '../../utils/validators';
import { EditModal, EditModalProps } from '../EditModal';

import { onEmptyVddkConfirm } from './onEmptyVddkConfirm';
import { onVddkConfirm } from './onVddkConfirm';
import { onNoneEmptyVddkConfirm } from './onNoneEmptyVddkConfirm';

export type EditProviderVDDKImageProps = Modify<
EditModalProps,
Expand Down Expand Up @@ -67,8 +67,8 @@ export const EditProviderVDDKImage: React.FC<EditProviderVDDKImageProps> = (prop
label={props?.label || t('VDDK init image')}
model={ProviderModel}
body={body}
validationHook={isEmptyImage ? validateEmptyVDDKImage : validateVDDKImage}
onConfirmHook={isEmptyImage ? onEmptyVddkConfirm : onVddkConfirm}
validationHook={isEmptyImage ? validateEmptyVDDKImage : validateNoneEmptyVDDKImage}
onConfirmHook={isEmptyImage ? onEmptyVddkConfirm : onNoneEmptyVddkConfirm}
InputComponent={isEmptyImage ? EmptyVddkTextInput : VddkTextInput}
/>
);
Expand All @@ -89,3 +89,6 @@ const EmptyVddkTextInput: React.FC = () => (

// Validation of empty vddk image
const validateEmptyVDDKImage = () => validateVDDKImage(undefined);

// Validation of none empty vddk image, make sure it's not undefined
const validateNoneEmptyVDDKImage = (value) => validateVDDKImage(value || '');
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @index('./*.tsx', f => `export * from '${f.path}';`)
export * from './EditProviderVDDKImage';
export * from './onEmptyVddkConfirm';
export * from './onVddkConfirm';
export * from './onNoneEmptyVddkConfirm';
// @endindex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { OnConfirmHookType } from '../EditModal';
* @param {any} options.newValue - The new value for the 'vddkInitImage' spec settings.
* @returns {Promise<Object>} - The modified resource.
*/
export const onVddkConfirm: OnConfirmHookType = async ({ resource, model, newValue: value }) => {
export const onNoneEmptyVddkConfirm: OnConfirmHookType = async ({
resource,
model,
newValue: value,
}) => {
const provider = resource as V1beta1Provider;
const vddkInitImage: string = value as string;
let op: string;
Expand Down

0 comments on commit 1f7364e

Please sign in to comment.