@blaze-cms/plugin-media-ui 0.146.0-node18-core-styles.2 → 0.146.0-node18-core-styles-tooltips.3

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +3 -12
  2. package/lib/components/EditMediaFile/EditMediaFile.js +63 -9
  3. package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
  4. package/lib/components/EditorAdapter/EditorAdapter.js +14 -5
  5. package/lib/components/EditorAdapter/EditorAdapter.js.map +1 -1
  6. package/lib/components/FilePreview/Actions/index.js +2 -2
  7. package/lib/components/FilePreview/Actions/index.js.map +1 -1
  8. package/lib/components/FilePreview/Image/Image.js +11 -3
  9. package/lib/components/FilePreview/Image/Image.js.map +1 -1
  10. package/lib/components/FilePreview/Image/imageSchema.js +1 -1
  11. package/lib/components/FilePreview/Image/imageSchema.js.map +1 -1
  12. package/lib/components/FilePreview/index.js +6 -2
  13. package/lib/components/FilePreview/index.js.map +1 -1
  14. package/lib/components/FilePreviewReadOnly/FileList.js +2 -2
  15. package/lib/components/FilePreviewReadOnly/FileList.js.map +1 -1
  16. package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js +30 -20
  17. package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
  18. package/lib/components/FileUploadAdapter/FileUploadAdapter.js +7 -1
  19. package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
  20. package/lib/components/FileUploadModal/FileUploadModal.js +32 -12
  21. package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
  22. package/lib-es/components/EditMediaFile/EditMediaFile.js +43 -11
  23. package/lib-es/components/EditMediaFile/EditMediaFile.js.map +1 -1
  24. package/lib-es/components/EditorAdapter/EditorAdapter.js +15 -6
  25. package/lib-es/components/EditorAdapter/EditorAdapter.js.map +1 -1
  26. package/lib-es/components/FilePreview/Actions/index.js +2 -2
  27. package/lib-es/components/FilePreview/Actions/index.js.map +1 -1
  28. package/lib-es/components/FilePreview/Image/Image.js +11 -3
  29. package/lib-es/components/FilePreview/Image/Image.js.map +1 -1
  30. package/lib-es/components/FilePreview/Image/imageSchema.js +1 -1
  31. package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -1
  32. package/lib-es/components/FilePreview/index.js +6 -2
  33. package/lib-es/components/FilePreview/index.js.map +1 -1
  34. package/lib-es/components/FilePreviewReadOnly/FileList.js +2 -2
  35. package/lib-es/components/FilePreviewReadOnly/FileList.js.map +1 -1
  36. package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js +14 -12
  37. package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
  38. package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +7 -1
  39. package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
  40. package/lib-es/components/FileUploadModal/FileUploadModal.js +31 -16
  41. package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -1
  42. package/package.json +10 -9
  43. package/src/components/EditMediaFile/EditMediaFile.js +56 -28
  44. package/src/components/EditorAdapter/EditorAdapter.js +19 -4
  45. package/src/components/FilePreview/Actions/index.js +25 -27
  46. package/src/components/FilePreview/Image/Image.js +9 -2
  47. package/src/components/FilePreview/Image/imageSchema.js +1 -1
  48. package/src/components/FilePreview/index.js +17 -2
  49. package/src/components/FilePreviewReadOnly/FileList.js +1 -3
  50. package/src/components/FilePreviewReadOnly/FilePreviewReadOnly.js +17 -29
  51. package/src/components/FileUploadAdapter/FileUploadAdapter.js +7 -1
  52. package/src/components/FileUploadModal/FileUploadModal.js +44 -30
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import React, { useState } from 'react';
2
5
  import { ModalAdapter as Modal, getMutation, getQuery } from '@blaze-cms/admin-ui-utils';
3
6
  import FileUpload from '@blaze-react/file-upload';
