@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
|
@@ -1,138 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect } from 'react';
|
|
4
|
-
import { SearchBar } from '@blaze-cms/plugin-search-ui';
|
|
5
|
-
import classnames from 'classnames';
|
|
6
|
-
import Select from '@blaze-react/select';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MediaSearchFilter from './MediaSearchFilter';
|
|
7
3
|
import { useMediaContext, MediaContext } from '../../utils/media-context';
|
|
8
|
-
import useFileList from '../FileList/useFileList';
|
|
9
4
|
|
|
10
5
|
const FilterPanel = () => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
const { filters, selectedFilter, changeSelectedFilter } = useMediaContext(MediaContext);
|
|
7
|
+
|
|
8
|
+
const handleOnSelectFilter = (esFilters = []) => {
|
|
9
|
+
let nextSearchTerm = null;
|
|
10
|
+
let nextFilterId = selectedFilter.filter;
|
|
11
|
+
let nextStoreKey = selectedFilter.storeKey || '';
|
|
12
|
+
|
|
13
|
+
esFilters.forEach(filterObj => {
|
|
14
|
+
const { simple_query_string: simpleQueryString, match } = filterObj || {};
|
|
15
|
+
|
|
16
|
+
if (simpleQueryString) {
|
|
17
|
+
const { query } = simpleQueryString;
|
|
18
|
+
if (query != null) {
|
|
19
|
+
nextSearchTerm = String(query).trim();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (match) {
|
|
24
|
+
const { 'type.keyword': typeKeyword, 'storeKey.keyword': storeKeyKeyword } = match;
|
|
25
|
+
|
|
26
|
+
if (typeKeyword && typeKeyword.query != null) {
|
|
27
|
+
nextFilterId = typeKeyword.query;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (storeKeyKeyword && storeKeyKeyword.query != null) {
|
|
31
|
+
nextStoreKey = storeKeyKeyword.query;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
changeSelectedFilter({
|
|
37
|
+
filter: nextFilterId,
|
|
38
|
+
isSearch: Boolean(nextSearchTerm),
|
|
39
|
+
searchTerm: nextSearchTerm || null,
|
|
40
|
+
storeKey: nextStoreKey,
|
|
41
|
+
esFilters
|
|
42
|
+
});
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
const handleKeyDown = ({ key }) => {
|
|
47
|
-
if (key === 'Enter') {
|
|
48
|
-
searchTerm
|
|
49
|
-
? changeSelectedFilter({
|
|
50
|
-
filter: selectedFilter.filter,
|
|
51
|
-
isSearch: true,
|
|
52
|
-
searchTerm: searchTerm.trim(),
|
|
53
|
-
storeKey
|
|
54
|
-
})
|
|
55
|
-
: changeSelectedFilter({
|
|
56
|
-
filter: selectedFilter.filter,
|
|
57
|
-
isSearch: false,
|
|
58
|
-
searchTerm: null,
|
|
59
|
-
storeKey
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const onSelectFilter = ({ value }) => {
|
|
65
|
-
searchTerm
|
|
66
|
-
? changeSelectedFilter({
|
|
67
|
-
filter: selectedFilter.filter,
|
|
68
|
-
isSearch: true,
|
|
69
|
-
searchTerm: searchTerm.trim(),
|
|
70
|
-
storeKey: value
|
|
71
|
-
})
|
|
72
|
-
: changeSelectedFilter({
|
|
73
|
-
filter: selectedFilter.filter,
|
|
74
|
-
isSearch: false,
|
|
75
|
-
searchTerm: null,
|
|
76
|
-
storeKey: value
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const activeSegements = filters.reduce((acc, { id }, index) => {
|
|
81
|
-
acc[`active-${index}`] = active === id;
|
|
82
|
-
return acc;
|
|
83
|
-
}, {});
|
|
84
|
-
const activeBarSegment = classnames('filter-panel__barWrapper--active', activeSegements);
|
|
85
|
-
const storeOptions = (fileStores || []).map(type => [type.key, type.name]);
|
|
86
|
-
|
|
87
45
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<li key={label} className="filter-panel__list-item">
|
|
94
|
-
<a onClick={() => onChangeFilter(id)}>
|
|
95
|
-
{label} ({data[id]})
|
|
96
|
-
</a>
|
|
97
|
-
</li>
|
|
98
|
-
) : (
|
|
99
|
-
<li key={label} className="filter-panel__list-item active">
|
|
100
|
-
{label} ({data[id]})
|
|
101
|
-
</li>
|
|
102
|
-
)
|
|
103
|
-
)}
|
|
104
|
-
</ul>
|
|
105
|
-
<div className="filter-panel__barWrapper">
|
|
106
|
-
<div className={activeBarSegment} />
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
<div className="filter-panel__searchBarWrapper">
|
|
110
|
-
<div className="select__wrapper">
|
|
111
|
-
<Select
|
|
112
|
-
name="filter"
|
|
113
|
-
defaultTextValue="Any"
|
|
114
|
-
options={storeOptions}
|
|
115
|
-
onChange={onSelectFilter}
|
|
116
|
-
selected={selectedFilter.storeKey}
|
|
117
|
-
/>
|
|
118
|
-
</div>
|
|
119
|
-
<SearchBar
|
|
120
|
-
search={() =>
|
|
121
|
-
changeSelectedFilter({
|
|
122
|
-
filter: selectedFilter.filter,
|
|
123
|
-
isSearch: true,
|
|
124
|
-
searchTerm,
|
|
125
|
-
storeKey: selectedFilter.storeKey
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
handleKeyDown={handleKeyDown}
|
|
129
|
-
searchTerm={searchTerm}
|
|
130
|
-
handleSearchTerm={handleSearchTerm}
|
|
131
|
-
placeholder="Search term here..."
|
|
132
|
-
close={false}
|
|
133
|
-
/>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
46
|
+
<MediaSearchFilter
|
|
47
|
+
selectedFilter={selectedFilter}
|
|
48
|
+
listFilters={filters}
|
|
49
|
+
updateListingFilters={handleOnSelectFilter}
|
|
50
|
+
/>
|
|
136
51
|
);
|
|
137
52
|
};
|
|
138
53
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
5
|
+
import { SearchFilter } from '@blaze-cms/plugin-data-ui';
|
|
6
|
+
|
|
7
|
+
const MediaSearchFilter = ({ selectedFilter, listFilters, updateListingFilters }) => {
|
|
8
|
+
const { data } = useQuery(getQuery('GET_ENTITY_SCHEMA'), {
|
|
9
|
+
variables: { identifier: 'file' }
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const getEntitySchemas = data?.getEntitySchemas ?? [];
|
|
13
|
+
|
|
14
|
+
if (!getEntitySchemas.length) return null;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<SearchFilter
|
|
18
|
+
schema={getEntitySchemas[0]}
|
|
19
|
+
listFilters={listFilters}
|
|
20
|
+
setListFilters={updateListingFilters}
|
|
21
|
+
values={selectedFilter.defaultFilters}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
MediaSearchFilter.propTypes = {
|
|
27
|
+
selectedFilter: PropTypes.object.isRequired,
|
|
28
|
+
updateListingFilters: PropTypes.func.isRequired,
|
|
29
|
+
listFilters: PropTypes.array.isRequired
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default MediaSearchFilter;
|
|
@@ -13,11 +13,16 @@ const Listing = ({
|
|
|
13
13
|
getSelectedFiles,
|
|
14
14
|
setDisplayFileUploadModal,
|
|
15
15
|
closeModalAndSetValue,
|
|
16
|
-
simpleLayout
|
|
16
|
+
simpleLayout,
|
|
17
|
+
openEditInModal,
|
|
18
|
+
storeKey,
|
|
19
|
+
selectedStoreKey
|
|
17
20
|
}) => (
|
|
18
21
|
<div className="page">
|
|
19
22
|
{displayFileUploadModal && (
|
|
20
23
|
<FileUploadModal
|
|
24
|
+
selectedStoreKey={selectedStoreKey}
|
|
25
|
+
storeKey={storeKey}
|
|
21
26
|
onClose={() => {
|
|
22
27
|
handleDisplayFileUploadModal(false);
|
|
23
28
|
setDisplayFileUploadModal(false);
|
|
@@ -36,7 +41,7 @@ const Listing = ({
|
|
|
36
41
|
onClick={() => {
|
|
37
42
|
handleDisplayFileUploadModal(true);
|
|
38
43
|
}}>
|
|
39
|
-
|
|
44
|
+
Upload
|
|
40
45
|
</Button>
|
|
41
46
|
<More displayBg>
|
|
42
47
|
<More.Avatar isMoreMenu>
|
|
@@ -48,7 +53,7 @@ const Listing = ({
|
|
|
48
53
|
</PageHeader>
|
|
49
54
|
<div className="page__content page__content--with-side-panel">
|
|
50
55
|
<FilterPanel />
|
|
51
|
-
<MediaListing />
|
|
56
|
+
<MediaListing openEditInModal={openEditInModal} />
|
|
52
57
|
</div>
|
|
53
58
|
</>
|
|
54
59
|
)}
|
|
@@ -61,13 +66,18 @@ Listing.propTypes = {
|
|
|
61
66
|
simpleLayout: PropTypes.bool,
|
|
62
67
|
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
63
68
|
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
64
|
-
closeModalAndSetValue: PropTypes.func
|
|
69
|
+
closeModalAndSetValue: PropTypes.func,
|
|
70
|
+
openEditInModal: PropTypes.bool,
|
|
71
|
+
storeKey: PropTypes.string.isRequired,
|
|
72
|
+
selectedStoreKey: PropTypes.string
|
|
65
73
|
};
|
|
66
74
|
|
|
67
75
|
Listing.defaultProps = {
|
|
68
76
|
closeModalAndSetValue: () => {},
|
|
69
77
|
handleDisplayFileUploadModal: () => {},
|
|
70
|
-
simpleLayout: false
|
|
78
|
+
simpleLayout: false,
|
|
79
|
+
openEditInModal: false,
|
|
80
|
+
selectedStoreKey: null
|
|
71
81
|
};
|
|
72
82
|
|
|
73
83
|
export default Listing;
|
|
@@ -18,7 +18,8 @@ const MediaFileList = ({
|
|
|
18
18
|
setDisplayCardPrompt,
|
|
19
19
|
displayLayout,
|
|
20
20
|
wrapperRef,
|
|
21
|
-
modalTargetRef
|
|
21
|
+
modalTargetRef,
|
|
22
|
+
openEditInModal
|
|
22
23
|
}) => {
|
|
23
24
|
const [currentListIndex, setCurrentListIndex] = useState(1);
|
|
24
25
|
const [verifiedRanges, setVerifiedRanges] = useState([]);
|
|
@@ -33,6 +34,8 @@ const MediaFileList = ({
|
|
|
33
34
|
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
if (!loading && !hasFiles) setDisplayCardPrompt(true);
|
|
37
|
+
if (!loading) setDisplayCardPrompt(false);
|
|
38
|
+
if (hasFiles) setDisplayCardPrompt(false);
|
|
36
39
|
}, [loading, hasFiles, setDisplayCardPrompt]);
|
|
37
40
|
|
|
38
41
|
useEffect(
|
|
@@ -40,6 +43,7 @@ const MediaFileList = ({
|
|
|
40
43
|
setVerifiedRanges([]);
|
|
41
44
|
setCurrentListIndex(0);
|
|
42
45
|
setQueryParams({
|
|
46
|
+
...selectedFilter,
|
|
43
47
|
where: {
|
|
44
48
|
...AVAILABLE_FILTER_TYPES[selectedFilter.filter],
|
|
45
49
|
storeKey: selectedFilter.storeKey
|
|
@@ -53,7 +57,8 @@ const MediaFileList = ({
|
|
|
53
57
|
selectedFilter.filter,
|
|
54
58
|
selectedFilter.storeKey,
|
|
55
59
|
selectedFilter.isSearch,
|
|
56
|
-
selectedFilter.searchTerm
|
|
60
|
+
selectedFilter.searchTerm,
|
|
61
|
+
selectedFilter.esFilters
|
|
57
62
|
]
|
|
58
63
|
);
|
|
59
64
|
|
|
@@ -69,7 +74,8 @@ const MediaFileList = ({
|
|
|
69
74
|
storeKey: selectedFilter.storeKey
|
|
70
75
|
},
|
|
71
76
|
isSearch: selectedFilter.isSearch,
|
|
72
|
-
searchTerm: selectedFilter.searchTerm
|
|
77
|
+
searchTerm: selectedFilter.searchTerm,
|
|
78
|
+
esFilters: selectedFilter.esFilters
|
|
73
79
|
});
|
|
74
80
|
setVerifiedRanges([...verifiedRanges, loadIndex]);
|
|
75
81
|
setCurrentListIndex(startIndex + MEDIA_OVER_SCAN_COUNT);
|
|
@@ -108,7 +114,7 @@ const MediaFileList = ({
|
|
|
108
114
|
scrollToIndex={currentListIndex}
|
|
109
115
|
onItemsRendered={handleRenderedItems}
|
|
110
116
|
renderItem={({ index, style }) => {
|
|
111
|
-
const { name, url, mimetype, id } = data.files[index];
|
|
117
|
+
const { name, url, mimetype, id, data: fileData, updated } = data.files[index];
|
|
112
118
|
const isSelected = existPrevious(selectedFiles, id);
|
|
113
119
|
return (
|
|
114
120
|
<div key={index} style={style} className="list__item--resultWrapper">
|
|
@@ -127,6 +133,9 @@ const MediaFileList = ({
|
|
|
127
133
|
id={id}
|
|
128
134
|
index={index}
|
|
129
135
|
removeFile={removeFile}
|
|
136
|
+
openEditInModal={openEditInModal}
|
|
137
|
+
data={fileData}
|
|
138
|
+
updated={updated}
|
|
130
139
|
/>
|
|
131
140
|
</div>
|
|
132
141
|
);
|
|
@@ -137,7 +146,7 @@ const MediaFileList = ({
|
|
|
137
146
|
{displayCardPrompt && (
|
|
138
147
|
<CardPrompt>
|
|
139
148
|
<Button onClick={onClickPrompt} className="button button--rounded button--cta">
|
|
140
|
-
|
|
149
|
+
Upload
|
|
141
150
|
</Button>
|
|
142
151
|
</CardPrompt>
|
|
143
152
|
)}
|
|
@@ -150,11 +159,13 @@ MediaFileList.propTypes = {
|
|
|
150
159
|
displayCardPrompt: PropTypes.bool,
|
|
151
160
|
displayLayout: PropTypes.string.isRequired,
|
|
152
161
|
wrapperRef: PropTypes.object.isRequired,
|
|
153
|
-
modalTargetRef: PropTypes.object.isRequired
|
|
162
|
+
modalTargetRef: PropTypes.object.isRequired,
|
|
163
|
+
openEditInModal: PropTypes.bool
|
|
154
164
|
};
|
|
155
165
|
|
|
156
166
|
MediaFileList.defaultProps = {
|
|
157
|
-
displayCardPrompt: true
|
|
167
|
+
displayCardPrompt: true,
|
|
168
|
+
openEditInModal: false
|
|
158
169
|
};
|
|
159
170
|
|
|
160
171
|
export default MediaFileList;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
1
2
|
import React, { useState, useRef } from 'react';
|
|
2
3
|
import MediaFileList from './MediaFileList';
|
|
3
4
|
|
|
4
|
-
const MediaListing = () => {
|
|
5
|
+
const MediaListing = ({ openEditInModal }) => {
|
|
5
6
|
const [displayCardPrompt, setDisplayCardPrompt] = useState(false);
|
|
6
7
|
const mediaFileListWrapperRef = useRef();
|
|
7
8
|
const modalTargetRef = useRef();
|
|
@@ -15,6 +16,7 @@ const MediaListing = () => {
|
|
|
15
16
|
displayCardPrompt={displayCardPrompt}
|
|
16
17
|
setDisplayCardPrompt={setDisplayCardPrompt}
|
|
17
18
|
displayLayout="list"
|
|
19
|
+
openEditInModal={openEditInModal}
|
|
18
20
|
/>
|
|
19
21
|
</div>
|
|
20
22
|
{/* render edit card modal outside of the virtual list */}
|
|
@@ -23,6 +25,12 @@ const MediaListing = () => {
|
|
|
23
25
|
);
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
MediaListing.propTypes = {
|
|
28
|
+
MediaListing.propTypes = {
|
|
29
|
+
openEditInModal: PropTypes.bool
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
MediaListing.defaultProps = {
|
|
33
|
+
openEditInModal: false
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
export default MediaListing;
|
|
@@ -16,14 +16,16 @@ const ListingContainer = ({
|
|
|
16
16
|
displayFileUploadModal,
|
|
17
17
|
setDisplayFileUploadModal,
|
|
18
18
|
closeModalAndSetValue,
|
|
19
|
-
simpleLayout
|
|
19
|
+
simpleLayout,
|
|
20
|
+
openEditInModal,
|
|
21
|
+
storeKey
|
|
20
22
|
}) => {
|
|
21
23
|
const [selectedFiles, setSelectedFiles] = useState(filesSelected || []);
|
|
22
24
|
const [selectedFilter, setSelectedFilter] = useState({
|
|
23
25
|
filter: 'all',
|
|
24
26
|
isSearch: false,
|
|
25
27
|
searchTerm: null,
|
|
26
|
-
storeKey
|
|
28
|
+
storeKey
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
const fileStoresType = getQuery('GET_FILE_STORES');
|
|
@@ -65,7 +67,10 @@ const ListingContainer = ({
|
|
|
65
67
|
changeSelectedFilter: value => setSelectedFilter(value),
|
|
66
68
|
selectedFilter: {
|
|
67
69
|
...selectedFilter,
|
|
68
|
-
storeKey: selectedFilter.storeKey || defaultFileStore
|
|
70
|
+
storeKey: selectedFilter.storeKey || defaultFileStore,
|
|
71
|
+
defaultFilters: {
|
|
72
|
+
storeKey: selectedFilter.storeKey || defaultFileStore
|
|
73
|
+
}
|
|
69
74
|
},
|
|
70
75
|
selectedFiles,
|
|
71
76
|
getSelectedFiles,
|
|
@@ -82,6 +87,9 @@ const ListingContainer = ({
|
|
|
82
87
|
handleDisplayFileUploadModal={handleDisplayFileUploadModal}
|
|
83
88
|
setSelectedFiles={setSelectedFiles}
|
|
84
89
|
handleSelectedFiles={handleSelectedFiles}
|
|
90
|
+
openEditInModal={openEditInModal}
|
|
91
|
+
selectedStoreKey={selectedFilter.storeKey || defaultFileStore}
|
|
92
|
+
storeKey={storeKey}
|
|
85
93
|
/>
|
|
86
94
|
</FilesListProvider>
|
|
87
95
|
</MediaContextProvider>
|
|
@@ -96,7 +104,9 @@ ListingContainer.propTypes = {
|
|
|
96
104
|
simpleLayout: PropTypes.bool,
|
|
97
105
|
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
98
106
|
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
99
|
-
closeModalAndSetValue: PropTypes.func
|
|
107
|
+
closeModalAndSetValue: PropTypes.func,
|
|
108
|
+
openEditInModal: PropTypes.bool,
|
|
109
|
+
storeKey: PropTypes.string
|
|
100
110
|
};
|
|
101
111
|
|
|
102
112
|
ListingContainer.defaultProps = {
|
|
@@ -104,7 +114,9 @@ ListingContainer.defaultProps = {
|
|
|
104
114
|
handleSelectedFiles: () => {},
|
|
105
115
|
maxItems: false,
|
|
106
116
|
filesSelected: [],
|
|
107
|
-
simpleLayout: false
|
|
117
|
+
simpleLayout: false,
|
|
118
|
+
openEditInModal: false,
|
|
119
|
+
storeKey: 'default'
|
|
108
120
|
};
|
|
109
121
|
|
|
110
122
|
export default ListingContainer;
|
package/src/constants.js
CHANGED
|
@@ -16,7 +16,7 @@ const AVAILABLE_FILTER_TYPES = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const MEDIA_LIST_ITEM_SIZE = 97;
|
|
19
|
-
const MEDIA_OVER_SCAN_COUNT =
|
|
19
|
+
const MEDIA_OVER_SCAN_COUNT = 3;
|
|
20
20
|
|
|
21
21
|
const ICON_SIZE = {
|
|
22
22
|
WIDTH: '25px',
|
|
@@ -38,6 +38,19 @@ const REORDER = 'Reorder';
|
|
|
38
38
|
const IMAGES = 'Images';
|
|
39
39
|
const MORE = 'more ...';
|
|
40
40
|
|
|
41
|
+
const FILE_DEFAULT_PROPS = [
|
|
42
|
+
'id',
|
|
43
|
+
'location',
|
|
44
|
+
'mimetype',
|
|
45
|
+
'url',
|
|
46
|
+
'data',
|
|
47
|
+
'name',
|
|
48
|
+
'storeKey',
|
|
49
|
+
'filename',
|
|
50
|
+
'type',
|
|
51
|
+
'updated'
|
|
52
|
+
];
|
|
53
|
+
|
|
41
54
|
export {
|
|
42
55
|
ALL,
|
|
43
56
|
AVAILABLE_FILTER_TYPES,
|
|
@@ -53,5 +66,6 @@ export {
|
|
|
53
66
|
REORDER,
|
|
54
67
|
STORE_KEY,
|
|
55
68
|
ICON_SIZE,
|
|
56
|
-
ICON_COLOR
|
|
69
|
+
ICON_COLOR,
|
|
70
|
+
FILE_DEFAULT_PROPS
|
|
57
71
|
};
|
package/src/index.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import FileUploadAdapter from './components/FileUploadAdapter';
|
|
3
2
|
import EditorAdapter from './components/EditorAdapter';
|
|
4
3
|
import { MediaLibraryIcon } from './icons';
|
|
5
4
|
import pkg from '../package.json';
|
|
6
5
|
import { PLUGIN_NAME } from './constants';
|
|
6
|
+
import FilePreviewReadOnly from './components/FilePreviewReadOnly';
|
|
7
|
+
import MediaListing from './components/MediaListing';
|
|
8
|
+
import EditMediaFilePage from './components/EditMediaFile/EditMediaFilePage';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
10
|
+
// todo: renable lazy loading after bundler optimisations, currently they are too slow in dev mode
|
|
11
|
+
// export const FilePreviewReadOnly = React.lazy(
|
|
12
|
+
// () =>
|
|
13
|
+
// import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */ './components/FilePreviewReadOnly')
|
|
14
|
+
// );
|
|
12
15
|
|
|
13
|
-
const MediaListing = React.lazy(
|
|
14
|
-
|
|
15
|
-
);
|
|
16
|
+
// const MediaListing = React.lazy(
|
|
17
|
+
// () => import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')
|
|
18
|
+
// );
|
|
16
19
|
|
|
17
|
-
const EditMediaFilePage = React.lazy(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
20
|
+
// const EditMediaFilePage = React.lazy(
|
|
21
|
+
// () =>
|
|
22
|
+
// import(
|
|
23
|
+
// /* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage'
|
|
24
|
+
// )
|
|
25
|
+
// );
|
|
23
26
|
export default async function load(app) {
|
|
24
27
|
app.events.once('admin:menu:config:load', ({ addConfig }) => {
|
|
25
28
|
addConfig({
|
package/babel.config.js
DELETED