@blaze-cms/plugin-media-ui 0.146.0-alpha.2 → 0.146.0-alpha.22
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 +53 -0
- package/lib/components/FilePreview/Actions/index.js +2 -2
- package/lib/components/FilePreview/Actions/index.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FileList.js +27 -0
- package/lib/components/FilePreviewReadOnly/FileList.js.map +1 -0
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js +34 -0
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -0
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js +122 -0
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -0
- package/lib/components/FilePreviewReadOnly/index.js +11 -0
- package/lib/components/FilePreviewReadOnly/index.js.map +1 -0
- package/lib/components/FilePreviewReadOnly/mappers/format-initial-value.js +18 -0
- package/lib/components/FilePreviewReadOnly/mappers/format-initial-value.js.map +1 -0
- package/lib/components/FilePreviewReadOnly/mappers/index.js +14 -0
- package/lib/components/FilePreviewReadOnly/mappers/index.js.map +1 -0
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js +68 -29
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib/components/FileUploadModal/FileUploadModal.js +30 -9
- package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib/components/ListingContainer/Listing/Listing.js +22 -9
- package/lib/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib/components/ListingContainer/ListingContainer.js +36 -19
- package/lib/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib/components/MediaListing.js +49 -0
- package/lib/components/MediaListing.js.map +1 -0
- package/lib/index.js +13 -3
- package/lib/index.js.map +1 -1
- package/lib/utils/media-context/media-context.js +1 -1
- package/lib/utils/media-context/media-context.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/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 +66 -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/FileUploadAdapter.js +42 -10
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib-es/components/FileUploadModal/FileUploadModal.js +20 -5
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib-es/components/ListingContainer/Listing/Listing.js +23 -8
- package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib-es/components/ListingContainer/ListingContainer.js +29 -8
- package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib-es/components/MediaListing.js +29 -0
- package/lib-es/components/MediaListing.js.map +1 -0
- package/lib-es/index.js +7 -2
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/media-context/media-context.js +1 -1
- package/lib-es/utils/media-context/media-context.js.map +1 -1
- package/package.json +6 -6
- package/src/components/FilePreview/Actions/index.js +18 -14
- package/src/components/FilePreviewReadOnly/FileList.js +20 -0
- package/src/components/FilePreviewReadOnly/FilePreviewList.js +23 -0
- package/src/components/FilePreviewReadOnly/FilePreviewReadOnly.js +71 -0
- package/src/components/FilePreviewReadOnly/index.js +3 -0
- package/src/components/FilePreviewReadOnly/mappers/format-initial-value.js +8 -0
- package/src/components/FilePreviewReadOnly/mappers/index.js +3 -0
- package/src/components/FileUploadAdapter/FileUploadAdapter.js +64 -21
- package/src/components/FileUploadModal/FileUploadModal.js +19 -5
- package/src/components/ListingContainer/Listing/Listing.js +51 -27
- package/src/components/ListingContainer/ListingContainer.js +30 -7
- package/src/components/MediaListing.js +31 -0
- package/src/index.js +8 -3
- package/src/utils/media-context/media-context.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadModal.js","names":["React","useState","ModalAdapter","Modal","getMutation","getQuery","FileUpload","PropTypes","useToasts","useApolloClient","useQuery","useFileList","FileUploadModal","onClose","files","setFiles","addToast","client","addNewFile","fileStoresType","data","getFileStores","storeType","variables","visibleInAdmin","handleFiles","filesToUpload","uploadFiles","response","Promise","all","map","file","name","fileData","storeKey","mutate","mutation","input","filename","catch","error","message","appearance","autoDismiss","parsedResponse","result","fileNames","join","handleOnSave","length","storeOptions","type","key","createElement","Fragment","title","actions","textButton","callback","modifiers","upload","onChange","selectOptions","propTypes","func","defaultProps"],"sources":["../../../src/components/FileUploadModal/FileUploadModal.js"],"sourcesContent":["import React, { useState } from 'react';\nimport { ModalAdapter as Modal, getMutation, getQuery } from '@blaze-cms/admin-ui-utils';\nimport FileUpload from '@blaze-react/file-upload';\nimport PropTypes from 'prop-types';\nimport { useToasts } from '@blaze-react/toaster';\nimport { useApolloClient, useQuery } from '@apollo/client';\nimport useFileList from '../FileList/useFileList';\n\nconst FileUploadModal = ({ onClose }) => {\n const [files, setFiles] = useState([]);\n const { addToast } = useToasts();\n const client = useApolloClient();\n const { addNewFile } = useFileList();\n\n const fileStoresType = getQuery('GET_FILE_STORES');\n\n const { data: { getFileStores: storeType = [] } = {} } = useQuery(fileStoresType, {\n variables: { visibleInAdmin: true }\n });\n\n const handleFiles = filesToUpload => {\n setFiles(filesToUpload);\n };\n\n const uploadFiles = async () => {\n const response = await Promise.all(\n files.map(({ file, name, data: fileData, storeKey }) =>\n client.mutate({\n mutation: getMutation('UPLOAD_FILE'),\n variables: {\n input: {\n file,\n name: name || file.filename,\n storeKey,\n data: fileData\n }\n }\n })\n )\n ).catch(error => {\n addToast(error.message, {\n appearance: 'error',\n autoDismiss: true\n });\n });\n\n const parsedResponse = response.map(({ data: { file } }) => file.result);\n\n const fileNames = files.map(({ file }) => file.name);\n addNewFile(parsedResponse);\n
|
|
1
|
+
{"version":3,"file":"FileUploadModal.js","names":["React","useState","ModalAdapter","Modal","getMutation","getQuery","FileUpload","PropTypes","useToasts","useApolloClient","useQuery","useFileList","FileUploadModal","onClose","getSelectedFiles","closeModalAndSetValue","simpleLayout","files","setFiles","addToast","client","addNewFile","fileStoresType","data","getFileStores","storeType","variables","visibleInAdmin","handleFiles","filesToUpload","uploadFiles","response","Promise","all","map","file","name","fileData","storeKey","mutate","mutation","input","filename","catch","error","message","appearance","autoDismiss","parsedResponse","result","fileNames","toastMessage","join","filesToSelect","id","handleOnSave","length","storeOptions","type","key","createElement","Fragment","title","actions","textButton","callback","modifiers","upload","onChange","selectOptions","propTypes","func","isRequired","bool","defaultProps"],"sources":["../../../src/components/FileUploadModal/FileUploadModal.js"],"sourcesContent":["import React, { useState } from 'react';\nimport { ModalAdapter as Modal, getMutation, getQuery } from '@blaze-cms/admin-ui-utils';\nimport FileUpload from '@blaze-react/file-upload';\nimport PropTypes from 'prop-types';\nimport { useToasts } from '@blaze-react/toaster';\nimport { useApolloClient, useQuery } from '@apollo/client';\nimport useFileList from '../FileList/useFileList';\n\nconst FileUploadModal = ({ onClose, getSelectedFiles, closeModalAndSetValue, simpleLayout }) => {\n const [files, setFiles] = useState([]);\n const { addToast } = useToasts();\n const client = useApolloClient();\n const { addNewFile } = useFileList();\n\n const fileStoresType = getQuery('GET_FILE_STORES');\n\n const { data: { getFileStores: storeType = [] } = {} } = useQuery(fileStoresType, {\n variables: { visibleInAdmin: true }\n });\n\n const handleFiles = filesToUpload => {\n setFiles(filesToUpload);\n };\n\n const uploadFiles = async () => {\n const response = await Promise.all(\n files.map(({ file, name, data: fileData, storeKey }) =>\n client.mutate({\n mutation: getMutation('UPLOAD_FILE'),\n variables: {\n input: {\n file,\n name: name || file.filename,\n storeKey,\n data: fileData\n }\n }\n })\n )\n ).catch(error => {\n addToast(error.message, {\n appearance: 'error',\n autoDismiss: true\n });\n });\n\n const parsedResponse = response.map(({ data: { file } }) => file.result);\n\n const fileNames = files.map(({ file }) => file.name);\n addNewFile(parsedResponse);\n const toastMessage = `Uploaded: ${fileNames.join(', ')}`;\n\n if (simpleLayout) {\n const filesToSelect = parsedResponse.map(file => file.id);\n getSelectedFiles(null, filesToSelect);\n closeModalAndSetValue(simpleLayout, filesToSelect, toastMessage);\n return;\n }\n\n addToast(toastMessage, {\n appearance: 'success',\n autoDismiss: true\n });\n };\n\n const handleOnSave = async () => {\n if (files.length) await uploadFiles();\n onClose();\n };\n\n const storeOptions = storeType.map(type => [type.key, type.name]);\n\n return (\n <>\n <Modal\n onClose={onClose}\n title=\"Add media\"\n actions={[\n {\n textButton: 'Cancel',\n callback: onClose,\n modifiers: ['cancel']\n },\n {\n textButton: 'Save',\n callback: handleOnSave,\n modifiers: []\n }\n ]}\n upload>\n <FileUpload onChange={handleFiles} selectOptions={storeOptions} />\n </Modal>\n </>\n );\n};\n\nFileUploadModal.propTypes = {\n getSelectedFiles: PropTypes.func.isRequired,\n onClose: PropTypes.func,\n simpleLayout: PropTypes.bool,\n closeModalAndSetValue: PropTypes.func\n};\n\nFileUploadModal.defaultProps = {\n onClose: () => {},\n closeModalAndSetValue: () => {},\n simpleLayout: false\n};\n\nexport default FileUploadModal;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,YAAY,IAAIC,KAAK,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,2BAA2B;AACxF,OAAOC,UAAU,MAAM,0BAA0B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AAA,CAAA6D,QAAA,qBACE7D,KAAA,CAAA4D,aAAA,CAACzD,KAAK;IACJU,OAAO,EAAEA,OAAQ;IACjBiD,KAAK,EAAC,WAAW;IACjBC,OAAO,EAAE,CACP;MACEC,UAAU,EAAE,QAAQ;MACpBC,QAAQ,EAAEpD,OAAO;MACjBqD,SAAS,EAAE,CAAC,QAAQ;IACtB,CAAC,EACD;MACEF,UAAU,EAAE,MAAM;MAClBC,QAAQ,EAAEV,YAAY;MACtBW,SAAS,EAAE;IACb,CAAC,CACD;IACFC,MAAM;EAAA,gBACNnE,KAAA,CAAA4D,aAAA,CAACtD,UAAU;IAAC8D,QAAQ,EAAExC,WAAY;IAACyC,aAAa,EAAEZ;EAAa,CAAE,CAC5D,CACP,CAAC;AAEP,CAAC;AAED7C,eAAe,CAAC0D,SAAS,GAAG;EAC1BxD,gBAAgB,EAAEP,SAAS,CAACgE,IAAI,CAACC,UAAU;EAC3C3D,OAAO,EAAEN,SAAS,CAACgE,IAAI;EACvBvD,YAAY,EAAET,SAAS,CAACkE,IAAI;EAC5B1D,qBAAqB,EAAER,SAAS,CAACgE;AACnC,CAAC;AAED3D,eAAe,CAAC8D,YAAY,GAAG;EAC7B7D,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBE,qBAAqB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC/BC,YAAY,EAAE;AAChB,CAAC;AAED,eAAeJ,eAAe","ignoreList":[]}
|
|
@@ -8,12 +8,22 @@ import MediaListing from './MediaListing';
|
|
|
8
8
|
import FilterPanel from '../../FilterPanel';
|
|
9
9
|
const Listing = ({
|
|
10
10
|
displayFileUploadModal,
|
|
11
|
-
handleDisplayFileUploadModal
|
|
11
|
+
handleDisplayFileUploadModal,
|
|
12
|
+
getSelectedFiles,
|
|
13
|
+
setDisplayFileUploadModal,
|
|
14
|
+
closeModalAndSetValue,
|
|
15
|
+
simpleLayout
|
|
12
16
|
}) => /*#__PURE__*/React.createElement("div", {
|
|
13
17
|
className: "page"
|
|
14
18
|
}, displayFileUploadModal && /*#__PURE__*/React.createElement(FileUploadModal, {
|
|
15
|
-
onClose: () =>
|
|
16
|
-
|
|
19
|
+
onClose: () => {
|
|
20
|
+
handleDisplayFileUploadModal(false);
|
|
21
|
+
setDisplayFileUploadModal(false);
|
|
22
|
+
},
|
|
23
|
+
closeModalAndSetValue: closeModalAndSetValue,
|
|
24
|
+
simpleLayout: simpleLayout,
|
|
25
|
+
getSelectedFiles: getSelectedFiles
|
|
26
|
+
}), !simpleLayout && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PageHeader, {
|
|
17
27
|
title: "Media library"
|
|
18
28
|
}, /*#__PURE__*/React.createElement(PageHeader.Actions, null, /*#__PURE__*/React.createElement(Button, {
|
|
19
29
|
modifiers: ['small'],
|
|
@@ -30,14 +40,19 @@ const Listing = ({
|
|
|
30
40
|
isMoreMenu: true
|
|
31
41
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
32
42
|
className: "page__content page__content--with-side-panel"
|
|
33
|
-
}, /*#__PURE__*/React.createElement(FilterPanel, null), /*#__PURE__*/React.createElement(MediaListing, null)));
|
|
43
|
+
}, /*#__PURE__*/React.createElement(FilterPanel, null), /*#__PURE__*/React.createElement(MediaListing, null))));
|
|
34
44
|
Listing.propTypes = {
|
|
35
|
-
|
|
36
|
-
handleDisplayFileUploadModal: PropTypes.func
|
|
45
|
+
getSelectedFiles: PropTypes.func.isRequired,
|
|
46
|
+
handleDisplayFileUploadModal: PropTypes.func,
|
|
47
|
+
simpleLayout: PropTypes.bool,
|
|
48
|
+
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
49
|
+
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
50
|
+
closeModalAndSetValue: PropTypes.func
|
|
37
51
|
};
|
|
38
52
|
Listing.defaultProps = {
|
|
39
|
-
|
|
40
|
-
handleDisplayFileUploadModal: () => {}
|
|
53
|
+
closeModalAndSetValue: () => {},
|
|
54
|
+
handleDisplayFileUploadModal: () => {},
|
|
55
|
+
simpleLayout: false
|
|
41
56
|
};
|
|
42
57
|
export default Listing;
|
|
43
58
|
//# sourceMappingURL=Listing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Listing.js","names":["React","PageHeader","Button","More","PropTypes","FileUploadModal","MediaListing","FilterPanel","Listing","displayFileUploadModal","handleDisplayFileUploadModal","createElement","className","onClose","title","Actions","modifiers","onClick","displayBg","Avatar","isMoreMenu","Content","propTypes","
|
|
1
|
+
{"version":3,"file":"Listing.js","names":["React","PageHeader","Button","More","PropTypes","FileUploadModal","MediaListing","FilterPanel","Listing","displayFileUploadModal","handleDisplayFileUploadModal","getSelectedFiles","setDisplayFileUploadModal","closeModalAndSetValue","simpleLayout","createElement","className","onClose","Fragment","title","Actions","modifiers","onClick","displayBg","Avatar","isMoreMenu","Content","propTypes","func","isRequired","bool","defaultProps"],"sources":["../../../../src/components/ListingContainer/Listing/Listing.js"],"sourcesContent":["import React from 'react';\nimport { PageHeader } from '@blaze-cms/admin';\nimport Button from '@blaze-react/button';\nimport More from '@blaze-react/more';\nimport PropTypes from 'prop-types';\nimport FileUploadModal from '../../FileUploadModal';\nimport MediaListing from './MediaListing';\nimport FilterPanel from '../../FilterPanel';\n\nconst Listing = ({\n displayFileUploadModal,\n handleDisplayFileUploadModal,\n getSelectedFiles,\n setDisplayFileUploadModal,\n closeModalAndSetValue,\n simpleLayout\n}) => (\n <div className=\"page\">\n {displayFileUploadModal && (\n <FileUploadModal\n onClose={() => {\n handleDisplayFileUploadModal(false);\n setDisplayFileUploadModal(false);\n }}\n closeModalAndSetValue={closeModalAndSetValue}\n simpleLayout={simpleLayout}\n getSelectedFiles={getSelectedFiles}\n />\n )}\n {!simpleLayout && (\n <>\n <PageHeader title=\"Media library\">\n <PageHeader.Actions>\n <Button\n modifiers={['small']}\n onClick={() => {\n handleDisplayFileUploadModal(true);\n }}>\n Add\n </Button>\n <More displayBg>\n <More.Avatar isMoreMenu>\n <span className=\"material-icons\">more_vert</span>\n </More.Avatar>\n <More.Content isMoreMenu />\n </More>\n </PageHeader.Actions>\n </PageHeader>\n <div className=\"page__content page__content--with-side-panel\">\n <FilterPanel />\n <MediaListing />\n </div>\n </>\n )}\n </div>\n);\n\nListing.propTypes = {\n getSelectedFiles: PropTypes.func.isRequired,\n handleDisplayFileUploadModal: PropTypes.func,\n simpleLayout: PropTypes.bool,\n setDisplayFileUploadModal: PropTypes.func.isRequired,\n displayFileUploadModal: PropTypes.bool.isRequired,\n closeModalAndSetValue: PropTypes.func\n};\n\nListing.defaultProps = {\n closeModalAndSetValue: () => {},\n handleDisplayFileUploadModal: () => {},\n simpleLayout: false\n};\n\nexport default Listing;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,eAAe,MAAM,uBAAuB;AACnD,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,WAAW,MAAM,mBAAmB;AAE3C,MAAMC,OAAO,GAAGA,CAAC;EACfC,sBAAsB;EACtBC,4BAA4B;EAC5BC,gBAAgB;EAChBC,yBAAyB;EACzBC,qBAAqB;EACrBC;AACF,CAAC,kBACCd,KAAA,CAAAe,aAAA;EAAKC,SAAS,EAAC;AAAM,GAClBP,sBAAsB,iBACrBT,KAAA,CAAAe,aAAA,CAACV,eAAe;EACdY,OAAO,EAAEA,CAAA,KAAM;IACbP,4BAA4B,CAAC,KAAK,CAAC;IACnCE,yBAAyB,CAAC,KAAK,CAAC;EAClC,CAAE;EACFC,qBAAqB,EAAEA,qBAAsB;EAC7CC,YAAY,EAAEA,YAAa;EAC3BH,gBAAgB,EAAEA;AAAiB,CACpC,CACF,EACA,CAACG,YAAY,iBACZd,KAAA,CAAAe,aAAA,CAAAf,KAAA,CAAAk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M,CAAC,CAAC;EACtCI,YAAY,EAAE;AAChB,CAAC;AAED,eAAeN,OAAO","ignoreList":[]}
|
|
@@ -14,9 +14,12 @@ import { existPrevious } from './mappers';
|
|
|
14
14
|
const ListingContainer = ({
|
|
15
15
|
handleSelectedFiles,
|
|
16
16
|
maxItems,
|
|
17
|
-
filesSelected
|
|
17
|
+
filesSelected,
|
|
18
|
+
displayFileUploadModal,
|
|
19
|
+
setDisplayFileUploadModal,
|
|
20
|
+
closeModalAndSetValue,
|
|
21
|
+
simpleLayout
|
|
18
22
|
}) => {
|
|
19
|
-
const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
|
|
20
23
|
const [selectedFiles, setSelectedFiles] = useState(filesSelected || []);
|
|
21
24
|
const [selectedFilter, setSelectedFilter] = useState({
|
|
22
25
|
filter: 'all',
|
|
@@ -36,9 +39,15 @@ const ListingContainer = ({
|
|
|
36
39
|
}
|
|
37
40
|
});
|
|
38
41
|
if (loading) return null;
|
|
39
|
-
const getSelectedFiles = ({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const getSelectedFiles = (file, files) => {
|
|
43
|
+
if (simpleLayout) {
|
|
44
|
+
handleSelectedFiles(files, false);
|
|
45
|
+
setSelectedFiles(files);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const {
|
|
49
|
+
id
|
|
50
|
+
} = file;
|
|
42
51
|
const existPreviousFile = existPrevious(selectedFiles, id);
|
|
43
52
|
if (maxItems === selectedFiles.length && !existPreviousFile) {
|
|
44
53
|
handleSelectedFiles([id], false);
|
|
@@ -67,19 +76,31 @@ const ListingContainer = ({
|
|
|
67
76
|
onClickPrompt: () => handleDisplayFileUploadModal(true)
|
|
68
77
|
}
|
|
69
78
|
}, /*#__PURE__*/React.createElement(FilesListProvider, null, /*#__PURE__*/React.createElement(Listing, {
|
|
79
|
+
closeModalAndSetValue: closeModalAndSetValue,
|
|
80
|
+
simpleLayout: simpleLayout,
|
|
81
|
+
getSelectedFiles: getSelectedFiles,
|
|
82
|
+
setDisplayFileUploadModal: setDisplayFileUploadModal,
|
|
70
83
|
displayFileUploadModal: displayFileUploadModal,
|
|
71
|
-
handleDisplayFileUploadModal: handleDisplayFileUploadModal
|
|
84
|
+
handleDisplayFileUploadModal: handleDisplayFileUploadModal,
|
|
85
|
+
setSelectedFiles: setSelectedFiles,
|
|
86
|
+
handleSelectedFiles: handleSelectedFiles
|
|
72
87
|
}))));
|
|
73
88
|
};
|
|
74
89
|
ListingContainer.propTypes = {
|
|
75
90
|
handleSelectedFiles: PropTypes.func,
|
|
76
91
|
maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
|
|
77
|
-
filesSelected: PropTypes.arrayOf(PropTypes.string)
|
|
92
|
+
filesSelected: PropTypes.arrayOf(PropTypes.string),
|
|
93
|
+
simpleLayout: PropTypes.bool,
|
|
94
|
+
setDisplayFileUploadModal: PropTypes.func.isRequired,
|
|
95
|
+
displayFileUploadModal: PropTypes.bool.isRequired,
|
|
96
|
+
closeModalAndSetValue: PropTypes.func
|
|
78
97
|
};
|
|
79
98
|
ListingContainer.defaultProps = {
|
|
99
|
+
closeModalAndSetValue: () => {},
|
|
80
100
|
handleSelectedFiles: () => {},
|
|
81
101
|
maxItems: false,
|
|
82
|
-
filesSelected: []
|
|
102
|
+
filesSelected: [],
|
|
103
|
+
simpleLayout: false
|
|
83
104
|
};
|
|
84
105
|
export default ListingContainer;
|
|
85
106
|
//# sourceMappingURL=ListingContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListingContainer.js","names":["React","useState","PropTypes","useQuery","getQuery","ToastProvider","Listing","availableFilters","MediaContextProvider","FilesListProvider","existPrevious","ListingContainer","handleSelectedFiles","maxItems","filesSelected","displayFileUploadModal","setDisplayFileUploadModal","selectedFiles","setSelectedFiles","selectedFilter","setSelectedFilter","filter","isSearch","searchTerm","storeKey","fileStoresType","loading","data","getFileStores","fileStores","variables","visibleInAdmin","getSelectedFiles","id","existPreviousFile","length","allSelectedFiles","fileId","handleDisplayFileUploadModal","param","defaultFileStore","find","isDefault","key","createElement","value","changeSelectedFilter","_objectSpread","filters","onClickPrompt","propTypes","func","oneOfType","number","bool","arrayOf","string","defaultProps"],"sources":["../../../src/components/ListingContainer/ListingContainer.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ToastProvider } from '@blaze-react/toaster';\nimport Listing from './Listing';\nimport { availableFilters } from '../../utils/available-filters/available-filters';\nimport { MediaContextProvider } from '../../utils/media-context';\nimport FilesListProvider from '../FileList/FilesListProvider';\nimport { existPrevious } from './mappers';\n\nconst ListingContainer = ({
|
|
1
|
+
{"version":3,"file":"ListingContainer.js","names":["React","useState","PropTypes","useQuery","getQuery","ToastProvider","Listing","availableFilters","MediaContextProvider","FilesListProvider","existPrevious","ListingContainer","handleSelectedFiles","maxItems","filesSelected","displayFileUploadModal","setDisplayFileUploadModal","closeModalAndSetValue","simpleLayout","selectedFiles","setSelectedFiles","selectedFilter","setSelectedFilter","filter","isSearch","searchTerm","storeKey","fileStoresType","loading","data","getFileStores","fileStores","variables","visibleInAdmin","getSelectedFiles","file","files","id","existPreviousFile","length","allSelectedFiles","fileId","handleDisplayFileUploadModal","param","defaultFileStore","find","isDefault","key","createElement","value","changeSelectedFilter","_objectSpread","filters","onClickPrompt","propTypes","func","oneOfType","number","bool","arrayOf","string","isRequired","defaultProps"],"sources":["../../../src/components/ListingContainer/ListingContainer.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ToastProvider } from '@blaze-react/toaster';\nimport Listing from './Listing';\nimport { availableFilters } from '../../utils/available-filters/available-filters';\nimport { MediaContextProvider } from '../../utils/media-context';\nimport FilesListProvider from '../FileList/FilesListProvider';\nimport { existPrevious } from './mappers';\n\nconst ListingContainer = ({\n handleSelectedFiles,\n maxItems,\n filesSelected,\n displayFileUploadModal,\n setDisplayFileUploadModal,\n closeModalAndSetValue,\n simpleLayout\n}) => {\n const [selectedFiles, setSelectedFiles] = useState(filesSelected || []);\n const [selectedFilter, setSelectedFilter] = useState({\n filter: 'all',\n isSearch: false,\n searchTerm: null,\n storeKey: null\n });\n\n const fileStoresType = getQuery('GET_FILE_STORES');\n const { loading, data: { getFileStores: fileStores = [] } = {} } = useQuery(fileStoresType, {\n variables: { visibleInAdmin: true }\n });\n if (loading) return null;\n\n const getSelectedFiles = (file, files) => {\n if (simpleLayout) {\n handleSelectedFiles(files, false);\n setSelectedFiles(files);\n return;\n }\n const { id } = file;\n const existPreviousFile = existPrevious(selectedFiles, id);\n if (maxItems === selectedFiles.length && !existPreviousFile) {\n handleSelectedFiles([id], false);\n setSelectedFiles([id]);\n } else {\n const allSelectedFiles = existPreviousFile\n ? selectedFiles.filter(fileId => fileId !== existPreviousFile)\n : [...selectedFiles, id];\n\n handleSelectedFiles(allSelectedFiles, false);\n setSelectedFiles(allSelectedFiles);\n }\n };\n\n const handleDisplayFileUploadModal = param => setDisplayFileUploadModal(param);\n const defaultFileStore = (fileStores.find(({ isDefault }) => isDefault) || {}).key;\n\n return (\n <ToastProvider>\n <MediaContextProvider\n value={{\n fileStores,\n defaultFileStore,\n changeSelectedFilter: value => setSelectedFilter(value),\n selectedFilter: {\n ...selectedFilter,\n storeKey: selectedFilter.storeKey || defaultFileStore\n },\n selectedFiles,\n getSelectedFiles,\n filters: availableFilters,\n onClickPrompt: () => handleDisplayFileUploadModal(true)\n }}>\n <FilesListProvider>\n <Listing\n closeModalAndSetValue={closeModalAndSetValue}\n simpleLayout={simpleLayout}\n getSelectedFiles={getSelectedFiles}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n displayFileUploadModal={displayFileUploadModal}\n handleDisplayFileUploadModal={handleDisplayFileUploadModal}\n setSelectedFiles={setSelectedFiles}\n handleSelectedFiles={handleSelectedFiles}\n />\n </FilesListProvider>\n </MediaContextProvider>\n </ToastProvider>\n );\n};\n\nListingContainer.propTypes = {\n handleSelectedFiles: PropTypes.func,\n maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),\n filesSelected: PropTypes.arrayOf(PropTypes.string),\n simpleLayout: PropTypes.bool,\n setDisplayFileUploadModal: PropTypes.func.isRequired,\n displayFileUploadModal: PropTypes.bool.isRequired,\n closeModalAndSetValue: PropTypes.func\n};\n\nListingContainer.defaultProps = {\n closeModalAndSetValue: () => {},\n handleSelectedFiles: () => {},\n maxItems: false,\n filesSelected: [],\n simpleLayout: false\n};\n\nexport default ListingContainer;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,OAAOC,OAAO,MAAM,WAAW;AAC/B,SAASC,gBAAgB,QAAQ,iDAAiD;AAClF,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,OAAOC,iBAAiB,MAAM,+BAA+B;AAC7D,SAASC,aAAa,QAAQ,WAAW;AAEzC,MAAMC,gBAAgB,GAAGA,CAAC;EACxBC,mBAAmB;EACnBC,QAAQ;EACRC,aAAa;EACbC,sBAAsB;EACtBC,yBAAyB;EACzBC,qBAAqB;EACrBC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGnB,QAAQ,CAACa,aAAa,IAAI,EAAE,CAAC;EACvE,MAAM,CAACO,cAAc,EAAEC,iBAAiB,CAAC,GAAGrB,QAAQ,CAAC;IACnDsB,MAAM,EAAE,KAAK;IACbC,QAAQ,EAAE,KAAK;IACfC,UAAU,EAAE,IAAI;IAChBC,QAAQ,EAAE;EACZ,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAG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EAAEb,SAAS,CAACwD,IAAI,CAACG,UAAU;EACjD5C,qBAAqB,EAAEf,SAAS,CAACqD;AACnC,CAAC;AAED5C,gBAAgB,CAACmD,YAAY,GAAG;EAC9B7C,qBAAqB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC/BL,mBAAmB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC7BC,QAAQ,EAAE,KAAK;EACfC,aAAa,EAAE,EAAE;EACjBI,YAAY,EAAE;AAChB,CAAC;AAED,eAAeP,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import ListingContainer from './ListingContainer';
|
|
4
|
+
const MediaListing = ({
|
|
5
|
+
handleSelectedFiles,
|
|
6
|
+
maxItems,
|
|
7
|
+
filesSelected
|
|
8
|
+
}) => {
|
|
9
|
+
const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
|
|
10
|
+
return /*#__PURE__*/React.createElement(ListingContainer, {
|
|
11
|
+
setDisplayFileUploadModal: setDisplayFileUploadModal,
|
|
12
|
+
displayFileUploadModal: displayFileUploadModal,
|
|
13
|
+
handleSelectedFiles: handleSelectedFiles,
|
|
14
|
+
filesSelected: filesSelected,
|
|
15
|
+
maxItems: maxItems
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
MediaListing.propTypes = {
|
|
19
|
+
handleSelectedFiles: PropTypes.func,
|
|
20
|
+
maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
|
|
21
|
+
filesSelected: PropTypes.arrayOf(PropTypes.string)
|
|
22
|
+
};
|
|
23
|
+
MediaListing.defaultProps = {
|
|
24
|
+
handleSelectedFiles: () => {},
|
|
25
|
+
maxItems: false,
|
|
26
|
+
filesSelected: []
|
|
27
|
+
};
|
|
28
|
+
export default MediaListing;
|
|
29
|
+
//# sourceMappingURL=MediaListing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaListing.js","names":["React","useState","PropTypes","ListingContainer","MediaListing","handleSelectedFiles","maxItems","filesSelected","displayFileUploadModal","setDisplayFileUploadModal","createElement","propTypes","func","oneOfType","number","bool","arrayOf","string","defaultProps"],"sources":["../../src/components/MediaListing.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport ListingContainer from './ListingContainer';\n\nconst MediaListing = ({ handleSelectedFiles, maxItems, filesSelected }) => {\n const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);\n\n return (\n <ListingContainer\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n displayFileUploadModal={displayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n filesSelected={filesSelected}\n maxItems={maxItems}\n />\n );\n};\n\nMediaListing.propTypes = {\n handleSelectedFiles: PropTypes.func,\n maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),\n filesSelected: PropTypes.arrayOf(PropTypes.string)\n};\n\nMediaListing.defaultProps = {\n handleSelectedFiles: () => {},\n maxItems: false,\n filesSelected: []\n};\n\nexport default MediaListing;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,gBAAgB,MAAM,oBAAoB;AAEjD,MAAMC,YAAY,GAAGA,CAAC;EAAEC,mBAAmB;EAAEC,QAAQ;EAAEC;AAAc,CAAC,KAAK;EACzE,MAAM,CAACC,sBAAsB,EAAEC,yBAAyB,CAAC,GAAGR,QAAQ,CAAC,KAAK,CAAC;EAE3E,oBACED,KAAA,CAAAU,aAAA,CAACP,gBAAgB;IACfM,yBAAyB,EAAEA,yBAA0B;IACrDD,sBAAsB,EAAEA,sBAAuB;IAC/CH,mBAAmB,EAAEA,mBAAoB;IACzCE,aAAa,EAAEA,aAAc;IAC7BD,QAAQ,EAAEA;EAAS,CACpB,CAAC;AAEN,CAAC;AAEDF,YAAY,CAACO,SAAS,GAAG;EACvBN,mBAAmB,EAAEH,SAAS,CAACU,IAAI;EACnCN,QAAQ,EAAEJ,SAAS,CAACW,SAAS,CAAC,CAACX,SAAS,CAACY,MAAM,EAAEZ,SAAS,CAACa,IAAI,CAAC,CAAC;EACjER,aAAa,EAAEL,SAAS,CAACc,OAAO,CAACd,SAAS,CAACe,MAAM;AACnD,CAAC;AAEDb,YAAY,CAACc,YAAY,GAAG;EAC1Bb,mBAAmB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC7BC,QAAQ,EAAE,KAAK;EACfC,aAAa,EAAE;AACjB,CAAC;AAED,eAAeH,YAAY","ignoreList":[]}
|
package/lib-es/index.js
CHANGED
|
@@ -4,7 +4,8 @@ import EditorAdapter from './components/EditorAdapter';
|
|
|
4
4
|
import { MediaLibraryIcon } from './icons';
|
|
5
5
|
import pkg from '../package.json';
|
|
6
6
|
import { PLUGIN_NAME } from './constants';
|
|
7
|
-
const
|
|
7
|
+
export const FilePreviewReadOnly = React.lazy(() => import( /* webpackChunkName: 'MediaFilePreviewReadOnly' */'./components/FilePreviewReadOnly'));
|
|
8
|
+
const MediaListing = React.lazy(() => import( /* webpackChunkName: 'MediaListingContainer' */'./components/MediaListing'));
|
|
8
9
|
const EditMediaFilePage = React.lazy(() => import( /* webpackChunkName: 'EditMediaFilePage' */'./components/EditMediaFile/EditMediaFilePage'));
|
|
9
10
|
export default async function load(app) {
|
|
10
11
|
app.events.once('admin:menu:config:load', ({
|
|
@@ -28,6 +29,10 @@ export default async function load(app) {
|
|
|
28
29
|
type: 'fileUpload',
|
|
29
30
|
component: FileUploadAdapter
|
|
30
31
|
});
|
|
32
|
+
addFieldType({
|
|
33
|
+
type: 'filePreview',
|
|
34
|
+
component: FilePreviewReadOnly
|
|
35
|
+
});
|
|
31
36
|
addFieldType({
|
|
32
37
|
type: 'editor',
|
|
33
38
|
component: EditorAdapter
|
|
@@ -36,7 +41,7 @@ export default async function load(app) {
|
|
|
36
41
|
const mediaRoute = {
|
|
37
42
|
path: '/media',
|
|
38
43
|
key: 'media',
|
|
39
|
-
component:
|
|
44
|
+
component: MediaListing,
|
|
40
45
|
exact: true
|
|
41
46
|
};
|
|
42
47
|
const editMediaFileRoute = {
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","FileUploadAdapter","EditorAdapter","MediaLibraryIcon","pkg","PLUGIN_NAME","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","FileUploadAdapter","EditorAdapter","MediaLibraryIcon","pkg","PLUGIN_NAME","FilePreviewReadOnly","lazy","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 React from 'react';\nimport FileUploadAdapter from './components/FileUploadAdapter';\nimport EditorAdapter from './components/EditorAdapter';\nimport { MediaLibraryIcon } from './icons';\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\n\nexport const FilePreviewReadOnly = React.lazy(() =>\n import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */ './components/FilePreviewReadOnly')\n);\n\nconst MediaListing = React.lazy(() =>\n import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')\n);\n\nconst EditMediaFilePage = React.lazy(() =>\n import(/* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage')\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,KAAK,MAAM,OAAO;AACzB,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,OAAOC,aAAa,MAAM,4BAA4B;AACtD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AAEzC,OAAO,MAAMC,mBAAmB,GAAGN,KAAK,CAACO,IAAI,CAAC,MAC5C,MAAM,EAAC,kDAAmD,kCAAkC,CAC9F,CAAC;AAED,MAAMC,YAAY,GAAGR,KAAK,CAACO,IAAI,CAAC,MAC9B,MAAM,EAAC,+CAAgD,2BAA2B,CACpF,CAAC;AAED,MAAME,iBAAiB,GAAGT,KAAK,CAACO,IAAI,CAAC,MACnC,MAAM,EAAC,2CAA4C,8CAA8C,CACnG,CAAC;AACD,eAAe,eAAeG,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,EAAEjB,gBAAgB;YACtBkB,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,EAAEvB;IAAkB,CAAC,CAAC;IAClEqB,YAAY,CAAC;MAAEC,IAAI,EAAE,aAAa;MAAEC,SAAS,EAAElB;IAAoB,CAAC,CAAC;IACrEgB,YAAY,CAAC;MAAEC,IAAI,EAAE,QAAQ;MAAEC,SAAS,EAAEtB;IAAc,CAAC,CAAC;EAC5D,CAAC,CAAC;EAEF,MAAMuB,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,EAAE1B,WAAW;IACjB2B,OAAO,EAAE5B,GAAG,CAAC4B;EACf,CAAC;AACH;AAEAtB,IAAI,CAACuB,UAAU,GAAG5B,WAAW","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
const MediaContext = React.createContext();
|
|
2
|
+
const MediaContext = React.createContext({});
|
|
3
3
|
const MediaContextProvider = MediaContext.Provider;
|
|
4
4
|
const MediaContextConsumer = MediaContext.Consumer;
|
|
5
5
|
export { MediaContext, MediaContextProvider, MediaContextConsumer };
|
|
@@ -1 +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;
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-media-ui",
|
|
3
|
-
"version": "0.146.0-alpha.
|
|
3
|
+
"version": "0.146.0-alpha.22",
|
|
4
4
|
"description": "Blaze plugin media ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/admin-ui-utils": "
|
|
30
|
+
"@blaze-cms/admin-ui-utils": "0.146.0-alpha.17",
|
|
31
31
|
"@blaze-cms/core-errors": "^0.140.3",
|
|
32
|
-
"@blaze-cms/plugin-search-ui": "
|
|
33
|
-
"@blaze-cms/react-form-builder": "0.146.0-alpha.
|
|
32
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-alpha.17",
|
|
33
|
+
"@blaze-cms/react-form-builder": "0.146.0-alpha.17",
|
|
34
34
|
"@blaze-cms/setup-ui": "^0.140.3",
|
|
35
35
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
36
36
|
"@blaze-react/drafteditor": "0.7.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react-tiny-virtual-list": "2.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@blaze-cms/core-ui": "
|
|
47
|
+
"@blaze-cms/core-ui": "0.146.0-alpha.17"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@apollo/client": "3.x",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"lib/*",
|
|
58
58
|
"lib-es/*"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "862fa49df29cc762e340adcf0dabbacc77625606"
|
|
61
61
|
}
|
|
@@ -14,20 +14,24 @@ const Actions = ({ file }) => {
|
|
|
14
14
|
<span>{extension}</span>
|
|
15
15
|
</div>
|
|
16
16
|
<div>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
{handleEditModal && (
|
|
18
|
+
<div
|
|
19
|
+
data-testid={`open-media-library-${file.id}`}
|
|
20
|
+
className="FilePreviewItem__info__actionsIcon material-icons edit"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
onClick={() => handleEditModal(file)}>
|
|
23
|
+
<i className="fas fa-pen fa-xs" />
|
|
24
|
+
</div>
|
|
25
|
+
)}
|
|
26
|
+
{onUnselectFile && (
|
|
27
|
+
<div
|
|
28
|
+
data-testid={`unselect-${file.id}`}
|
|
29
|
+
className="FilePreviewItem__info__actionsIcon material-icons delete"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
onClick={() => onUnselectFile([file.id])}>
|
|
32
|
+
<i className="fas fa-trash fa-xs" />
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
31
35
|
</div>
|
|
32
36
|
</div>
|
|
33
37
|
</>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import FilePreviewList from './FilePreviewList';
|
|
4
|
+
|
|
5
|
+
const FileList = ({ selectedFiles, children }) => (
|
|
6
|
+
<>
|
|
7
|
+
<FilePreviewList selectedFiles={selectedFiles}>{children}</FilePreviewList>
|
|
8
|
+
</>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
FileList.propTypes = {
|
|
12
|
+
selectedFiles: PropTypes.array.isRequired,
|
|
13
|
+
children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string])
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
FileList.defaultProps = {
|
|
17
|
+
children: []
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default FileList;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import FilePreview from '../FilePreview';
|
|
4
|
+
|
|
5
|
+
const FilePreviewList = ({ selectedFiles, children }) => (
|
|
6
|
+
<div className="FileUploadAdapter__preview">
|
|
7
|
+
{selectedFiles.map(file => (
|
|
8
|
+
<FilePreview key={file.id} file={file} previewType={FilePreview.availablePreviewTypes.raw} />
|
|
9
|
+
))}
|
|
10
|
+
{children}
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
FilePreviewList.propTypes = {
|
|
15
|
+
selectedFiles: PropTypes.array.isRequired,
|
|
16
|
+
children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string])
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
FilePreviewList.defaultProps = {
|
|
20
|
+
children: []
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default FilePreviewList;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useApolloClient } from '@apollo/client';
|
|
4
|
+
import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
5
|
+
import FileList from './FileList';
|
|
6
|
+
import { formatInitialValue } from './mappers';
|
|
7
|
+
|
|
8
|
+
const FilePreviewReadOnly = ({ label, id, type, value }) => {
|
|
9
|
+
const initialValue = formatInitialValue({ value, type });
|
|
10
|
+
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
11
|
+
const client = useApolloClient();
|
|
12
|
+
|
|
13
|
+
const getFiles = async (offset, ids) => {
|
|
14
|
+
const {
|
|
15
|
+
data: { files: newFiles }
|
|
16
|
+
} = await client.query({
|
|
17
|
+
query: getQuery('GET_FILES'),
|
|
18
|
+
variables: {
|
|
19
|
+
offset,
|
|
20
|
+
where: {
|
|
21
|
+
id: {
|
|
22
|
+
_in: ids
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
skip: !initialValue.length,
|
|
27
|
+
fetchPolicy: 'network-only'
|
|
28
|
+
});
|
|
29
|
+
return newFiles;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
useEffect(
|
|
33
|
+
() => {
|
|
34
|
+
(async () => {
|
|
35
|
+
const files = await getFiles(0, initialValue);
|
|
36
|
+
const orderedFiles = orderFiles(files, initialValue);
|
|
37
|
+
setSelectedFiles(orderedFiles);
|
|
38
|
+
})();
|
|
39
|
+
},
|
|
40
|
+
[] //eslint-disable-line
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const orderFiles = (files, ids) =>
|
|
44
|
+
ids.map(currentId => files.find(({ id: fileId }) => fileId === currentId)).filter(Boolean);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<div className="form-field form-field--button">
|
|
49
|
+
<label>{label}</label>
|
|
50
|
+
{selectedFiles && (
|
|
51
|
+
<>
|
|
52
|
+
<FileList selectedFiles={selectedFiles} />
|
|
53
|
+
</>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
FilePreviewReadOnly.propTypes = {
|
|
61
|
+
label: PropTypes.string.isRequired,
|
|
62
|
+
id: PropTypes.string.isRequired,
|
|
63
|
+
type: PropTypes.string.isRequired,
|
|
64
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
FilePreviewReadOnly.defaultProps = {
|
|
68
|
+
value: ''
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default FilePreviewReadOnly;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const formatInitialValue = ({ value, type }) => {
|
|
2
|
+
const parsedValue = value && type === 'array' ? value : [value];
|
|
3
|
+
const existValue = parsedValue.filter(Boolean).length;
|
|
4
|
+
if (!parsedValue || !existValue) return [];
|
|
5
|
+
return parsedValue;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { formatInitialValue };
|