Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Add support for `privateImageSharing` feature flag for Private Image Sharing feature ([#12992](https://github.com/linode/manager/pull/12992))
1 change: 1 addition & 0 deletions packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const options: { flag: keyof Flags; label: string }[] = [
{ flag: 'nodebalancerVpc', label: 'NodeBalancer-VPC Integration' },
{ flag: 'objMultiCluster', label: 'OBJ Multi-Cluster' },
{ flag: 'objectStorageGen2', label: 'OBJ Gen2' },
{ flag: 'privateImageSharing', label: 'Private Image Sharing' },
{ flag: 'selfServeBetas', label: 'Self Serve Betas' },
{ flag: 'supportTicketSeverity', label: 'Support Ticket Severity' },
{ flag: 'dbaasV2', label: 'Databases V2 Beta' },
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export interface Flags {
objectStorageGen2: BaseFeatureFlag;
objMultiCluster: boolean;
objSummaryPage: boolean;
privateImageSharing: boolean;
productInformationBanners: ProductInformationBannerFlag[];
promos: boolean;
promotionalOffers: PromotionalOffer[];
Expand Down
34 changes: 33 additions & 1 deletion packages/manager/src/features/Images/utils.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { linodeFactory } from '@linode/utilities';
import { renderHook, waitFor } from '@testing-library/react';

import { eventFactory, imageFactory } from 'src/factories';
import { wrapWithTheme } from 'src/utilities/testHelpers';

import { getEventsForImages, getImageLabelForLinode } from './utils';
import {
getEventsForImages,
getImageLabelForLinode,
useIsPrivateImageSharingEnabled,
} from './utils';

describe('getImageLabelForLinode', () => {
it('handles finding an image and getting the label', () => {
Expand Down Expand Up @@ -57,3 +63,29 @@ describe('getEventsForImages', () => {
});
});
});

describe('useIsPrivateImageSharingEnabled', () => {
it('returns true if the feature is enabled', async () => {
const options = { flags: { privateImageSharing: true } };

const { result } = renderHook(() => useIsPrivateImageSharingEnabled(), {
wrapper: (ui) => wrapWithTheme(ui, options),
});

await waitFor(() => {
expect(result.current.isPrivateImageSharingEnabled).toBe(true);
});
});

it('returns false if the feature is NOT enabled', async () => {
const options = { flags: { privateImageSharing: false } };

const { result } = renderHook(() => useIsPrivateImageSharingEnabled(), {
wrapper: (ui) => wrapWithTheme(ui, options),
});

await waitFor(() => {
expect(result.current.isPrivateImageSharingEnabled).toBe(false);
});
});
});
16 changes: 16 additions & 0 deletions packages/manager/src/features/Images/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRegionsQuery } from '@linode/queries';

import { DISALLOWED_IMAGE_REGIONS } from 'src/constants';
import { useFlags } from 'src/hooks/useFlags';

import type { Event, Image, Linode } from '@linode/api-v4';

Expand Down Expand Up @@ -39,3 +40,18 @@
) ?? [],
};
};

/**
* Returns whether or not features related to the Private Image Sharing project
* should be enabled.
*
* Currently, this just uses the `privateImageSharing` feature flag as a source of truth,
* but will eventually also look at account capabilities.
*/

export const useIsPrivateImageSharingEnabled = () => {
const flags = useFlags();

// @TODO Private Image Sharing: check for customer tag/account capability when it exists

Check warning on line 55 in packages/manager/src/features/Images/utils.ts

View workflow job for this annotation

GitHub Actions / ESLint Review (manager)

[eslint] reported by reviewdog 🐢 Complete the task associated to this "TODO" comment. Raw Output: {"ruleId":"sonarjs/todo-tag","severity":1,"message":"Complete the task associated to this \"TODO\" comment.","line":55,"column":7,"nodeType":null,"messageId":"completeTODO","endLine":55,"endColumn":11}
return { isPrivateImageSharingEnabled: flags.privateImageSharing ?? false };
};