Skip to content

Commit

Permalink
ZKUI-397: Change the usecase tag to X-Scality-Usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengYanJin committed Nov 9, 2023
1 parent 28a7f9e commit ac73c46
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
30 changes: 16 additions & 14 deletions src/react/databrowser/buckets/details/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import { useWorkflows } from '../../../workflow/Workflows';
import { useEffect, useState } from 'react';
import { Button } from '@scality/core-ui/dist/next';
import {
BUCKET_TAG_USECASE,
VEEAMVERSION11,
VEEAMVERSION12,
} from '../../../ui-elements/Veeam/VeeamConfiguration';
} from '../../../ui-elements/Veeam/VeeamConstants';

function capitalize(string: string) {
return string.toLowerCase().replace(/^\w/, (c) => {
Expand Down Expand Up @@ -97,15 +98,16 @@ function Overview({ bucket, ingestionStates }: Props) {
const [isErrorModalOpen, setIsErrorModalOpen] = useState(false);

const { tags } = useBucketTagging({ bucketName: bucket.name });
console.log('fff', features.includes('Veeam'));
console.log('tags', tags);
const VEEAM_FEATURE_FLAG_ENABLED = features.includes('Veeam');
const isVeeamBucket =
tags.status === 'success' &&
(tags.value?.Usecase === VEEAMVERSION11 ||
tags.value?.Usecase === VEEAMVERSION12) &&
features.includes('Veeam');
const isVeeam12 = isVeeamBucket && tags.value.Usecase === VEEAMVERSION12;
console.log({ isVeeamBucket });
(tags.value?.[BUCKET_TAG_USECASE] === VEEAMVERSION11 ||
tags.value?.[BUCKET_TAG_USECASE] === VEEAMVERSION12) &&
VEEAM_FEATURE_FLAG_ENABLED;

const isVeeam12 =
isVeeamBucket && tags.value?.[BUCKET_TAG_USECASE] === VEEAMVERSION12;

useEffect(() => {
dispatch(getBucketInfo(bucket.name));
}, [dispatch, bucket.name]);
Expand Down Expand Up @@ -252,7 +254,7 @@ function Overview({ bucket, ingestionStates }: Props) {
<T.GroupName> Use-case </T.GroupName>
<T.Row>
<T.Key> Use-case </T.Key>
<T.Value> Backup - {tags.value.Usecase}</T.Value>
<T.Value> Backup - {tags.value?.[BUCKET_TAG_USECASE]}</T.Value>
</T.Row>
{isVeeam12 && (
<T.Row>
Expand Down Expand Up @@ -281,11 +283,7 @@ function Overview({ bucket, ingestionStates }: Props) {
<T.Row>
<T.Key> Default Object-lock Retention </T.Key>
<T.GroupValues>
{isVeeamBucket ? (
<>Managed by Veeam</>
) : (
<div>{getDefaultBucketRetention(bucketInfo)}</div>
)}
<div>{getDefaultBucketRetention(bucketInfo)}</div>
<Button
id="edit-retention-btn"
variant="outline"
Expand All @@ -297,6 +295,10 @@ function Overview({ bucket, ingestionStates }: Props) {
);
}}
disabled={isVeeamBucket}
tooltip={{
overlay:
'Edition is disabled as it is managed by Veeam.',
}}
/>
</T.GroupValues>
</T.Row>
Expand Down
7 changes: 2 additions & 5 deletions src/react/next-architecture/domain/business/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,9 @@ export const queries = {
enabled: !!buckets.length,
...noRefetchOptions,
}),
getBucketTagging: (s3Client: S3, bucketName?: string) => ({
getBucketTagging: (s3Client: S3, bucketName: string) => ({
queryKey: ['bucketTagging', getS3ClientHash(s3Client), bucketName],
queryFn: () =>
s3Client
.getBucketTagging({ Bucket: notFalsyTypeGuard(bucketName) })
.promise(),
queryFn: () => s3Client.getBucketTagging({ Bucket: bucketName }).promise(),
enabled: !!bucketName && !!s3Client.config.credentials?.accessKeyId,
...noRefetchOptions,
}),
Expand Down
4 changes: 1 addition & 3 deletions src/react/ui-elements/Veeam/VeeamConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { Button, Input, Select } from '@scality/core-ui/dist/next';
import { useRef, useState } from 'react';
import { Controller, useForm } from 'react-hook-form';
import VeeamTable from './VeeamTable';

export const VEEAMVERSION11 = 'Veeam 11';
export const VEEAMVERSION12 = 'Veeam 12';
import { VEEAMVERSION11, VEEAMVERSION12 } from './VeeamConstants';

const schema = Joi.object({
name: Joi.string().required(),
Expand Down
3 changes: 3 additions & 0 deletions src/react/ui-elements/Veeam/VeeamConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const BUCKET_TAG_USECASE = 'X-Scality-Usecase';
export const VEEAMVERSION11 = 'Veeam 11';
export const VEEAMVERSION12 = 'Veeam 12';

0 comments on commit ac73c46

Please sign in to comment.