From 37a7e48648668341ff205a5c5983fecda2b21a91 Mon Sep 17 00:00:00 2001 From: Patrick Ear Date: Thu, 19 Sep 2024 16:20:30 +0200 Subject: [PATCH 1/2] ARTESCA-13337 - fix error edit lock setting --- .../databrowser/objects/ObjectLockSetting.tsx | 11 +++++++---- .../details/__tests__/Properties.test.tsx | 18 ++++++------------ src/react/databrowser/objects/utils.ts | 9 +++++---- src/types/s3.ts | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/react/databrowser/objects/ObjectLockSetting.tsx b/src/react/databrowser/objects/ObjectLockSetting.tsx index 61301573b..8130dcc3f 100644 --- a/src/react/databrowser/objects/ObjectLockSetting.tsx +++ b/src/react/databrowser/objects/ObjectLockSetting.tsx @@ -137,7 +137,10 @@ export default function ObjectLockSetting() { useEffect(() => { setValue('isRetentionEnabled', isDefaultRetentionEnabled); setValue('retentionMode', defaultRetentionMode); - setValue('retentionUntilDate', defaultRetentionUntilDate); + setValue( + 'retentionUntilDate', + DateTime.fromJSDate(defaultRetentionUntilDate).toFormat('yyyy-LL-dd'), + ); }, [ setValue, isDefaultRetentionEnabled, @@ -285,9 +288,9 @@ export default function ObjectLockSetting() { type="date" name="retention-until-date" disabled={!isRetentionEnabled} - onChange={(e: ChangeEvent) => - onChange(e.target.value) - } + onChange={(e: ChangeEvent) => { + onChange(e.target.value); + }} value={retentionUntilDate} min={minRetainUtilDate} /> diff --git a/src/react/databrowser/objects/details/__tests__/Properties.test.tsx b/src/react/databrowser/objects/details/__tests__/Properties.test.tsx index 46b0f7f69..70a834e0b 100644 --- a/src/react/databrowser/objects/details/__tests__/Properties.test.tsx +++ b/src/react/databrowser/objects/details/__tests__/Properties.test.tsx @@ -89,11 +89,10 @@ describe('Properties', () => { , @@ -120,11 +119,10 @@ describe('Properties', () => { , @@ -145,11 +143,10 @@ describe('Properties', () => { { { { Date: Thu, 19 Sep 2024 16:35:10 +0200 Subject: [PATCH 2/2] fix types --- .../__tests__/ObjectLockSetting.test.tsx | 4 +- .../objects/details/Properties.tsx | 77 ++++++++----------- .../details/__tests__/Properties.test.tsx | 4 +- 3 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/react/databrowser/objects/__tests__/ObjectLockSetting.test.tsx b/src/react/databrowser/objects/__tests__/ObjectLockSetting.test.tsx index f4c7bc834..86d5f1304 100644 --- a/src/react/databrowser/objects/__tests__/ObjectLockSetting.test.tsx +++ b/src/react/databrowser/objects/__tests__/ObjectLockSetting.test.tsx @@ -42,7 +42,7 @@ describe('ObjectLockSetting', () => { bucketName: 'test-bucket', objectRetention: { mode: 'GOVERNANCE', - retainUntilDate: '2022-01-31 00:00:00"', + retainUntilDate: new Date('2022-01-31 00:00:00'), }, }, }, @@ -72,7 +72,7 @@ describe('ObjectLockSetting', () => { bucketName: 'test-bucket', objectRetention: { mode: 'COMPLIANCE', - retainUntilDate: '2022-01-31 00:00:00"', + retainUntilDate: new Date('2022-01-31 00:00:00'), }, }, }, diff --git a/src/react/databrowser/objects/details/Properties.tsx b/src/react/databrowser/objects/details/Properties.tsx index 269856c12..ed57106e8 100644 --- a/src/react/databrowser/objects/details/Properties.tsx +++ b/src/react/databrowser/objects/details/Properties.tsx @@ -2,7 +2,7 @@ import Table, * as T from '../../../ui-elements/TableKeyValue2'; import { Clipboard } from '../../../ui-elements/Clipboard'; import MiddleEllipsis from '../../../ui-elements/MiddleEllipsis'; -import type { ObjectMetadata } from '../../../../types/s3'; +import type { ObjectEntity, ObjectMetadata } from '../../../../types/s3'; import { FormattedDateTime, Icon, @@ -31,7 +31,7 @@ import { } from '../../../ui-elements/Veeam/VeeamConstants'; type Props = { - objectMetadata: ObjectMetadata; + objectMetadata: ObjectMetadata & { lockStatus?: ObjectEntity['lockStatus'] }; }; const TruncatedValue = styled.div` max-width: 18rem; @@ -203,47 +203,38 @@ function Properties({ objectMetadata }: Props) { Lock
- { - //@ts-expect-error fix this when you are working on it - objectMetadata.lockStatus === 'LOCKED' && ( - <> - Locked ( - {objectMetadata.objectRetention.mode.toLowerCase()}) -
- until{' '} - - - ) - } - { - //@ts-expect-error fix this when you are working on it - objectMetadata.lockStatus === 'RELEASED' && ( - <> - Released -
- since{' '} - - - ) - } - { - //@ts-expect-error fix this when you are working on it - objectMetadata.lockStatus === 'NONE' && 'No retention' - } + {objectMetadata.lockStatus === 'LOCKED' && ( + <> + Locked ( + {objectMetadata.objectRetention.mode.toLowerCase()}) +
+ until{' '} + + + )} + {objectMetadata.lockStatus === 'RELEASED' && ( + <> + Released +
+ since{' '} + + + )} + {objectMetadata.lockStatus === 'NONE' && 'No retention'}
{isObjectLockEnabled && (