Skip to content

Commit

Permalink
ZKUI-373 // disable list versions for veeam xml
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Aug 21, 2023
1 parent 060a9f7 commit 31bfd3e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/react/databrowser/objects/ObjectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type Props = {
toggled: List<ObjectEntity>;
listType: ListObjectsType;
};

export const VEEAM_XML_PREFIX = '.system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c';

export default function ObjectList({
objects,
bucketName,
Expand All @@ -37,6 +40,7 @@ export default function ObjectList({
const { pathname } = useLocation();
const query = useQueryParams();
const searchInput = query.get('metadatasearch');
const prefixPath = query.get('prefix');

const { versionning } = useBucketVersionning({ bucketName });

Expand All @@ -51,6 +55,7 @@ export default function ObjectList({
const isMetadataType = !!searchInput;
const isVersioningType = listType === LIST_OBJECT_VERSIONS_S3_TYPE;
const isToggledEmpty = toggled.size === 0;
const isVeeamXML = prefixPath?.includes(VEEAM_XML_PREFIX);

const maybeListTable = () => {
if (errorZenkoMsg) {
Expand Down Expand Up @@ -106,7 +111,7 @@ export default function ObjectList({
/>
<Toggle
id="list-versions-toggle"
disabled={isMetadataType || !isBucketVersioned}
disabled={isMetadataType || !isBucketVersioned || isVeeamXML}
toggle={isVersioningType}
label="List Versions"
onChange={() => {
Expand Down
27 changes: 26 additions & 1 deletion src/react/databrowser/objects/__tests__/ObjectList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as hooks from '../../../next-architecture/domain/business/buckets';
import * as queryHooks from '../../../utils/hooks';
import * as s3object from '../../../actions/s3object';
import {
FIRST_FORMATTED_OBJECT,
Expand All @@ -8,7 +9,7 @@ import { LIST_OBJECTS_S3_TYPE } from '../../../utils/s3';
import { checkBox, reduxMount } from '../../../utils/testUtil';
import { BUCKET_NAME } from '../../../actions/__tests__/utils/testUtil';
import { List } from 'immutable';
import ObjectList from '../ObjectList';
import ObjectList, { VEEAM_XML_PREFIX } from '../ObjectList';
import router from 'react-router';
import { waitFor } from '@testing-library/react';
describe('ObjectList', () => {
Expand Down Expand Up @@ -204,4 +205,28 @@ describe('ObjectList', () => {
expect(toggle.prop('disabled')).toBe(true);
});
});

it.only('should disable versioning toggle if it is a veeam xml folder', async () => {
jest.spyOn(hooks, 'useBucketVersionning').mockReturnValue({
versionning: { status: 'success', value: 'Enabled' },
});
jest
.spyOn(queryHooks, 'useQueryParams')
.mockReturnValue(new URLSearchParams(`?prefix=${VEEAM_XML_PREFIX}`));

const { component } = reduxMount(
<ObjectList
objects={List([FIRST_FORMATTED_OBJECT])}
toggled={List()}
bucketName={BUCKET_NAME}
prefixWithSlash=""
listType={LIST_OBJECTS_S3_TYPE}
/>,
);

await waitFor(() => {
const toggle = component.find('ToggleSwitch#list-versions-toggle');
expect(toggle.prop('disabled')).toBe(true);
});
});
});

0 comments on commit 31bfd3e

Please sign in to comment.