@blaze-cms/plugin-media-ui 0.146.0-node18-core-styles-tooltips.5 → 0.146.0-node18-core-styles-tooltips.11
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 +26 -0
- package/lib/components/FilePreview/Image/imageSchema.js +1 -1
- package/lib/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib/components/FilePreview/index.js +7 -3
- package/lib/components/FilePreview/index.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/RawPreviewDefault.js +12 -4
- package/lib/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js +53 -35
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +5 -4
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -1
- package/lib/components/FileUploadModal/FileUploadModal.js +18 -6
- package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib/components/ListingContainer/Listing/Listing.js +10 -3
- package/lib/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib/components/ListingContainer/ListingContainer.js +10 -5
- package/lib/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib-es/components/FilePreview/Image/imageSchema.js +1 -1
- package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib-es/components/FilePreview/index.js +7 -3
- package/lib-es/components/FilePreview/index.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/FileUploadAdapter/FileUploadAdapter.js +30 -17
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.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 +14 -6
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib-es/components/ListingContainer/Listing/Listing.js +10 -3
- package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib-es/components/ListingContainer/ListingContainer.js +10 -5
- package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -1
- package/package.json +5 -5
- package/src/components/FilePreview/Image/imageSchema.js +1 -1
- package/src/components/FilePreview/index.js +7 -3
- package/src/components/FilePreview/previewDefault/RawPreviewDefault.js +17 -7
- package/src/components/FileUploadAdapter/FileUploadAdapter.js +28 -14
- package/src/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +6 -4
- package/src/components/FileUploadModal/FileUploadModal.js +20 -9
- package/src/components/ListingContainer/Listing/Listing.js +10 -3
- package/src/components/ListingContainer/ListingContainer.js +9 -4
|
@@ -33,7 +33,9 @@ const FileUploadAdapter = ({
|
|
|
33
33
|
simpleLayout,
|
|
34
34
|
tooltip,
|
|
35
35
|
previewAllFiles,
|
|
36
|
-
|
|
36
|
+
disableFilePreview,
|
|
37
|
+
fileType,
|
|
38
|
+
storeKey
|
|
37
39
|
}) => {
|
|
38
40
|
const { InjectPreview } = useContext(FileUploadAdapter.FormContext);
|
|
39
41
|
const [currentLimit] = useLimit(maxItems);
|
|
@@ -41,9 +43,9 @@ const FileUploadAdapter = ({
|
|
|
41
43
|
const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
|
|
42
44
|
const initialValue = formatInitialValue({ value, type });
|
|
43
45
|
const [currentValue, setCurrentValue] = useState(initialValue);
|
|
44
|
-
const [currentOffset, setCurrentOffset] = useState(0);
|
|
45
46
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
46
47
|
const [editFile, setEditFile] = useState(null);
|
|
48
|
+
const [allFilesLoaded, setAllFilesLoaded] = useState(false);
|
|
47
49
|
const client = useApolloClient();
|
|
48
50
|
const { addToast } = useToasts();
|
|
49
51
|
|
|
@@ -70,6 +72,13 @@ const FileUploadAdapter = ({
|
|
|
70
72
|
useEffect(
|
|
71
73
|
() => {
|
|
72
74
|
(async () => {
|
|
75
|
+
if (allFilesLoaded) {
|
|
76
|
+
const loadedFiles = await getFiles(0, currentValue, true);
|
|
77
|
+
const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);
|
|
78
|
+
setSelectedFiles(loadedOrderedFiles);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
73
82
|
const initialFiles =
|
|
74
83
|
!selectedFiles.length && !previewAllFiles
|
|
75
84
|
? currentValue.filter((_, i) => i <= 3)
|
|
@@ -77,8 +86,8 @@ const FileUploadAdapter = ({
|
|
|
77
86
|
|
|
78
87
|
const files = await getFiles(0, initialFiles);
|
|
79
88
|
const orderedFiles = orderFiles(files, currentValue);
|
|
80
|
-
setCurrentOffset(0);
|
|
81
89
|
setSelectedFiles(orderedFiles);
|
|
90
|
+
setAllFilesLoaded(false);
|
|
82
91
|
})();
|
|
83
92
|
},
|
|
84
93
|
[currentValue] //eslint-disable-line
|
|
@@ -86,14 +95,10 @@ const FileUploadAdapter = ({
|
|
|
86
95
|
|
|
87
96
|
const fetchMore = async shouldFetchAll => {
|
|
88
97
|
if (selectedFiles.length === currentValue.length) return;
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const newFiles = [...selectedFiles, ...files];
|
|
94
|
-
const orderedFiles = orderFiles(newFiles, currentValue);
|
|
95
|
-
setSelectedFiles(orderedFiles);
|
|
96
|
-
setCurrentOffset(newOffset);
|
|
98
|
+
const newFiles = await getFiles(0, currentValue, true);
|
|
99
|
+
const newOrderedFiles = orderFiles(newFiles, currentValue);
|
|
100
|
+
setSelectedFiles(newOrderedFiles);
|
|
101
|
+
setAllFilesLoaded(true);
|
|
97
102
|
};
|
|
98
103
|
|
|
99
104
|
const handleSelectedFiles = (files, checkIsUnselecting = true) => {
|
|
@@ -162,7 +167,7 @@ const FileUploadAdapter = ({
|
|
|
162
167
|
|
|
163
168
|
const filesPending = previewAllFiles
|
|
164
169
|
? 0
|
|
165
|
-
: getNumberFilesPendingToFetch(
|
|
170
|
+
: getNumberFilesPendingToFetch(selectedFiles.length, currentValue);
|
|
166
171
|
const onOpenLibrary = () => setDisplayModal(true);
|
|
167
172
|
const handleEditModal = file => {
|
|
168
173
|
const selectedEditFile = selectedFiles.find(({ id: _id }) => _id === file.id);
|
|
@@ -299,6 +304,7 @@ const FileUploadAdapter = ({
|
|
|
299
304
|
)}
|
|
300
305
|
<FileUpload
|
|
301
306
|
actionText={fileUploadButtonText}
|
|
307
|
+
storeKey={storeKey}
|
|
302
308
|
handleLibraryClick={() => {
|
|
303
309
|
if (simpleLayout) {
|
|
304
310
|
setDisplayFileUploadModal(true);
|
|
@@ -317,6 +323,7 @@ const FileUploadAdapter = ({
|
|
|
317
323
|
handleFormChange={handleEditFileForm}
|
|
318
324
|
displayForm
|
|
319
325
|
previewType="card"
|
|
326
|
+
disableFilePreview={disableFilePreview}
|
|
320
327
|
/>
|
|
321
328
|
</Modal>
|
|
322
329
|
)}
|
|
@@ -331,6 +338,8 @@ const FileUploadAdapter = ({
|
|
|
331
338
|
maxItems={currentLimit}
|
|
332
339
|
simpleLayout={simpleLayout}
|
|
333
340
|
filesSelected={currentValue.length > 1 ? currentValue : []}
|
|
341
|
+
openEditInModal
|
|
342
|
+
storeKey={storeKey}
|
|
334
343
|
/>
|
|
335
344
|
</div>
|
|
336
345
|
)}
|
|
@@ -350,6 +359,7 @@ const FileUploadAdapter = ({
|
|
|
350
359
|
maxItems={currentLimit}
|
|
351
360
|
filesSelected={currentValue.length > 1 ? currentValue : []}
|
|
352
361
|
openEditInModal
|
|
362
|
+
storeKey={storeKey}
|
|
353
363
|
/>
|
|
354
364
|
</Modal>
|
|
355
365
|
</div>
|
|
@@ -370,7 +380,9 @@ FileUploadAdapter.propTypes = {
|
|
|
370
380
|
simpleLayout: PropTypes.bool,
|
|
371
381
|
previewAllFiles: PropTypes.bool,
|
|
372
382
|
tooltip: PropTypes.string,
|
|
373
|
-
fileType: PropTypes.string
|
|
383
|
+
fileType: PropTypes.string,
|
|
384
|
+
disableFilePreview: PropTypes.bool,
|
|
385
|
+
storeKey: PropTypes.string
|
|
374
386
|
};
|
|
375
387
|
|
|
376
388
|
FileUploadAdapter.defaultProps = {
|
|
@@ -381,7 +393,9 @@ FileUploadAdapter.defaultProps = {
|
|
|
381
393
|
simpleLayout: false,
|
|
382
394
|
previewAllFiles: false,
|
|
383
395
|
tooltip: '',
|
|
384
|
-
fileType: 'file'
|
|
396
|
+
fileType: 'file',
|
|
397
|
+
disableFilePreview: true,
|
|
398
|
+
storeKey: null
|
|
385
399
|
};
|
|
386
400
|
|
|
387
401
|
export default FileUploadAdapter;
|
|
@@ -1,5 +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
|
+
|
|
6
|
+
return currentValue.length - loadedFilesCount;
|
|
5
7
|
};
|
|
@@ -11,7 +11,9 @@ const FileUploadModal = ({
|
|
|
11
11
|
getSelectedFiles,
|
|
12
12
|
closeModalAndSetValue,
|
|
13
13
|
simpleLayout,
|
|
14
|
-
fileId
|
|
14
|
+
fileId,
|
|
15
|
+
storeKey,
|
|
16
|
+
selectedStoreKey
|
|
15
17
|
}) => {
|
|
16
18
|
const [files, setFiles] = useState([]);
|
|
17
19
|
const { addToast } = useToasts();
|
|
@@ -30,10 +32,10 @@ const FileUploadModal = ({
|
|
|
30
32
|
|
|
31
33
|
const uploadFiles = async () => {
|
|
32
34
|
const response = await Promise.all(
|
|
33
|
-
files.map(({ file, name, data, storeKey }) => {
|
|
35
|
+
files.map(({ file, name, data, storeKey: fileStoreKey }) => {
|
|
34
36
|
const payload = {
|
|
35
37
|
name,
|
|
36
|
-
storeKey,
|
|
38
|
+
storeKey: fileStoreKey,
|
|
37
39
|
data
|
|
38
40
|
};
|
|
39
41
|
if (fileId) {
|
|
@@ -82,7 +84,8 @@ const FileUploadModal = ({
|
|
|
82
84
|
onClose();
|
|
83
85
|
};
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
let storeOptions = storeType.map(type => [type.key, type.name]);
|
|
88
|
+
storeOptions = storeKey ? storeOptions.filter(([key]) => key === storeKey) : storeOptions;
|
|
86
89
|
|
|
87
90
|
return (
|
|
88
91
|
<Modal
|
|
@@ -101,7 +104,11 @@ const FileUploadModal = ({
|
|
|
101
104
|
}
|
|
102
105
|
]}
|
|
103
106
|
upload>
|
|
104
|
-
<FileUpload
|
|
107
|
+
<FileUpload
|
|
108
|
+
storeKey={selectedStoreKey || storeKey}
|
|
109
|
+
onChange={handleFiles}
|
|
110
|
+
selectOptions={storeOptions}
|
|
111
|
+
/>
|
|
105
112
|
</Modal>
|
|
106
113
|
);
|
|
107
114
|
};
|
|
@@ -111,14 +118,18 @@ FileUploadModal.propTypes = {
|
|
|
111
118
|
getSelectedFiles: PropTypes.func.isRequired,
|
|
112
119
|
onClose: PropTypes.func,
|
|
113
120
|
simpleLayout: PropTypes.bool,
|
|
114
|
-
closeModalAndSetValue: PropTypes.func
|
|
121
|
+
closeModalAndSetValue: PropTypes.func,
|
|
122
|
+
storeKey: PropTypes.string,
|
|
123
|
+
selectedStoreKey: PropTypes.string
|
|
115
124
|
};
|
|
116
125
|
|
|
117
126
|
FileUploadModal.defaultProps = {
|
|
118
|
-
onClose: () => {},
|
|
119
|
-
closeModalAndSetValue: () => {},
|
|
127
|
+
onClose: () => { },
|
|
128
|
+
closeModalAndSetValue: () => { },
|
|
120
129
|
simpleLayout: false,
|
|
121
|
-
fileId: null
|
|
130
|
+
fileId: null,
|
|
131
|
+
storeKey: null,
|
|
132
|
+
selectedStoreKey: null
|
|
122
133
|
};
|
|
123
134
|
|
|
124
135
|
export default FileUploadModal;
|
|
@@ -14,11 +14,15 @@ const Listing = ({
|
|
|
14
14
|
setDisplayFileUploadModal,
|
|
15
15
|
closeModalAndSetValue,
|
|
16
16
|
simpleLayout,
|
|
17
|
-
openEditInModal
|
|
17
|
+
openEditInModal,
|
|
18
|
+
storeKey,
|
|
19
|
+
selectedStoreKey
|
|
18
20
|
}) => (
|
|
19
21
|
<div className="page">
|
|
20
22
|
{displayFileUploadModal && (
|
|
21
23
|
<FileUploadModal
|
|
24
|
+
selectedStoreKey={selectedStoreKey}
|
|
25
|
+
storeKey={storeKey}
|
|
22
26
|
onClose={() => {
|
|
23
27
|
handleDisplayFileUploadModal(false);
|
|
24
28
|
setDisplayFileUploadModal(false);
|
|
@@ -63,14 +67,17 @@ Listing.propTypes = {
|
|
|
63
67
|
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
64
68
|
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
65
69
|
closeModalAndSetValue: PropTypes.func,
|
|
66
|
-
openEditInModal: PropTypes.bool
|
|
70
|
+
openEditInModal: PropTypes.bool,
|
|
71
|
+
storeKey: PropTypes.string.isRequired,
|
|
72
|
+
selectedStoreKey: PropTypes.string
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
Listing.defaultProps = {
|
|
70
76
|
closeModalAndSetValue: () => {},
|
|
71
77
|
handleDisplayFileUploadModal: () => {},
|
|
72
78
|
simpleLayout: false,
|
|
73
|
-
openEditInModal: false
|
|
79
|
+
openEditInModal: false,
|
|
80
|
+
selectedStoreKey: null
|
|
74
81
|
};
|
|
75
82
|
|
|
76
83
|
export default Listing;
|
|
@@ -17,14 +17,15 @@ const ListingContainer = ({
|
|
|
17
17
|
setDisplayFileUploadModal,
|
|
18
18
|
closeModalAndSetValue,
|
|
19
19
|
simpleLayout,
|
|
20
|
-
openEditInModal
|
|
20
|
+
openEditInModal,
|
|
21
|
+
storeKey
|
|
21
22
|
}) => {
|
|
22
23
|
const [selectedFiles, setSelectedFiles] = useState(filesSelected || []);
|
|
23
24
|
const [selectedFilter, setSelectedFilter] = useState({
|
|
24
25
|
filter: 'all',
|
|
25
26
|
isSearch: false,
|
|
26
27
|
searchTerm: null,
|
|
27
|
-
storeKey
|
|
28
|
+
storeKey
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
const fileStoresType = getQuery('GET_FILE_STORES');
|
|
@@ -84,6 +85,8 @@ const ListingContainer = ({
|
|
|
84
85
|
setSelectedFiles={setSelectedFiles}
|
|
85
86
|
handleSelectedFiles={handleSelectedFiles}
|
|
86
87
|
openEditInModal={openEditInModal}
|
|
88
|
+
selectedStoreKey={selectedFilter.storeKey || defaultFileStore}
|
|
89
|
+
storeKey={storeKey}
|
|
87
90
|
/>
|
|
88
91
|
</FilesListProvider>
|
|
89
92
|
</MediaContextProvider>
|
|
@@ -99,7 +102,8 @@ ListingContainer.propTypes = {
|
|
|
99
102
|
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
100
103
|
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
101
104
|
closeModalAndSetValue: PropTypes.func,
|
|
102
|
-
openEditInModal: PropTypes.bool
|
|
105
|
+
openEditInModal: PropTypes.bool,
|
|
106
|
+
storeKey: PropTypes.string
|
|
103
107
|
};
|
|
104
108
|
|
|
105
109
|
ListingContainer.defaultProps = {
|
|
@@ -108,7 +112,8 @@ ListingContainer.defaultProps = {
|
|
|
108
112
|
maxItems: false,
|
|
109
113
|
filesSelected: [],
|
|
110
114
|
simpleLayout: false,
|
|
111
|
-
openEditInModal: false
|
|
115
|
+
openEditInModal: false,
|
|
116
|
+
storeKey: 'default'
|
|
112
117
|
};
|
|
113
118
|
|
|
114
119
|
export default ListingContainer;
|