From 1922af492d7e8f04d7ac82adaaf0843799d18a03 Mon Sep 17 00:00:00 2001 From: Banks Nussman <115251059+bnussman-akamai@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:36:35 -0400 Subject: [PATCH] upcoming: [M3-8613] - Restrict Image Upload to regions with Object Storage (#11038) * limit upload regions based on feature flag * add flag to disallow non-obj regions * update cypress test to use compatible region * Added changeset: Restrict Image Upload to regions with Object Storage --------- Co-authored-by: Banks Nussman --- .../.changeset/pr-11038-upcoming-features-1727969322447.md | 5 +++++ .../cypress/e2e/core/images/machine-image-upload.spec.ts | 2 +- .../manager/src/components/RegionSelect/RegionSelect.tsx | 4 +++- .../src/components/RegionSelect/RegionSelect.types.ts | 7 +++++-- packages/manager/src/featureFlags.ts | 1 + .../src/features/Images/ImagesCreate/ImageUpload.tsx | 7 ++++++- 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 packages/manager/.changeset/pr-11038-upcoming-features-1727969322447.md diff --git a/packages/manager/.changeset/pr-11038-upcoming-features-1727969322447.md b/packages/manager/.changeset/pr-11038-upcoming-features-1727969322447.md new file mode 100644 index 00000000000..4ff0320ddac --- /dev/null +++ b/packages/manager/.changeset/pr-11038-upcoming-features-1727969322447.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +Restrict Image Upload to regions with Object Storage ([#11038](https://github.com/linode/manager/pull/11038)) diff --git a/packages/manager/cypress/e2e/core/images/machine-image-upload.spec.ts b/packages/manager/cypress/e2e/core/images/machine-image-upload.spec.ts index 25339973135..3f265228211 100644 --- a/packages/manager/cypress/e2e/core/images/machine-image-upload.spec.ts +++ b/packages/manager/cypress/e2e/core/images/machine-image-upload.spec.ts @@ -112,7 +112,7 @@ const assertProcessing = (label: string, id: string) => { * @param label - Label to apply to uploaded image. */ const uploadImage = (label: string) => { - const region = chooseRegion(); + const region = chooseRegion({ capabilities: ['Object Storage'] }); const upload = 'machine-images/test-image.gz'; cy.visitWithLogin('/images/create/upload'); getClick('[id="label"][data-testid="textfield-input"]').type(label); diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.tsx b/packages/manager/src/components/RegionSelect/RegionSelect.tsx index 4a48d2fd9b5..cb126df244a 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.tsx +++ b/packages/manager/src/components/RegionSelect/RegionSelect.tsx @@ -50,6 +50,7 @@ export const RegionSelect = < disabledRegions: disabledRegionsFromProps, errorText, helperText, + ignoreAccountAvailability, label, onChange, placeholder, @@ -67,7 +68,7 @@ export const RegionSelect = < const { data: accountAvailability, isLoading: accountAvailabilityLoading, - } = useAllAccountAvailabilitiesQuery(); + } = useAllAccountAvailabilitiesQuery(!ignoreAccountAvailability); const regionOptions = getRegionOptions({ currentCapability, @@ -86,6 +87,7 @@ export const RegionSelect = < acc[region.id] = disabledRegionsFromProps[region.id]; } if ( + !ignoreAccountAvailability && isRegionOptionUnavailable({ accountAvailabilityData: accountAvailability, currentCapability, diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.types.ts b/packages/manager/src/components/RegionSelect/RegionSelect.types.ts index 0a394d1a833..8c46d66c574 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.types.ts +++ b/packages/manager/src/components/RegionSelect/RegionSelect.types.ts @@ -44,8 +44,6 @@ export interface RegionSelectProps< * The specified capability to filter the regions on. Any region that does not have the `currentCapability` will not appear in the RegionSelect dropdown. * Only use `undefined` for situations where there is no relevant capability for the RegionSelect - this will not filter any of the regions passed in. * Otherwise, a capability should always be passed in. - * - * See `ImageUpload.tsx` for an example of a RegionSelect with an undefined `currentCapability` - there is no capability associated with Images yet. */ currentCapability: Capabilities | undefined; /** @@ -53,6 +51,11 @@ export interface RegionSelectProps< */ disabledRegions?: Record; helperText?: string; + /** + * Ignores account availability information when rendering region options + * @default false + */ + ignoreAccountAvailability?: boolean; label?: string; regionFilter?: RegionFilterValue; regions: Region[]; diff --git a/packages/manager/src/featureFlags.ts b/packages/manager/src/featureFlags.ts index 39c8ea3c9f4..444dadd7e16 100644 --- a/packages/manager/src/featureFlags.ts +++ b/packages/manager/src/featureFlags.ts @@ -96,6 +96,7 @@ export interface Flags { databases: boolean; dbaasV2: BetaFeatureFlag; disableLargestGbPlans: boolean; + disallowImageUploadToNonObjRegions: boolean; gecko2: GeckoFeatureFlag; gpuv2: gpuV2; imageServiceGen2: boolean; diff --git a/packages/manager/src/features/Images/ImagesCreate/ImageUpload.tsx b/packages/manager/src/features/Images/ImagesCreate/ImageUpload.tsx index e986e99db95..706ed3e603a 100644 --- a/packages/manager/src/features/Images/ImagesCreate/ImageUpload.tsx +++ b/packages/manager/src/features/Images/ImagesCreate/ImageUpload.tsx @@ -255,6 +255,11 @@ export const ImageUpload = () => { ( { inputRef: field.ref, onBlur: field.onBlur, }} - currentCapability={undefined} disableClearable errorText={fieldState.error?.message} + ignoreAccountAvailability label="Region" onChange={(e, region) => field.onChange(region.id)} regionFilter="core" // Images service will not be supported for Gecko Beta