@scality/data-browser-library 1.0.0-preview.9 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DataBrowserUI.d.ts +12 -0
- package/dist/components/DataBrowserUI.js +99 -0
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketAccessor.test.js +214 -0
- package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
- package/dist/components/__tests__/BucketCreate.test.js +271 -105
- package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
- package/dist/components/__tests__/BucketDetails.test.js +421 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +13 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +178 -178
- package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
- package/dist/components/__tests__/BucketList.test.js +463 -239
- package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
- package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
- package/dist/components/__tests__/BucketOverview.test.js +281 -266
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +15 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +544 -544
- package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
- package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
- package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
- package/dist/components/__tests__/EmptyBucketButton.test.js +59 -59
- package/dist/components/__tests__/MetadataSearch.test.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +741 -240
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/components/breadcrumb/Breadcrumb.js +37 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
- package/dist/components/breadcrumb/index.d.ts +8 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
- package/dist/components/buckets/BucketAccessor.d.ts +2 -0
- package/dist/components/buckets/BucketAccessor.js +125 -0
- package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
- package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
- package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
- package/dist/components/buckets/BucketCorsPage.js +234 -0
- package/dist/components/buckets/BucketCreate.d.ts +3 -2
- package/dist/components/buckets/BucketCreate.js +93 -47
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +249 -85
- package/dist/components/buckets/BucketLifecycleFormPage.js +225 -191
- package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
- package/dist/components/buckets/BucketLifecycleList.js +59 -61
- package/dist/components/buckets/BucketList.d.ts +7 -8
- package/dist/components/buckets/BucketList.js +158 -101
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +22 -2
- package/dist/components/buckets/BucketOverview.js +394 -187
- package/dist/components/buckets/BucketPage.js +43 -21
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.js +134 -133
- package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
- package/dist/components/buckets/BucketReplicationList.js +48 -45
- package/dist/components/buckets/BucketVersioning.d.ts +4 -0
- package/dist/components/buckets/BucketVersioning.js +76 -0
- package/dist/components/buckets/DeleteBucketButton.js +8 -8
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +2 -2
- package/dist/components/buckets/EmptyBucketButton.js +24 -24
- package/dist/components/buckets/EmptyBucketSummary.d.ts +2 -2
- package/dist/components/buckets/EmptyBucketSummary.js +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +1 -1
- package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
- package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
- package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
- package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
- package/dist/components/buckets/notifications/EventsSection.js +145 -29
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +27 -20
- package/dist/components/index.js +17 -10
- package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
- package/dist/components/layouts/ArrowNavigation.js +28 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
- package/dist/components/layouts/BrowserPageLayout.js +10 -5
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +12 -12
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +19 -21
- package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
- package/dist/components/objects/GetPresignedUrlButton.js +255 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +289 -230
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectTags.js +103 -123
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
- package/dist/components/objects/ObjectDetails/formUtils.d.ts +15 -0
- package/dist/components/objects/ObjectDetails/formUtils.js +7 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
- package/dist/components/objects/ObjectDetails/index.js +152 -40
- package/dist/components/objects/ObjectList.d.ts +12 -10
- package/dist/components/objects/ObjectList.js +590 -263
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +4 -4
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +15 -15
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +32 -31
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +51 -51
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +78 -78
- package/dist/components/objects/ObjectPage.js +12 -8
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +10 -10
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +21 -0
- package/dist/components/search/MetadataSearch.js +29 -28
- package/dist/components/search/SearchHints.js +1 -1
- package/dist/components/ui/ArrayFieldActions.js +12 -7
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +2 -2
- package/dist/components/ui/ConfirmDeleteRuleModal.js +6 -1
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- package/dist/components/ui/FilterFormSection.d.ts +2 -2
- package/dist/components/ui/FilterFormSection.js +29 -29
- package/dist/components/ui/Search.elements.d.ts +2 -2
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.d.ts +2 -1
- package/dist/components/ui/Table.elements.js +18 -12
- package/dist/config/__tests__/factory.test.d.ts +1 -0
- package/dist/config/__tests__/factory.test.js +311 -0
- package/dist/config/factory.d.ts +10 -56
- package/dist/config/factory.js +23 -71
- package/dist/config/types.d.ts +212 -34
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
- package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +45 -45
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +27 -27
- package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
- package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
- package/dist/hooks/bucketConfiguration.d.ts +8 -1
- package/dist/hooks/bucketConfiguration.js +52 -51
- package/dist/hooks/bucketOperations.d.ts +10 -1
- package/dist/hooks/bucketOperations.js +10 -9
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +65 -65
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/index.js +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +11 -6
- package/dist/hooks/index.d.ts +19 -12
- package/dist/hooks/index.js +16 -9
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +50 -49
- package/dist/hooks/presignedOperations.d.ts +4 -4
- package/dist/hooks/presignedOperations.js +5 -5
- package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
- package/dist/hooks/useAccessibleBuckets.js +115 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +48 -0
- package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
- package/dist/hooks/useBucketConfigEditor.js +82 -0
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
- package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
- package/dist/hooks/useEmptyBucket.js +11 -11
- package/dist/hooks/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.js +6 -6
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
- package/dist/hooks/useLimitedAccessFlow.js +23 -0
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/schemas/bucketPolicySchema.json +3 -13
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +32 -17
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +77 -54
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/index.js +1 -1
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +13 -30
- package/dist/test/testUtils.d.ts +85 -33
- package/dist/test/testUtils.js +176 -111
- package/dist/test/utils/errorHandling.test.js +119 -119
- package/dist/types/index.d.ts +50 -37
- package/dist/types/monaco.d.ts +13 -0
- package/dist/types/monaco.js +0 -0
- package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
- package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
- package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
- package/dist/utils/__tests__/s3Client.test.js +340 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +19 -9
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/index.js +1 -1
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +3 -3
- package/dist/utils/errorHandling.js +6 -6
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +4 -2
- package/dist/utils/proxyMiddleware.d.ts +32 -13
- package/dist/utils/proxyMiddleware.js +90 -36
- package/dist/utils/s3Client.d.ts +14 -4
- package/dist/utils/s3Client.js +5 -26
- package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
- package/dist/utils/s3ConfigIdentifier.js +57 -0
- package/dist/utils/s3RuleUtils.d.ts +5 -5
- package/dist/utils/s3RuleUtils.js +17 -17
- package/package.json +10 -8
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
- package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
- package/dist/hooks/useLoginMutation.d.ts +0 -21
- package/dist/hooks/useLoginMutation.js +0 -9
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
- /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
|
@@ -1,47 +1,74 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Icon, Loader, Text, spacing, useToast } from "@scality/core-ui";
|
|
3
|
+
import { convertSizeToRem } from "@scality/core-ui/dist/components/inputv2/inputv2";
|
|
4
4
|
import { Box, Button, Input, Select } from "@scality/core-ui/dist/next";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
|
5
7
|
import { useCopyObject, useObjectMetadata } from "../../../hooks/index.js";
|
|
8
|
+
import { useInvalidateQueries } from "../../providers/DataBrowserProvider.js";
|
|
9
|
+
import { ArrayFieldActions } from "../../ui/ArrayFieldActions.js";
|
|
6
10
|
import { TableContainer } from "../../ui/Table.elements.js";
|
|
11
|
+
import { hasFormDataChanged } from "./formUtils.js";
|
|
7
12
|
const METADATA_KEYS = [
|
|
8
13
|
{
|
|
9
|
-
key:
|
|
10
|
-
label:
|
|
14
|
+
key: 'CacheControl',
|
|
15
|
+
label: 'cache-control'
|
|
11
16
|
},
|
|
12
17
|
{
|
|
13
|
-
key:
|
|
14
|
-
label:
|
|
18
|
+
key: 'ContentDisposition',
|
|
19
|
+
label: 'content-disposition'
|
|
15
20
|
},
|
|
16
21
|
{
|
|
17
|
-
key:
|
|
18
|
-
label:
|
|
22
|
+
key: 'ContentEncoding',
|
|
23
|
+
label: 'content-encoding'
|
|
19
24
|
},
|
|
20
25
|
{
|
|
21
|
-
key:
|
|
22
|
-
label:
|
|
26
|
+
key: 'ContentType',
|
|
27
|
+
label: 'content-type'
|
|
23
28
|
},
|
|
24
29
|
{
|
|
25
|
-
key:
|
|
26
|
-
label:
|
|
30
|
+
key: 'WebsiteRedirectLocation',
|
|
31
|
+
label: 'website-redirect-location'
|
|
27
32
|
},
|
|
28
33
|
{
|
|
29
|
-
key:
|
|
30
|
-
label:
|
|
34
|
+
key: 'x-amz-meta',
|
|
35
|
+
label: 'x-amz-meta'
|
|
31
36
|
}
|
|
32
37
|
];
|
|
33
38
|
const ObjectMetadata = ({ bucketName, objectKey, versionId })=>{
|
|
39
|
+
const getVersionParams = ()=>versionId ? {
|
|
40
|
+
VersionId: versionId
|
|
41
|
+
} : {};
|
|
34
42
|
const { data: metadata, status: metadataStatus } = useObjectMetadata({
|
|
35
43
|
Bucket: bucketName,
|
|
36
44
|
Key: objectKey,
|
|
37
|
-
...
|
|
38
|
-
VersionId: versionId
|
|
39
|
-
}
|
|
45
|
+
...getVersionParams()
|
|
40
46
|
});
|
|
41
47
|
const copyObjectMutation = useCopyObject();
|
|
42
|
-
const
|
|
48
|
+
const { showToast } = useToast();
|
|
49
|
+
const invalidateQueries = useInvalidateQueries();
|
|
50
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
51
|
+
const [originalMetadata, setOriginalMetadata] = useState([]);
|
|
52
|
+
const { control, handleSubmit, setValue, watch, formState: { errors, isValid, isSubmitting } } = useForm({
|
|
53
|
+
mode: 'onChange',
|
|
54
|
+
defaultValues: {
|
|
55
|
+
metadata: []
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const { fields, append, remove } = useFieldArray({
|
|
59
|
+
control,
|
|
60
|
+
name: 'metadata'
|
|
61
|
+
});
|
|
62
|
+
const normalizeMetadata = (metadata)=>metadata.filter((row)=>{
|
|
63
|
+
const hasKey = 'x-amz-meta' === row.keyType ? row.customKey.trim() : row.keyType;
|
|
64
|
+
return hasKey && row.value.trim();
|
|
65
|
+
}).map((row)=>({
|
|
66
|
+
key: 'x-amz-meta' === row.keyType ? `x-amz-meta-${row.customKey.trim()}` : row.keyType,
|
|
67
|
+
value: row.value.trim()
|
|
68
|
+
})).sort((a, b)=>a.key.localeCompare(b.key));
|
|
69
|
+
const hasChanges = ()=>hasFormDataChanged(watch('metadata'), originalMetadata, normalizeMetadata);
|
|
43
70
|
useEffect(()=>{
|
|
44
|
-
|
|
71
|
+
setIsInitialized(false);
|
|
45
72
|
copyObjectMutation.reset();
|
|
46
73
|
}, [
|
|
47
74
|
bucketName,
|
|
@@ -49,114 +76,98 @@ const ObjectMetadata = ({ bucketName, objectKey, versionId })=>{
|
|
|
49
76
|
versionId
|
|
50
77
|
]);
|
|
51
78
|
useEffect(()=>{
|
|
52
|
-
if (metadata &&
|
|
79
|
+
if (metadata && 'success' === metadataStatus && !isInitialized) {
|
|
53
80
|
const rows = [];
|
|
54
81
|
const standardKeys = [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
'CacheControl',
|
|
83
|
+
'ContentDisposition',
|
|
84
|
+
'ContentEncoding',
|
|
85
|
+
'ContentType',
|
|
86
|
+
'WebsiteRedirectLocation'
|
|
60
87
|
];
|
|
61
88
|
standardKeys.forEach((keyType)=>{
|
|
62
89
|
const value = metadata[keyType];
|
|
63
90
|
if (value) rows.push({
|
|
64
|
-
id: `init-${rows.length}`,
|
|
65
91
|
keyType,
|
|
66
|
-
customKey:
|
|
92
|
+
customKey: '',
|
|
67
93
|
value
|
|
68
94
|
});
|
|
69
95
|
});
|
|
70
96
|
const userMetadata = metadata.Metadata || {};
|
|
71
97
|
Object.entries(userMetadata).forEach(([key, value])=>{
|
|
72
98
|
rows.push({
|
|
73
|
-
|
|
74
|
-
keyType: "x-amz-meta",
|
|
99
|
+
keyType: 'x-amz-meta',
|
|
75
100
|
customKey: key,
|
|
76
101
|
value: value
|
|
77
102
|
});
|
|
78
103
|
});
|
|
79
|
-
|
|
104
|
+
if (0 === rows.length) rows.push({
|
|
105
|
+
keyType: '',
|
|
106
|
+
customKey: '',
|
|
107
|
+
value: ''
|
|
108
|
+
});
|
|
109
|
+
setValue('metadata', rows);
|
|
110
|
+
setOriginalMetadata(rows);
|
|
111
|
+
setIsInitialized(true);
|
|
80
112
|
}
|
|
81
113
|
}, [
|
|
82
114
|
metadata,
|
|
83
|
-
metadataStatus
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setMetadataRows((prev)=>[
|
|
87
|
-
...prev,
|
|
88
|
-
{
|
|
89
|
-
id: `new-${Date.now()}`,
|
|
90
|
-
keyType: "",
|
|
91
|
-
customKey: "",
|
|
92
|
-
value: ""
|
|
93
|
-
}
|
|
94
|
-
]);
|
|
95
|
-
}, []);
|
|
96
|
-
const handleDeleteRow = useCallback((id)=>{
|
|
97
|
-
setMetadataRows((prev)=>prev.filter((row)=>row.id !== id));
|
|
98
|
-
}, []);
|
|
99
|
-
const handleRowChange = useCallback((id, field, value)=>{
|
|
100
|
-
setMetadataRows((prev)=>prev.map((row)=>row.id === id ? {
|
|
101
|
-
...row,
|
|
102
|
-
[field]: value,
|
|
103
|
-
..."keyType" === field && "x-amz-meta" !== value && {
|
|
104
|
-
customKey: ""
|
|
105
|
-
}
|
|
106
|
-
} : row));
|
|
107
|
-
}, []);
|
|
108
|
-
const validationErrors = useMemo(()=>{
|
|
109
|
-
const errors = [];
|
|
110
|
-
const seenKeys = new Set();
|
|
111
|
-
metadataRows.forEach((row, index)=>{
|
|
112
|
-
if (!row.keyType) return void errors.push(`Row ${index + 1}: Please select a metadata key`);
|
|
113
|
-
if ("x-amz-meta" === row.keyType && !row.customKey.trim()) return void errors.push(`Row ${index + 1}: Please provide a custom key name`);
|
|
114
|
-
if (!row.value.trim()) return void errors.push(`Row ${index + 1}: Please provide a value`);
|
|
115
|
-
const fullKey = "x-amz-meta" === row.keyType ? `x-amz-meta-${row.customKey}` : row.keyType;
|
|
116
|
-
if (seenKeys.has(fullKey)) errors.push(`Row ${index + 1}: Duplicate key "${"x-amz-meta" === row.keyType ? `x-amz-meta-${row.customKey}` : row.keyType}"`);
|
|
117
|
-
else seenKeys.add(fullKey);
|
|
118
|
-
});
|
|
119
|
-
return errors;
|
|
120
|
-
}, [
|
|
121
|
-
metadataRows
|
|
122
|
-
]);
|
|
123
|
-
const canSave = metadataRows.length > 0 && 0 === validationErrors.length;
|
|
124
|
-
const getAvailableOptions = useCallback((currentRowId)=>{
|
|
125
|
-
const usedKeys = new Set(metadataRows.filter((row)=>row.id !== currentRowId && "x-amz-meta" !== row.keyType).map((row)=>row.keyType));
|
|
126
|
-
return METADATA_KEYS.filter((key)=>"x-amz-meta" === key.key || !usedKeys.has(key.key));
|
|
127
|
-
}, [
|
|
128
|
-
metadataRows
|
|
115
|
+
metadataStatus,
|
|
116
|
+
setValue,
|
|
117
|
+
isInitialized
|
|
129
118
|
]);
|
|
130
|
-
const
|
|
131
|
-
|
|
119
|
+
const getAvailableOptions = (currentIndex)=>{
|
|
120
|
+
const allMetadata = watch('metadata') || [];
|
|
121
|
+
const usedKeys = new Set(allMetadata.filter((row, idx)=>idx !== currentIndex && 'x-amz-meta' !== row.keyType).map((row)=>row.keyType));
|
|
122
|
+
return METADATA_KEYS.filter((key)=>'x-amz-meta' === key.key || !usedKeys.has(key.key));
|
|
123
|
+
};
|
|
124
|
+
const onSubmit = async (data)=>{
|
|
125
|
+
if (!metadata) return;
|
|
132
126
|
try {
|
|
127
|
+
const validMetadata = data.metadata.filter((row)=>{
|
|
128
|
+
const hasKey = 'x-amz-meta' === row.keyType ? row.customKey.trim() : row.keyType;
|
|
129
|
+
return hasKey && row.value.trim();
|
|
130
|
+
});
|
|
133
131
|
const encodedKey = encodeURIComponent(objectKey);
|
|
134
132
|
const copySource = versionId ? `${bucketName}/${encodedKey}?versionId=${versionId}` : `${bucketName}/${encodedKey}`;
|
|
135
133
|
const copyParams = {
|
|
136
134
|
Bucket: bucketName,
|
|
137
135
|
Key: objectKey,
|
|
138
136
|
CopySource: copySource,
|
|
139
|
-
MetadataDirective:
|
|
137
|
+
MetadataDirective: 'REPLACE',
|
|
140
138
|
Metadata: {}
|
|
141
139
|
};
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
else if (row.keyType) copyParams[row.keyType] = row.value;
|
|
140
|
+
validMetadata.forEach((row)=>{
|
|
141
|
+
if ('x-amz-meta' === row.keyType) copyParams.Metadata[row.customKey.trim()] = row.value.trim();
|
|
142
|
+
else if (row.keyType) copyParams[row.keyType] = row.value.trim();
|
|
145
143
|
});
|
|
146
144
|
if (!copyParams.ContentType && metadata.ContentType) copyParams.ContentType = metadata.ContentType;
|
|
147
145
|
await copyObjectMutation.mutateAsync(copyParams);
|
|
146
|
+
await invalidateQueries({
|
|
147
|
+
queryKey: [
|
|
148
|
+
'HeadObject',
|
|
149
|
+
{
|
|
150
|
+
Bucket: bucketName,
|
|
151
|
+
Key: objectKey,
|
|
152
|
+
...getVersionParams()
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
showToast({
|
|
157
|
+
open: true,
|
|
158
|
+
message: 'Metadata saved successfully',
|
|
159
|
+
status: 'success'
|
|
160
|
+
});
|
|
148
161
|
} catch (error) {
|
|
149
|
-
|
|
162
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to save metadata';
|
|
163
|
+
showToast({
|
|
164
|
+
open: true,
|
|
165
|
+
message: errorMessage,
|
|
166
|
+
status: 'error'
|
|
167
|
+
});
|
|
150
168
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
metadata,
|
|
154
|
-
bucketName,
|
|
155
|
-
objectKey,
|
|
156
|
-
metadataRows,
|
|
157
|
-
copyObjectMutation
|
|
158
|
-
]);
|
|
159
|
-
if ("pending" === metadataStatus) return /*#__PURE__*/ jsx(TableContainer, {
|
|
169
|
+
};
|
|
170
|
+
if ('pending' === metadataStatus) return /*#__PURE__*/ jsx(TableContainer, {
|
|
160
171
|
children: /*#__PURE__*/ jsx(Box, {
|
|
161
172
|
display: "flex",
|
|
162
173
|
justifyContent: "center",
|
|
@@ -164,7 +175,7 @@ const ObjectMetadata = ({ bucketName, objectKey, versionId })=>{
|
|
|
164
175
|
children: /*#__PURE__*/ jsx(Loader, {})
|
|
165
176
|
})
|
|
166
177
|
});
|
|
167
|
-
if (
|
|
178
|
+
if ('error' === metadataStatus) return /*#__PURE__*/ jsx(TableContainer, {
|
|
168
179
|
children: /*#__PURE__*/ jsx(Box, {
|
|
169
180
|
padding: spacing.r16,
|
|
170
181
|
children: /*#__PURE__*/ jsx(Text, {
|
|
@@ -173,151 +184,199 @@ const ObjectMetadata = ({ bucketName, objectKey, versionId })=>{
|
|
|
173
184
|
})
|
|
174
185
|
})
|
|
175
186
|
});
|
|
176
|
-
return /*#__PURE__*/
|
|
177
|
-
children:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
copyObjectMutation.isError && /*#__PURE__*/ jsx(Text, {
|
|
200
|
-
color: "statusCritical",
|
|
201
|
-
children: "Failed to save"
|
|
202
|
-
}),
|
|
203
|
-
/*#__PURE__*/ jsx(Button, {
|
|
204
|
-
variant: "primary",
|
|
205
|
-
label: "Save",
|
|
206
|
-
disabled: !canSave || copyObjectMutation.isPending,
|
|
207
|
-
onClick: handleSave,
|
|
208
|
-
icon: /*#__PURE__*/ jsx(Icon, {
|
|
209
|
-
name: "Save"
|
|
210
|
-
})
|
|
211
|
-
})
|
|
212
|
-
]
|
|
213
|
-
})
|
|
214
|
-
]
|
|
215
|
-
}),
|
|
216
|
-
validationErrors.length > 0 && /*#__PURE__*/ jsxs(Box, {
|
|
217
|
-
padding: spacing.r16,
|
|
218
|
-
backgroundColor: "backgroundLevel2",
|
|
219
|
-
borderLeft: "3px solid",
|
|
220
|
-
borderColor: "statusCritical",
|
|
221
|
-
children: [
|
|
222
|
-
/*#__PURE__*/ jsx(Text, {
|
|
223
|
-
color: "statusCritical",
|
|
224
|
-
isEmphazed: true,
|
|
225
|
-
children: "Validation Errors:"
|
|
226
|
-
}),
|
|
227
|
-
validationErrors.map((error, index)=>/*#__PURE__*/ jsx(Box, {
|
|
228
|
-
paddingLeft: spacing.r8,
|
|
229
|
-
children: /*#__PURE__*/ jsxs(Text, {
|
|
230
|
-
color: "statusCritical",
|
|
231
|
-
children: [
|
|
232
|
-
"• ",
|
|
233
|
-
error
|
|
234
|
-
]
|
|
235
|
-
})
|
|
236
|
-
}, index))
|
|
237
|
-
]
|
|
238
|
-
}),
|
|
239
|
-
/*#__PURE__*/ jsxs(Box, {
|
|
240
|
-
padding: spacing.r16,
|
|
241
|
-
display: "flex",
|
|
242
|
-
flexDirection: "column",
|
|
243
|
-
gap: spacing.r12,
|
|
244
|
-
flex: "1",
|
|
245
|
-
children: [
|
|
246
|
-
metadataRows.length > 0 && /*#__PURE__*/ jsxs(Box, {
|
|
247
|
-
display: "flex",
|
|
248
|
-
children: [
|
|
249
|
-
/*#__PURE__*/ jsx(Box, {
|
|
250
|
-
flex: "1",
|
|
251
|
-
children: /*#__PURE__*/ jsx(Text, {
|
|
252
|
-
color: "textSecondary",
|
|
253
|
-
isEmphazed: true,
|
|
254
|
-
children: "Key"
|
|
255
|
-
})
|
|
256
|
-
}),
|
|
257
|
-
/*#__PURE__*/ jsx(Box, {
|
|
258
|
-
flex: "1",
|
|
259
|
-
children: /*#__PURE__*/ jsx(Text, {
|
|
260
|
-
color: "textSecondary",
|
|
261
|
-
isEmphazed: true,
|
|
262
|
-
children: "Value"
|
|
263
|
-
})
|
|
187
|
+
return /*#__PURE__*/ jsx(TableContainer, {
|
|
188
|
+
children: /*#__PURE__*/ jsxs("form", {
|
|
189
|
+
onSubmit: handleSubmit(onSubmit),
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
192
|
+
display: "flex",
|
|
193
|
+
justifyContent: "space-between",
|
|
194
|
+
alignItems: "center",
|
|
195
|
+
padding: spacing.r16,
|
|
196
|
+
borderBottom: "1px solid",
|
|
197
|
+
borderColor: "backgroundLevel3",
|
|
198
|
+
children: [
|
|
199
|
+
/*#__PURE__*/ jsx(Text, {
|
|
200
|
+
isEmphazed: true,
|
|
201
|
+
children: "Edit Metadata"
|
|
202
|
+
}),
|
|
203
|
+
/*#__PURE__*/ jsx(Button, {
|
|
204
|
+
variant: "primary",
|
|
205
|
+
label: "Save",
|
|
206
|
+
disabled: !isValid || isSubmitting || !hasChanges(),
|
|
207
|
+
type: "submit",
|
|
208
|
+
icon: /*#__PURE__*/ jsx(Icon, {
|
|
209
|
+
name: "Save"
|
|
264
210
|
})
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
}),
|
|
214
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
215
|
+
padding: spacing.r16,
|
|
216
|
+
display: "flex",
|
|
217
|
+
flexDirection: "column",
|
|
218
|
+
gap: spacing.r12,
|
|
219
|
+
children: [
|
|
220
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
268
221
|
display: "flex",
|
|
269
222
|
gap: spacing.r8,
|
|
270
|
-
alignItems: "center",
|
|
271
223
|
children: [
|
|
272
|
-
/*#__PURE__*/ jsx(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
children: key.label
|
|
280
|
-
}, key.key))
|
|
224
|
+
/*#__PURE__*/ jsx(Box, {
|
|
225
|
+
flex: "1",
|
|
226
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
227
|
+
color: "textSecondary",
|
|
228
|
+
isEmphazed: true,
|
|
229
|
+
children: "Key"
|
|
230
|
+
})
|
|
281
231
|
}),
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
232
|
+
/*#__PURE__*/ jsx(Box, {
|
|
233
|
+
flex: "1",
|
|
234
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
235
|
+
color: "textSecondary",
|
|
236
|
+
isEmphazed: true,
|
|
237
|
+
children: "Value"
|
|
238
|
+
})
|
|
287
239
|
}),
|
|
288
|
-
/*#__PURE__*/ jsx(
|
|
289
|
-
|
|
290
|
-
children: ":"
|
|
291
|
-
}),
|
|
292
|
-
/*#__PURE__*/ jsx(Input, {
|
|
293
|
-
id: `value-${row.id}`,
|
|
294
|
-
value: row.value,
|
|
295
|
-
onChange: (e)=>handleRowChange(row.id, "value", e.target.value),
|
|
296
|
-
placeholder: "Value"
|
|
297
|
-
}),
|
|
298
|
-
/*#__PURE__*/ jsx(Button, {
|
|
299
|
-
variant: "secondary",
|
|
300
|
-
icon: /*#__PURE__*/ jsx(Icon, {
|
|
301
|
-
name: "Delete"
|
|
302
|
-
}),
|
|
303
|
-
onClick: ()=>handleDeleteRow(row.id),
|
|
304
|
-
"aria-label": "Delete row"
|
|
240
|
+
/*#__PURE__*/ jsx(Box, {
|
|
241
|
+
width: convertSizeToRem('1/3')
|
|
305
242
|
})
|
|
306
243
|
]
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
244
|
+
}),
|
|
245
|
+
fields.map((field, index)=>/*#__PURE__*/ jsxs(Box, {
|
|
246
|
+
children: [
|
|
247
|
+
/*#__PURE__*/ jsxs(Box, {
|
|
248
|
+
display: "flex",
|
|
249
|
+
gap: spacing.r8,
|
|
250
|
+
alignItems: "center",
|
|
251
|
+
children: [
|
|
252
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
253
|
+
control: control,
|
|
254
|
+
name: `metadata.${index}.keyType`,
|
|
255
|
+
rules: {
|
|
256
|
+
validate: (value, formValues)=>{
|
|
257
|
+
if (1 === formValues.metadata.length && !value && !formValues.metadata[0].value.trim()) return true;
|
|
258
|
+
if (!value) return 'Please select a metadata key';
|
|
259
|
+
const allMetadata = formValues.metadata;
|
|
260
|
+
const usedKeys = allMetadata.map((row, idx)=>{
|
|
261
|
+
if (idx === index) return null;
|
|
262
|
+
if ('x-amz-meta' === row.keyType) return row.customKey ? `x-amz-meta-${row.customKey.trim()}` : null;
|
|
263
|
+
return row.keyType;
|
|
264
|
+
}).filter(Boolean);
|
|
265
|
+
const currentKey = 'x-amz-meta' === value ? formValues.metadata[index].customKey ? `x-amz-meta-${formValues.metadata[index].customKey.trim()}` : null : value;
|
|
266
|
+
if (currentKey && usedKeys.includes(currentKey)) return `Duplicate key "${currentKey}"`;
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Select, {
|
|
271
|
+
id: `key-${field.id}`,
|
|
272
|
+
value: value,
|
|
273
|
+
onChange: (newValue)=>{
|
|
274
|
+
onChange(newValue);
|
|
275
|
+
if ('x-amz-meta' !== newValue) setValue(`metadata.${index}.customKey`, '');
|
|
276
|
+
},
|
|
277
|
+
placeholder: "Select key",
|
|
278
|
+
children: getAvailableOptions(index).map((key)=>/*#__PURE__*/ jsx(Select.Option, {
|
|
279
|
+
value: key.key,
|
|
280
|
+
children: key.label
|
|
281
|
+
}, key.key))
|
|
282
|
+
})
|
|
283
|
+
}),
|
|
284
|
+
'x-amz-meta' === watch(`metadata.${index}.keyType`) && /*#__PURE__*/ jsx(Controller, {
|
|
285
|
+
control: control,
|
|
286
|
+
name: `metadata.${index}.customKey`,
|
|
287
|
+
rules: {
|
|
288
|
+
validate: (value, formValues)=>{
|
|
289
|
+
if ('x-amz-meta' === formValues.metadata[index].keyType) {
|
|
290
|
+
if (!value.trim()) return 'Custom key required';
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Input, {
|
|
296
|
+
id: `customKey-${field.id}`,
|
|
297
|
+
value: value,
|
|
298
|
+
onChange: onChange,
|
|
299
|
+
size: "1/3"
|
|
300
|
+
})
|
|
301
|
+
}),
|
|
302
|
+
/*#__PURE__*/ jsx(Text, {
|
|
303
|
+
color: "textSecondary",
|
|
304
|
+
children: ":"
|
|
305
|
+
}),
|
|
306
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
307
|
+
control: control,
|
|
308
|
+
name: `metadata.${index}.value`,
|
|
309
|
+
rules: {
|
|
310
|
+
validate: (value, formValues)=>{
|
|
311
|
+
if (1 === formValues.metadata.length && !value.trim() && !formValues.metadata[0].keyType) return true;
|
|
312
|
+
if (!value.trim()) return 'Value cannot be empty';
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
render: ({ field: { onChange, value } })=>/*#__PURE__*/ jsx(Input, {
|
|
317
|
+
id: `value-${field.id}`,
|
|
318
|
+
value: value,
|
|
319
|
+
onChange: onChange,
|
|
320
|
+
placeholder: "Value"
|
|
321
|
+
})
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ jsx(ArrayFieldActions, {
|
|
324
|
+
showAdd: index === fields.length - 1,
|
|
325
|
+
onRemove: ()=>{
|
|
326
|
+
remove(index);
|
|
327
|
+
if (1 === fields.length) append({
|
|
328
|
+
keyType: '',
|
|
329
|
+
customKey: '',
|
|
330
|
+
value: ''
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
onAdd: ()=>append({
|
|
334
|
+
keyType: '',
|
|
335
|
+
customKey: '',
|
|
336
|
+
value: ''
|
|
337
|
+
}),
|
|
338
|
+
canRemove: (()=>{
|
|
339
|
+
const keyType = watch(`metadata.${index}.keyType`);
|
|
340
|
+
const customKey = watch(`metadata.${index}.customKey`);
|
|
341
|
+
const value = watch(`metadata.${index}.value`);
|
|
342
|
+
const hasKey = 'x-amz-meta' === keyType ? customKey : keyType;
|
|
343
|
+
return !!hasKey && !!value;
|
|
344
|
+
})(),
|
|
345
|
+
canAdd: (()=>{
|
|
346
|
+
const keyType = watch(`metadata.${index}.keyType`);
|
|
347
|
+
const customKey = watch(`metadata.${index}.customKey`);
|
|
348
|
+
const value = watch(`metadata.${index}.value`);
|
|
349
|
+
const hasKey = 'x-amz-meta' === keyType ? customKey : keyType;
|
|
350
|
+
return !!hasKey && !!value;
|
|
351
|
+
})(),
|
|
352
|
+
removeLabel: "Remove metadata",
|
|
353
|
+
addLabel: "Add metadata"
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
}),
|
|
357
|
+
(errors.metadata?.[index]?.keyType || errors.metadata?.[index]?.customKey || errors.metadata?.[index]?.value) && /*#__PURE__*/ jsxs(Box, {
|
|
358
|
+
paddingTop: spacing.r4,
|
|
359
|
+
children: [
|
|
360
|
+
errors.metadata?.[index]?.keyType && /*#__PURE__*/ jsx(Text, {
|
|
361
|
+
color: "statusCritical",
|
|
362
|
+
children: errors.metadata[index]?.keyType?.message
|
|
363
|
+
}),
|
|
364
|
+
errors.metadata?.[index]?.customKey && /*#__PURE__*/ jsx(Text, {
|
|
365
|
+
color: "statusCritical",
|
|
366
|
+
children: errors.metadata[index]?.customKey?.message
|
|
367
|
+
}),
|
|
368
|
+
errors.metadata?.[index]?.value && /*#__PURE__*/ jsx(Text, {
|
|
369
|
+
color: "statusCritical",
|
|
370
|
+
children: errors.metadata[index]?.value?.message
|
|
371
|
+
})
|
|
372
|
+
]
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}, field.id))
|
|
376
|
+
]
|
|
377
|
+
})
|
|
378
|
+
]
|
|
379
|
+
})
|
|
321
380
|
});
|
|
322
381
|
};
|
|
323
382
|
export { ObjectMetadata };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ObjectCommonProps } from
|
|
2
|
-
declare const ObjectSummary: ({ bucketName, objectKey, versionId
|
|
1
|
+
import type { ObjectCommonProps } from '.';
|
|
2
|
+
declare const ObjectSummary: ({ bucketName, objectKey, versionId }: ObjectCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export { ObjectSummary };
|