@blaze-cms/plugin-media-ui 0.146.0-rc-eagle.0 → 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 +8 -1
- package/lib/components/CardMedia/CardMedia.js +96 -52
- package/lib/components/CardMedia/CardMedia.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFile.js +24 -39
- package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFilePage.js +16 -8
- package/lib/components/EditMediaFile/EditMediaFilePage.js.map +1 -1
- package/lib/components/FileList/useGetFiles/getFiles.js +6 -3
- package/lib/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib/components/FileList/useGetFiles/useGetFiles.js +7 -2
- package/lib/components/FileList/useGetFiles/useGetFiles.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js +4 -1
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -1
- package/lib/components/FilePreview/Actions/index.js +2 -1
- package/lib/components/FilePreview/Actions/index.js.map +1 -1
- package/lib/components/FilePreview/Image/imageSchema.js +8 -4
- package/lib/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib/components/FilePreview/PDF/schema.js +2 -1
- package/lib/components/FilePreview/PDF/schema.js.map +1 -1
- package/lib/components/FilePreview/index.js +47 -3
- package/lib/components/FilePreview/index.js.map +1 -1
- package/lib/components/FilePreview/previewDefault/previewDefaultSchema.js +2 -1
- package/lib/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js +2 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileList.js +2 -1
- package/lib/components/FileUploadAdapter/FileList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js +35 -23
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib/components/FileUploadModal/FileUploadModal.js +82 -18
- package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib/components/FilterPanel/FilterPanel.js +43 -125
- 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/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +9 -5
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js +2 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -1
- package/lib/components/ListingContainer/ListingContainer.js +6 -2
- package/lib/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib/components/MediaListing.js +2 -1
- package/lib/components/MediaListing.js.map +1 -1
- package/lib/constants.js +3 -2
- package/lib/constants.js.map +1 -1
- package/lib-es/components/CardMedia/CardMedia.js +276 -0
- package/lib-es/components/CardMedia/CardMedia.js.map +1 -0
- package/lib-es/components/CardMedia/index.js +3 -0
- package/lib-es/components/CardMedia/index.js.map +1 -0
- package/lib-es/components/EditMediaFile/EditMediaFile.js +171 -0
- package/lib-es/components/EditMediaFile/EditMediaFile.js.map +1 -0
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js +116 -0
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js.map +1 -0
- package/lib-es/components/EditMediaFile/index.js +3 -0
- package/lib-es/components/EditMediaFile/index.js.map +1 -0
- package/lib-es/components/EditorAdapter/EditorAdapter.js +59 -0
- package/lib-es/components/EditorAdapter/EditorAdapter.js.map +1 -0
- package/lib-es/components/EditorAdapter/index.js +3 -0
- package/lib-es/components/EditorAdapter/index.js.map +1 -0
- package/lib-es/components/FileList/FilesListContext/index.js +4 -0
- package/lib-es/components/FileList/FilesListContext/index.js.map +1 -0
- package/lib-es/components/FileList/FilesListProvider/index.js +36 -0
- package/lib-es/components/FileList/FilesListProvider/index.js.map +1 -0
- package/lib-es/components/FileList/useFileList/index.js +5 -0
- package/lib-es/components/FileList/useFileList/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/getFiles.js +182 -0
- package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/index.js +3 -0
- package/lib-es/components/FileList/useGetFiles/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js +119 -0
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/getCounters.js +11 -0
- package/lib-es/components/FileList/useGetFilesList/getCounters.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/index.js +3 -0
- package/lib-es/components/FileList/useGetFilesList/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js +175 -0
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -0
- package/lib-es/components/FilePreview/Actions/index.js +38 -0
- package/lib-es/components/FilePreview/Actions/index.js.map +1 -0
- package/lib-es/components/FilePreview/Image/Image.js +40 -0
- package/lib-es/components/FilePreview/Image/Image.js.map +1 -0
- package/lib-es/components/FilePreview/Image/RawImage.js +31 -0
- package/lib-es/components/FilePreview/Image/RawImage.js.map +1 -0
- package/lib-es/components/FilePreview/Image/imageSchema.js +57 -0
- package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -0
- package/lib-es/components/FilePreview/Image/index.js +12 -0
- package/lib-es/components/FilePreview/Image/index.js.map +1 -0
- 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 +49 -0
- package/lib-es/components/FilePreview/PDF/PDF.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/RawPDF.js +33 -0
- package/lib-es/components/FilePreview/PDF/RawPDF.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/index.js +12 -0
- package/lib-es/components/FilePreview/PDF/index.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/schema.js +22 -0
- package/lib-es/components/FilePreview/PDF/schema.js.map +1 -0
- package/lib-es/components/FilePreview/get-preview.js +28 -0
- package/lib-es/components/FilePreview/get-preview.js.map +1 -0
- package/lib-es/components/FilePreview/index.js +148 -0
- package/lib-es/components/FilePreview/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js +41 -0
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js +39 -0
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js +121 -0
- package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/icons/index.js +3 -0
- package/lib-es/components/FilePreview/previewDefault/icons/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/index.js +12 -0
- package/lib-es/components/FilePreview/previewDefault/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js +26 -0
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FileList.js +18 -0
- package/lib-es/components/FilePreviewReadOnly/FileList.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js +22 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js +68 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/index.js +3 -0
- package/lib-es/components/FilePreviewReadOnly/index.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js +11 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/index.js +3 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileList.js +52 -0
- package/lib-es/components/FileUploadAdapter/FileList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FilePreviewList.js +22 -0
- package/lib-es/components/FileUploadAdapter/FilePreviewList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileReorderList.js +32 -0
- package/lib-es/components/FileUploadAdapter/FileReorderList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileReorderListItem.js +24 -0
- package/lib-es/components/FileUploadAdapter/FileReorderListItem.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +402 -0
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/index.js +3 -0
- package/lib-es/components/FileUploadAdapter/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js +11 -0
- package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js +11 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-format.js +12 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-format.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +7 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/index.js +8 -0
- package/lib-es/components/FileUploadAdapter/mappers/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js +2 -0
- package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js +2 -0
- package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/useLimit.js +13 -0
- package/lib-es/components/FileUploadAdapter/useLimit.js.map +1 -0
- package/lib-es/components/FileUploadModal/FileUploadModal.js +241 -0
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -0
- package/lib-es/components/FileUploadModal/index.js +3 -0
- package/lib-es/components/FileUploadModal/index.js.map +1 -0
- package/lib-es/components/FilterPanel/FilterPanel.js +55 -0
- package/lib-es/components/FilterPanel/FilterPanel.js.map +1 -0
- package/lib-es/components/FilterPanel/MediaSearchFilter.js +34 -0
- package/lib-es/components/FilterPanel/MediaSearchFilter.js.map +1 -0
- package/lib-es/components/FilterPanel/index.js +3 -0
- package/lib-es/components/FilterPanel/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/Listing.js +70 -0
- package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +156 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js +33 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/index.js.map +1 -0
- package/lib-es/components/ListingContainer/ListingContainer.js +118 -0
- package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -0
- package/lib-es/components/ListingContainer/index.js +3 -0
- package/lib-es/components/ListingContainer/index.js.map +1 -0
- package/lib-es/components/ListingContainer/mappers/exist-previous.js +3 -0
- package/lib-es/components/ListingContainer/mappers/exist-previous.js.map +1 -0
- package/lib-es/components/ListingContainer/mappers/index.js +3 -0
- package/lib-es/components/ListingContainer/mappers/index.js.map +1 -0
- package/lib-es/components/MediaListing.js +29 -0
- package/lib-es/components/MediaListing.js.map +1 -0
- package/lib-es/constants.js +37 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/icons/MediaLibraryIcon.js +70 -0
- package/lib-es/icons/MediaLibraryIcon.js.map +1 -0
- package/lib-es/icons/index.js +3 -0
- package/lib-es/icons/index.js.map +1 -0
- package/lib-es/index.js +77 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/utils/available-filters/available-filters.js +26 -0
- package/lib-es/utils/available-filters/available-filters.js.map +1 -0
- package/lib-es/utils/bustUrl.js +7 -0
- package/lib-es/utils/bustUrl.js.map +1 -0
- package/lib-es/utils/media-context/index.js +4 -0
- package/lib-es/utils/media-context/index.js.map +1 -0
- package/lib-es/utils/media-context/media-context.js +6 -0
- package/lib-es/utils/media-context/media-context.js.map +1 -0
- package/lib-es/utils/media-context/useMediaContext.js +4 -0
- package/lib-es/utils/media-context/useMediaContext.js.map +1 -0
- package/package.json +16 -9
- package/src/components/CardMedia/CardMedia.js +119 -89
- package/src/components/EditMediaFile/EditMediaFile.js +20 -21
- package/src/components/EditMediaFile/EditMediaFilePage.js +12 -7
- 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/Image/imageSchema.js +8 -4
- package/src/components/FilePreview/PDF/schema.js +2 -1
- package/src/components/FilePreview/index.js +36 -2
- package/src/components/FilePreview/previewDefault/previewDefaultSchema.js +2 -1
- package/src/components/FileUploadAdapter/FileUploadAdapter.js +24 -14
- package/src/components/FileUploadModal/FileUploadModal.js +71 -6
- package/src/components/FilterPanel/FilterPanel.js +44 -129
- package/src/components/FilterPanel/MediaSearchFilter.js +32 -0
- package/src/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +7 -2
- package/src/components/ListingContainer/ListingContainer.js +4 -1
- package/src/constants.js +16 -2
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
package/lib-es/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import FileUploadAdapter from './components/FileUploadAdapter';
|
|
2
|
+
import EditorAdapter from './components/EditorAdapter';
|
|
3
|
+
import { MediaLibraryIcon } from './icons';
|
|
4
|
+
import pkg from '../package.json';
|
|
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';
|
|
9
|
+
|
|
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
|
+
// );
|
|
15
|
+
|
|
16
|
+
// const MediaListing = React.lazy(
|
|
17
|
+
// () => import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')
|
|
18
|
+
// );
|
|
19
|
+
|
|
20
|
+
// const EditMediaFilePage = React.lazy(
|
|
21
|
+
// () =>
|
|
22
|
+
// import(
|
|
23
|
+
// /* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage'
|
|
24
|
+
// )
|
|
25
|
+
// );
|
|
26
|
+
export default async function load(app) {
|
|
27
|
+
app.events.once('admin:menu:config:load', ({
|
|
28
|
+
addConfig
|
|
29
|
+
}) => {
|
|
30
|
+
addConfig({
|
|
31
|
+
main: {
|
|
32
|
+
items: {
|
|
33
|
+
media: {
|
|
34
|
+
label: 'Media',
|
|
35
|
+
uri: '/media',
|
|
36
|
+
icon: MediaLibraryIcon,
|
|
37
|
+
order: 30
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
app.events.once('load:custom:field:type', addFieldType => {
|
|
44
|
+
addFieldType({
|
|
45
|
+
type: 'fileUpload',
|
|
46
|
+
component: FileUploadAdapter
|
|
47
|
+
});
|
|
48
|
+
addFieldType({
|
|
49
|
+
type: 'filePreview',
|
|
50
|
+
component: FilePreviewReadOnly
|
|
51
|
+
});
|
|
52
|
+
addFieldType({
|
|
53
|
+
type: 'editor',
|
|
54
|
+
component: EditorAdapter
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const mediaRoute = {
|
|
58
|
+
path: '/media',
|
|
59
|
+
key: 'media',
|
|
60
|
+
component: MediaListing,
|
|
61
|
+
exact: true
|
|
62
|
+
};
|
|
63
|
+
const editMediaFileRoute = {
|
|
64
|
+
path: '/media/edit/:fileId',
|
|
65
|
+
key: 'editMedia',
|
|
66
|
+
component: EditMediaFilePage,
|
|
67
|
+
exact: true
|
|
68
|
+
};
|
|
69
|
+
app.addRoute(mediaRoute);
|
|
70
|
+
app.addRoute(editMediaFileRoute);
|
|
71
|
+
return {
|
|
72
|
+
name: PLUGIN_NAME,
|
|
73
|
+
version: pkg.version
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
load.pluginName = PLUGIN_NAME;
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["FileUploadAdapter","EditorAdapter","MediaLibraryIcon","pkg","PLUGIN_NAME","FilePreviewReadOnly","MediaListing","EditMediaFilePage","load","app","events","once","addConfig","main","items","media","label","uri","icon","order","addFieldType","type","component","mediaRoute","path","key","exact","editMediaFileRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import FileUploadAdapter from './components/FileUploadAdapter';\nimport EditorAdapter from './components/EditorAdapter';\nimport { MediaLibraryIcon } from './icons';\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\nimport FilePreviewReadOnly from './components/FilePreviewReadOnly';\nimport MediaListing from './components/MediaListing';\nimport EditMediaFilePage from './components/EditMediaFile/EditMediaFilePage';\n\n// todo: renable lazy loading after bundler optimisations, currently they are too slow in dev mode\n// export const FilePreviewReadOnly = React.lazy(\n// () =>\n// import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */ './components/FilePreviewReadOnly')\n// );\n\n// const MediaListing = React.lazy(\n// () => import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')\n// );\n\n// const EditMediaFilePage = React.lazy(\n// () =>\n// import(\n// /* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage'\n// )\n// );\nexport default async function load(app) {\n app.events.once('admin:menu:config:load', ({ addConfig }) => {\n addConfig({\n main: {\n items: {\n media: {\n label: 'Media',\n uri: '/media',\n icon: MediaLibraryIcon,\n order: 30\n }\n }\n }\n });\n });\n\n app.events.once('load:custom:field:type', addFieldType => {\n addFieldType({ type: 'fileUpload', component: FileUploadAdapter });\n addFieldType({ type: 'filePreview', component: FilePreviewReadOnly });\n addFieldType({ type: 'editor', component: EditorAdapter });\n });\n\n const mediaRoute = {\n path: '/media',\n key: 'media',\n component: MediaListing,\n exact: true\n };\n\n const editMediaFileRoute = {\n path: '/media/edit/:fileId',\n key: 'editMedia',\n component: EditMediaFilePage,\n exact: true\n };\n\n app.addRoute(mediaRoute);\n app.addRoute(editMediaFileRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,gCAAgC;AAC9D,OAAOC,aAAa,MAAM,4BAA4B;AACtD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AACzC,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,OAAOC,YAAY,MAAM,2BAA2B;AACpD,OAAOC,iBAAiB,MAAM,8CAA8C;;AAE5E;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,IAAIA,CAACC,GAAG,EAAE;EACtCA,GAAG,CAACC,MAAM,CAACC,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAAEC;EAAU,CAAC,KAAK;IAC3DA,SAAS,CAAC;MACRC,IAAI,EAAE;QACJC,KAAK,EAAE;UACLC,KAAK,EAAE;YACLC,KAAK,EAAE,OAAO;YACdC,GAAG,EAAE,QAAQ;YACbC,IAAI,EAAEhB,gBAAgB;YACtBiB,KAAK,EAAE;UACT;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFV,GAAG,CAACC,MAAM,CAACC,IAAI,CAAC,wBAAwB,EAAES,YAAY,IAAI;IACxDA,YAAY,CAAC;MAAEC,IAAI,EAAE,YAAY;MAAEC,SAAS,EAAEtB;IAAkB,CAAC,CAAC;IAClEoB,YAAY,CAAC;MAAEC,IAAI,EAAE,aAAa;MAAEC,SAAS,EAAEjB;IAAoB,CAAC,CAAC;IACrEe,YAAY,CAAC;MAAEC,IAAI,EAAE,QAAQ;MAAEC,SAAS,EAAErB;IAAc,CAAC,CAAC;EAC5D,CAAC,CAAC;EAEF,MAAMsB,UAAU,GAAG;IACjBC,IAAI,EAAE,QAAQ;IACdC,GAAG,EAAE,OAAO;IACZH,SAAS,EAAEhB,YAAY;IACvBoB,KAAK,EAAE;EACT,CAAC;EAED,MAAMC,kBAAkB,GAAG;IACzBH,IAAI,EAAE,qBAAqB;IAC3BC,GAAG,EAAE,WAAW;IAChBH,SAAS,EAAEf,iBAAiB;IAC5BmB,KAAK,EAAE;EACT,CAAC;EAEDjB,GAAG,CAACmB,QAAQ,CAACL,UAAU,CAAC;EACxBd,GAAG,CAACmB,QAAQ,CAACD,kBAAkB,CAAC;EAEhC,OAAO;IACLE,IAAI,EAAEzB,WAAW;IACjB0B,OAAO,EAAE3B,GAAG,CAAC2B;EACf,CAAC;AACH;AAEAtB,IAAI,CAACuB,UAAU,GAAG3B,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const availableFilters = [{
|
|
2
|
+
label: 'All',
|
|
3
|
+
searchTerm: 'all',
|
|
4
|
+
id: 'all',
|
|
5
|
+
type: 'all',
|
|
6
|
+
formats: ['text/csv', 'text/plain', 'text/rtf', 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/svg+xml', 'image/tiff', 'image/webp', 'application/pdf']
|
|
7
|
+
}, {
|
|
8
|
+
label: 'Images',
|
|
9
|
+
searchTerm: 'images',
|
|
10
|
+
id: 'images',
|
|
11
|
+
type: 'image',
|
|
12
|
+
formats: ['image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/svg+xml', 'image/tiff', 'image/webp']
|
|
13
|
+
}, {
|
|
14
|
+
label: 'Videos',
|
|
15
|
+
searchTerm: 'videos',
|
|
16
|
+
type: 'video',
|
|
17
|
+
id: 'videos'
|
|
18
|
+
}, {
|
|
19
|
+
label: 'Docs',
|
|
20
|
+
searchTerm: 'documents',
|
|
21
|
+
id: 'documents',
|
|
22
|
+
type: 'text',
|
|
23
|
+
formats: ['text/csv', 'text/plain', 'text/rtf', 'application/pdf']
|
|
24
|
+
}];
|
|
25
|
+
export { availableFilters };
|
|
26
|
+
//# sourceMappingURL=available-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"available-filters.js","names":["availableFilters","label","searchTerm","id","type","formats"],"sources":["../../../src/utils/available-filters/available-filters.js"],"sourcesContent":["const availableFilters = [\n {\n label: 'All',\n searchTerm: 'all',\n id: 'all',\n type: 'all',\n formats: [\n 'text/csv',\n 'text/plain',\n 'text/rtf',\n 'image/gif',\n 'image/jpeg',\n 'image/png',\n 'image/bmp',\n 'image/svg+xml',\n 'image/tiff',\n 'image/webp',\n 'application/pdf'\n ]\n },\n {\n label: 'Images',\n searchTerm: 'images',\n id: 'images',\n type: 'image',\n formats: [\n 'image/gif',\n 'image/jpeg',\n 'image/png',\n 'image/bmp',\n 'image/svg+xml',\n 'image/tiff',\n 'image/webp'\n ]\n },\n {\n label: 'Videos',\n searchTerm: 'videos',\n type: 'video',\n id: 'videos'\n },\n {\n label: 'Docs',\n searchTerm: 'documents',\n id: 'documents',\n type: 'text',\n formats: ['text/csv', 'text/plain', 'text/rtf', 'application/pdf']\n }\n];\n\nexport { availableFilters };\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAG,CACvB;EACEC,KAAK,EAAE,KAAK;EACZC,UAAU,EAAE,KAAK;EACjBC,EAAE,EAAE,KAAK;EACTC,IAAI,EAAE,KAAK;EACXC,OAAO,EAAE,CACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,iBAAiB;AAErB,CAAC,EACD;EACEJ,KAAK,EAAE,QAAQ;EACfC,UAAU,EAAE,QAAQ;EACpBC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,OAAO;EACbC,OAAO,EAAE,CACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY;AAEhB,CAAC,EACD;EACEJ,KAAK,EAAE,QAAQ;EACfC,UAAU,EAAE,QAAQ;EACpBE,IAAI,EAAE,OAAO;EACbD,EAAE,EAAE;AACN,CAAC,EACD;EACEF,KAAK,EAAE,MAAM;EACbC,UAAU,EAAE,WAAW;EACvBC,EAAE,EAAE,WAAW;EACfC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB;AACnE,CAAC,CACF;AAED,SAASL,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bustUrl.js","names":["bustUrl","url","updated","separator","includes","version","Date","now"],"sources":["../../src/utils/bustUrl.js"],"sourcesContent":["export default function bustUrl(url, updated) {\n if (!url) return url;\n const separator = url.includes('?') ? '&' : '?';\n const version = updated || Date.now();\n return `${url}${separator}v=${version}`;\n}\n"],"mappings":"AAAA,eAAe,SAASA,OAAOA,CAACC,GAAG,EAAEC,OAAO,EAAE;EAC5C,IAAI,CAACD,GAAG,EAAE,OAAOA,GAAG;EACpB,MAAME,SAAS,GAAGF,GAAG,CAACG,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG;EAC/C,MAAMC,OAAO,GAAGH,OAAO,IAAII,IAAI,CAACC,GAAG,CAAC,CAAC;EACrC,OAAO,GAAGN,GAAG,GAAGE,SAAS,KAAKE,OAAO,EAAE;AACzC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["MediaContext","MediaContextProvider","MediaContextConsumer","useMediaContext"],"sources":["../../../src/utils/media-context/index.js"],"sourcesContent":["import { MediaContext, MediaContextProvider, MediaContextConsumer } from './media-context';\nimport { useMediaContext } from './useMediaContext';\n\nexport { MediaContext, MediaContextProvider, MediaContextConsumer, useMediaContext };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,oBAAoB,EAAEC,oBAAoB,QAAQ,iBAAiB;AAC1F,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASH,YAAY,EAAEC,oBAAoB,EAAEC,oBAAoB,EAAEC,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const MediaContext = React.createContext({});
|
|
3
|
+
const MediaContextProvider = MediaContext.Provider;
|
|
4
|
+
const MediaContextConsumer = MediaContext.Consumer;
|
|
5
|
+
export { MediaContext, MediaContextProvider, MediaContextConsumer };
|
|
6
|
+
//# sourceMappingURL=media-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-context.js","names":["React","MediaContext","createContext","MediaContextProvider","Provider","MediaContextConsumer","Consumer"],"sources":["../../../src/utils/media-context/media-context.js"],"sourcesContent":["import React from 'react';\n\nconst MediaContext = React.createContext({});\nconst MediaContextProvider = MediaContext.Provider;\nconst MediaContextConsumer = MediaContext.Consumer;\n\nexport { MediaContext, MediaContextProvider, MediaContextConsumer };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,MAAMC,YAAY,GAAGD,KAAK,CAACE,aAAa,CAAC,CAAC,CAAC,CAAC;AAC5C,MAAMC,oBAAoB,GAAGF,YAAY,CAACG,QAAQ;AAClD,MAAMC,oBAAoB,GAAGJ,YAAY,CAACK,QAAQ;AAElD,SAASL,YAAY,EAAEE,oBAAoB,EAAEE,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaContext.js","names":["useContext","useMediaContext","ctx"],"sources":["../../../src/utils/media-context/useMediaContext.js"],"sourcesContent":["import { useContext } from 'react';\n\nconst useMediaContext = ctx => useContext(ctx);\n\nexport { useMediaContext };\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,MAAMC,eAAe,GAAGC,GAAG,IAAIF,UAAU,CAACE,GAAG,CAAC;AAE9C,SAASD,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-media-ui",
|
|
3
|
-
"version": "0.146.0-rc-eagle.0",
|
|
3
|
+
"version": "0.146.0-rc-eagle-3.0",
|
|
4
4
|
"description": "Blaze plugin media ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"lib-es",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
7
12
|
"source": "src/index.js",
|
|
8
13
|
"directories": {
|
|
9
14
|
"src": "src/"
|
|
@@ -27,15 +32,16 @@
|
|
|
27
32
|
},
|
|
28
33
|
"license": "GPL-3.0",
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/admin-ui-utils": "0.146.0-rc-eagle.0",
|
|
31
|
-
"@blaze-cms/core-errors": "0.146.0-rc-eagle.0",
|
|
32
|
-
"@blaze-cms/plugin-search-ui": "0.146.0-rc-eagle.0",
|
|
33
|
-
"@blaze-cms/react-form-builder": "0.146.0-rc-eagle.0",
|
|
34
|
-
"@blaze-cms/setup-ui": "0.146.0-rc-eagle.0",
|
|
35
|
+
"@blaze-cms/admin-ui-utils": "0.146.0-rc-eagle-3.0",
|
|
36
|
+
"@blaze-cms/core-errors": "0.146.0-rc-eagle-3.0",
|
|
37
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-rc-eagle-3.0",
|
|
38
|
+
"@blaze-cms/react-form-builder": "0.146.0-rc-eagle-3.0",
|
|
39
|
+
"@blaze-cms/setup-ui": "0.146.0-rc-eagle-3.0",
|
|
35
40
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
36
41
|
"@blaze-react/dnd": "^0.7.0",
|
|
37
42
|
"@blaze-react/drafteditor": "0.7.0",
|
|
38
|
-
"@blaze-react/file-upload": "0.8.0-alpha.
|
|
43
|
+
"@blaze-react/file-upload": "0.8.0-alpha.118",
|
|
44
|
+
"@blaze-react/input": "0.8.0-alpha.112",
|
|
39
45
|
"@blaze-react/modal": "0.5.19",
|
|
40
46
|
"@blaze-react/more": "0.5.19",
|
|
41
47
|
"@blaze-react/select": "0.8.0-alpha.100",
|
|
@@ -47,7 +53,7 @@
|
|
|
47
53
|
"react-tiny-virtual-list": "2.2.0"
|
|
48
54
|
},
|
|
49
55
|
"devDependencies": {
|
|
50
|
-
"@blaze-cms/core-ui": "0.146.0-rc-eagle.0"
|
|
56
|
+
"@blaze-cms/core-ui": "0.146.0-rc-eagle-3.0"
|
|
51
57
|
},
|
|
52
58
|
"peerDependencies": {
|
|
53
59
|
"@apollo/client": "3.x",
|
|
@@ -59,5 +65,6 @@
|
|
|
59
65
|
"eslintIgnore": [
|
|
60
66
|
"lib/*",
|
|
61
67
|
"lib-es/*"
|
|
62
|
-
]
|
|
68
|
+
],
|
|
69
|
+
"gitHead": "eeb5c91d33bae79f7605ffa99d8cbf430840e27a"
|
|
63
70
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import More from '@blaze-react/more';
|
|
3
|
-
import Button from '@blaze-react/button';
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
4
2
|
import { DeleteAction } from '@blaze-cms/admin';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
6
4
|
import { getQuery, getMutation } from '@blaze-cms/admin-ui-utils';
|
|
7
|
-
import { useMutation, useApolloClient } from '@apollo/client';
|
|
5
|
+
import { useMutation, useApolloClient, useQuery } from '@apollo/client';
|
|
8
6
|
import classnames from 'classnames';
|
|
9
7
|
import { useToasts } from '@blaze-react/toaster';
|
|
10
8
|
import Modal from '@blaze-react/modal';
|
|
11
9
|
import { createPortal } from 'react-dom';
|
|
12
10
|
import { Link } from 'react-router-dom';
|
|
11
|
+
import { DeleteIcon, EditIcon } from '@blaze-cms/plugin-page-builder-ui';
|
|
13
12
|
import EditMediaFile from '../EditMediaFile';
|
|
14
13
|
import bustUrl from '../../utils/bustUrl';
|
|
15
14
|
|
|
@@ -38,52 +37,53 @@ const CardMedia = ({
|
|
|
38
37
|
const [type, extension] = mimetype.split('/');
|
|
39
38
|
const client = useApolloClient();
|
|
40
39
|
|
|
40
|
+
const { data: { getEntitySchemas: [schemaData] = [] } = {}, loading: schemaLoading } = useQuery(
|
|
41
|
+
getQuery('GET_ENTITY_SCHEMA'),
|
|
42
|
+
{
|
|
43
|
+
variables: { identifier: 'file' }
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
41
47
|
const deleteFileById = async () => {
|
|
42
48
|
setDisplayDeleteModal(false);
|
|
43
49
|
try {
|
|
44
|
-
await deleteFile({
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
removeFile({
|
|
49
|
-
index
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
addToast(`File: ${name} has been deleted`, {
|
|
53
|
-
appearance: 'success',
|
|
54
|
-
autoDismiss: true
|
|
55
|
-
});
|
|
50
|
+
await deleteFile({ variables: { input: { id } } });
|
|
51
|
+
removeFile({ index });
|
|
52
|
+
addToast(`File: ${name} has been deleted`, { appearance: 'success', autoDismiss: true });
|
|
56
53
|
} catch (error) {
|
|
57
|
-
addToast(error.message, {
|
|
58
|
-
appearance: 'error',
|
|
59
|
-
autoDismiss: true
|
|
60
|
-
});
|
|
54
|
+
addToast(error.message, { appearance: 'error', autoDismiss: true });
|
|
61
55
|
}
|
|
62
56
|
};
|
|
63
57
|
|
|
64
|
-
const
|
|
65
|
-
onSelected({ id, url, name, data });
|
|
66
|
-
};
|
|
58
|
+
const handleRowClick = () => onSelected({ id, url, name, data });
|
|
67
59
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
const handleCheckboxToggle = useCallback(
|
|
61
|
+
e => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
onSelected({ id, url, name, data });
|
|
65
|
+
},
|
|
66
|
+
[id, url, name, data, onSelected]
|
|
67
|
+
);
|
|
72
68
|
|
|
73
|
-
const
|
|
74
|
-
|
|
69
|
+
const handleKeyDown = e => {
|
|
70
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
handleRowClick();
|
|
73
|
+
}
|
|
75
74
|
};
|
|
76
75
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const cardMediaClassNames = classnames(
|
|
77
|
+
'card card--media-list card--media-list-row',
|
|
78
|
+
`card--media-${displayLayout}`,
|
|
79
|
+
{ 'card--media-list--selected': selected }
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const handleCloseModal = () => setDisplayEditModal(false);
|
|
83
|
+
const handleSaveButtonStatus = state => setEnableSaveButton(state);
|
|
80
84
|
|
|
81
85
|
const modalActions = [
|
|
82
|
-
{
|
|
83
|
-
textButton: 'Cancel',
|
|
84
|
-
callback: handleCloseModal,
|
|
85
|
-
modifiers: ['cancel']
|
|
86
|
-
},
|
|
86
|
+
{ textButton: 'Cancel', callback: handleCloseModal, modifiers: ['cancel'] },
|
|
87
87
|
{
|
|
88
88
|
textButton: 'Apply',
|
|
89
89
|
callback: () => handleFormSave(),
|
|
@@ -91,9 +91,9 @@ const CardMedia = ({
|
|
|
91
91
|
}
|
|
92
92
|
];
|
|
93
93
|
|
|
94
|
-
const handleFileChange = file =>
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const handleFileChange = file => setFileData(file);
|
|
95
|
+
|
|
96
|
+
const handleStopPropagation = e => e.stopPropagation();
|
|
97
97
|
|
|
98
98
|
const handleFormSave = async () => {
|
|
99
99
|
try {
|
|
@@ -101,7 +101,7 @@ const CardMedia = ({
|
|
|
101
101
|
data: { updateFile: updatedFile }
|
|
102
102
|
} = await client.mutate({
|
|
103
103
|
mutation: getMutation('UPDATE_FILE'),
|
|
104
|
-
variables: { input: fileData },
|
|
104
|
+
variables: { input: fileData.formData },
|
|
105
105
|
update(cache, { data: { updateFile: fileUpdated } }) {
|
|
106
106
|
cache.writeQuery({
|
|
107
107
|
query: getQuery('GET_FILE_BY_ID'),
|
|
@@ -127,6 +127,8 @@ const CardMedia = ({
|
|
|
127
127
|
setEnableSaveButton(false);
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
if (schemaLoading) return null;
|
|
131
|
+
|
|
130
132
|
return (
|
|
131
133
|
<>
|
|
132
134
|
{displayEditModal &&
|
|
@@ -138,28 +140,52 @@ const CardMedia = ({
|
|
|
138
140
|
handleSaveButtonStatus={handleSaveButtonStatus}
|
|
139
141
|
handleFormSave={handleFormSave}
|
|
140
142
|
enableSaveButton={enableSaveButton}
|
|
143
|
+
schemaData={schemaData}
|
|
141
144
|
/>
|
|
142
145
|
</Modal>,
|
|
143
146
|
modalTargetRef.current
|
|
144
147
|
)}
|
|
145
|
-
<div className={cardMediaClassNames} role="button" onClick={handleClick}>
|
|
146
|
-
{displayDeleteModal &&
|
|
147
|
-
createPortal(
|
|
148
|
-
<DeleteAction
|
|
149
|
-
onClose={() => setDisplayDeleteModal(false)}
|
|
150
|
-
deleteAction={() => deleteFileById()}
|
|
151
|
-
itemName={name}
|
|
152
|
-
/>,
|
|
153
|
-
modalTargetRef.current
|
|
154
|
-
)}
|
|
155
148
|
|
|
149
|
+
{displayDeleteModal &&
|
|
150
|
+
createPortal(
|
|
151
|
+
<DeleteAction
|
|
152
|
+
onClose={() => setDisplayDeleteModal(false)}
|
|
153
|
+
deleteAction={() => deleteFileById()}
|
|
154
|
+
itemName={name}
|
|
155
|
+
/>,
|
|
156
|
+
modalTargetRef.current
|
|
157
|
+
)}
|
|
158
|
+
|
|
159
|
+
<div
|
|
160
|
+
className={cardMediaClassNames}
|
|
161
|
+
role="option"
|
|
162
|
+
aria-selected={selected}
|
|
163
|
+
tabIndex={0}
|
|
164
|
+
onClick={handleRowClick}
|
|
165
|
+
onKeyDown={handleKeyDown}>
|
|
166
|
+
{openEditInModal && (
|
|
167
|
+
<div className="card__select">
|
|
168
|
+
<input
|
|
169
|
+
type="checkbox"
|
|
170
|
+
aria-label={`Select ${name}`}
|
|
171
|
+
checked={!!selected}
|
|
172
|
+
onChange={handleCheckboxToggle}
|
|
173
|
+
onClick={handleStopPropagation}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
156
177
|
{type === 'image' ? (
|
|
157
178
|
<div className={`card__image card__image--media-${displayLayout}`}>
|
|
158
179
|
<img src={bustUrl(url, updated)} alt={name} />
|
|
159
180
|
</div>
|
|
160
181
|
) : (
|
|
161
182
|
<div className="card__image card__image--media-list-document">
|
|
162
|
-
<svg
|
|
183
|
+
<svg
|
|
184
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
185
|
+
width="100"
|
|
186
|
+
height="100"
|
|
187
|
+
viewBox="0 0 8 8"
|
|
188
|
+
aria-hidden="true">
|
|
163
189
|
<path d="M0 0v8h7v-4h-4v-4h-3zm4 0v3h3l-3-3zm-3 2h1v1h-1v-1zm0 2h1v1h-1v-1zm0 2h4v1h-4v-1z" />
|
|
164
190
|
</svg>
|
|
165
191
|
</div>
|
|
@@ -168,46 +194,50 @@ const CardMedia = ({
|
|
|
168
194
|
<footer className={`card__footer card__footer--media-${displayLayout}`}>
|
|
169
195
|
<div className={`card__details card__details--media-${displayLayout}`}>
|
|
170
196
|
<div className={`card__title card__title--media-${displayLayout}`}>
|
|
171
|
-
<h2>{name}</h2>
|
|
197
|
+
<h2 className="card__file-name">{name}</h2>
|
|
172
198
|
</div>
|
|
173
|
-
<p>
|
|
174
|
-
<span>
|
|
199
|
+
<p className="card__meta">
|
|
200
|
+
<span>Format: {extension}</span>
|
|
175
201
|
</p>
|
|
176
202
|
</div>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
|
|
204
|
+
<div className={`card__menu card__menu--icons card__menu--${displayLayout}`}>
|
|
205
|
+
{openEditInModal ? (
|
|
206
|
+
<button
|
|
207
|
+
type="button"
|
|
208
|
+
className="card__icon-btn"
|
|
209
|
+
title="Edit"
|
|
210
|
+
aria-label="Edit"
|
|
211
|
+
onClick={e => {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
e.stopPropagation();
|
|
214
|
+
setDisplayEditModal(true);
|
|
215
|
+
}}>
|
|
216
|
+
<EditIcon width="20px" height="20px" />
|
|
217
|
+
</button>
|
|
218
|
+
) : (
|
|
219
|
+
<Link
|
|
220
|
+
to={`/media/edit/${id}`}
|
|
221
|
+
className="card__icon-btn"
|
|
222
|
+
title="Edit"
|
|
223
|
+
aria-label="Edit"
|
|
224
|
+
onClick={e => e.stopPropagation()}>
|
|
225
|
+
<EditIcon width="20px" height="20px" />
|
|
226
|
+
</Link>
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
<button
|
|
230
|
+
type="button"
|
|
231
|
+
className="card__icon-btn"
|
|
232
|
+
title="Delete"
|
|
233
|
+
aria-label="Delete"
|
|
234
|
+
onClick={e => {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
e.stopPropagation();
|
|
237
|
+
setDisplayDeleteModal(true);
|
|
238
|
+
}}>
|
|
239
|
+
<DeleteIcon width="18px" height="18px" />
|
|
240
|
+
</button>
|
|
211
241
|
</div>
|
|
212
242
|
</footer>
|
|
213
243
|
</div>
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
3
|
+
import { getQuery, getDynamicQuery } from '@blaze-cms/admin-ui-utils';
|
|
4
4
|
import { useQuery } from '@apollo/client';
|
|
5
5
|
import { useToasts } from '@blaze-react/toaster';
|
|
6
6
|
import FilePreview from '../FilePreview';
|
|
7
7
|
import FileUploadModal from '../FileUploadModal';
|
|
8
|
-
import {
|
|
8
|
+
import { FILE_DEFAULT_PROPS } from '../../constants';
|
|
9
9
|
|
|
10
10
|
const EditMediaFile = ({
|
|
11
11
|
onChange,
|
|
12
12
|
handleSaveButtonStatus,
|
|
13
13
|
fileId,
|
|
14
14
|
showChangeButton,
|
|
15
|
-
fileUpdated
|
|
15
|
+
fileUpdated,
|
|
16
|
+
schemaData
|
|
16
17
|
}) => {
|
|
17
18
|
const [formValues, setFormValues] = useState(null);
|
|
18
19
|
const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
|
|
19
20
|
const { addToast } = useToasts();
|
|
20
21
|
|
|
21
|
-
const fileQuery =
|
|
22
|
+
const fileQuery = getDynamicQuery('DATA_QUERY')(schemaData, fileId, null, FILE_DEFAULT_PROPS);
|
|
22
23
|
const {
|
|
23
24
|
loading,
|
|
24
|
-
data: { file } = {},
|
|
25
|
+
data: { entityData: file } = {},
|
|
25
26
|
refetch: refetchFile
|
|
26
27
|
} = useQuery(fileQuery, {
|
|
27
28
|
variables: { id: fileId },
|
|
@@ -52,32 +53,30 @@ const EditMediaFile = ({
|
|
|
52
53
|
|
|
53
54
|
const handleFormChange = ({ isValid, isNewValueSet, valuesChecked }) => {
|
|
54
55
|
const baseFile = formValues || file;
|
|
55
|
-
const valuesCheckedWithoutName = valuesChecked.filter(
|
|
56
|
-
({ id }) => id !== NAME && id !== STORE_KEY
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const dataValues = valuesCheckedWithoutName.reduce((acc, { id, value }) => {
|
|
60
|
-
acc[id] = value;
|
|
61
|
-
return acc;
|
|
62
|
-
}, {});
|
|
63
56
|
|
|
64
|
-
const
|
|
65
|
-
|
|
57
|
+
const dataValues = valuesChecked.reduce(
|
|
58
|
+
(acc, { id, value, isDataPropery }) => {
|
|
59
|
+
if (isDataPropery) {
|
|
60
|
+
acc.data[id] = value;
|
|
61
|
+
} else {
|
|
62
|
+
acc[id] = value;
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
},
|
|
66
|
+
{ id: baseFile.id, data: { ...baseFile.data } }
|
|
67
|
+
);
|
|
68
|
+
delete dataValues.data.__typename; // Remove __typename if it exists in data to avoid issues with Apollo cache.
|
|
66
69
|
|
|
67
70
|
const shouldEnableSaveButton = isNewValueSet && isValid;
|
|
68
71
|
handleSaveButtonStatus(shouldEnableSaveButton);
|
|
69
72
|
|
|
70
73
|
const updatedFile = {
|
|
71
74
|
...baseFile,
|
|
72
|
-
|
|
73
|
-
storeKey: storeKey || baseFile.storeKey,
|
|
74
|
-
data: { ...(baseFile.data || {}), ...dataValues }
|
|
75
|
+
...dataValues
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
setFormValues(updatedFile);
|
|
78
|
-
|
|
79
|
-
const { __typename, ...cleanData } = updatedFile.data || {};
|
|
80
|
-
onChange({ id: updatedFile.id, name: updatedFile.name, data: cleanData });
|
|
79
|
+
onChange({ ...updatedFile, formData: dataValues });
|
|
81
80
|
};
|
|
82
81
|
|
|
83
82
|
const getFileWithStoreType = sourceFile => {
|
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { withRouter } from 'react-router-dom';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Button from '@blaze-react/button';
|
|
5
|
-
import { useApolloClient } from '@apollo/client';
|
|
5
|
+
import { useApolloClient, useQuery } from '@apollo/client';
|
|
6
6
|
import { getQuery, getMutation } from '@blaze-cms/admin-ui-utils';
|
|
7
7
|
import { useToasts } from '@blaze-react/toaster';
|
|
8
8
|
import EditMediaFile from './EditMediaFile';
|
|
@@ -13,6 +13,13 @@ const EditMediaFilePage = ({ match, history }) => {
|
|
|
13
13
|
const client = useApolloClient();
|
|
14
14
|
const { addToast } = useToasts();
|
|
15
15
|
|
|
16
|
+
const { data: { getEntitySchemas: [schemaData] = [] } = {}, loading: schemaLoading } = useQuery(
|
|
17
|
+
getQuery('GET_ENTITY_SCHEMA'),
|
|
18
|
+
{
|
|
19
|
+
variables: { identifier: 'file' }
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
16
23
|
const handleFileChange = values => setFile(values);
|
|
17
24
|
|
|
18
25
|
const handleSaveButtonStatus = value => {
|
|
@@ -29,12 +36,7 @@ const EditMediaFilePage = ({ match, history }) => {
|
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
try {
|
|
32
|
-
const inputData =
|
|
33
|
-
id: file.id,
|
|
34
|
-
name: file.name,
|
|
35
|
-
data: file.data,
|
|
36
|
-
storeKey: file.storeKey
|
|
37
|
-
};
|
|
39
|
+
const inputData = file.formData;
|
|
38
40
|
|
|
39
41
|
const {
|
|
40
42
|
data: { updateFile: updatedFile }
|
|
@@ -75,6 +77,8 @@ const EditMediaFilePage = ({ match, history }) => {
|
|
|
75
77
|
|
|
76
78
|
const buttonModifiers = shouldEnableSaveButton ? [] : ['disabled'];
|
|
77
79
|
|
|
80
|
+
if (schemaLoading) return null;
|
|
81
|
+
|
|
78
82
|
return (
|
|
79
83
|
<div className="page">
|
|
80
84
|
<div className="page__content">
|
|
@@ -86,6 +90,7 @@ const EditMediaFilePage = ({ match, history }) => {
|
|
|
86
90
|
handleFormSave={handleFormSave}
|
|
87
91
|
showChangeButton
|
|
88
92
|
fileUpdated={file}
|
|
93
|
+
schemaData={schemaData}
|
|
89
94
|
/>
|
|
90
95
|
<div className="page__content__mediaWrapperActions">
|
|
91
96
|
<Button onClick={pushBack}>Cancel</Button>
|