Skip to content

Commit

Permalink
fix: usePoolIfAvailable default value (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleixhub authored Oct 14, 2024
1 parent cbeadd1 commit bef3a7a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions catalog/ui/src/app/Catalog/CatalogItemFormReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function checkCondition(condition: string, vars: ConditionValues): boolea
.join('\n') +
'return (' +
condition +
');',
');'
);
const ret: boolean | Error = checkFunction();
if (ret instanceof Error) {
Expand All @@ -146,7 +146,7 @@ async function _checkCondition(
condition: string,
vars: ConditionValues,
debouncedApiFetch: (path: string) => Promise<unknown>,
dispatchFn: React.Dispatch<FormStateAction>,
dispatchFn: React.Dispatch<FormStateAction>
): Promise<boolean> {
const checkSalesforceIds: string[] = [];
condition.replace(checkSalesforceIdRegex, (match, name) => {
Expand All @@ -158,7 +158,7 @@ async function _checkCondition(
const { valid, message } = await checkSalesforceId(
vars[name] as string,
debouncedApiFetch,
vars['sales_type'] as 'string',
vars['sales_type'] as 'string'
);
dispatchFn({
type: 'salesforceIdMessage',
Expand All @@ -168,13 +168,13 @@ async function _checkCondition(
}
return checkCondition(
condition.replace(checkSalesforceIdRegex, () => (checkResults.shift() ? 'true' : 'false')),
vars,
vars
);
}
export async function checkConditionsInFormState(
initialState: FormState,
dispatchFn: React.Dispatch<FormStateAction>,
debouncedApiFetch: (path: string) => Promise<unknown>,
debouncedApiFetch: (path: string) => Promise<unknown>
): Promise<void> {
const parameters = Object.assign({}, initialState.parameters);
const conditionValues: ConditionValues = {
Expand All @@ -195,7 +195,7 @@ export async function checkConditionsInFormState(
'check_salesforce_id(salesforce_id)',
{ salesforce_id: initialState.salesforceId.value, sales_type: initialState.salesforceId.type },
debouncedApiFetch,
dispatchFn,
dispatchFn
);
}
for (const [, parameterState] of Object.entries(parameters)) {
Expand All @@ -206,7 +206,7 @@ export async function checkConditionsInFormState(
parameterSpec.formDisableCondition,
conditionValues,
debouncedApiFetch,
dispatchFn,
dispatchFn
);
}

Expand All @@ -215,7 +215,7 @@ export async function checkConditionsInFormState(
parameterSpec.formHideCondition,
conditionValues,
debouncedApiFetch,
dispatchFn,
dispatchFn
);
}

Expand All @@ -224,7 +224,7 @@ export async function checkConditionsInFormState(
parameterSpec.formRequireCondition,
conditionValues,
debouncedApiFetch,
dispatchFn,
dispatchFn
);
}

Expand All @@ -235,7 +235,7 @@ export async function checkConditionsInFormState(
parameterSpec.validation,
conditionValues,
debouncedApiFetch,
dispatchFn,
dispatchFn
);
parameterState.validationMessage = undefined;
} catch (error) {
Expand Down Expand Up @@ -269,7 +269,7 @@ function reduceFormStateInit(
catalogItem: CatalogItem,
serviceNamespace: ServiceNamespace,
{ isAdmin, groups, roles },
purposeOpts: TPurposeOpts,
purposeOpts: TPurposeOpts
): FormState {
const formGroups: FormStateParameterGroup[] = [];
const parameters: { [name: string]: FormStateParameter } = {};
Expand Down Expand Up @@ -330,7 +330,7 @@ function reduceFormStateInit(
termsOfServiceRequired: catalogItem.spec.termsOfService ? true : false,
workshop: null,
error: '',
usePoolIfAvailable: true,
usePoolIfAvailable: isAdmin ? false : true,
useAutoDetach: true,
activity: null,
purpose: null,
Expand All @@ -356,7 +356,7 @@ function reduceFormStateComplete(
error = '',
salesforceIdValid,
parameters,
}: { error: string; salesforceIdValid: boolean; parameters: { [name: string]: FormStateParameter } },
}: { error: string; salesforceIdValid: boolean; parameters: { [name: string]: FormStateParameter } }
): FormState {
return {
...state,
Expand All @@ -374,7 +374,7 @@ function reduceFormStateComplete(

function reduceFormStateParameterUpdate(
initialState: FormState,
parameter: { name: string; value: boolean | number | string; isValid: boolean },
parameter: { name: string; value: boolean | number | string; isValid: boolean }
): FormState {
const parameters = Object.assign({}, initialState.parameters);
Object.assign(parameters[parameter.name], {
Expand Down Expand Up @@ -462,7 +462,7 @@ function reduceFormStatePurpose(
initialState: FormState,
activity: string,
purpose: string,
explanation: string,
explanation: string
): FormState {
return {
...initialState,
Expand All @@ -488,7 +488,7 @@ function salesforceIdRequired(state: FormState): boolean {

function reduceFormStateSalesforceId(
initialState: FormState,
salesforceId: { required: boolean; value: string; valid: boolean },
salesforceId: { required: boolean; value: string; valid: boolean }
): FormState {
return {
...initialState,
Expand Down

0 comments on commit bef3a7a

Please sign in to comment.