Skip to content

Commit 2e95628

Browse files
committed
fix(pci-block-storage): add feature flipping
ref: #TAPC-5227 Signed-off-by: Adrien Turmo <[email protected]>
1 parent 5ab14f8 commit 2e95628

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { usePCIFeatureAvailability } from '@ovh-ux/manager-pci-common';
2+
3+
export const FILE_STORAGE_ALPHA = 'pci-block-storage:file-storage-alpha-banner';
4+
5+
export const useIsFileStorageAlphaBannerAvailable = () => {
6+
const { data } = usePCIFeatureAvailability([FILE_STORAGE_ALPHA]);
7+
8+
return data?.get(FILE_STORAGE_ALPHA) ?? false;
9+
};

packages/manager/apps/pci-block-storage/src/components/banner/FileStorageAlphaBanner.component.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { useTranslation } from 'react-i18next';
33
import { useGeneralBannerContext } from '@/contexts/GeneralBanner.context';
44
import { Banner } from '@/components/banner/Banner.component';
55
import { ButtonLink } from '@/components/button-link/ButtonLink';
6+
import { useIsFileStorageAlphaBannerAvailable } from '@/api/feature';
67

78
export const FileStorageAlphaBanner = () => {
89
const { t } = useTranslation(['general-banners']);
910

1011
const { addBanner, getBanner } = useGeneralBannerContext();
12+
const isFileStorageAlphaBannerAvailable = useIsFileStorageAlphaBannerAvailable();
1113

1214
useEffect(() => {
15+
if (!isFileStorageAlphaBannerAvailable) return;
16+
1317
addBanner('alpha_file_storage', ({ onRemove }) => (
1418
<Banner
1519
iconName="circle-info"
@@ -34,7 +38,7 @@ export const FileStorageAlphaBanner = () => {
3438
</div>
3539
</Banner>
3640
));
37-
}, []);
41+
}, [isFileStorageAlphaBannerAvailable]);
3842

3943
return getBanner('alpha_file_storage');
4044
};

packages/manager/apps/pci-block-storage/src/pages/list/List.page.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { waitFor } from '@testing-library/react';
22
import { describe, it, vi } from 'vitest';
33
import ListingPage from './List.page';
44
import { renderWithMockedWrappers } from '@/__tests__/renderWithMockedWrappers';
5+
import { useIsFileStorageAlphaBannerAvailable } from '@/api/feature';
56

67
vi.mock('@ovh-ux/manager-react-shell-client', async (importOriginal) => {
78
const actual: any = await importOriginal();
@@ -93,6 +94,10 @@ vi.mock('@/api/hooks/useVolume', () => ({
9394
})),
9495
}));
9596

97+
vi.mock('@/api/feature', () => ({
98+
useIsFileStorageAlphaBannerAvailable: () => true,
99+
}));
100+
96101
afterEach(() => {
97102
vi.clearAllMocks();
98103
});

0 commit comments

Comments
 (0)