Skip to content

Commit

Permalink
Merge pull request #531 from konstructio/fix-ami-instancesize
Browse files Browse the repository at this point in the history
fix: send api calls with ami type
  • Loading branch information
jokestax authored Feb 13, 2025
2 parents 9bcf7b2 + f6e005c commit 0e9cfe6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
18 changes: 18 additions & 0 deletions containers/ClusterForms/shared/SetupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ const SetupForm: FunctionComponent = () => {
const handleRegionChange = useCallback(
(region: string) => {
setSelectedRegion(region);
if (installType == InstallationType.AWS) {
return;
}
// if using google hold off on grabbing instances
// since it requires the zone as well

Expand All @@ -112,6 +115,20 @@ const SetupForm: FunctionComponent = () => {
[dispatch, installType, values],
);

const handleAmiTypeSelect = useCallback(
(amiType: string) => {
dispatch(
getInstanceSizes({
installType,
region: selectedRegion as string,
values,
amiType,
}),
);
},
[dispatch, installType, selectedRegion, values],
);

const handleZoneSelect = useCallback(
(zone: string) => {
if (cloudRegion) {
Expand Down Expand Up @@ -228,6 +245,7 @@ const SetupForm: FunctionComponent = () => {
value: amiType,
}))}
defaultValue={AWS_AMI_TYPES[0]}
onChange={handleAmiTypeSelect}
/>
)}
<ControlledAutocomplete
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@
"volta": {
"node": "18.18.0",
"yarn": "1.22.19"
}
},
}
11 changes: 9 additions & 2 deletions redux/thunks/api.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,26 @@ export const getCloudDomains = createAsyncThunk<

export const getInstanceSizes = createAsyncThunk<
string[],
{ region: string; installType?: InstallationType; values?: InstallValues; zone?: string },
{
region: string;
installType?: InstallationType;
values?: InstallValues;
zone?: string;
amiType?: string;
},
{
dispatch: AppDispatch;
state: RootState;
}
>('api/getInstanceSizes', async ({ region, installType, values, zone }) => {
>('api/getInstanceSizes', async ({ region, installType, values, zone, amiType }) => {
const { instance_sizes } = (
await axios.post<{ instance_sizes: string[] }>('/api/proxy', {
url: `/instance-sizes/${installType}`,
body: {
...values,
cloud_region: region,
cloud_zone: zone,
ami_type: amiType,
},
})
).data;
Expand Down

0 comments on commit 0e9cfe6

Please sign in to comment.