Skip to content

Commit a5e523d

Browse files
committed
Add gen2 flag to access key drawer - filter regions
1 parent f83171e commit a5e523d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/manager/src/components/RegionSelect/RegionMultiSelect.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import CloseIcon from '@mui/icons-material/Close';
33
import React from 'react';
44

55
import { Flag } from 'src/components/Flag';
6+
import { useIsObjectStorageGen2Enabled } from 'src/features/ObjectStorage/hooks/useIsObjectStorageGen2Enabled';
67
import { useAllAccountAvailabilitiesQuery } from 'src/queries/account/availability';
78
import { getRegionCountryGroup } from 'src/utilities/formatRegion';
89

@@ -50,12 +51,18 @@ export const RegionMultiSelect = React.memo((props: RegionMultiSelectProps) => {
5051
...rest
5152
} = props;
5253

54+
const { isObjectStorageGen2Enabled } = useIsObjectStorageGen2Enabled();
55+
5356
const {
5457
data: accountAvailability,
5558
isLoading: accountAvailabilityLoading,
5659
} = useAllAccountAvailabilitiesQuery();
5760

58-
const regionOptions = getRegionOptions({ currentCapability, regions });
61+
const regionOptions = getRegionOptions({
62+
currentCapability,
63+
isObjectStorageGen2Enabled,
64+
regions,
65+
});
5966

6067
const selectedRegions = regionOptions.filter((r) =>
6168
selectedIds.includes(r.id)

packages/manager/src/features/ObjectStorage/AccessKeyLanding/AccessKeyRegions/AccessKeyRegions.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22

33
import { RegionMultiSelect } from 'src/components/RegionSelect/RegionMultiSelect';
4-
import { useRegionsQuery } from 'src/queries/regions/regions';
4+
import { useObjectStorageRegions } from 'src/features/ObjectStorage/hooks/useObjectStorageRegions';
55
import { sortByString } from 'src/utilities/sort-by';
66

77
import type { Region } from '@linode/api-v4';
@@ -22,10 +22,13 @@ const sortRegionOptions = (a: Region, b: Region) => {
2222
export const AccessKeyRegions = (props: Props) => {
2323
const { disabled, error, onChange, required, selectedRegion } = props;
2424

25-
const { data: regions, error: regionsError } = useRegionsQuery();
25+
const {
26+
allRegionsError,
27+
availableStorageRegions,
28+
} = useObjectStorageRegions();
2629

2730
// Error could be: 1. General Regions error, 2. Field error, 3. Nothing
28-
const errorText = error || regionsError?.[0]?.reason;
31+
const errorText = error || allRegionsError?.[0]?.reason;
2932

3033
return (
3134
<RegionMultiSelect
@@ -38,7 +41,7 @@ export const AccessKeyRegions = (props: Props) => {
3841
isClearable={false}
3942
label="Regions"
4043
onChange={onChange}
41-
regions={regions ?? []}
44+
regions={availableStorageRegions ?? []}
4245
required={required}
4346
selectedIds={selectedRegion}
4447
sortRegionOptions={sortRegionOptions}

0 commit comments

Comments
 (0)