Skip to content

Commit

Permalink
ARTESCA-12108: Disable the version toogle for Veeam bucket and adding…
Browse files Browse the repository at this point in the history
… a tooltip of explaination
  • Loading branch information
ChengYanJin committed May 6, 2024
1 parent 8c89610 commit 81efb64
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/js/mock/S3Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,22 @@ export const bucketInfoResponseVersioningDisabled: BucketInfo = {
ObjectLockEnabled: 'Disabled',
},
};

export const VeeamBucketWithObjectLockDisabled: 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({
Expand Down
22 changes: 19 additions & 3 deletions src/react/databrowser/buckets/details/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ const workflowAttachedError = (count: number, bucketName: string) => (
</div>
);

function VersionningValue({ bucketInfo }: { bucketInfo: BucketInfo }) {
function VersionningValue({
bucketInfo,
isVeeamBucket,
}: {
bucketInfo: BucketInfo;
isVeeamBucket: boolean;
}) {
const dispatch = useDispatch();
const accountsLocationsEndpointsAdapter =
useAccountsLocationsEndpointsAdapter();
Expand Down Expand Up @@ -130,14 +136,21 @@ 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
}
>
<Toggle
aria-label="versioningToggle"
disabled={
locationsStatus === 'idle' ||
locationsStatus === 'loading' ||
isBucketHostedOnAzureOrGCP
isBucketHostedOnAzureOrGCP ||
isVeeamBucket
}
toggle={bucketInfo.isVersioning}
label={
Expand Down Expand Up @@ -285,7 +298,10 @@ function Overview({ bucket, ingestionStates }: Props) {
</T.Row>
<T.Row>
<T.Key> Versioning </T.Key>
<VersionningValue bucketInfo={bucketInfo} />
<VersionningValue
bucketInfo={bucketInfo}
isVeeamBucket={isVeeamBucket}
/>
</T.Row>
<T.Row>
<T.Key> Location </T.Key>
Expand Down
21 changes: 21 additions & 0 deletions src/react/databrowser/buckets/details/__tests__/Overview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import userEvent from '@testing-library/user-event';
import Immutable from 'immutable';
import {
VeeamBucketWithObjectLockDisabled,
bucketInfoResponseNoVersioning,
bucketInfoResponseObjectLockDefaultRetention,
bucketInfoResponseObjectLockNoDefaultRetention,
Expand Down Expand Up @@ -302,6 +303,7 @@ const selectors = {
screen.getByRole('generic', {
name: /indicate if object lock is enabled/i,
}),
inactionVersioningToggle: () => screen.getByLabelText('versioningToggle'),
};

describe('Overview', () => {
Expand Down Expand Up @@ -411,4 +413,23 @@ describe('Overview', () => {
expect(selectors.bucketTaggingErorToastQuery()).toBe(null);
});
});

it('should disable the versioning toggle for Veeam bucket', async () => {
//Setup
server.use(mockGetBucketTagging(bucketName));
//Exercise
render(
<Overview
//@ts-expect-error fix this when you are working on it
bucket={{ name: bucketName }}
/>,
{
wrapper: NewWrapper('/', {
s3: { bucketInfo: VeeamBucketWithObjectLockDisabled },
}),
},
);
//Verify
expect(selectors.inactionVersioningToggle()).toBeDisabled();
});
});

0 comments on commit 81efb64

Please sign in to comment.