diff --git a/src/js/mock/S3Client.ts b/src/js/mock/S3Client.ts index 0aae044e9..7d062a455 100644 --- a/src/js/mock/S3Client.ts +++ b/src/js/mock/S3Client.ts @@ -174,6 +174,22 @@ export const bucketInfoResponseVersioningDisabled: BucketInfo = { ObjectLockEnabled: 'Disabled', }, }; + +export const BucketWithObjectLockDisabled: BucketInfo = { + name: bucketName, + policy: false, + owner: ownerName, + aclGrantees: 0, + cors: false, + versioning: 'Disabled', + isVersioning: false, + public: false, + locationConstraint: '', + objectLockConfiguration: { + ObjectLockEnabled: 'Disabled', + }, +}; + export class MockS3Client implements S3ClientInterface { listBucketsWithLocation() { return Promise.resolve({ diff --git a/src/react/databrowser/buckets/details/Overview.tsx b/src/react/databrowser/buckets/details/Overview.tsx index 0982335ed..adc327e85 100644 --- a/src/react/databrowser/buckets/details/Overview.tsx +++ b/src/react/databrowser/buckets/details/Overview.tsx @@ -93,7 +93,13 @@ const workflowAttachedError = (count: number, bucketName: string) => ( ); -function VersionningValue({ bucketInfo }: { bucketInfo: BucketInfo }) { +function VersionningValue({ + bucketInfo, + isVeeamBucket, +}: { + bucketInfo: BucketInfo; + isVeeamBucket: boolean; +}) { const dispatch = useDispatch(); const accountsLocationsEndpointsAdapter = useAccountsLocationsEndpointsAdapter(); @@ -114,6 +120,11 @@ function VersionningValue({ bucketInfo }: { bucketInfo: BucketInfo }) { }, }); }; + const isVersioningToggleDisabled = + locationsStatus === 'idle' || + locationsStatus === 'loading' || + isBucketHostedOnAzureOrGCP || + isVeeamBucket; return ( @@ -130,15 +141,17 @@ function VersionningValue({ bucketInfo }: { bucketInfo: BucketInfo }) { Enabling versioning is not possible due to the bucket being hosted on Google Cloud. + ) : isVeeamBucket ? ( + <> + Enabling versioning is not possible due to the bucket being + managed by Veeam. + ) : null } > - Versioning - + Versioning + Location diff --git a/src/react/databrowser/buckets/details/__tests__/Overview.test.tsx b/src/react/databrowser/buckets/details/__tests__/Overview.test.tsx index 9f54b4ef0..321374e6d 100644 --- a/src/react/databrowser/buckets/details/__tests__/Overview.test.tsx +++ b/src/react/databrowser/buckets/details/__tests__/Overview.test.tsx @@ -1,5 +1,4 @@ import { - fireEvent, render, screen, waitFor, @@ -9,6 +8,7 @@ import { import userEvent from '@testing-library/user-event'; import Immutable from 'immutable'; import { + BucketWithObjectLockDisabled, bucketInfoResponseNoVersioning, bucketInfoResponseObjectLockDefaultRetention, bucketInfoResponseObjectLockNoDefaultRetention, @@ -195,17 +195,8 @@ describe('Overview', () => { ); await waitForElementToBeRemoved(() => screen.getByText(/loading/i)); await waitFor(() => { - expect( - screen.getByRole('checkbox', { - name: /inactive/i, - }), - ).toBeInTheDocument(); - }); - const versioningToggleItem = screen.getByRole('checkbox', { - name: /inactive/i, + expect(selectors.versioningToggle()).toBeDisabled(); }); - //V - expect(versioningToggleItem).toHaveAttribute('disabled'); }); }); @@ -302,6 +293,7 @@ const selectors = { screen.getByRole('generic', { name: /indicate if object lock is enabled/i, }), + versioningToggle: () => screen.getByLabelText(/inactive/i), }; describe('Overview', () => { @@ -322,22 +314,14 @@ describe('Overview', () => { undefined, { ...TEST_STATE, - ...{ s3: { bucketInfo: bucketInfoResponseVersioningDisabled } }, + ...{ s3: { bucketInfo: BucketWithObjectLockDisabled } }, }, ); - - const versioningToggleItem = screen - .getByRole('checkbox', { - name: /inactive/i, - }) - .querySelector('input'); - await waitFor(() => { - expect(versioningToggleItem).toBeInTheDocument(); + expect(selectors.versioningToggle()).toBeEnabled(); }); - versioningToggleItem && fireEvent.click(versioningToggleItem); - + await userEvent.click(selectors.versioningToggle()); await waitFor(() => { expect(useUpdateBucketVersioningMock).toHaveBeenCalledWith(mockResponse); }); @@ -411,4 +395,25 @@ describe('Overview', () => { expect(selectors.bucketTaggingErorToastQuery()).toBe(null); }); }); + + it('should disable the versioning toggle for Veeam bucket', async () => { + //S + server.use(mockGetBucketTagging(bucketName)); + //E + render( + , + { + wrapper: NewWrapper('/', { + s3: { bucketInfo: BucketWithObjectLockDisabled }, + }), + }, + ); + //V + await waitFor(() => { + expect(selectors.versioningToggle()).toBeDisabled(); + }); + }); });