@webiny/app-file-manager 6.4.11 → 6.6.0-alpha.1
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/app.js +21 -2
- package/app.js.map +1 -1
- package/domain/tagsHelpers.d.ts +2 -2
- package/domain/types.d.ts +0 -8
- package/features/permissions/abstractions.d.ts +2 -2
- package/features/permissions/feature.d.ts +3 -3
- package/features/shared/FILE_FIELDS.js +4 -0
- package/features/shared/FILE_FIELDS.js.map +1 -1
- package/features/shared/FileFieldsProviderWithWcp.d.ts +5 -5
- package/features/shared/FileFieldsProviderWithWcp.js +7 -7
- package/features/shared/FileFieldsProviderWithWcp.js.map +1 -1
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.d.ts +18 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js +33 -0
- package/modules/AiEnrichment/AiImageEnrichmentEventHandler.js.map +1 -0
- package/modules/AiEnrichment/ReenrichFileGateway.d.ts +12 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js +23 -0
- package/modules/AiEnrichment/ReenrichFileGateway.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAi.d.ts +11 -0
- package/modules/AiEnrichment/ReenrichWithAi.js +57 -0
- package/modules/AiEnrichment/ReenrichWithAi.js.map +1 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.d.ts +50 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js +114 -0
- package/modules/AiEnrichment/ReenrichWithAiPresenter.js.map +1 -0
- package/modules/AiEnrichment/StreamingPlaceholder.d.ts +15 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js +32 -0
- package/modules/AiEnrichment/StreamingPlaceholder.js.map +1 -0
- package/modules/AiEnrichment/abstractions.d.ts +70 -0
- package/modules/AiEnrichment/abstractions.js +6 -0
- package/modules/AiEnrichment/abstractions.js.map +1 -0
- package/modules/AiEnrichment/feature.d.ts +3 -0
- package/modules/AiEnrichment/feature.js +21 -0
- package/modules/AiEnrichment/feature.js.map +1 -0
- package/modules/AiEnrichment/index.d.ts +2 -0
- package/modules/AiEnrichment/index.js +9 -0
- package/modules/AiEnrichment/index.js.map +1 -0
- package/modules/Enterprise/index.js +3 -3
- package/modules/Enterprise/index.js.map +1 -1
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.d.ts +26 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js +39 -0
- package/modules/HeadlessCms/fieldType/AssetFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.d.ts +34 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.d.ts +21 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js +42 -0
- package/modules/HeadlessCms/fieldType/AssetFormFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js +20 -0
- package/modules/HeadlessCms/fieldType/AssetInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.d.ts +16 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js +33 -0
- package/modules/HeadlessCms/fieldType/FileFieldSettingsModifier.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.d.ts +25 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js +38 -0
- package/modules/HeadlessCms/fieldType/FileFieldType.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.d.ts +15 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js +19 -0
- package/modules/HeadlessCms/fieldType/FileInputsRenderer.js.map +1 -0
- package/modules/HeadlessCms/fieldType/feature.d.ts +1 -0
- package/modules/HeadlessCms/fieldType/feature.js +27 -0
- package/modules/HeadlessCms/fieldType/feature.js.map +1 -0
- package/modules/HeadlessCms/fieldType/isAssetField.d.ts +2 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js +4 -0
- package/modules/HeadlessCms/fieldType/isAssetField.js.map +1 -0
- package/package.json +24 -34
- package/presentation/FileActions/FileDetails/EditImage.d.ts +2 -0
- package/presentation/FileActions/FileDetails/EditImage.js +39 -0
- package/presentation/FileActions/FileDetails/EditImage.js.map +1 -0
- package/presentation/FileActions/index.js +8 -0
- package/presentation/FileActions/index.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.d.ts +5 -4
- package/presentation/FileDetails/FileDetailsPresenter.js +40 -46
- package/presentation/FileDetails/FileDetailsPresenter.js.map +1 -1
- package/presentation/FileDetails/FileDetailsPresenter.test.js +39 -56
- package/presentation/FileDetails/FileDetailsPresenter.test.js.map +1 -1
- package/presentation/FileDetails/abstractions.d.ts +2 -0
- package/presentation/FileDetails/abstractions.js.map +1 -1
- package/presentation/FileDetails/components/Content.d.ts +6 -4
- package/presentation/FileDetails/components/Content.js +2 -2
- package/presentation/FileDetails/components/Content.js.map +1 -1
- package/presentation/FileDetails/components/FileDetailsDrawer.d.ts +2 -2
- package/presentation/FileDetails/components/FileDetailsDrawer.js +11 -5
- package/presentation/FileDetails/components/FileDetailsDrawer.js.map +1 -1
- package/presentation/FileList/FileListDataSource.d.ts +8 -12
- package/presentation/FileList/FileListDataSource.js +47 -87
- package/presentation/FileList/FileListDataSource.js.map +1 -1
- package/presentation/FileList/FileListPresenter.test.js +9 -3
- package/presentation/FileList/FileListPresenter.test.js.map +1 -1
- package/presentation/FileList/FileManagerPresenter.d.ts +1 -0
- package/presentation/FileList/FileManagerPresenter.js +15 -5
- package/presentation/FileList/FileManagerPresenter.js.map +1 -1
- package/presentation/FileList/abstractions.d.ts +3 -0
- package/presentation/FileList/abstractions.js.map +1 -1
- package/presentation/FileList/components/BulkActions/BulkActionBar.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionDelete.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/BulkActionMove.d.ts +2 -2
- package/presentation/FileList/components/BulkActions/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/index.js +0 -1
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.d.ts +9 -8
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js +3 -9
- package/presentation/FileList/components/BulkActions/useBulkActionWorker.js.map +1 -1
- package/presentation/FileList/components/Filters/SubFoldersToggle.d.ts +2 -2
- package/presentation/FileList/components/Filters/TagsFilter.d.ts +2 -2
- package/presentation/FileList/components/Filters/TypeFilter.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.d.ts +2 -2
- package/presentation/FileList/components/Grid/FileGrid.js +1 -1
- package/presentation/FileList/components/Grid/FileGrid.js.map +1 -1
- package/presentation/FileList/components/Grid/FileGrid.test.js +18 -7
- package/presentation/FileList/components/Grid/FileGrid.test.js.map +1 -1
- package/presentation/FileList/components/Header/FileManagerHeader.d.ts +2 -2
- package/presentation/FileList/components/Search/SearchBar.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.d.ts +2 -2
- package/presentation/FileList/components/Table/FileTable.js +1 -1
- package/presentation/FileList/components/Table/FileTable.js.map +1 -1
- package/presentation/FileList/components/Table/FileTable.test.js +9 -4
- package/presentation/FileList/components/Table/FileTable.test.js.map +1 -1
- package/presentation/FileList/components/Upload/UploadProgress.d.ts +2 -2
- package/presentation/FileManager/FileManagerBreadcrumbs.d.ts +12 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js +37 -0
- package/presentation/FileManager/FileManagerBreadcrumbs.js.map +1 -0
- package/presentation/FileManager/FileManagerView.js +36 -2
- package/presentation/FileManager/FileManagerView.js.map +1 -1
- package/presentation/FileManager/RouteParamsSync.d.ts +2 -0
- package/presentation/FileManager/RouteParamsSync.js +30 -0
- package/presentation/FileManager/RouteParamsSync.js.map +1 -0
- package/presentation/Settings/components/SettingsView.d.ts +2 -2
- package/presentation/config/DefaultFileManagerConfig.js +13 -11
- package/presentation/config/DefaultFileManagerConfig.js.map +1 -1
- package/presentation/config/FileManagerViewConfig.d.ts +19 -25
- package/presentation/config/configComponents/Browser/BulkAction.d.ts +10 -8
- package/presentation/config/configComponents/Browser/BulkAction.js +3 -9
- package/presentation/config/configComponents/Browser/BulkAction.js.map +1 -1
- package/presentation/config/configComponents/Browser/FileAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/FolderAction.d.ts +2 -1
- package/presentation/config/configComponents/Browser/Table/Column.d.ts +9 -8
- package/presentation/config/configComponents/Browser/Table/index.d.ts +9 -9
- package/presentation/config/configComponents/Browser/index.d.ts +20 -20
- package/presentation/config/configComponents/Browser/index.js +0 -8
- package/presentation/config/configComponents/Browser/index.js.map +1 -1
- package/presentation/config/configComponents/FileDetails/index.d.ts +4 -2
- package/presentation/config/thumbnailRenderers/CroppedFileImage.d.ts +18 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js +66 -0
- package/presentation/config/thumbnailRenderers/CroppedFileImage.js.map +1 -0
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/FilePreviewImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/GridItemImageRenderer.js.map +1 -1
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js +6 -9
- package/presentation/config/thumbnailRenderers/TableItemImageRenderer.js.map +1 -1
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.d.ts +22 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js +56 -0
- package/presentation/fieldRenderers/CmsAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js +36 -0
- package/presentation/fieldRenderers/CmsFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.d.ts +7 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js +32 -0
- package/presentation/fieldRenderers/CmsImageEditorDialog.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.d.ts +18 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js +88 -0
- package/presentation/fieldRenderers/CmsMultiAssetPickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.d.ts +13 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js +60 -0
- package/presentation/fieldRenderers/CmsMultiFilePickerRenderer.js.map +1 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.d.ts +15 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js +25 -0
- package/presentation/fieldRenderers/CroppedAssetThumb.js.map +1 -0
- package/presentation/fieldRenderers/assetValue.d.ts +10 -0
- package/presentation/fieldRenderers/assetValue.js +88 -0
- package/presentation/fieldRenderers/assetValue.js.map +1 -0
- package/presentation/hooks/useCmsImageEditor.d.ts +10 -0
- package/presentation/hooks/useCmsImageEditor.js +76 -0
- package/presentation/hooks/useCmsImageEditor.js.map +1 -0
- package/presentation/hooks/useEditImage.d.ts +14 -0
- package/presentation/hooks/useEditImage.js +67 -0
- package/presentation/hooks/useEditImage.js.map +1 -0
- package/routes.d.ts +1 -0
- package/routes.js +2 -1
- package/routes.js.map +1 -1
- package/modules/HeadlessCms/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileField.js +0 -44
- package/modules/HeadlessCms/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileField.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileField.js +0 -53
- package/modules/HeadlessCms/fileRenderer/fileField.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/fileFields.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/fileFields.js +0 -73
- package/modules/HeadlessCms/fileRenderer/fileFields.js.map +0 -1
- package/modules/HeadlessCms/fileRenderer/utils.d.ts +0 -2
- package/modules/HeadlessCms/fileRenderer/utils.js +0 -15
- package/modules/HeadlessCms/fileRenderer/utils.js.map +0 -1
- package/modules/HeadlessCms/index.d.ts +0 -1
- package/modules/HeadlessCms/index.js +0 -14
- package/modules/HeadlessCms/index.js.map +0 -1
- package/modules/Settings/graphql.d.ts +0 -12
- package/modules/Settings/graphql.js +0 -36
- package/modules/Settings/graphql.js.map +0 -1
- package/modules/Settings/views/FileManagerSettings.d.ts +0 -2
- package/modules/Settings/views/FileManagerSettings.js +0 -134
- package/modules/Settings/views/FileManagerSettings.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.d.ts +0 -7
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/AddOperation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js +0 -44
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditor.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.d.ts +0 -15
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js +0 -52
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.d.ts +0 -61
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js +0 -111
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js +0 -372
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.d.ts +0 -8
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js +0 -31
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.d.ts +0 -11
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js +0 -33
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js.map +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.d.ts +0 -1
- package/presentation/FileList/components/BulkActions/BatchEditorDialog/index.js +0 -1
- package/presentation/FileList/components/BulkActions/BulkActionEdit.d.ts +0 -4
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js +0 -105
- package/presentation/FileList/components/BulkActions/BulkActionEdit.js.map +0 -1
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.d.ts +0 -7
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js +0 -11
- package/presentation/config/configComponents/Browser/FolderFieldDecorator.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.js","sources":["../../../../../../src/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.test.ts"],"sourcesContent":["import { BatchEditorDialogPresenter } from \"./BatchEditorDialogPresenter.js\";\nimport type {\n BatchDTO,\n FieldDTO,\n OperatorDTO\n} from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport { OperatorType } from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport { vi, describe, it, expect, beforeEach } from \"vitest\";\n\ndescribe(\"BatchEditorDialogPresenter\", () => {\n const batch: BatchDTO = {\n operations: [\n {\n field: \"\",\n operator: \"\",\n value: undefined\n }\n ]\n };\n\n const fields: FieldDTO[] = [\n {\n label: \"Field 1\",\n value: \"field1\",\n operators: [\n {\n label: \"Override existing values\",\n value: OperatorType.OVERRIDE\n },\n {\n label: \"Clear all existing values\",\n value: OperatorType.REMOVE\n }\n ],\n raw: {\n id: \"field1\",\n fieldId: \"field1\",\n label: \"Field 1\",\n type: \"text\",\n renderer: {\n name: \"text-input\"\n },\n tags: [\"$bulk-edit\"],\n storageId: \"text@field1\"\n }\n },\n {\n label: \"Field 2\",\n value: \"field2\",\n operators: [\n {\n label: \"Override existing values\",\n value: OperatorType.OVERRIDE\n },\n {\n label: \"Clear all existing values\",\n value: OperatorType.REMOVE\n }\n ],\n raw: {\n id: \"field2\",\n fieldId: \"field2\",\n label: \"Field 1\",\n type: \"text\",\n renderer: {\n name: \"text-input\"\n },\n tags: [\"$bulk-edit\"],\n storageId: \"text@field2\"\n }\n }\n ];\n\n const operators: OperatorDTO[] = [\n {\n value: OperatorType.OVERRIDE,\n label: \"Override existing values\"\n },\n {\n value: OperatorType.REMOVE,\n label: \"Clear all existing values\"\n },\n {\n value: OperatorType.APPEND,\n label: \"Append to existing values\"\n }\n ];\n\n let presenter: BatchEditorDialogPresenter;\n\n beforeEach(() => {\n vi.clearAllMocks();\n presenter = new BatchEditorDialogPresenter();\n });\n\n it(\"should load data\", () => {\n presenter.load(batch, fields);\n\n // `vm` should have the expected `data` definition\n expect(presenter.vm.data).toEqual({\n operations: [\n {\n title: \"Operation #1\",\n open: true,\n canDelete: false,\n field: \"\",\n operator: \"\",\n value: undefined,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n }\n ]\n });\n\n // `vm` should have the expected `invalidFields` definition\n expect(presenter.vm.invalidFields).toEqual({});\n\n // `vm` should have the expected `canAddOperation` definition\n expect(presenter.vm.canAddOperation).toEqual(true);\n });\n\n it(\"should be able to add and delete operations\", () => {\n presenter.load(batch, fields);\n\n // should only have 1 operator, created by default\n expect(presenter.vm.data.operations.length).toBe(1);\n expect(presenter.vm.data.operations).toEqual([\n {\n title: \"Operation #1\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n }\n ]);\n\n presenter.addOperation();\n\n // should only have 2 operators\n expect(presenter.vm.data.operations.length).toBe(2);\n expect(presenter.vm.data.operations).toEqual([\n {\n title: \"Operation #1\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n },\n {\n title: \"Operation #2\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: true,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n }\n ]);\n\n // let's delete the first operation\n presenter.deleteOperation(0);\n\n expect(presenter.vm.data.operations.length).toBe(1);\n expect(presenter.vm.data.operations).toEqual([\n {\n title: \"Operation #1\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n }\n ]);\n\n // let's delete the remaining operation\n presenter.deleteOperation(0);\n\n // should still have 1 default operation\n expect(presenter.vm.data.operations.length).toBe(1);\n expect(presenter.vm.data.operations).toEqual([\n {\n title: \"Operation #1\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n }\n ]);\n });\n\n it(\"should be able to handle the `fieldOptions` based operations set in the batch\", () => {\n presenter.load(batch, fields);\n\n // let's set some `data` back to the operation\n presenter.setBatch({\n operations: [\n {\n title: `Override existing values for field \"${fields[0].label}\"`,\n open: true,\n field: fields[0].value,\n operator: OperatorType.OVERRIDE,\n value: {\n [fields[0].value]: \"newValue\"\n },\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n }\n ]\n });\n\n // I should be able to add a new operation\n expect(presenter.vm.canAddOperation).toBeTruthy();\n\n presenter.addOperation();\n\n // Only the not-set field should be available\n expect(presenter.vm.data.operations[1]).toEqual({\n title: \"Operation #2\",\n open: true,\n field: \"\",\n operator: \"\",\n value: undefined,\n canDelete: true,\n fieldOptions: [fields[1]],\n operatorOptions: [],\n selectedField: undefined\n });\n\n // let's set some `data` back to the operations\n presenter.setBatch({\n operations: [\n {\n title: `Override existing values for field \"${fields[0].label}\"`,\n open: true,\n field: fields[0].value,\n operator: OperatorType.OVERRIDE,\n value: {\n [fields[0].value]: \"newValue\"\n },\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n },\n {\n title: `Remove all values for field \"${fields[1].label}\"`,\n open: false,\n field: fields[1].value,\n operator: OperatorType.REMOVE,\n value: undefined,\n canDelete: true,\n fieldOptions: [fields[1]],\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[1]\n }\n ]\n });\n\n // I should NOT be able to add a new operation\n expect(presenter.vm.canAddOperation).toBeFalsy();\n });\n\n it(\"should be able to set data back to the operation\", () => {\n presenter.load(batch, fields);\n\n // should be able to set the `data` operation\n presenter.setBatch({\n operations: [\n {\n title: `Remove all values for field \"${fields[0].label}\"`,\n open: false,\n field: fields[0].value,\n operator: OperatorType.OVERRIDE,\n value: {\n [fields[0].value]: \"newValue\"\n },\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n }\n ]\n });\n\n expect(presenter.vm.data.operations[0].field).toEqual(fields[0].value);\n expect(presenter.vm.data.operations[0].operator).toEqual(OperatorType.OVERRIDE);\n expect(presenter.vm.data.operations[0].value).toEqual({\n [fields[0].value]: \"newValue\"\n });\n expect(presenter.vm.data.operations[0].fieldOptions).toEqual(fields);\n });\n\n it(\"should able to set the operation `field` data\", () => {\n presenter.load(batch, fields);\n\n presenter.setBatch({\n operations: [\n {\n title: `Override existing values for field \"${fields[0].label}\"`,\n open: true,\n field: fields[0].value,\n operator: OperatorType.OVERRIDE,\n value: {\n [fields[0].value]: \"newValue\"\n },\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n }\n ]\n });\n\n // let's empty the operation\n presenter.setOperationFieldData(0, \"new-field\");\n\n // should have an operation with default definition and new field value\n expect(presenter.vm.data.operations[0]).toEqual({\n title: \"Operation #1\",\n open: true,\n field: \"new-field\",\n operator: \"\",\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [],\n selectedField: undefined\n });\n });\n\n it(\"should perform validation and call provided callbacks `onApply`\", () => {\n presenter.load(batch, fields);\n\n const onSuccess = vi.fn();\n const onError = vi.fn();\n\n presenter.setBatch({\n operations: [\n {\n title: `Override existing values for field \"${fields[0].label}\"`,\n open: true,\n field: fields[0].value,\n operator: \"\", // empty value -> this should trigger the error\n value: undefined,\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n }\n ]\n });\n\n presenter.onApply(onSuccess, onError);\n\n expect(onError).toHaveBeenCalledTimes(1);\n expect(Object.keys(presenter.vm.invalidFields).length).toBe(1);\n\n presenter.setBatch({\n operations: [\n {\n title: `Override existing values for field \"${fields[0].label}\"`,\n open: true,\n field: fields[0].value,\n operator: OperatorType.OVERRIDE,\n value: {\n [fields[0].value]: \"newValue\"\n },\n canDelete: false,\n fieldOptions: fields,\n operatorOptions: [operators[0], operators[1]],\n selectedField: fields[0]\n }\n ]\n });\n\n presenter.onApply(onSuccess, onError);\n\n expect(onSuccess).toHaveBeenCalledTimes(1);\n expect(presenter.vm.invalidFields).toEqual({});\n });\n});\n"],"names":["describe","batch","undefined","fields","OperatorType","operators","presenter","beforeEach","vi","BatchEditorDialogPresenter","it","expect","onSuccess","onError","Object"],"mappings":";;;AASAA,SAAS,8BAA8B;IACnC,MAAMC,QAAkB;QACpB,YAAY;YACR;gBACI,OAAO;gBACP,UAAU;gBACV,OAAOC;YACX;SACH;IACL;IAEA,MAAMC,SAAqB;QACvB;YACI,OAAO;YACP,OAAO;YACP,WAAW;gBACP;oBACI,OAAO;oBACP,OAAOC,aAAa,QAAQ;gBAChC;gBACA;oBACI,OAAO;oBACP,OAAOA,aAAa,MAAM;gBAC9B;aACH;YACD,KAAK;gBACD,IAAI;gBACJ,SAAS;gBACT,OAAO;gBACP,MAAM;gBACN,UAAU;oBACN,MAAM;gBACV;gBACA,MAAM;oBAAC;iBAAa;gBACpB,WAAW;YACf;QACJ;QACA;YACI,OAAO;YACP,OAAO;YACP,WAAW;gBACP;oBACI,OAAO;oBACP,OAAOA,aAAa,QAAQ;gBAChC;gBACA;oBACI,OAAO;oBACP,OAAOA,aAAa,MAAM;gBAC9B;aACH;YACD,KAAK;gBACD,IAAI;gBACJ,SAAS;gBACT,OAAO;gBACP,MAAM;gBACN,UAAU;oBACN,MAAM;gBACV;gBACA,MAAM;oBAAC;iBAAa;gBACpB,WAAW;YACf;QACJ;KACH;IAED,MAAMC,YAA2B;QAC7B;YACI,OAAOD,aAAa,QAAQ;YAC5B,OAAO;QACX;QACA;YACI,OAAOA,aAAa,MAAM;YAC1B,OAAO;QACX;QACA;YACI,OAAOA,aAAa,MAAM;YAC1B,OAAO;QACX;KACH;IAED,IAAIE;IAEJC,WAAW;QACPC,GAAG,aAAa;QAChBF,YAAY,IAAIG;IACpB;IAEAC,GAAG,oBAAoB;QACnBJ,UAAU,IAAI,CAACL,OAAOE;QAGtBQ,OAAOL,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;YAC9B,YAAY;gBACR;oBACI,OAAO;oBACP,MAAM;oBACN,WAAW;oBACX,OAAO;oBACP,UAAU;oBACV,OAAOJ;oBACP,cAAcC;oBACd,iBA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;IAChD;AACJ"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { FieldDTO } from "../../../../../presentation/FileList/components/BulkActions/domain/index.js";
|
|
3
|
-
export interface FieldRendererProps {
|
|
4
|
-
name: string;
|
|
5
|
-
operator: string;
|
|
6
|
-
field: FieldDTO;
|
|
7
|
-
}
|
|
8
|
-
export declare const FieldRenderer: (props: FieldRendererProps) => React.JSX.Element | null;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { FieldElement, ModelProvider } from "@webiny/app-headless-cms";
|
|
3
|
-
import { Bind, BindPrefix } from "@webiny/form";
|
|
4
|
-
import { Grid } from "@webiny/admin-ui";
|
|
5
|
-
import { OperatorType } from "../domain/index.js";
|
|
6
|
-
import { useFileManagerPresenter } from "../../../FileManagerPresenterProvider.js";
|
|
7
|
-
import { useFileManagerConfig } from "../../../../config/FileManagerViewConfig.js";
|
|
8
|
-
const FieldRenderer = (props)=>{
|
|
9
|
-
const { vm } = useFileManagerPresenter();
|
|
10
|
-
const fileModel = vm.fileModel;
|
|
11
|
-
const { browser } = useFileManagerConfig();
|
|
12
|
-
if (!fileModel || !props.operator || props.operator === OperatorType.REMOVE) return null;
|
|
13
|
-
const customFieldRenderer = browser.bulkEditFields.find((field)=>field.name === props.field.value);
|
|
14
|
-
const renderer = customFieldRenderer ? /*#__PURE__*/ react.createElement(BindPrefix, {
|
|
15
|
-
name: props.name
|
|
16
|
-
}, customFieldRenderer.element) : /*#__PURE__*/ react.createElement(BindPrefix, {
|
|
17
|
-
name: props.name + ".extensions"
|
|
18
|
-
}, /*#__PURE__*/ react.createElement(FieldElement, {
|
|
19
|
-
field: props.field.raw,
|
|
20
|
-
Bind: Bind,
|
|
21
|
-
contentModel: fileModel
|
|
22
|
-
}));
|
|
23
|
-
return /*#__PURE__*/ react.createElement(ModelProvider, {
|
|
24
|
-
model: fileModel
|
|
25
|
-
}, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
26
|
-
span: 12
|
|
27
|
-
}, renderer));
|
|
28
|
-
};
|
|
29
|
-
export { FieldRenderer };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=FieldRenderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js","sources":["../../../../../../src/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { FieldElement, ModelProvider } from \"@webiny/app-headless-cms\";\nimport { Bind, BindPrefix } from \"@webiny/form\";\nimport { Grid } from \"@webiny/admin-ui\";\nimport type { FieldDTO } from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport { OperatorType } from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport { useFileManagerPresenter } from \"~/presentation/FileList/FileManagerPresenterProvider.js\";\nimport { useFileManagerConfig } from \"~/presentation/config/FileManagerViewConfig.js\";\n\nexport interface FieldRendererProps {\n name: string;\n operator: string;\n field: FieldDTO;\n}\n\nexport const FieldRenderer = (props: FieldRendererProps) => {\n const { vm } = useFileManagerPresenter();\n const fileModel = vm.fileModel;\n const { browser } = useFileManagerConfig();\n\n if (!fileModel || !props.operator || props.operator === OperatorType.REMOVE) {\n return null;\n }\n\n const customFieldRenderer = browser.bulkEditFields.find(\n field => field.name === props.field.value\n );\n\n const renderer = customFieldRenderer ? (\n <BindPrefix name={props.name}>{customFieldRenderer.element}</BindPrefix>\n ) : (\n <BindPrefix name={props.name + \".extensions\"}>\n <FieldElement field={props.field.raw} Bind={Bind as any} contentModel={fileModel} />\n </BindPrefix>\n );\n\n return (\n <ModelProvider model={fileModel}>\n <Grid.Column span={12}>{renderer}</Grid.Column>\n </ModelProvider>\n );\n};\n"],"names":["FieldRenderer","props","vm","useFileManagerPresenter","fileModel","browser","useFileManagerConfig","OperatorType","customFieldRenderer","field","renderer","BindPrefix","FieldElement","Bind","ModelProvider","Grid"],"mappings":";;;;;;;AAeO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,EAAE,EAAE,GAAGC;IACf,MAAMC,YAAYF,GAAG,SAAS;IAC9B,MAAM,EAAEG,OAAO,EAAE,GAAGC;IAEpB,IAAI,CAACF,aAAa,CAACH,MAAM,QAAQ,IAAIA,MAAM,QAAQ,KAAKM,aAAa,MAAM,EACvE,OAAO;IAGX,MAAMC,sBAAsBH,QAAQ,cAAc,CAAC,IAAI,CACnDI,CAAAA,QAASA,MAAM,IAAI,KAAKR,MAAM,KAAK,CAAC,KAAK;IAG7C,MAAMS,WAAWF,sBAAsB,WAAtBA,GACb,oBAACG,YAAUA;QAAC,MAAMV,MAAM,IAAI;OAAGO,oBAAoB,OAAO,kBAE1D,oBAACG,YAAUA;QAAC,MAAMV,MAAM,IAAI,GAAG;qBAC3B,oBAACW,cAAYA;QAAC,OAAOX,MAAM,KAAK,CAAC,GAAG;QAAE,MAAMY;QAAa,cAAcT;;IAI/E,OAAO,WAAP,GACI,oBAACU,eAAaA;QAAC,OAAOV;qBAClB,oBAACW,KAAK,MAAM;QAAC,MAAM;OAAKL;AAGpC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { OperationFormData } from "../../../../../presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js";
|
|
3
|
-
export interface OperationProps {
|
|
4
|
-
operation: OperationFormData;
|
|
5
|
-
name: string;
|
|
6
|
-
onDelete: () => void;
|
|
7
|
-
onSetOperationFieldData: (data: string) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const Operation: ((props: OperationProps) => React.JSX.Element) & {
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { observer } from "mobx-react-lite";
|
|
3
|
-
import { Grid, Select } from "@webiny/admin-ui";
|
|
4
|
-
import { Bind } from "@webiny/form";
|
|
5
|
-
import { FieldRenderer } from "./FieldRenderer.js";
|
|
6
|
-
const Operation = observer((props)=>/*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
7
|
-
span: 6
|
|
8
|
-
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
9
|
-
name: `${props.name}.field`
|
|
10
|
-
}, ({ value, validation })=>/*#__PURE__*/ react.createElement(Select, {
|
|
11
|
-
label: "Field",
|
|
12
|
-
options: props.operation.fieldOptions,
|
|
13
|
-
value: value,
|
|
14
|
-
onChange: (data)=>props.onSetOperationFieldData(data),
|
|
15
|
-
validation: validation
|
|
16
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
17
|
-
span: 6
|
|
18
|
-
}, props.operation.field && /*#__PURE__*/ react.createElement(Bind, {
|
|
19
|
-
name: `${props.name}.operator`
|
|
20
|
-
}, ({ value, onChange, validation })=>/*#__PURE__*/ react.createElement(Select, {
|
|
21
|
-
label: "Operation",
|
|
22
|
-
options: props.operation.operatorOptions,
|
|
23
|
-
value: value,
|
|
24
|
-
onChange: onChange,
|
|
25
|
-
validation: validation
|
|
26
|
-
}))), /*#__PURE__*/ react.createElement(react.Fragment, null, props.operation.selectedField ? /*#__PURE__*/ react.createElement(FieldRenderer, {
|
|
27
|
-
operator: props.operation.operator,
|
|
28
|
-
field: props.operation.selectedField,
|
|
29
|
-
name: `${props.name}.value`
|
|
30
|
-
}) : null)));
|
|
31
|
-
export { Operation };
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=Operation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.js","sources":["../../../../../../src/presentation/FileList/components/BulkActions/BatchEditorDialog/Operation.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { observer } from \"mobx-react-lite\";\nimport { Grid, Select } from \"@webiny/admin-ui\";\nimport { Bind } from \"@webiny/form\";\n\nimport { FieldRenderer } from \"~/presentation/FileList/components/BulkActions/BatchEditorDialog/FieldRenderer.js\";\nimport type { OperationFormData } from \"~/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialogPresenter.js\";\n\nexport interface OperationProps {\n operation: OperationFormData;\n name: string;\n onDelete: () => void;\n onSetOperationFieldData: (data: string) => void;\n}\n\nexport const Operation = observer((props: OperationProps) => {\n return (\n <Grid>\n <Grid.Column span={6}>\n <Bind name={`${props.name}.field`}>\n {({ value, validation }) => (\n <Select\n label={\"Field\"}\n options={props.operation.fieldOptions}\n value={value}\n onChange={data => props.onSetOperationFieldData(data)}\n validation={validation}\n />\n )}\n </Bind>\n </Grid.Column>\n <Grid.Column span={6}>\n {props.operation.field && (\n <Bind name={`${props.name}.operator`}>\n {({ value, onChange, validation }) => (\n <Select\n label={\"Operation\"}\n options={props.operation.operatorOptions}\n value={value}\n onChange={onChange}\n validation={validation}\n />\n )}\n </Bind>\n )}\n </Grid.Column>\n <>\n {props.operation.selectedField ? (\n <FieldRenderer\n operator={props.operation.operator}\n field={props.operation.selectedField}\n name={`${props.name}.value`}\n />\n ) : null}\n </>\n </Grid>\n );\n});\n"],"names":["Operation","observer","props","Grid","Bind","value","validation","Select","data","onChange","FieldRenderer"],"mappings":";;;;;AAgBO,MAAMA,YAAYC,SAAS,CAACC,QACxB,WAAP,GACI,oBAACC,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM,GAAGF,MAAM,IAAI,CAAC,MAAM,CAAC;OAC5B,CAAC,EAAEG,KAAK,EAAEC,UAAU,EAAE,iBACnB,oBAACC,QAAMA;YACH,OAAO;YACP,SAASL,MAAM,SAAS,CAAC,YAAY;YACrC,OAAOG;YACP,UAAUG,CAAAA,OAAQN,MAAM,uBAAuB,CAACM;YAChD,YAAYF;4BAK5B,oBAACH,KAAK,MAAM;QAAC,MAAM;OACdD,MAAM,SAAS,CAAC,KAAK,IAAI,WAAJ,GAClB,oBAACE,MAAIA;QAAC,MAAM,GAAGF,MAAM,IAAI,CAAC,SAAS,CAAC;OAC/B,CAAC,EAAEG,KAAK,EAAEI,QAAQ,EAAEH,UAAU,EAAE,iBAC7B,oBAACC,QAAMA;YACH,OAAO;YACP,SAASL,MAAM,SAAS,CAAC,eAAe;YACxC,OAAOG;YACP,UAAUI;YACV,YAAYH;4BAMhC,0CACKJ,MAAM,SAAS,CAAC,aAAa,GAAG,WAAH,GAC1B,oBAACQ,eAAaA;QACV,UAAUR,MAAM,SAAS,CAAC,QAAQ;QAClC,OAAOA,MAAM,SAAS,CAAC,aAAa;QACpC,MAAM,GAAGA,MAAM,IAAI,CAAC,MAAM,CAAC;SAE/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./BatchEditorDialog.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./BatchEditorDialog.js";
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import react, { useCallback, useEffect, useMemo } from "react";
|
|
2
|
-
import { observer } from "mobx-react-lite";
|
|
3
|
-
import { ReactComponent } from "@webiny/icons/edit.svg";
|
|
4
|
-
import { Tooltip } from "@webiny/admin-ui";
|
|
5
|
-
import { useFeature } from "@webiny/app";
|
|
6
|
-
import omit from "lodash/omit.js";
|
|
7
|
-
import { prepareFormData } from "@webiny/app-headless-cms-common";
|
|
8
|
-
import { BulkAction, getFilesLabel } from "./useBulkActionWorker.js";
|
|
9
|
-
import { useFileManagerPresenter } from "../../FileManagerPresenterProvider.js";
|
|
10
|
-
import { UpdateFileFeature } from "../../../../features/updateFile/feature.js";
|
|
11
|
-
import { ActionEditPresenter } from "./ActionEditPresenter.js";
|
|
12
|
-
import { BatchEditorDialog } from "./BatchEditorDialog/BatchEditorDialog.js";
|
|
13
|
-
import { GraphQLInputMapper } from "./GraphQLInputMapper.js";
|
|
14
|
-
const { useButtons: useButtons } = BulkAction;
|
|
15
|
-
const BulkActionEdit_BulkActionEdit = observer(function() {
|
|
16
|
-
const { ButtonDefault } = useButtons();
|
|
17
|
-
const { vm } = useFileManagerPresenter();
|
|
18
|
-
const { useCase: updateFileUseCase } = useFeature(UpdateFileFeature);
|
|
19
|
-
const { useWorker, useDialog } = BulkAction;
|
|
20
|
-
const worker = useWorker();
|
|
21
|
-
const { showConfirmationDialog, showResultsDialog } = useDialog();
|
|
22
|
-
const fields = vm.fileModel?.fields ?? [];
|
|
23
|
-
const presenter = useMemo(()=>new ActionEditPresenter(), []);
|
|
24
|
-
useEffect(()=>{
|
|
25
|
-
presenter.load(fields);
|
|
26
|
-
}, [
|
|
27
|
-
fields
|
|
28
|
-
]);
|
|
29
|
-
const filesLabel = useMemo(()=>getFilesLabel(worker.items.length), [
|
|
30
|
-
worker.items.length
|
|
31
|
-
]);
|
|
32
|
-
const openWorkerDialog = useCallback((batch, modelFields)=>{
|
|
33
|
-
showConfirmationDialog({
|
|
34
|
-
title: "Edit files",
|
|
35
|
-
message: `You are about to edit ${filesLabel}. Are you sure you want to continue?`,
|
|
36
|
-
loadingLabel: `Processing ${filesLabel}`,
|
|
37
|
-
execute: async ()=>{
|
|
38
|
-
await worker.processInSeries(async ({ item, report })=>{
|
|
39
|
-
try {
|
|
40
|
-
const modifiedFileData = GraphQLInputMapper.applyOperations(item, batch);
|
|
41
|
-
const output = omit(modifiedFileData, [
|
|
42
|
-
"id",
|
|
43
|
-
"createdBy",
|
|
44
|
-
"createdOn",
|
|
45
|
-
"src"
|
|
46
|
-
]);
|
|
47
|
-
const fileData = prepareFormData(output, modelFields);
|
|
48
|
-
const result = await updateFileUseCase.execute({
|
|
49
|
-
id: item.id,
|
|
50
|
-
data: fileData
|
|
51
|
-
});
|
|
52
|
-
if (!result.success) return void report.error({
|
|
53
|
-
title: `${item.name}`,
|
|
54
|
-
message: result.error.message
|
|
55
|
-
});
|
|
56
|
-
report.success({
|
|
57
|
-
title: `${item.name}`,
|
|
58
|
-
message: "File successfully edited."
|
|
59
|
-
});
|
|
60
|
-
} catch (e) {
|
|
61
|
-
report.error({
|
|
62
|
-
title: `${item.name}`,
|
|
63
|
-
message: e.message
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
worker.resetItems();
|
|
68
|
-
showResultsDialog({
|
|
69
|
-
results: worker.results,
|
|
70
|
-
title: "Edit files",
|
|
71
|
-
message: "Finished editing files! See full report below:"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}, [
|
|
76
|
-
filesLabel
|
|
77
|
-
]);
|
|
78
|
-
const onBatchEditorSubmit = useCallback((batch)=>{
|
|
79
|
-
presenter.closeEditor();
|
|
80
|
-
openWorkerDialog(batch, fields);
|
|
81
|
-
}, [
|
|
82
|
-
openWorkerDialog,
|
|
83
|
-
fields
|
|
84
|
-
]);
|
|
85
|
-
if (!presenter.vm.show) return null;
|
|
86
|
-
if (!vm.permissions.canEdit) return null;
|
|
87
|
-
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Tooltip, {
|
|
88
|
-
side: "bottom",
|
|
89
|
-
content: `Edit ${filesLabel}`,
|
|
90
|
-
trigger: /*#__PURE__*/ react.createElement(ButtonDefault, {
|
|
91
|
-
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
92
|
-
onAction: ()=>presenter.openEditor(),
|
|
93
|
-
size: "sm"
|
|
94
|
-
}, "Edit")
|
|
95
|
-
}), /*#__PURE__*/ react.createElement(BatchEditorDialog, {
|
|
96
|
-
onClose: ()=>presenter.closeEditor(),
|
|
97
|
-
fields: presenter.vm.fields,
|
|
98
|
-
batch: presenter.vm.currentBatch,
|
|
99
|
-
vm: presenter.vm.editorVm,
|
|
100
|
-
onApply: onBatchEditorSubmit
|
|
101
|
-
}));
|
|
102
|
-
});
|
|
103
|
-
export { BulkActionEdit_BulkActionEdit as BulkActionEdit };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=BulkActionEdit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/FileList/components/BulkActions/BulkActionEdit.js","sources":["../../../../../src/presentation/FileList/components/BulkActions/BulkActionEdit.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { Tooltip } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport omit from \"lodash/omit.js\";\nimport { prepareFormData } from \"@webiny/app-headless-cms-common\";\nimport type { CmsModelField } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { BulkAction, getFilesLabel } from \"./useBulkActionWorker.js\";\nimport { useFileManagerPresenter } from \"../../FileManagerPresenterProvider.js\";\nimport { UpdateFileFeature } from \"~/features/updateFile/feature.js\";\nimport { ActionEditPresenter } from \"~/presentation/FileList/components/BulkActions/ActionEditPresenter.js\";\nimport { BatchEditorDialog } from \"~/presentation/FileList/components/BulkActions/BatchEditorDialog/BatchEditorDialog.js\";\nimport { GraphQLInputMapper } from \"~/presentation/FileList/components/BulkActions/GraphQLInputMapper.js\";\nimport type { BatchDTO } from \"~/presentation/FileList/components/BulkActions/domain/index.js\";\nimport type { FmFile } from \"~/features/shared/types.js\";\n\nconst { useButtons } = BulkAction;\n\nexport const BulkActionEdit = observer(function BulkActionEdit() {\n const { ButtonDefault } = useButtons();\n\n const { vm } = useFileManagerPresenter();\n const { useCase: updateFileUseCase } = useFeature(UpdateFileFeature);\n\n const { useWorker, useDialog } = BulkAction;\n const worker = useWorker();\n const { showConfirmationDialog, showResultsDialog } = useDialog();\n\n const fields = vm.fileModel?.fields ?? [];\n\n const presenter = useMemo<ActionEditPresenter>(() => {\n return new ActionEditPresenter();\n }, []);\n\n useEffect(() => {\n presenter.load(fields);\n }, [fields]);\n\n const filesLabel = useMemo(() => {\n return getFilesLabel(worker.items.length);\n }, [worker.items.length]);\n\n const openWorkerDialog = useCallback(\n (batch: BatchDTO, modelFields: CmsModelField[]) => {\n showConfirmationDialog({\n title: \"Edit files\",\n message: `You are about to edit ${filesLabel}. Are you sure you want to continue?`,\n loadingLabel: `Processing ${filesLabel}`,\n execute: async () => {\n await worker.processInSeries(async ({ item, report }) => {\n try {\n // Apply batch operations to the file data.\n const modifiedFileData = GraphQLInputMapper.applyOperations(\n item as any,\n batch\n ) as FmFile;\n\n const output = omit(modifiedFileData, [\n \"id\",\n \"createdBy\",\n \"createdOn\",\n \"src\"\n ]);\n\n const fileData = prepareFormData(output, modelFields);\n\n const result = await updateFileUseCase.execute({\n id: item.id,\n data: fileData\n });\n\n if (!result.success) {\n report.error({\n title: `${item.name}`,\n message: result.error.message\n });\n return;\n }\n\n report.success({\n title: `${item.name}`,\n message: \"File successfully edited.\"\n });\n } catch (e) {\n report.error({\n title: `${item.name}`,\n message: (e as Error).message\n });\n }\n });\n\n worker.resetItems();\n\n showResultsDialog({\n results: worker.results,\n title: \"Edit files\",\n message: \"Finished editing files! See full report below:\"\n });\n }\n });\n },\n [filesLabel]\n );\n\n const onBatchEditorSubmit = useCallback(\n (batch: BatchDTO) => {\n presenter.closeEditor();\n openWorkerDialog(batch, fields);\n },\n [openWorkerDialog, fields]\n );\n\n if (!presenter.vm.show) {\n return null;\n }\n\n if (!vm.permissions.canEdit) {\n return null;\n }\n\n return (\n <>\n <Tooltip\n side={\"bottom\"}\n content={`Edit ${filesLabel}`}\n trigger={\n <ButtonDefault\n icon={<EditIcon />}\n onAction={() => presenter.openEditor()}\n size={\"sm\"}\n >\n {\"Edit\"}\n </ButtonDefault>\n }\n />\n <BatchEditorDialog\n onClose={() => presenter.closeEditor()}\n fields={presenter.vm.fields}\n batch={presenter.vm.currentBatch}\n vm={presenter.vm.editorVm}\n onApply={onBatchEditorSubmit}\n />\n </>\n );\n});\n"],"names":["useButtons","BulkAction","BulkActionEdit","observer","ButtonDefault","vm","useFileManagerPresenter","updateFileUseCase","useFeature","UpdateFileFeature","useWorker","useDialog","worker","showConfirmationDialog","showResultsDialog","fields","presenter","useMemo","ActionEditPresenter","useEffect","filesLabel","getFilesLabel","openWorkerDialog","useCallback","batch","modelFields","item","report","modifiedFileData","GraphQLInputMapper","output","omit","fileData","prepareFormData","result","e","onBatchEditorSubmit","Tooltip","EditIcon","BatchEditorDialog"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,EAAEA,YAAAA,UAAU,EAAE,GAAGC;AAEhB,MAAMC,gCAAiBC,SAAS;IACnC,MAAM,EAAEC,aAAa,EAAE,GAAGJ;IAE1B,MAAM,EAAEK,EAAE,EAAE,GAAGC;IACf,MAAM,EAAE,SAASC,iBAAiB,EAAE,GAAGC,WAAWC;IAElD,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGV;IACjC,MAAMW,SAASF;IACf,MAAM,EAAEG,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGH;IAEtD,MAAMI,SAASV,GAAG,SAAS,EAAE,UAAU,EAAE;IAEzC,MAAMW,YAAYC,QAA6B,IACpC,IAAIC,uBACZ,EAAE;IAELC,UAAU;QACNH,UAAU,IAAI,CAACD;IACnB,GAAG;QAACA;KAAO;IAEX,MAAMK,aAAaH,QAAQ,IAChBI,cAAcT,OAAO,KAAK,CAAC,MAAM,GACzC;QAACA,OAAO,KAAK,CAAC,MAAM;KAAC;IAExB,MAAMU,mBAAmBC,YACrB,CAACC,OAAiBC;QACdZ,uBAAuB;YACnB,OAAO;YACP,SAAS,CAAC,sBAAsB,EAAEO,WAAW,oCAAoC,CAAC;YAClF,cAAc,CAAC,WAAW,EAAEA,YAAY;YACxC,SAAS;gBACL,MAAMR,OAAO,eAAe,CAAC,OAAO,EAAEc,IAAI,EAAEC,MAAM,EAAE;oBAChD,IAAI;wBAEA,MAAMC,mBAAmBC,mBAAmB,eAAe,CACvDH,MACAF;wBAGJ,MAAMM,SAASC,KAAKH,kBAAkB;4BAClC;4BACA;4BACA;4BACA;yBACH;wBAED,MAAMI,WAAWC,gBAAgBH,QAAQL;wBAEzC,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|
1
|
-
import type React from "react";
|
|
2
|
-
import type { FieldElement } from "@webiny/app-headless-cms-common";
|
|
3
|
-
export type FieldProps = React.ComponentProps<typeof FieldElement>;
|
|
4
|
-
export type FolderFieldDecoratorProps = {
|
|
5
|
-
id?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const shouldDecorateFolderField: (decoratorProps: FolderFieldDecoratorProps, componentProps: FieldProps) => boolean;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useFoldersType } from "@webiny/app-aco";
|
|
2
|
-
const shouldDecorateFolderField = (decoratorProps, componentProps)=>{
|
|
3
|
-
const { id } = decoratorProps;
|
|
4
|
-
const type = useFoldersType();
|
|
5
|
-
if ("FmFile" !== type) return false;
|
|
6
|
-
if (id) return "*" === id ? true : id === componentProps.field.id;
|
|
7
|
-
return true;
|
|
8
|
-
};
|
|
9
|
-
export { shouldDecorateFolderField };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=FolderFieldDecorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/config/configComponents/Browser/FolderFieldDecorator.js","sources":["../../../../../src/presentation/config/configComponents/Browser/FolderFieldDecorator.tsx"],"sourcesContent":["import type React from \"react\";\nimport type { FieldElement } from \"@webiny/app-headless-cms-common\";\nimport { useFoldersType } from \"@webiny/app-aco\";\n\nexport type FieldProps = React.ComponentProps<typeof FieldElement>;\n\nexport type FolderFieldDecoratorProps = {\n id?: string;\n};\n\nexport const shouldDecorateFolderField = (\n decoratorProps: FolderFieldDecoratorProps,\n componentProps: FieldProps\n) => {\n const { id } = decoratorProps;\n const type = useFoldersType();\n\n if (type !== \"FmFile\") {\n return false;\n }\n\n if (id) {\n return id === \"*\" ? true : id === componentProps.field.id;\n }\n\n return true;\n};\n"],"names":["shouldDecorateFolderField","decoratorProps","componentProps","id","type","useFoldersType"],"mappings":";AAUO,MAAMA,4BAA4B,CACrCC,gBACAC;IAEA,MAAM,EAAEC,EAAE,EAAE,GAAGF;IACf,MAAMG,OAAOC;IAEb,IAAID,AAAS,aAATA,MACA,OAAO;IAGX,IAAID,IACA,OAAOA,AAAO,QAAPA,KAAa,OAAOA,OAAOD,eAAe,KAAK,CAAC,EAAE;IAG7D,OAAO;AACX"}
|