@@ -9,7 +12,8 @@ const FileUploadModal = ({
9
12
  onClose,
10
13
  getSelectedFiles,
11
14
  closeModalAndSetValue,
12
- simpleLayout
15
+ simpleLayout,
16
+ fileId
13
17
  }) => {
14
18
  const [files, setFiles] = useState([]);
15
19
  const {
@@ -36,19 +40,28 @@ const FileUploadModal = ({
36
40
  const response = await Promise.all(files.map(({
37
41
  file,
38
42
  name,
39
- data: fileData,
43
+ data,
40
44
  storeKey
41
- }) => client.mutate({
42
- mutation: getMutation('UPLOAD_FILE'),
43
- variables: {
44
- input: {
45
- file,
46
- name: name || file.filename,
47
- storeKey,
48
- data: fileData
49
- }
45
+ }) => {
46
+ const payload = {
47
+ name,
48
+ storeKey,
49
+ data
50
+ };
51
+ if (fileId) {
52
+ payload.id = fileId;
53
+ } else if (!name) {
54
+ payload.name = file.filename;
50
55
  }
51
- }))).catch(error => {
56
+ return client.mutate({
57
+ mutation: getMutation('UPLOAD_FILE'),
58
+ variables: {
59
+ input: _objectSpread({
60
+ file
61
+ }, payload)
62
+ }
63
+ });
64
+ })).catch(error => {
52
65
  addToast(error.message, {
53
66
  appearance: 'error',
54
67
  autoDismiss: true
@@ -62,7 +75,7 @@ const FileUploadModal = ({
62
75
  const fileNames = files.map(({
63
76
  file
64
77
  }) => file.name);
65
- addNewFile(parsedResponse);
78
+ addNewFile && addNewFile(parsedResponse);
66
79
  const toastMessage = `Uploaded: ${fileNames.join(', ')}`;
67
80
  if (simpleLayout) {
68
81
  const filesToSelect = parsedResponse.map(file => file.id);
@@ -80,7 +93,7 @@ const FileUploadModal = ({
80
93
  onClose();
81
94
  };
82
95
  const storeOptions = storeType.map(type => [type.key, type.name]);
83
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Modal, {
96
+ return /*#__PURE__*/React.createElement(Modal, {
84
97
  onClose: onClose,
85
98
  title: "Add media",
86
99
  actions: [{
@@ -96,9 +109,10 @@ const FileUploadModal = ({
96
109
  }, /*#__PURE__*/React.createElement(FileUpload, {
97
110
  onChange: handleFiles,
98
111
  selectOptions: storeOptions
99
- })));
112
+ }));
100
113
  };
101
114
  FileUploadModal.propTypes = {
115
+ fileId: PropTypes.string,
102
116
  getSelectedFiles: PropTypes.func.isRequired,
103
117
  onClose: PropTypes.func,
104
118
  simpleLayout: PropTypes.bool,
@@ -107,7 +121,8 @@ FileUploadModal.propTypes = {
107
121
  FileUploadModal.defaultProps = {
108
122
  onClose: () => {},
109
123
  closeModalAndSetValue: () => {},
110
- simpleLayout: false
124
+ simpleLayout: false,
125
+ fileId: null
111
126
  };
112
127
  export default FileUploadModal;
113
128
  //# sourceMappingURL=FileUploadModal.js.map
@@ -1 +1 @@
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;AACjD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,eAAe,EAAEC,QAAQ,QAAQ,gBAAgB;AAC1D,OAAOC,WAAW,MAAM,yBAAyB;AAEjD,MAAMC,eAAe,GAAGA,CAAC;EAAEC,OAAO;EAAEC,gBAAgB;EAAEC,qBAAqB;EAAEC;AAAa,CAAC,KAAK;EAC9F,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGjB,QAAQ,CAAC,EAAE,CAAC;EACtC,MAAM;IAAEkB;EAAS,CAAC,GAAGX,SAAS,CAAC,CAAC;EAChC,MAAMY,MAAM,GAAGX,eAAe,CAAC,CAAC;EAChC,MAAM;IAAEY;EAAW,CAAC,GAAGV,WAAW,CAAC,CAAC;EAEpC,MAAMW,cAAc,GAAGjB,QAAQ,CAAC,iBAAiB,CAAC;EAElD,MAAM;IAAEkB,IAAI,EAAE;MAAEC,aAAa,EAAEC,SAAS,GAAG;IAAG,CAAC,GAAG,CAAC;EAAE,CAAC,GAAGf,QAAQ,CAACY,cAAc,EAAE;IAChFI,SAAS,EAAE;MAAEC,cAAc,EAAE;IAAK;EACpC,CAAC,CAAC;EAEF,MAAMC,WAAW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AAA,KAAM,CAAC,CAAC;EACjBE,qBAAqB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC/BC,YAAY,EAAE;AAChB,CAAC;AAED,eAAeJ,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"FileUploadModal.js","names":["React","useState","ModalAdapter","Modal","getMutation","getQuery","FileUpload","PropTypes","useToasts","useApolloClient","useQuery","useFileList","FileUploadModal","onClose","getSelectedFiles","closeModalAndSetValue","simpleLayout","fileId","files","setFiles","addToast","client","addNewFile","fileStoresType","data","getFileStores","storeType","variables","visibleInAdmin","handleFiles","filesToUpload","uploadFiles","response","Promise","all","map","file","name","storeKey","payload","id","filename","mutate","mutation","input","_objectSpread","catch","error","message","appearance","autoDismiss","parsedResponse","result","fileNames","toastMessage","join","filesToSelect","handleOnSave","length","storeOptions","type","key","createElement","title","actions","textButton","callback","modifiers","upload","onChange","selectOptions","propTypes","string","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 = ({\n onClose,\n getSelectedFiles,\n closeModalAndSetValue,\n simpleLayout,\n fileId\n}) => {\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, storeKey }) => {\n const payload = {\n name,\n storeKey,\n data\n };\n if (fileId) {\n payload.id = fileId;\n } else if (!name) {\n payload.name = file.filename;\n }\n return client.mutate({\n mutation: getMutation('UPLOAD_FILE'),\n variables: {\n input: {\n file,\n ...payload\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 && 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 <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\nFileUploadModal.propTypes = {\n fileId: PropTypes.string,\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 fileId: null\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;AACjD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,sBAAsB;AAChD,S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,CAACyB,IAAI,IAAI,CAACA,IAAI,CAACC,GAAG,EAAED,IAAI,CAACvB,IAAI,CAAC,CAAC;EAEjE,oBACErC,KAAA,CAAA8D,aAAA,CAAC3D,KAAK;IACJU,OAAO,EAAEA,OAAQ;IACjBkD,KAAK,EAAC,WAAW;IACjBC,OAAO,EAAE,CACP;MACEC,UAAU,EAAE,QAAQ;MACpBC,QAAQ,EAAErD,OAAO;MACjBsD,SAAS,EAAE,CAAC,QAAQ;IACtB,CAAC,EACD;MACEF,UAAU,EAAE,MAAM;MAClBC,QAAQ,EAAET,YAAY;MACtBU,SAAS,EAAE;IACb,CAAC,CACD;IACFC,MAAM;EAAA,gBACNpE,KAAA,CAAA8D,aAAA,CAACxD,UAAU;IAAC+D,QAAQ,EAAExC,WAAY;IAACyC,aAAa,EAAEX;EAAa,CAAE,CAC5D,CAAC;AAEZ,CAAC;AAED/C,eAAe,CAAC2D,SAAS,GAAG;EAC1BtD,MAAM,EAAEV,SAAS,CAACiE,MAAM;EACxB1D,gBAAgB,EAAEP,SAAS,CAACkE,IAAI,CAACC,UAAU;EAC3C7D,OAAO,EAAEN,SAAS,CAACkE,IAAI;EACvBzD,YAAY,EAAET,SAAS,CAACoE,IAAI;EAC5B5D,qBAAqB,EAAER,SAAS,CAACkE;AACnC,CAAC;AAED7D,eAAe,CAACgE,YAAY,GAAG;EAC7B/D,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBE,qBAAqB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC/BC,YAAY,EAAE,KAAK;EACnBC,MAAM,EAAE;AACV,CAAC;AAED,eAAeL,eAAe","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/plugin-media-ui",
3
- "version": "0.146.0-node18-core-styles.2",
3
+ "version": "0.146.0-node18-core-styles-tooltips.3",
4
4
  "description": "Blaze plugin media ui",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,26 +27,27 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/admin-ui-utils": "0.146.0-node18-core-styles.2",
31
- "@blaze-cms/core-errors": "0.146.0-node18-core-styles.2",
32
- "@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles.2",
33
- "@blaze-cms/react-form-builder": "0.146.0-node18-core-styles.2",
34
- "@blaze-cms/setup-ui": "0.146.0-node18-core-styles.0",
30
+ "@blaze-cms/admin-ui-utils": "0.146.0-node18-core-styles-tooltips.3",
31
+ "@blaze-cms/core-errors": "0.146.0-node18-core-styles-tooltips.3",
32
+ "@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.3",
33
+ "@blaze-cms/react-form-builder": "0.146.0-node18-core-styles-tooltips.3",
34
+ "@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.3",
35
35
  "@blaze-react/button": "0.8.0-alpha.82",
36
36
  "@blaze-react/dnd": "^0.7.0",
37
37
  "@blaze-react/drafteditor": "0.7.0",
38
38
  "@blaze-react/file-upload": "0.8.0-alpha.78",
39
39
  "@blaze-react/modal": "0.5.19",
40
40
  "@blaze-react/more": "0.5.19",
41
- "@blaze-react/select": "^0.7.0",
41
+ "@blaze-react/select": "0.8.0-alpha.100",
42
42
  "@blaze-react/toaster": "^0.7.0",
43
+ "@blaze-react/tooltip": "0.8.0-alpha.100",
43
44
  "classnames": "^2.2.6",
44
45
  "lodash.differencewith": "^4.5.0",
45
46
  "lodash.isequal": "^4.5.0",
46
47
  "react-tiny-virtual-list": "2.2.0"
47
48
  },
48
49
  "devDependencies": {
49
- "@blaze-cms/core-ui": "0.146.0-node18-core-styles.2"
50
+ "@blaze-cms/core-ui": "0.146.0-node18-core-styles-tooltips.3"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "@apollo/client": "3.x",
@@ -59,5 +60,5 @@
59
60
  "lib/*",
60
61
  "lib-es/*"
61
62
  ],
62
- "gitHead": "c124596c6b8d92f08f58c4dc004a4ea7d1703f23"
63
+ "gitHead": "92ba8597805e2d7b354f553467072fbcec37b1d8"
63
64
  }
@@ -2,16 +2,25 @@ import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { getQuery } from '@blaze-cms/admin-ui-utils';
4
4
  import { useQuery } from '@apollo/client';
5
+ import { useToasts } from '@blaze-react/toaster';
5
6
  import FilePreview from '../FilePreview';
7
+ import FileUploadModal from '../FileUploadModal';
6
8
  import { STORE_KEY, NAME } from '../../constants';
7
9
 
8
10
  const EditMediaFile = ({ onChange, handleSaveButtonStatus, enableSaveButton, fileId }) => {
9
11
  const [formValues, setFormValues] = useState(null);
10
- const query = getQuery('GET_FILE_BY_ID');
11
- const { loading, data: { file } = {} } = useQuery(query, {
12
- variables: { id: fileId }
13
- });
12
+ const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
13
+ const { addToast } = useToasts();
14
14
 
15
+ const fileQuery = getQuery('GET_FILE_BY_ID');
16
+ const {
17
+ loading,
18
+ data: { file } = {},
19
+ refetch: refetchFile
20
+ } = useQuery(fileQuery, {
21
+ variables: { id: fileId },
22
+ fetchPolicy: 'network-only'
23
+ });
15
24
  const fileStoresType = getQuery('GET_FILE_STORES');
16
25
  const { data: { getFileStores: storeType = [] } = {} } = useQuery(fileStoresType, {
17
26
  variables: { visibleInAdmin: true }
@@ -24,25 +33,20 @@ const EditMediaFile = ({ onChange, handleSaveButtonStatus, enableSaveButton, fil
24
33
  }, [file, formValues, storeType]);
25
34
 
26
35
  const handleFormChange = ({ isValid, isNewValueSet, valuesChecked }) => {
27
- const valuesCheckedWithoutName = valuesChecked.filter(({ id }) => {
28
- if (id === NAME || id === STORE_KEY) return false;
29
- return true;
30
- });
31
-
36
+ const valuesCheckedWithoutName = valuesChecked.filter(
37
+ ({ id }) => id !== NAME && id !== STORE_KEY
38
+ );
32
39
  const dataValues = valuesCheckedWithoutName.reduce((acc, { id, value }) => {
33
40
  acc[id] = value;
34
41
  return acc;
35
42
  }, {});
36
43
  const { value: newFileName } = valuesChecked.find(({ id }) => id === NAME) || {};
37
44
  const { value: storeKey } = valuesChecked.find(({ id }) => id === STORE_KEY) || {};
38
-
39
45
  const shouldEnableSaveButton = isNewValueSet && isValid;
40
46
  handleSaveButtonStatus(false);
41
-
42
47
  if (shouldEnableSaveButton && shouldEnableSaveButton !== enableSaveButton) {
43
48
  handleSaveButtonStatus(shouldEnableSaveButton);
44
49
  }
45
-
46
50
  const updatedFile = {
47
51
  id: file.id,
48
52
  name: newFileName,
@@ -52,43 +56,67 @@ const EditMediaFile = ({ onChange, handleSaveButtonStatus, enableSaveButton, fil
52
56
  setFormValues(updatedFile);
53
57
  onChange(updatedFile);
54
58
  };
55
-
56
59
  const getFileWithStoreType = () => {
57
- if (storeType) {
60
+ if (storeType && file) {
58
61
  const storeOptions = storeType.map(type => [type.key, type.name]);
59
62
  const defaultStore = storeType.find(type => type.isDefault) || null;
60
63
  return { ...file, store: { defaultStore, storeOptions } };
61
64
  }
62
-
63
65
  return file;
64
66
  };
65
-
67
+ const closeModalAndSetValue = async (isSaving, values, toastMessage) => {
68
+ if (toastMessage) {
69
+ addToast(toastMessage, {
70
+ appearance: 'success',
71
+ autoDismiss: true
72
+ });
73
+ }
74
+ await refetchFile({
75
+ id: fileId,
76
+ timestamp: Date.now()
77
+ });
78
+ setDisplayFileUploadModal(false);
79
+ };
80
+ const handleChangeFile = () => {
81
+ setDisplayFileUploadModal(true);
82
+ };
66
83
  const fileWithStoreType = getFileWithStoreType();
67
84
 
68
- return (
85
+ return !loading ? (
69
86
  <>
70
- {!loading ? (
71
- <>
72
- {file ? (
73
- <FilePreview file={fileWithStoreType} handleFormChange={handleFormChange} displayForm />
74
- ) : null}
75
- </>
76
- ) : (
77
- <div>loading...</div>
87
+ {file ? (
88
+ <FilePreview
89
+ file={fileWithStoreType}
90
+ handleFormChange={handleFormChange}
91
+ handleChangeFile={handleChangeFile}
92
+ displayForm
93
+ />
94
+ ) : null}
95
+ {displayFileUploadModal && (
96
+ <div className="file-upload-modal-wrapper">
97
+ <FileUploadModal
98
+ onClose={() => {
99
+ setDisplayFileUploadModal(false);
100
+ }}
101
+ closeModalAndSetValue={closeModalAndSetValue}
102
+ simpleLayout
103
+ fileId={fileId}
104
+ getSelectedFiles={() => {}}
105
+ />
106
+ </div>
78
107
  )}
79
108
  </>
109
+ ) : (
110
+ <div>loading...</div>
80
111
  );
81
112
  };
82
-
83
113
  EditMediaFile.propTypes = {
84
114
  fileId: PropTypes.string.isRequired,
85
115
  onChange: PropTypes.func.isRequired,
86
116
  handleSaveButtonStatus: PropTypes.func.isRequired,
87
117
  enableSaveButton: PropTypes.bool
88
118
  };
89
-
90
119
  EditMediaFile.defaultProps = {
91
120
  enableSaveButton: false
92
121
  };
93
-
94
122
  export default EditMediaFile;
@@ -1,16 +1,29 @@
1
1
  import React from 'react';
2
2
  import DraftEditor from '@blaze-react/drafteditor';
3
3
  import PropTypes from 'prop-types';
4
+ import Tooltip from '@blaze-react/tooltip';
4
5
 
5
- const DraftEditorAdapter = ({ id, value, onChange, error, validationMessage, label, ...props }) => (
6
+ const DraftEditorAdapter = ({
7
+ id,
8
+ value,
9
+ onChange,
10
+ error,
11
+ validationMessage,
12
+ label,
13
+ tooltip,
14
+ ...props
15
+ }) => (
6
16
  <div className="form-field form-field--full-width">
7
- <label>{label}</label>
17
+ <label>
18
+ <Tooltip tooltipContent={tooltip} />
19
+ </label>
8
20
  <DraftEditor
9
21
  name={id}
10
22
  value={value}
11
23
  onChange={onChange}
12
24
  error={error}
13
25
  validationMessage={validationMessage}
26
+ tooltip={{ tooltipContent: tooltip }}
14
27
  />
15
28
  </div>
16
29
  );
@@ -21,12 +34,14 @@ DraftEditorAdapter.propTypes = {
21
34
  onChange: PropTypes.func.isRequired,
22
35
  error: PropTypes.bool,
23
36
  validationMessage: PropTypes.string,
24
- label: PropTypes.string.isRequired
37
+ label: PropTypes.string.isRequired,
38
+ tooltip: PropTypes.string
25
39
  };
26
40
 
27
41
  DraftEditorAdapter.defaultProps = {
28
42
  error: false,
29
- validationMessage: undefined
43
+ validationMessage: undefined,
44
+ tooltip: ''
30
45
  };
31
46
 
32
47
  export default DraftEditorAdapter;
@@ -7,34 +7,32 @@ const Actions = ({ file }) => {
7
7
  const [, extension] = file.mimetype.split('/');
8
8
 
9
9
  return (
10
- <>
11
- <div className="FilePreviewItem__info__actions">
12
- <div className="FilePreviewItem__info__actions FilePreviewItem__info__actions--media-type">
13
- <i className="FilePreviewItem__info__actionsIcon material-icons">insert_photo</i>{' '}
14
- <span>{extension}</span>
15
- </div>
16
- <div>
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
- )}
35
- </div>
10
+ <div className="FilePreviewItem__info__actions">
11
+ <div className="FilePreviewItem__info__actions FilePreviewItem__info__actions--media-type">
12
+ <i className="FilePreviewItem__info__actionsIcon material-icons">insert_photo</i>{' '}
13
+ <span>{extension}</span>
36
14
  </div>
37
- </>
15
+ <div>
16
+ {handleEditModal && (
17
+ <div
18
+ data-testid={`open-media-library-${file.id}`}
19
+ className="FilePreviewItem__info__actionsIcon material-icons edit"
20
+ aria-hidden="true"
21
+ onClick={() => handleEditModal(file)}>
22
+ <i className="fas fa-pen fa-xs" />
23
+ </div>
24
+ )}
25
+ {onUnselectFile && (
26
+ <div
27
+ data-testid={`unselect-${file.id}`}
28
+ className="FilePreviewItem__info__actionsIcon material-icons delete"
29
+ aria-hidden="true"
30
+ onClick={() => onUnselectFile([file.id])}>
31
+ <i className="fas fa-trash fa-xs" />
32
+ </div>
33
+ )}
34
+ </div>
35
+ </div>
38
36
  );
39
37
  };
40
38
 
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import Button from '@blaze-react/button';
3
4
 
4
- const Image = ({ url, name, children }) => (
5
+ const Image = ({ url, name, children, handleChangeFile }) => (
5
6
  <div className="preview">
6
7
  <div className="preview__file preview__file--image">
7
8
  <img src={url} alt={name} />
@@ -12,6 +13,7 @@ const Image = ({ url, name, children }) => (
12
13
  Original
13
14
  </a>
14
15
  </p>
16
+ <Button onClick={handleChangeFile}>Change file</Button>
15
17
  </div>
16
18
  </div>
17
19
  {children}
@@ -21,7 +23,12 @@ const Image = ({ url, name, children }) => (
21
23
  Image.propTypes = {
22
24
  url: PropTypes.string.isRequired,
23
25
  name: PropTypes.string.isRequired,
24
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
26
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
27
+ handleChangeFile: PropTypes.func
28
+ };
29
+
30
+ Image.defaultProps = {
31
+ handleChangeFile: () => {}
25
32
  };
26
33
 
27
34
  export { Image };
@@ -40,7 +40,7 @@ const imageSchema = {
40
40
  hrefUrl: {
41
41
  type: 'string',
42
42
  format: 'uri-template',
43
- label: 'url',
43
+ label: 'Url',
44
44
  showInForm: true,
45
45
  formFieldType: 'text',
46
46
  description: 'Url format is not valid'
@@ -3,7 +3,14 @@ import { FormBuilder } from '@blaze-cms/react-form-builder';
3
3
  import PropTypes from 'prop-types';
4
4
  import { getPreview } from './get-preview';
5
5
 
6
- const FilePreview = ({ file, handleFormChange, displayForm, previewType, children }) => {
6
+ const FilePreview = ({
7
+ file,
8
+ handleFormChange,
9
+ displayForm,
10
+ previewType,
11
+ children,
12
+ handleChangeFile
13
+ }) => {
7
14
  const { name, url, mimetype, data, store } = file;
8
15
  const [Preview, schema] = getPreview({ mimetype, previewType });
9
16
  const shouldRenderForm = schema && displayForm;
@@ -23,7 +30,13 @@ const FilePreview = ({ file, handleFormChange, displayForm, previewType, childre
23
30
 
24
31
  return (
25
32
  <>
26
- <Preview mimetype={mimetype} url={url} name={name} {...data} file={file}>
33
+ <Preview
34
+ mimetype={mimetype}
35
+ url={url}
36
+ name={name}
37
+ {...data}
38
+ file={file}
39
+ handleChangeFile={handleChangeFile}>
27
40
  {shouldRenderForm && (
28
41
  <div className="preview__details">
29
42
  <div className="preview__filename">{file.filename}</div>
@@ -50,6 +63,7 @@ FilePreview.propTypes = {
50
63
  file: PropTypes.object.isRequired,
51
64
  fileName: PropTypes.string,
52
65
  handleFormChange: PropTypes.func,
66
+ handleChangeFile: PropTypes.func,
53
67
  displayForm: PropTypes.bool,
54
68
  handlers: PropTypes.object,
55
69
  previewType: PropTypes.oneOf(Object.keys(FilePreview.availablePreviewTypes)),
@@ -62,6 +76,7 @@ FilePreview.defaultProps = {
62
76
  handlers: {},
63
77
  previewType: FilePreview.availablePreviewTypes.card,
64
78
  handleFormChange: () => {},
79
+ handleChangeFile: () => {},
65
80
  children: []
66
81
  };
67
82
 
@@ -3,9 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import FilePreviewList from './FilePreviewList';
4
4
 
5
5
  const FileList = ({ selectedFiles, children }) => (
6
- <>
7
- <FilePreviewList selectedFiles={selectedFiles}>{children}</FilePreviewList>
8
- </>
6
+ <FilePreviewList selectedFiles={selectedFiles}>{children}</FilePreviewList>
9
7
  );
10
8
 
11
9
  FileList.propTypes = {
@@ -11,49 +11,37 @@ const FilePreviewReadOnly = ({ label, id, type, value }) => {
11
11
  const client = useApolloClient();
12
12
 
13
13
  const getFiles = async (offset, ids) => {
14
- const {
15
- data: { files: newFiles }
16
- } = await client.query({
14
+ if (!ids.length) return [];
15
+ const { data: { files = [] } = {} } = await client.query({
17
16
  query: getQuery('GET_FILES'),
18
17
  variables: {
19
18
  offset,
20
19
  where: {
21
- id: {
22
- _in: ids
23
- }
20
+ id: { _in: ids }
24
21
  }
25
22
  },
26
- skip: !initialValue.length,
27
23
  fetchPolicy: 'network-only'
28
24
  });
29
- return newFiles;
25
+ return files;
30
26
  };
31
27
 
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
28
  const orderFiles = (files, ids) =>
44
29
  ids.map(currentId => files.find(({ id: fileId }) => fileId === currentId)).filter(Boolean);
45
30
 
31
+ useEffect(() => {
32
+ (async () => {
33
+ const files = await getFiles(0, initialValue);
34
+ const orderedFiles = orderFiles(files, initialValue);
35
+ setSelectedFiles(orderedFiles);
36
+ })();
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, []);
39
+
46
40
  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
- </>
41
+ <div className="form-field form-field--button">
42
+ <label htmlFor={id}>{label}</label>
43
+ {selectedFiles.length > 0 && <FileList selectedFiles={selectedFiles} />}
44
+ </div>
57
45
  );
58
46
  };
59
47
 
@@ -5,6 +5,7 @@ import { useApolloClient } from '@apollo/client';
5
5
  import { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';
6
6
  import { parseFormValues } from '@blaze-cms/react-form-builder';
7
7
  import { useToasts } from '@blaze-react/toaster';
8
+ import Tooltip from '@blaze-react/tooltip';
8
9
  import { MORE } from '../../constants';
9
10
  import ListingContainer from '../ListingContainer';
10
11
  import { MediaContextProvider } from '../../utils/media-context';
@@ -30,6 +31,7 @@ const FileUploadAdapter = ({
30
31
  shouldRenderInPreview,
31
32
  canDragAndDrop,
32
33
  simpleLayout,
34
+ tooltip,
33
35
  previewAllFiles,
34
36
  fileType
35
37
  }) => {
@@ -270,7 +272,9 @@ const FileUploadAdapter = ({
270
272
  return (
271
273
  <>
272
274
  <div className="form-field form-field--button">
273
- <label>{label}</label>
275
+ <label>
276
+ {label} <Tooltip tooltipContent={tooltip} />
277
+ </label>
274
278
  {selectedFiles && (
275
279
  <MediaContextProvider value={{ handleEditModal, onUnselectFile: handleSelectedFiles }}>
276
280
  {shouldRenderInPreview ? (
@@ -364,6 +368,7 @@ FileUploadAdapter.propTypes = {
364
368
  canDragAndDrop: PropTypes.bool,
365
369
  simpleLayout: PropTypes.bool,
366
370
  previewAllFiles: PropTypes.bool,
371
+ tooltip: PropTypes.string,
367
372
  fileType: PropTypes.string
368
373
  };
369
374
 
@@ -374,6 +379,7 @@ FileUploadAdapter.defaultProps = {
374
379
  canDragAndDrop: false,
375
380
  simpleLayout: false,
376
381
  previewAllFiles: false,
382
+ tooltip: '',
377
383
  fileType: 'file'
378
384
  };
379
385