@blaze-cms/plugin-media-ui 0.146.0-node18.1 → 0.146.0-rc-eagle-3.0
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/CHANGELOG.md +13 -12
- package/lib/components/CardMedia/CardMedia.js +235 -244
- package/lib/components/CardMedia/CardMedia.js.map +1 -1
- package/lib/components/CardMedia/index.js +2 -3
- package/lib/components/CardMedia/index.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFile.js +149 -115
- package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFilePage.js +89 -97
- package/lib/components/EditMediaFile/EditMediaFilePage.js.map +1 -1
- package/lib/components/EditMediaFile/index.js +2 -3
- package/lib/components/EditMediaFile/index.js.map +1 -1
- package/lib/components/EditorAdapter/EditorAdapter.js +43 -22
- package/lib/components/EditorAdapter/EditorAdapter.js.map +1 -1
- package/lib/components/EditorAdapter/index.js +2 -3
- package/lib/components/EditorAdapter/index.js.map +1 -1
- package/lib/components/FileList/FilesListContext/index.js +3 -4
- package/lib/components/FileList/FilesListContext/index.js.map +1 -1
- package/lib/components/FileList/FilesListProvider/index.js +27 -29
- package/lib/components/FileList/FilesListProvider/index.js.map +1 -1
- package/lib/components/FileList/useFileList/index.js +3 -6
- package/lib/components/FileList/useFileList/index.js.map +1 -1
- package/lib/components/FileList/useGetFiles/getFiles.js +167 -185
- package/lib/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib/components/FileList/useGetFiles/index.js +2 -3
- package/lib/components/FileList/useGetFiles/index.js.map +1 -1
- package/lib/components/FileList/useGetFiles/useGetFiles.js +93 -133
- package/lib/components/FileList/useGetFiles/useGetFiles.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/getCounters.js +10 -30
- package/lib/components/FileList/useGetFilesList/getCounters.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/index.js +2 -3
- package/lib/components/FileList/useGetFilesList/index.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js +92 -110
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -1
- package/lib/components/FilePreview/Actions/index.js +25 -38
- package/lib/components/FilePreview/Actions/index.js.map +1 -1
- package/lib/components/FilePreview/Image/Image.js +35 -24
- package/lib/components/FilePreview/Image/Image.js.map +1 -1
- package/lib/components/FilePreview/Image/RawImage.js +25 -27
- package/lib/components/FilePreview/Image/RawImage.js.map +1 -1
- package/lib/components/FilePreview/Image/imageSchema.js +10 -7
- package/lib/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib/components/FilePreview/Image/index.js +1 -2
- package/lib/components/FilePreview/Image/index.js.map +1 -1
- package/lib/components/FilePreview/ModalContext.js +9 -0
- package/lib/components/FilePreview/ModalContext.js.map +1 -0
- package/lib/components/FilePreview/PDF/PDF.js +44 -31
- package/lib/components/FilePreview/PDF/PDF.js.map +1 -1
- package/lib/components/FilePreview/PDF/RawPDF.js +27 -29
- package/lib/components/FilePreview/PDF/RawPDF.js.map +1 -1
- package/lib/components/FilePreview/PDF/index.js +1 -2
- package/lib/components/FilePreview/PDF/index.js.map +1 -1
- package/lib/components/FilePreview/PDF/schema.js +3 -3
- package/lib/components/FilePreview/PDF/schema.js.map +1 -1
- package/lib/components/FilePreview/get-preview.js +12 -10
- package/lib/components/FilePreview/get-preview.js.map +1 -1
- package/lib/components/FilePreview/index.js +111 -58
- package/lib/components/FilePreview/index.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/PreviewDefault.js +35 -23
- package/lib/components/FilePreview/previewDefault/PreviewDefault.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/RawPreviewDefault.js +33 -27
- package/lib/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/icons/DefaultIcon.js +120 -123
- package/lib/components/FilePreview/previewDefault/icons/DefaultIcon.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/icons/index.js +2 -3
- package/lib/components/FilePreview/previewDefault/icons/index.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/index.js +1 -2
- package/lib/components/FilePreview/previewDefault/index.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/previewDefaultSchema.js +3 -3
- package/lib/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FileList.js +10 -12
- package/lib/components/FilePreviewReadOnly/FileList.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js +14 -20
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js +53 -98
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/index.js +2 -3
- package/lib/components/FilePreviewReadOnly/index.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/mappers/format-initial-value.js +7 -8
- package/lib/components/FilePreviewReadOnly/mappers/format-initial-value.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/mappers/index.js +1 -2
- package/lib/components/FilePreviewReadOnly/mappers/index.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileList.js +27 -39
- package/lib/components/FileUploadAdapter/FileList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FilePreviewList.js +14 -20
- package/lib/components/FileUploadAdapter/FilePreviewList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileReorderList.js +18 -21
- package/lib/components/FileUploadAdapter/FileReorderList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileReorderListItem.js +20 -23
- package/lib/components/FileUploadAdapter/FileReorderListItem.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js +253 -341
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib/components/FileUploadAdapter/index.js +2 -3
- package/lib/components/FileUploadAdapter/index.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/format-initial-value.js +7 -8
- package/lib/components/FileUploadAdapter/mappers/format-initial-value.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/get-button-text.js +9 -6
- package/lib/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/get-format.js +7 -13
- package/lib/components/FileUploadAdapter/mappers/get-format.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +6 -5
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/index.js +6 -7
- package/lib/components/FileUploadAdapter/mappers/index.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/is-unselecting.js +2 -10
- package/lib/components/FileUploadAdapter/mappers/is-unselecting.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/transform-to-array.js +2 -5
- package/lib/components/FileUploadAdapter/mappers/transform-to-array.js.map +1 -1
- package/lib/components/FileUploadAdapter/useLimit.js +4 -10
- package/lib/components/FileUploadAdapter/useLimit.js.map +1 -1
- package/lib/components/FileUploadModal/FileUploadModal.js +215 -146
- package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib/components/FileUploadModal/index.js +2 -3
- package/lib/components/FileUploadModal/index.js.map +1 -1
- package/lib/components/FilterPanel/FilterPanel.js +49 -151
- package/lib/components/FilterPanel/FilterPanel.js.map +1 -1
- package/lib/components/FilterPanel/MediaSearchFilter.js +41 -0
- package/lib/components/FilterPanel/MediaSearchFilter.js.map +1 -0
- package/lib/components/FilterPanel/index.js +2 -3
- package/lib/components/FilterPanel/index.js.map +1 -1
- package/lib/components/ListingContainer/Listing/Listing.js +58 -48
- package/lib/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +83 -96
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js +2 -3
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js +23 -26
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/index.js +2 -3
- package/lib/components/ListingContainer/Listing/MediaListing/index.js.map +1 -1
- package/lib/components/ListingContainer/Listing/index.js +2 -3
- package/lib/components/ListingContainer/Listing/index.js.map +1 -1
- package/lib/components/ListingContainer/ListingContainer.js +74 -93
- package/lib/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib/components/ListingContainer/index.js +2 -3
- package/lib/components/ListingContainer/index.js.map +1 -1
- package/lib/components/ListingContainer/mappers/exist-previous.js +3 -10
- package/lib/components/ListingContainer/mappers/exist-previous.js.map +1 -1
- package/lib/components/ListingContainer/mappers/index.js +2 -3
- package/lib/components/ListingContainer/mappers/index.js.map +1 -1
- package/lib/components/MediaListing.js +15 -26
- package/lib/components/MediaListing.js.map +1 -1
- package/lib/constants.js +17 -17
- package/lib/constants.js.map +1 -1
- package/lib/icons/MediaLibraryIcon.js +17 -20
- package/lib/icons/MediaLibraryIcon.js.map +1 -1
- package/lib/icons/index.js +2 -3
- package/lib/icons/index.js.map +1 -1
- package/lib/index.js +67 -92
- package/lib/index.js.map +1 -1
- package/lib/utils/available-filters/available-filters.js +1 -2
- package/lib/utils/available-filters/available-filters.js.map +1 -1
- package/lib/utils/bustUrl.js +13 -0
- package/lib/utils/bustUrl.js.map +1 -0
- package/lib/utils/media-context/index.js +4 -5
- package/lib/utils/media-context/index.js.map +1 -1
- package/lib/utils/media-context/media-context.js +3 -4
- package/lib/utils/media-context/media-context.js.map +1 -1
- package/lib/utils/media-context/useMediaContext.js +2 -4
- package/lib/utils/media-context/useMediaContext.js.map +1 -1
- package/lib-es/components/CardMedia/CardMedia.js +109 -52
- package/lib-es/components/CardMedia/CardMedia.js.map +1 -1
- package/lib-es/components/EditMediaFile/EditMediaFile.js +109 -53
- package/lib-es/components/EditMediaFile/EditMediaFile.js.map +1 -1
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js +45 -15
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js.map +1 -1
- package/lib-es/components/EditorAdapter/EditorAdapter.js +26 -6
- package/lib-es/components/EditorAdapter/EditorAdapter.js.map +1 -1
- package/lib-es/components/FileList/useGetFiles/getFiles.js +6 -3
- package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js +7 -2
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js.map +1 -1
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js +4 -1
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -1
- package/lib-es/components/FilePreview/Actions/index.js +2 -2
- package/lib-es/components/FilePreview/Actions/index.js.map +1 -1
- package/lib-es/components/FilePreview/Image/Image.js +16 -3
- package/lib-es/components/FilePreview/Image/Image.js.map +1 -1
- package/lib-es/components/FilePreview/Image/imageSchema.js +9 -5
- package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib-es/components/FilePreview/ModalContext.js +3 -0
- package/lib-es/components/FilePreview/ModalContext.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/PDF.js +19 -4
- package/lib-es/components/FilePreview/PDF/PDF.js.map +1 -1
- package/lib-es/components/FilePreview/PDF/schema.js +2 -1
- package/lib-es/components/FilePreview/PDF/schema.js.map +1 -1
- package/lib-es/components/FilePreview/index.js +72 -9
- package/lib-es/components/FilePreview/index.js.map +1 -1
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js +18 -4
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js.map +1 -1
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js +12 -4
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -1
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js +2 -1
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -1
- package/lib-es/components/FilePreviewReadOnly/FileList.js +2 -2
- package/lib-es/components/FilePreviewReadOnly/FileList.js.map +1 -1
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js +14 -12
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +78 -43
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js +5 -3
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +5 -4
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -1
- package/lib-es/components/FileUploadModal/FileUploadModal.js +157 -29
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib-es/components/FilterPanel/FilterPanel.js +43 -123
- package/lib-es/components/FilterPanel/FilterPanel.js.map +1 -1
- package/lib-es/components/FilterPanel/MediaSearchFilter.js +34 -0
- package/lib-es/components/FilterPanel/MediaSearchFilter.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/Listing.js +17 -5
- package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +21 -10
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -1
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js +12 -3
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -1
- package/lib-es/components/ListingContainer/ListingContainer.js +18 -6
- package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib-es/constants.js +3 -2
- package/lib-es/constants.js.map +1 -1
- package/lib-es/index.js +20 -4
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/bustUrl.js +7 -0
- package/lib-es/utils/bustUrl.js.map +1 -0
- package/package.json +20 -13
- package/src/components/CardMedia/CardMedia.js +131 -82
- package/src/components/EditMediaFile/EditMediaFile.js +123 -46
- package/src/components/EditMediaFile/EditMediaFilePage.js +41 -10
- package/src/components/EditorAdapter/EditorAdapter.js +31 -4
- package/src/components/FileList/useGetFiles/getFiles.js +12 -4
- package/src/components/FileList/useGetFiles/useGetFiles.js +3 -4
- package/src/components/FileList/useGetFilesList/useGetFilesList.js +2 -1
- package/src/components/FilePreview/Actions/index.js +25 -27
- package/src/components/FilePreview/Image/Image.js +15 -2
- package/src/components/FilePreview/Image/imageSchema.js +9 -5
- package/src/components/FilePreview/ModalContext.js +3 -0
- package/src/components/FilePreview/PDF/PDF.js +17 -4
- package/src/components/FilePreview/PDF/schema.js +2 -1
- package/src/components/FilePreview/index.js +69 -6
- package/src/components/FilePreview/previewDefault/PreviewDefault.js +16 -3
- package/src/components/FilePreview/previewDefault/RawPreviewDefault.js +17 -7
- package/src/components/FilePreview/previewDefault/previewDefaultSchema.js +2 -1
- package/src/components/FilePreviewReadOnly/FileList.js +1 -3
- package/src/components/FilePreviewReadOnly/FilePreviewReadOnly.js +17 -29
- package/src/components/FileUploadAdapter/FileUploadAdapter.js +66 -32
- package/src/components/FileUploadAdapter/mappers/get-button-text.js +4 -3
- package/src/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +6 -4
- package/src/components/FileUploadModal/FileUploadModal.js +156 -45
- package/src/components/FilterPanel/FilterPanel.js +44 -129
- package/src/components/FilterPanel/MediaSearchFilter.js +32 -0
- package/src/components/ListingContainer/Listing/Listing.js +15 -5
- package/src/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +18 -7
- package/src/components/ListingContainer/Listing/MediaListing/MediaListing.js +10 -2
- package/src/components/ListingContainer/ListingContainer.js +17 -5
- package/src/constants.js +16 -2
- package/src/index.js +17 -14
- package/src/utils/bustUrl.js +6 -0
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -4,10 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React, { useState, useContext, useEffect } from 'react';
|
|
5
5
|
import FileUpload from '@blaze-react/file-upload';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import { useApolloClient } from '@apollo/client';
|
|
7
|
+
import { useApolloClient, useQuery } from '@apollo/client';
|
|
8
8
|
import { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';
|
|
9
|
-
import { parseFormValues } from '@blaze-cms/react-form-builder';
|
|
10
9
|
import { useToasts } from '@blaze-react/toaster';
|
|
10
|
+
import Tooltip from '@blaze-react/tooltip';
|
|
11
11
|
import { MORE } from '../../constants';
|
|
12
12
|
import ListingContainer from '../ListingContainer';
|
|
13
13
|
import { MediaContextProvider } from '../../utils/media-context';
|
|
@@ -25,7 +25,11 @@ const FileUploadAdapter = ({
|
|
|
25
25
|
shouldRenderInPreview,
|
|
26
26
|
canDragAndDrop,
|
|
27
27
|
simpleLayout,
|
|
28
|
-
|
|
28
|
+
tooltip,
|
|
29
|
+
previewAllFiles,
|
|
30
|
+
disableFilePreview,
|
|
31
|
+
fileType,
|
|
32
|
+
storeKey
|
|
29
33
|
}) => {
|
|
30
34
|
const {
|
|
31
35
|
InjectPreview
|
|
@@ -38,13 +42,22 @@ const FileUploadAdapter = ({
|
|
|
38
42
|
type
|
|
39
43
|
});
|
|
40
44
|
const [currentValue, setCurrentValue] = useState(initialValue);
|
|
41
|
-
const [currentOffset, setCurrentOffset] = useState(0);
|
|
42
45
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
43
46
|
const [editFile, setEditFile] = useState(null);
|
|
47
|
+
const [allFilesLoaded, setAllFilesLoaded] = useState(false);
|
|
44
48
|
const client = useApolloClient();
|
|
45
49
|
const {
|
|
46
50
|
addToast
|
|
47
51
|
} = useToasts();
|
|
52
|
+
const {
|
|
53
|
+
data: {
|
|
54
|
+
getEntitySchemas: [schemaData] = []
|
|
55
|
+
} = {}
|
|
56
|
+
} = useQuery(getQuery('GET_ENTITY_SCHEMA'), {
|
|
57
|
+
variables: {
|
|
58
|
+
identifier: 'file'
|
|
59
|
+
}
|
|
60
|
+
});
|
|
48
61
|
const getFiles = async (offset, ids, fetchAll = previewAllFiles) => {
|
|
49
62
|
const {
|
|
50
63
|
data: {
|
|
@@ -68,24 +81,26 @@ const FileUploadAdapter = ({
|
|
|
68
81
|
};
|
|
69
82
|
useEffect(() => {
|
|
70
83
|
(async () => {
|
|
84
|
+
if (allFilesLoaded) {
|
|
85
|
+
const loadedFiles = await getFiles(0, currentValue, true);
|
|
86
|
+
const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);
|
|
87
|
+
setSelectedFiles(loadedOrderedFiles);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
71
90
|
const initialFiles = !selectedFiles.length && !previewAllFiles ? currentValue.filter((_, i) => i <= 3) : currentValue;
|
|
72
91
|
const files = await getFiles(0, initialFiles);
|
|
73
92
|
const orderedFiles = orderFiles(files, currentValue);
|
|
74
|
-
setCurrentOffset(0);
|
|
75
93
|
setSelectedFiles(orderedFiles);
|
|
94
|
+
setAllFilesLoaded(false);
|
|
76
95
|
})();
|
|
77
96
|
}, [currentValue] //eslint-disable-line
|
|
78
97
|
);
|
|
79
98
|
const fetchMore = async shouldFetchAll => {
|
|
80
99
|
if (selectedFiles.length === currentValue.length) return;
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const newFiles = [...selectedFiles, ...files];
|
|
86
|
-
const orderedFiles = orderFiles(newFiles, currentValue);
|
|
87
|
-
setSelectedFiles(orderedFiles);
|
|
88
|
-
setCurrentOffset(newOffset);
|
|
100
|
+
const newFiles = await getFiles(0, currentValue, true);
|
|
101
|
+
const newOrderedFiles = orderFiles(newFiles, currentValue);
|
|
102
|
+
setSelectedFiles(newOrderedFiles);
|
|
103
|
+
setAllFilesLoaded(true);
|
|
89
104
|
};
|
|
90
105
|
const handleSelectedFiles = (files, checkIsUnselecting = true) => {
|
|
91
106
|
const isUnselectingFile = isUnselecting(value, checkIsUnselecting, files);
|
|
@@ -159,9 +174,10 @@ const FileUploadAdapter = ({
|
|
|
159
174
|
};
|
|
160
175
|
const fileUploadButtonText = getButtonText({
|
|
161
176
|
maxItems,
|
|
162
|
-
value: initialValue
|
|
177
|
+
value: initialValue,
|
|
178
|
+
fileType
|
|
163
179
|
});
|
|
164
|
-
const filesPending = previewAllFiles ? 0 : getNumberFilesPendingToFetch(
|
|
180
|
+
const filesPending = previewAllFiles ? 0 : getNumberFilesPendingToFetch(selectedFiles.length, currentValue);
|
|
165
181
|
const onOpenLibrary = () => setDisplayModal(true);
|
|
166
182
|
const handleEditModal = file => {
|
|
167
183
|
const selectedEditFile = selectedFiles.find(({
|
|
@@ -170,22 +186,25 @@ const FileUploadAdapter = ({
|
|
|
170
186
|
setEditFile(selectedEditFile);
|
|
171
187
|
};
|
|
172
188
|
const handleEditFileForm = editedFile => {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
name,
|
|
183
|
-
data: {
|
|
184
|
-
altText,
|
|
185
|
-
caption,
|
|
186
|
-
credits,
|
|
187
|
-
hrefUrl
|
|
189
|
+
const dataValues = editedFile.valuesChecked.reduce((acc, {
|
|
190
|
+
id: formValueId,
|
|
191
|
+
value: formValue,
|
|
192
|
+
isDataPropery
|
|
193
|
+
}) => {
|
|
194
|
+
if (isDataPropery) {
|
|
195
|
+
acc.data[formValueId] = formValue;
|
|
196
|
+
} else {
|
|
197
|
+
acc[formValueId] = formValue;
|
|
188
198
|
}
|
|
199
|
+
return acc;
|
|
200
|
+
}, {
|
|
201
|
+
id: editFile.id,
|
|
202
|
+
data: _objectSpread({}, editFile.data)
|
|
203
|
+
});
|
|
204
|
+
delete dataValues.data.__typename; // Remove __typename if it exists in data to avoid issues with Apollo cache.
|
|
205
|
+
|
|
206
|
+
setEditFile(_objectSpread(_objectSpread({}, editFile), {}, {
|
|
207
|
+
formData: dataValues
|
|
189
208
|
}));
|
|
190
209
|
};
|
|
191
210
|
const orderFiles = (files, ids) => ids.map(currentId => files.find(({
|
|
@@ -198,7 +217,7 @@ const FileUploadAdapter = ({
|
|
|
198
217
|
},
|
|
199
218
|
modifiers: ['cancel']
|
|
200
219
|
}, {
|
|
201
|
-
textButton: '
|
|
220
|
+
textButton: 'Apply',
|
|
202
221
|
callback: () => {
|
|
203
222
|
closeModalAndSetValue(true);
|
|
204
223
|
},
|
|
@@ -211,12 +230,13 @@ const FileUploadAdapter = ({
|
|
|
211
230
|
},
|
|
212
231
|
modifiers: ['cancel']
|
|
213
232
|
}, {
|
|
214
|
-
textButton: '
|
|
233
|
+
textButton: 'Apply',
|
|
215
234
|
callback: async () => {
|
|
216
235
|
const {
|
|
217
236
|
name,
|
|
218
237
|
id: editedFileId,
|
|
219
|
-
data
|
|
238
|
+
data,
|
|
239
|
+
formData
|
|
220
240
|
} = editFile;
|
|
221
241
|
const updatedSelectedFiles = selectedFiles.map(selectedFile => {
|
|
222
242
|
if (selectedFile.id === editedFileId) {
|
|
@@ -232,11 +252,9 @@ const FileUploadAdapter = ({
|
|
|
232
252
|
await client.mutate({
|
|
233
253
|
mutation: getMutation('UPDATE_FILE'),
|
|
234
254
|
variables: {
|
|
235
|
-
input: {
|
|
236
|
-
name,
|
|
237
|
-
data,
|
|
255
|
+
input: _objectSpread(_objectSpread({}, formData), {}, {
|
|
238
256
|
id: editedFileId
|
|
239
|
-
}
|
|
257
|
+
})
|
|
240
258
|
},
|
|
241
259
|
update(cache, {
|
|
242
260
|
data: {
|
|
@@ -280,7 +298,9 @@ const FileUploadAdapter = ({
|
|
|
280
298
|
}, "+ ", filesPendingString) : null;
|
|
281
299
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
282
300
|
className: "form-field form-field--button"
|
|
283
|
-
}, /*#__PURE__*/React.createElement("label", null, label
|
|
301
|
+
}, /*#__PURE__*/React.createElement("label", null, label, " ", /*#__PURE__*/React.createElement(Tooltip, {
|
|
302
|
+
tooltipContent: tooltip
|
|
303
|
+
})), selectedFiles && /*#__PURE__*/React.createElement(MediaContextProvider, {
|
|
284
304
|
value: {
|
|
285
305
|
handleEditModal,
|
|
286
306
|
onUnselectFile: handleSelectedFiles
|
|
@@ -299,6 +319,7 @@ const FileUploadAdapter = ({
|
|
|
299
319
|
fetchMore: fetchMore
|
|
300
320
|
})), /*#__PURE__*/React.createElement(FileUpload, {
|
|
301
321
|
actionText: fileUploadButtonText,
|
|
322
|
+
storeKey: storeKey,
|
|
302
323
|
handleLibraryClick: () => {
|
|
303
324
|
if (simpleLayout) {
|
|
304
325
|
setDisplayFileUploadModal(true);
|
|
@@ -316,7 +337,9 @@ const FileUploadAdapter = ({
|
|
|
316
337
|
fileName: editFile.fileName,
|
|
317
338
|
handleFormChange: handleEditFileForm,
|
|
318
339
|
displayForm: true,
|
|
319
|
-
previewType: "card"
|
|
340
|
+
previewType: "card",
|
|
341
|
+
disableFilePreview: disableFilePreview,
|
|
342
|
+
schemaData: schemaData
|
|
320
343
|
})), displayFileUploadModal && simpleLayout && /*#__PURE__*/React.createElement("div", {
|
|
321
344
|
className: "file-upload-modal-wrapper"
|
|
322
345
|
}, /*#__PURE__*/React.createElement(ListingContainer, {
|
|
@@ -326,7 +349,9 @@ const FileUploadAdapter = ({
|
|
|
326
349
|
handleSelectedFiles: handleSelectedFiles,
|
|
327
350
|
maxItems: currentLimit,
|
|
328
351
|
simpleLayout: simpleLayout,
|
|
329
|
-
filesSelected: currentValue.length > 1 ? currentValue : []
|
|
352
|
+
filesSelected: currentValue.length > 1 ? currentValue : [],
|
|
353
|
+
openEditInModal: true,
|
|
354
|
+
storeKey: storeKey
|
|
330
355
|
})), displayModal && !simpleLayout && /*#__PURE__*/React.createElement("div", {
|
|
331
356
|
className: "file-upload-modal-wrapper"
|
|
332
357
|
}, /*#__PURE__*/React.createElement(Modal, {
|
|
@@ -340,7 +365,9 @@ const FileUploadAdapter = ({
|
|
|
340
365
|
setDisplayFileUploadModal: setDisplayFileUploadModal,
|
|
341
366
|
handleSelectedFiles: handleSelectedFiles,
|
|
342
367
|
maxItems: currentLimit,
|
|
343
|
-
filesSelected: currentValue.length > 1 ? currentValue : []
|
|
368
|
+
filesSelected: currentValue.length > 1 ? currentValue : [],
|
|
369
|
+
openEditInModal: true,
|
|
370
|
+
storeKey: storeKey
|
|
344
371
|
}))));
|
|
345
372
|
};
|
|
346
373
|
FileUploadAdapter.propTypes = {
|
|
@@ -353,7 +380,11 @@ FileUploadAdapter.propTypes = {
|
|
|
353
380
|
shouldRenderInPreview: PropTypes.bool,
|
|
354
381
|
canDragAndDrop: PropTypes.bool,
|
|
355
382
|
simpleLayout: PropTypes.bool,
|
|
356
|
-
previewAllFiles: PropTypes.bool
|
|
383
|
+
previewAllFiles: PropTypes.bool,
|
|
384
|
+
tooltip: PropTypes.string,
|
|
385
|
+
fileType: PropTypes.string,
|
|
386
|
+
disableFilePreview: PropTypes.bool,
|
|
387
|
+
storeKey: PropTypes.string
|
|
357
388
|
};
|
|
358
389
|
FileUploadAdapter.defaultProps = {
|
|
359
390
|
value: '',
|
|
@@ -361,7 +392,11 @@ FileUploadAdapter.defaultProps = {
|
|
|
361
392
|
shouldRenderInPreview: false,
|
|
362
393
|
canDragAndDrop: false,
|
|
363
394
|
simpleLayout: false,
|
|
364
|
-
previewAllFiles: false
|
|
395
|
+
previewAllFiles: false,
|
|
396
|
+
tooltip: '',
|
|
397
|
+
fileType: 'file',
|
|
398
|
+
disableFilePreview: true,
|
|
399
|
+
storeKey: null
|
|
365
400
|
};
|
|
366
401
|
export default FileUploadAdapter;
|
|
367
402
|
//# sourceMappingURL=FileUploadAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadAdapter.js","names":["React","useState","useContext","useEffect","FileUpload","PropTypes","useApolloClient","getQuery","getMutation","ModalAdapter","Modal","parseFormValues","useToasts","MORE","ListingContainer","MediaContextProvider","FileList","useLimit","getFormat","formatInitialValue","transformToArray","isUnselecting","getButtonText","getNumberFilesPendingToFetch","FilePreview","FileUploadAdapter","onChange","label","id","type","value","maxItems","shouldRenderInPreview","canDragAndDrop","simpleLayout","previewAllFiles","InjectPreview","FormContext","currentLimit","displayModal","setDisplayModal","displayFileUploadModal","setDisplayFileUploadModal","initialValue","currentValue","setCurrentValue","currentOffset","setCurrentOffset","selectedFiles","setSelectedFiles","editFile","setEditFile","client","addToast","getFiles","offset","ids","fetchAll","data","files","newFiles","query","variables","limit","where","_in","skip","length","fetchPolicy","initialFiles","filter","_","i","orderedFiles","orderFiles","fetchMore","shouldFetchAll","newOffset","updatedOffset","offsetToUse","handleSelectedFiles","checkIsUnselecting","isUnselectingFile","valueArray","selectedFilesIds","valueId","includes","parsedValue","filesIds","event","target","name","fileData","handleReorderFiles","map","fileId","closeModalAndSetValue","isSaving","values","toastMessage","appearance","autoDismiss","fileUploadButtonText","filesPending","onOpenLibrary","handleEditModal","file","selectedEditFile","find","_id","handleEditFileForm","editedFile","valuesChecked","altText","caption","credits","hrefUrl","_objectSpread","currentId","Boolean","modalActions","textButton","callback","modifiers","editModalActions","editedFileId","updatedSelectedFiles","selectedFile","mutate","mutation","input","update","cache","updateFile","fileUpdated","writeQuery","result","e","console","error","filesPendingString","fileListSpan","createElement","className","onClick","Fragment","onUnselectFile","selector","previewerId","allFiles","actionText","handleLibraryClick","enableDragAndDrop","actions","title","onClose","fileName","handleFormChange","displayForm","previewType","filesSelected","propTypes","func","isRequired","string","oneOfType","array","number","bool","defaultProps"],"sources":["../../../src/components/FileUploadAdapter/FileUploadAdapter.js"],"sourcesContent":["import React, { useState, useContext, useEffect } from 'react';\nimport FileUpload from '@blaze-react/file-upload';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';\nimport { parseFormValues } from '@blaze-cms/react-form-builder';\nimport { useToasts } from '@blaze-react/toaster';\nimport { MORE } from '../../constants';\nimport ListingContainer from '../ListingContainer';\nimport { MediaContextProvider } from '../../utils/media-context';\nimport FileList from './FileList';\nimport useLimit from './useLimit';\nimport {\n getFormat,\n formatInitialValue,\n transformToArray,\n isUnselecting,\n getButtonText,\n getNumberFilesPendingToFetch\n} from './mappers';\nimport FilePreview from '../FilePreview';\n\nconst FileUploadAdapter = ({\n onChange,\n label,\n id,\n type,\n value,\n maxItems,\n shouldRenderInPreview,\n canDragAndDrop,\n simpleLayout,\n previewAllFiles\n}) => {\n const { InjectPreview } = useContext(FileUploadAdapter.FormContext);\n const [currentLimit] = useLimit(maxItems);\n const [displayModal, setDisplayModal] = useState(false);\n const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);\n const initialValue = formatInitialValue({ value, type });\n const [currentValue, setCurrentValue] = useState(initialValue);\n const [currentOffset, setCurrentOffset] = useState(0);\n const [selectedFiles, setSelectedFiles] = useState([]);\n const [editFile, setEditFile] = useState(null);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n const getFiles = async (offset, ids, fetchAll = previewAllFiles) => {\n const {\n data: { files: newFiles }\n } = await client.query({\n query: getQuery('GET_FILES'),\n variables: {\n limit: fetchAll ? 0 : 4,\n offset,\n where: {\n id: {\n _in: ids\n }\n }\n },\n skip: !currentValue.length,\n fetchPolicy: 'network-only'\n });\n return newFiles;\n };\n\n useEffect(\n () => {\n (async () => {\n const initialFiles =\n !selectedFiles.length && !previewAllFiles\n ? currentValue.filter((_, i) => i <= 3)\n : currentValue;\n\n const files = await getFiles(0, initialFiles);\n const orderedFiles = orderFiles(files, currentValue);\n setCurrentOffset(0);\n setSelectedFiles(orderedFiles);\n })();\n },\n [currentValue] //eslint-disable-line\n );\n\n const fetchMore = async shouldFetchAll => {\n if (selectedFiles.length === currentValue.length) return;\n const newOffset = currentOffset + 4;\n const updatedOffset = newOffset > currentValue.length ? currentValue.length : newOffset;\n const offsetToUse = shouldFetchAll ? 0 : updatedOffset;\n const files = await getFiles(offsetToUse, currentValue, shouldFetchAll);\n const newFiles = [...selectedFiles, ...files];\n const orderedFiles = orderFiles(newFiles, currentValue);\n setSelectedFiles(orderedFiles);\n setCurrentOffset(newOffset);\n };\n\n const handleSelectedFiles = (files, checkIsUnselecting = true) => {\n const isUnselectingFile = isUnselecting(value, checkIsUnselecting, files);\n if (isUnselectingFile) {\n const valueArray = transformToArray(value);\n const selectedFilesIds = valueArray.filter(valueId => !files.includes(valueId));\n const parsedValue = getFormat(type, { filesIds: selectedFilesIds });\n setCurrentValue(selectedFilesIds);\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: selectedFilesIds.length ? selectedFilesIds : null\n }\n },\n value: parsedValue\n });\n }\n\n setCurrentValue(files);\n };\n\n const handleReorderFiles = files => {\n const filesIds = files.map(({ id: fileId }) => fileId);\n const parsedValue = getFormat(type, { filesIds });\n setSelectedFiles(files);\n\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: filesIds\n }\n },\n value: parsedValue\n });\n };\n\n const closeModalAndSetValue = (isSaving, values, toastMessage) => {\n if (toastMessage) {\n addToast(toastMessage, {\n appearance: 'success',\n autoDismiss: true\n });\n }\n\n if (isSaving) {\n const parsedValue = getFormat(type, { filesIds: simpleLayout ? values : currentValue });\n setDisplayModal(false);\n return onChange({\n event: { target: { value: parsedValue, name: id, type, currentValue } },\n value: parsedValue\n });\n }\n\n setCurrentValue(initialValue);\n setDisplayModal(false);\n };\n\n const fileUploadButtonText = getButtonText({ maxItems, value: initialValue });\n\n const filesPending = previewAllFiles\n ? 0\n : getNumberFilesPendingToFetch(currentOffset, currentValue);\n const onOpenLibrary = () => setDisplayModal(true);\n const handleEditModal = file => {\n const selectedEditFile = selectedFiles.find(({ id: _id }) => _id === file.id);\n setEditFile(selectedEditFile);\n };\n\n const handleEditFileForm = editedFile => {\n const values = parseFormValues(editedFile.valuesChecked);\n\n const { altText, caption, credits, hrefUrl, name } = values;\n setEditFile({\n ...editFile,\n name,\n data: {\n altText,\n caption,\n credits,\n hrefUrl\n }\n });\n };\n\n const orderFiles = (files, ids) =>\n ids.map(currentId => files.find(({ id: fileId }) => fileId === currentId)).filter(Boolean);\n\n const modalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n closeModalAndSetValue();\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Save',\n callback: () => {\n closeModalAndSetValue(true);\n },\n modifiers: []\n }\n ];\n\n const editModalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n setEditFile(null);\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Save',\n callback: async () => {\n const { name, id: editedFileId, data } = editFile;\n const updatedSelectedFiles = selectedFiles.map(selectedFile => {\n if (selectedFile.id === editedFileId) {\n return { ...selectedFile, name, data };\n }\n return selectedFile;\n });\n setSelectedFiles(updatedSelectedFiles);\n\n try {\n await client.mutate({\n mutation: getMutation('UPDATE_FILE'),\n variables: {\n input: {\n name,\n data,\n id: editedFileId\n }\n },\n update(cache, { data: { updateFile: fileUpdated } }) {\n cache.writeQuery({\n query: getQuery('GET_FILE_BY_ID'),\n variables: { id },\n data: { file: fileUpdated.result }\n });\n }\n });\n\n addToast(`File: ${editFile.name} has been updated`, {\n appearance: 'success',\n autoDismiss: true\n });\n closeModalAndSetValue(true);\n setEditFile(null);\n } catch (e) {\n addToast(`File: ${editFile.name} has not been updated`, {\n appearance: 'error',\n autoDismiss: true\n });\n console.error(e); //eslint-disable-line\n }\n },\n modifiers: []\n }\n ];\n const filesPendingString = `${filesPending} ${MORE}`;\n const fileListSpan = filesPending ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <span className=\"FileUploadAdapter__preview-link button button--link\" onClick={fetchMore}>\n + {filesPendingString}\n </span>\n ) : null;\n\n return (\n <>\n <div className=\"form-field form-field--button\">\n <label>{label}</label>\n {selectedFiles && (\n <MediaContextProvider value={{ handleEditModal, onUnselectFile: handleSelectedFiles }}>\n {shouldRenderInPreview ? (\n <InjectPreview selector={FileUploadAdapter.previewerId}>\n <FileList\n selectedFiles={selectedFiles}\n allFiles={currentValue}\n handleReorderFiles={handleReorderFiles}\n canDragAndDrop={canDragAndDrop}\n fetchMore={fetchMore}>\n {fileListSpan}\n </FileList>\n </InjectPreview>\n ) : (\n <FileList\n selectedFiles={selectedFiles}\n handleReorderFiles={handleReorderFiles}\n fetchMore={fetchMore}\n />\n )}\n </MediaContextProvider>\n )}\n <FileUpload\n actionText={fileUploadButtonText}\n handleLibraryClick={() => {\n if (simpleLayout) {\n setDisplayFileUploadModal(true);\n } else {\n onOpenLibrary();\n }\n }}\n enableDragAndDrop={false}\n />\n </div>\n {editFile && (\n <Modal actions={editModalActions} title=\"Edit File\" onClose={() => setEditFile(null)}>\n <FilePreview\n file={editFile}\n fileName={editFile.fileName}\n handleFormChange={handleEditFileForm}\n displayForm\n previewType=\"card\"\n />\n </Modal>\n )}\n\n {displayFileUploadModal && simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <ListingContainer\n displayFileUploadModal={displayFileUploadModal}\n closeModalAndSetValue={closeModalAndSetValue}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n simpleLayout={simpleLayout}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n />\n </div>\n )}\n\n {displayModal && !simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <Modal\n actions={modalActions}\n className=\"file-upload-modal\"\n title=\"Media library\"\n onClose={() => closeModalAndSetValue()}>\n <ListingContainer\n closeModalAndSetValue={closeModalAndSetValue}\n displayFileUploadModal={displayFileUploadModal}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n />\n </Modal>\n </div>\n )}\n </>\n );\n};\n\nFileUploadAdapter.propTypes = {\n onChange: PropTypes.func.isRequired,\n label: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),\n maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),\n shouldRenderInPreview: PropTypes.bool,\n canDragAndDrop: PropTypes.bool,\n simpleLayout: PropTypes.bool,\n previewAllFiles: PropTypes.bool\n};\n\nFileUploadAdapter.defaultProps = {\n value: '',\n maxItems: false,\n shouldRenderInPreview: false,\n canDragAndDrop: false,\n simpleLayout: false,\n previewAllFiles: false\n};\n\nexport default FileUploadAdapter;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC9D,OAAOC,UAAU,MAAM,0BAA0B;AACjD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,YAAY,IAAIC,KAAK,QAAQ,2BAA2B;AACxF,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SACEC,SAAS,EACTC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa,EACbC,aAAa,EACbC,4BAA4B,QACvB,WAAW;AAClB,OAAOC,WAAW,MAAM,gBAAgB;AAExC,MAAMC,iBAAiB,GAAGA,CAAC;EACzBC,QAAQ;EACRC,KAAK;EACLC,EAAE;EACFC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC,qBAAqB;EACrBC,c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
|
+
{"version":3,"file":"FileUploadAdapter.js","names":["React","useState","useContext","useEffect","FileUpload","PropTypes","useApolloClient","useQuery","getQuery","getMutation","ModalAdapter","Modal","useToasts","Tooltip","MORE","ListingContainer","MediaContextProvider","FileList","useLimit","getFormat","formatInitialValue","transformToArray","isUnselecting","getButtonText","getNumberFilesPendingToFetch","FilePreview","FileUploadAdapter","onChange","label","id","type","value","maxItems","shouldRenderInPreview","canDragAndDrop","simpleLayout","tooltip","previewAllFiles","disableFilePreview","fileType","storeKey","InjectPreview","FormContext","currentLimit","displayModal","setDisplayModal","displayFileUploadModal","setDisplayFileUploadModal","initialValue","currentValue","setCurrentValue","selectedFiles","setSelectedFiles","editFile","setEditFile","allFilesLoaded","setAllFilesLoaded","client","addToast","data","getEntitySchemas","schemaData","variables","identifier","getFiles","offset","ids","fetchAll","files","newFiles","query","limit","where","_in","skip","length","fetchPolicy","loadedFiles","loadedOrderedFiles","orderFiles","initialFiles","filter","_","i","orderedFiles","fetchMore","shouldFetchAll","newOrderedFiles","handleSelectedFiles","checkIsUnselecting","isUnselectingFile","valueArray","selectedFilesIds","valueId","includes","parsedValue","filesIds","event","target","name","fileData","handleReorderFiles","map","fileId","closeModalAndSetValue","isSaving","values","toastMessage","appearance","autoDismiss","fileUploadButtonText","filesPending","onOpenLibrary","handleEditModal","file","selectedEditFile","find","_id","handleEditFileForm","editedFile","dataValues","valuesChecked","reduce","acc","formValueId","formValue","isDataPropery","_objectSpread","__typename","formData","currentId","Boolean","modalActions","textButton","callback","modifiers","editModalActions","editedFileId","updatedSelectedFiles","selectedFile","mutate","mutation","input","update","cache","updateFile","fileUpdated","writeQuery","result","e","console","error","filesPendingString","fileListSpan","createElement","className","onClick","Fragment","tooltipContent","onUnselectFile","selector","previewerId","allFiles","actionText","handleLibraryClick","enableDragAndDrop","actions","title","onClose","fileName","handleFormChange","displayForm","previewType","filesSelected","openEditInModal","propTypes","func","isRequired","string","oneOfType","array","number","bool","defaultProps"],"sources":["../../../src/components/FileUploadAdapter/FileUploadAdapter.js"],"sourcesContent":["import React, { useState, useContext, useEffect } from 'react';\nimport FileUpload from '@blaze-react/file-upload';\nimport PropTypes from 'prop-types';\nimport { useApolloClient, useQuery } from '@apollo/client';\nimport { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';\nimport { useToasts } from '@blaze-react/toaster';\nimport Tooltip from '@blaze-react/tooltip';\nimport { MORE } from '../../constants';\nimport ListingContainer from '../ListingContainer';\nimport { MediaContextProvider } from '../../utils/media-context';\nimport FileList from './FileList';\nimport useLimit from './useLimit';\nimport {\n getFormat,\n formatInitialValue,\n transformToArray,\n isUnselecting,\n getButtonText,\n getNumberFilesPendingToFetch\n} from './mappers';\nimport FilePreview from '../FilePreview';\n\nconst FileUploadAdapter = ({\n onChange,\n label,\n id,\n type,\n value,\n maxItems,\n shouldRenderInPreview,\n canDragAndDrop,\n simpleLayout,\n tooltip,\n previewAllFiles,\n disableFilePreview,\n fileType,\n storeKey\n}) => {\n const { InjectPreview } = useContext(FileUploadAdapter.FormContext);\n const [currentLimit] = useLimit(maxItems);\n const [displayModal, setDisplayModal] = useState(false);\n const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);\n const initialValue = formatInitialValue({ value, type });\n const [currentValue, setCurrentValue] = useState(initialValue);\n const [selectedFiles, setSelectedFiles] = useState([]);\n const [editFile, setEditFile] = useState(null);\n const [allFilesLoaded, setAllFilesLoaded] = useState(false);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n const { data: { getEntitySchemas: [schemaData] = [] } = {} } = useQuery(\n getQuery('GET_ENTITY_SCHEMA'),\n {\n variables: { identifier: 'file' }\n }\n );\n\n const getFiles = async (offset, ids, fetchAll = previewAllFiles) => {\n const {\n data: { files: newFiles }\n } = await client.query({\n query: getQuery('GET_FILES'),\n variables: {\n limit: fetchAll ? 0 : 4,\n offset,\n where: {\n id: {\n _in: ids\n }\n }\n },\n skip: !currentValue.length,\n fetchPolicy: 'network-only'\n });\n return newFiles;\n };\n\n useEffect(\n () => {\n (async () => {\n if (allFilesLoaded) {\n const loadedFiles = await getFiles(0, currentValue, true);\n const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);\n setSelectedFiles(loadedOrderedFiles);\n return;\n }\n\n const initialFiles =\n !selectedFiles.length && !previewAllFiles\n ? currentValue.filter((_, i) => i <= 3)\n : currentValue;\n\n const files = await getFiles(0, initialFiles);\n const orderedFiles = orderFiles(files, currentValue);\n setSelectedFiles(orderedFiles);\n setAllFilesLoaded(false);\n })();\n },\n [currentValue] //eslint-disable-line\n );\n\n const fetchMore = async shouldFetchAll => {\n if (selectedFiles.length === currentValue.length) return;\n const newFiles = await getFiles(0, currentValue, true);\n const newOrderedFiles = orderFiles(newFiles, currentValue);\n setSelectedFiles(newOrderedFiles);\n setAllFilesLoaded(true);\n };\n\n const handleSelectedFiles = (files, checkIsUnselecting = true) => {\n const isUnselectingFile = isUnselecting(value, checkIsUnselecting, files);\n if (isUnselectingFile) {\n const valueArray = transformToArray(value);\n const selectedFilesIds = valueArray.filter(valueId => !files.includes(valueId));\n const parsedValue = getFormat(type, { filesIds: selectedFilesIds });\n setCurrentValue(selectedFilesIds);\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: selectedFilesIds.length ? selectedFilesIds : null\n }\n },\n value: parsedValue\n });\n }\n\n setCurrentValue(files);\n };\n\n const handleReorderFiles = files => {\n const filesIds = files.map(({ id: fileId }) => fileId);\n const parsedValue = getFormat(type, { filesIds });\n setSelectedFiles(files);\n\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: filesIds\n }\n },\n value: parsedValue\n });\n };\n\n const closeModalAndSetValue = (isSaving, values, toastMessage) => {\n if (toastMessage) {\n addToast(toastMessage, {\n appearance: 'success',\n autoDismiss: true\n });\n }\n\n if (isSaving) {\n const parsedValue = getFormat(type, { filesIds: simpleLayout ? values : currentValue });\n setDisplayModal(false);\n return onChange({\n event: { target: { value: parsedValue, name: id, type, currentValue } },\n value: parsedValue\n });\n }\n\n setCurrentValue(initialValue);\n setDisplayModal(false);\n };\n\n const fileUploadButtonText = getButtonText({ maxItems, value: initialValue, fileType });\n\n const filesPending = previewAllFiles\n ? 0\n : getNumberFilesPendingToFetch(selectedFiles.length, currentValue);\n const onOpenLibrary = () => setDisplayModal(true);\n const handleEditModal = file => {\n const selectedEditFile = selectedFiles.find(({ id: _id }) => _id === file.id);\n setEditFile(selectedEditFile);\n };\n\n const handleEditFileForm = editedFile => {\n const dataValues = editedFile.valuesChecked.reduce(\n (acc, { id: formValueId, value: formValue, isDataPropery }) => {\n if (isDataPropery) {\n acc.data[formValueId] = formValue;\n } else {\n acc[formValueId] = formValue;\n }\n return acc;\n },\n { id: editFile.id, data: { ...editFile.data } }\n );\n delete dataValues.data.__typename; // Remove __typename if it exists in data to avoid issues with Apollo cache.\n\n setEditFile({\n ...editFile,\n formData: dataValues\n });\n };\n\n const orderFiles = (files, ids) =>\n ids.map(currentId => files.find(({ id: fileId }) => fileId === currentId)).filter(Boolean);\n\n const modalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n closeModalAndSetValue();\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Apply',\n callback: () => {\n closeModalAndSetValue(true);\n },\n modifiers: []\n }\n ];\n\n const editModalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n setEditFile(null);\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Apply',\n callback: async () => {\n const { name, id: editedFileId, data, formData } = editFile;\n const updatedSelectedFiles = selectedFiles.map(selectedFile => {\n if (selectedFile.id === editedFileId) {\n return { ...selectedFile, name, data };\n }\n return selectedFile;\n });\n setSelectedFiles(updatedSelectedFiles);\n\n try {\n await client.mutate({\n mutation: getMutation('UPDATE_FILE'),\n variables: {\n input: {\n ...formData,\n id: editedFileId\n }\n },\n update(cache, { data: { updateFile: fileUpdated } }) {\n cache.writeQuery({\n query: getQuery('GET_FILE_BY_ID'),\n variables: { id },\n data: { file: fileUpdated.result }\n });\n }\n });\n\n addToast(`File: ${editFile.name} has been updated`, {\n appearance: 'success',\n autoDismiss: true\n });\n closeModalAndSetValue(true);\n setEditFile(null);\n } catch (e) {\n addToast(`File: ${editFile.name} has not been updated`, {\n appearance: 'error',\n autoDismiss: true\n });\n console.error(e); //eslint-disable-line\n }\n },\n modifiers: []\n }\n ];\n const filesPendingString = `${filesPending} ${MORE}`;\n const fileListSpan = filesPending ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <span className=\"FileUploadAdapter__preview-link button button--link\" onClick={fetchMore}>\n + {filesPendingString}\n </span>\n ) : null;\n\n return (\n <>\n <div className=\"form-field form-field--button\">\n <label>\n {label} <Tooltip tooltipContent={tooltip} />\n </label>\n {selectedFiles && (\n <MediaContextProvider value={{ handleEditModal, onUnselectFile: handleSelectedFiles }}>\n {shouldRenderInPreview ? (\n <InjectPreview selector={FileUploadAdapter.previewerId}>\n <FileList\n selectedFiles={selectedFiles}\n allFiles={currentValue}\n handleReorderFiles={handleReorderFiles}\n canDragAndDrop={canDragAndDrop}\n fetchMore={fetchMore}>\n {fileListSpan}\n </FileList>\n </InjectPreview>\n ) : (\n <FileList\n selectedFiles={selectedFiles}\n handleReorderFiles={handleReorderFiles}\n fetchMore={fetchMore}\n />\n )}\n </MediaContextProvider>\n )}\n <FileUpload\n actionText={fileUploadButtonText}\n storeKey={storeKey}\n handleLibraryClick={() => {\n if (simpleLayout) {\n setDisplayFileUploadModal(true);\n } else {\n onOpenLibrary();\n }\n }}\n enableDragAndDrop={false}\n />\n </div>\n {editFile && (\n <Modal actions={editModalActions} title=\"Edit File\" onClose={() => setEditFile(null)}>\n <FilePreview\n file={editFile}\n fileName={editFile.fileName}\n handleFormChange={handleEditFileForm}\n displayForm\n previewType=\"card\"\n disableFilePreview={disableFilePreview}\n schemaData={schemaData}\n />\n </Modal>\n )}\n\n {displayFileUploadModal && simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <ListingContainer\n displayFileUploadModal={displayFileUploadModal}\n closeModalAndSetValue={closeModalAndSetValue}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n simpleLayout={simpleLayout}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n openEditInModal\n storeKey={storeKey}\n />\n </div>\n )}\n\n {displayModal && !simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <Modal\n actions={modalActions}\n className=\"file-upload-modal\"\n title=\"Media library\"\n onClose={() => closeModalAndSetValue()}>\n <ListingContainer\n closeModalAndSetValue={closeModalAndSetValue}\n displayFileUploadModal={displayFileUploadModal}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n openEditInModal\n storeKey={storeKey}\n />\n </Modal>\n </div>\n )}\n </>\n );\n};\n\nFileUploadAdapter.propTypes = {\n onChange: PropTypes.func.isRequired,\n label: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),\n maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),\n shouldRenderInPreview: PropTypes.bool,\n canDragAndDrop: PropTypes.bool,\n simpleLayout: PropTypes.bool,\n previewAllFiles: PropTypes.bool,\n tooltip: PropTypes.string,\n fileType: PropTypes.string,\n disableFilePreview: PropTypes.bool,\n storeKey: PropTypes.string\n};\n\nFileUploadAdapter.defaultProps = {\n value: '',\n maxItems: false,\n shouldRenderInPreview: false,\n canDragAndDrop: false,\n simpleLayout: false,\n previewAllFiles: false,\n tooltip: '',\n fileType: 'file',\n disableFilePreview: true,\n storeKey: null\n};\n\nexport default FileUploadAdapter;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC9D,OAAOC,UAAU,MAAM,0BAA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E9B,SAAS,CAACiL,IAAI;EAC5BjJ,eAAe,EAAEhC,SAAS,CAACiL,IAAI;EAC/BlJ,OAAO,EAAE/B,SAAS,CAAC6K,MAAM;EACzB3I,QAAQ,EAAElC,SAAS,CAAC6K,MAAM;EAC1B5I,kBAAkB,EAAEjC,SAAS,CAACiL,IAAI;EAClC9I,QAAQ,EAAEnC,SAAS,CAAC6K;AACtB,CAAC;AAEDxJ,iBAAiB,CAAC6J,YAAY,GAAG;EAC/BxJ,KAAK,EAAE,EAAE;EACTC,QAAQ,EAAE,KAAK;EACfC,qBAAqB,EAAE,KAAK;EAC5BC,cAAc,EAAE,KAAK;EACrBC,YAAY,EAAE,KAAK;EACnBE,eAAe,EAAE,KAAK;EACtBD,OAAO,EAAE,EAAE;EACXG,QAAQ,EAAE,MAAM;EAChBD,kBAAkB,EAAE,IAAI;EACxBE,QAAQ,EAAE;AACZ,CAAC;AAED,eAAed,iBAAiB","ignoreList":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const getButtonText = ({
|
|
2
2
|
maxItems,
|
|
3
|
-
value
|
|
3
|
+
value,
|
|
4
|
+
fileType = 'file'
|
|
4
5
|
}) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
const pluralSuffix = maxItems > 1 ? 's' : '';
|
|
7
|
+
const fileLabel = `Add ${fileType}${pluralSuffix}`;
|
|
8
|
+
return value && value.length > 0 ? `Change ${fileType}${pluralSuffix}` : fileLabel;
|
|
7
9
|
};
|
|
8
10
|
export { getButtonText };
|
|
9
11
|
//# sourceMappingURL=get-button-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-button-text.js","names":["getButtonText","maxItems","value","fileLabel","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-button-text.js"],"sourcesContent":["const getButtonText = ({ maxItems, value }) => {\n const
|
|
1
|
+
{"version":3,"file":"get-button-text.js","names":["getButtonText","maxItems","value","fileType","pluralSuffix","fileLabel","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-button-text.js"],"sourcesContent":["const getButtonText = ({ maxItems, value, fileType = 'file' }) => {\n const pluralSuffix = maxItems > 1 ? 's' : '';\n const fileLabel = `Add ${fileType}${pluralSuffix}`;\n return value && value.length > 0 ? `Change ${fileType}${pluralSuffix}` : fileLabel;\n};\n\nexport { getButtonText };\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,QAAQ,GAAG;AAAO,CAAC,KAAK;EAChE,MAAMC,YAAY,GAAGH,QAAQ,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EAC5C,MAAMI,SAAS,GAAG,OAAOF,QAAQ,GAAGC,YAAY,EAAE;EAClD,OAAOF,KAAK,IAAIA,KAAK,CAACI,MAAM,GAAG,CAAC,GAAG,UAAUH,QAAQ,GAAGC,YAAY,EAAE,GAAGC,SAAS;AACpF,CAAC;AAED,SAASL,aAAa","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export const getNumberFilesPendingToFetch = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const getNumberFilesPendingToFetch = (loadedFilesCount, currentValue) => {
|
|
2
|
+
if (loadedFilesCount >= currentValue.length) {
|
|
3
|
+
return 0;
|
|
4
|
+
}
|
|
5
|
+
return currentValue.length - loadedFilesCount;
|
|
5
6
|
};
|
|
6
7
|
//# sourceMappingURL=get-number-files-pending-to-fetch.js.map
|
package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-number-files-pending-to-fetch.js","names":["getNumberFilesPendingToFetch","
|
|
1
|
+
{"version":3,"file":"get-number-files-pending-to-fetch.js","names":["getNumberFilesPendingToFetch","loadedFilesCount","currentValue","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js"],"sourcesContent":["export const getNumberFilesPendingToFetch = (loadedFilesCount, currentValue) => {\n if (loadedFilesCount >= currentValue.length) {\n return 0;\n }\n\n return currentValue.length - loadedFilesCount;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,4BAA4B,GAAGA,CAACC,gBAAgB,EAAEC,YAAY,KAAK;EAC9E,IAAID,gBAAgB,IAAIC,YAAY,CAACC,MAAM,EAAE;IAC3C,OAAO,CAAC;EACV;EAEA,OAAOD,YAAY,CAACC,MAAM,GAAGF,gBAAgB;AAC/C,CAAC","ignoreList":[]}
|