@akemona-org/strapi-plugin-upload 3.7.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.
Files changed (246) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +19 -0
  3. package/admin/src/assets/images/logo.svg +1 -0
  4. package/admin/src/components/BrowseAssets/Wrapper.js +8 -0
  5. package/admin/src/components/BrowseAssets/index.js +182 -0
  6. package/admin/src/components/Card/index.js +146 -0
  7. package/admin/src/components/CardBorder/index.js +28 -0
  8. package/admin/src/components/CardControl/Wrapper.js +89 -0
  9. package/admin/src/components/CardControl/index.js +61 -0
  10. package/admin/src/components/CardControlsWrapper/index.js +22 -0
  11. package/admin/src/components/CardEmpty/Bar.js +19 -0
  12. package/admin/src/components/CardEmpty/Wrapper.js +7 -0
  13. package/admin/src/components/CardEmpty/index.js +16 -0
  14. package/admin/src/components/CardErrorMessage/index.js +9 -0
  15. package/admin/src/components/CardImgWrapper/index.js +52 -0
  16. package/admin/src/components/CardPreview/Image.js +12 -0
  17. package/admin/src/components/CardPreview/Wrapper.js +25 -0
  18. package/admin/src/components/CardPreview/index.js +66 -0
  19. package/admin/src/components/CardTitle/index.js +14 -0
  20. package/admin/src/components/CardWrapper/index.js +23 -0
  21. package/admin/src/components/CheckControl/Button.js +49 -0
  22. package/admin/src/components/CheckControl/CustomDropdownSection.js +9 -0
  23. package/admin/src/components/CheckControl/Spacer.js +7 -0
  24. package/admin/src/components/CheckControl/index.js +74 -0
  25. package/admin/src/components/Container/index.js +7 -0
  26. package/admin/src/components/ContainerFluid/index.js +12 -0
  27. package/admin/src/components/ControlsWrapper/index.js +9 -0
  28. package/admin/src/components/DragLayer/Wrapper.js +13 -0
  29. package/admin/src/components/DragLayer/index.js +68 -0
  30. package/admin/src/components/DropdownButton/index.js +63 -0
  31. package/admin/src/components/DropdownSection/index.js +27 -0
  32. package/admin/src/components/Duration/index.js +25 -0
  33. package/admin/src/components/Duration/utils/formatDuration.js +13 -0
  34. package/admin/src/components/EditForm/CropWrapper.js +21 -0
  35. package/admin/src/components/EditForm/ErrorMessage.js +10 -0
  36. package/admin/src/components/EditForm/FileDetailsBox.js +95 -0
  37. package/admin/src/components/EditForm/FileDetailsBoxWrapper.js +14 -0
  38. package/admin/src/components/EditForm/FileWrapper.js +41 -0
  39. package/admin/src/components/EditForm/FormWrapper.js +7 -0
  40. package/admin/src/components/EditForm/SizeBox.js +13 -0
  41. package/admin/src/components/EditForm/Wrapper.js +8 -0
  42. package/admin/src/components/EditForm/index.js +425 -0
  43. package/admin/src/components/EditForm/utils/form.js +34 -0
  44. package/admin/src/components/EditForm/utils/isImageType.js +3 -0
  45. package/admin/src/components/EditForm/utils/isVideoType.js +3 -0
  46. package/admin/src/components/FileIcon/Wrapper.js +20 -0
  47. package/admin/src/components/FileIcon/index.js +33 -0
  48. package/admin/src/components/FileIcon/utils/extensions.json +4 -0
  49. package/admin/src/components/FileInfos/index.js +32 -0
  50. package/admin/src/components/Filters/index.js +30 -0
  51. package/admin/src/components/FiltersList/index.js +34 -0
  52. package/admin/src/components/FiltersList/utils/formatFilter.js +36 -0
  53. package/admin/src/components/FiltersPicker/FiltersCard/FilterButton.js +8 -0
  54. package/admin/src/components/FiltersPicker/FiltersCard/FilterInput.js +35 -0
  55. package/admin/src/components/FiltersPicker/FiltersCard/InputWrapper.js +10 -0
  56. package/admin/src/components/FiltersPicker/FiltersCard/SizeInput.js +57 -0
  57. package/admin/src/components/FiltersPicker/FiltersCard/Wrapper.js +8 -0
  58. package/admin/src/components/FiltersPicker/FiltersCard/index.js +97 -0
  59. package/admin/src/components/FiltersPicker/FiltersCard/init.js +21 -0
  60. package/admin/src/components/FiltersPicker/FiltersCard/reducer.js +47 -0
  61. package/admin/src/components/FiltersPicker/FiltersCard/utils/filtersForm.js +27 -0
  62. package/admin/src/components/FiltersPicker/index.js +43 -0
  63. package/admin/src/components/FiltersPicker/utils/formatFilter.js +18 -0
  64. package/admin/src/components/InfiniteLoadingIndicator/Button.js +20 -0
  65. package/admin/src/components/InfiniteLoadingIndicator/Container.js +12 -0
  66. package/admin/src/components/InfiniteLoadingIndicator/Wrapper.js +18 -0
  67. package/admin/src/components/InfiniteLoadingIndicator/index.js +39 -0
  68. package/admin/src/components/Input/index.js +7 -0
  69. package/admin/src/components/InputFileModal/Label.js +47 -0
  70. package/admin/src/components/InputFileModal/P.js +15 -0
  71. package/admin/src/components/InputFileModal/index.js +73 -0
  72. package/admin/src/components/InputMedia/CardControlWrapper.js +12 -0
  73. package/admin/src/components/InputMedia/CardPreviewWrapper.js +13 -0
  74. package/admin/src/components/InputMedia/Chevron/Wrapper.js +10 -0
  75. package/admin/src/components/InputMedia/Chevron/index.js +21 -0
  76. package/admin/src/components/InputMedia/EmptyInputMedia.js +60 -0
  77. package/admin/src/components/InputMedia/EmptyText.js +13 -0
  78. package/admin/src/components/InputMedia/ErrorMessage.js +12 -0
  79. package/admin/src/components/InputMedia/IconUpload.js +48 -0
  80. package/admin/src/components/InputMedia/InputFilePreview.js +37 -0
  81. package/admin/src/components/InputMedia/Name.js +10 -0
  82. package/admin/src/components/InputMedia/Wrapper.js +11 -0
  83. package/admin/src/components/InputMedia/index.js +238 -0
  84. package/admin/src/components/InputUploadURL/Wrapper.js +13 -0
  85. package/admin/src/components/InputUploadURL/index.js +46 -0
  86. package/admin/src/components/IntlText/index.js +26 -0
  87. package/admin/src/components/List/ListCell.js +19 -0
  88. package/admin/src/components/List/ListRow.js +8 -0
  89. package/admin/src/components/List/index.js +114 -0
  90. package/admin/src/components/ListEmpty/Wrapper.js +15 -0
  91. package/admin/src/components/ListEmpty/index.js +70 -0
  92. package/admin/src/components/ListEmpty/utils/generateRows.js +12 -0
  93. package/admin/src/components/ListModal/BaselineAlignmentWrapper.js +12 -0
  94. package/admin/src/components/ListModal/index.js +66 -0
  95. package/admin/src/components/ListWrapper/index.js +16 -0
  96. package/admin/src/components/LoadingIndicator/index.js +44 -0
  97. package/admin/src/components/ModalHeader/BackButton.js +33 -0
  98. package/admin/src/components/ModalHeader/Wrapper.js +24 -0
  99. package/admin/src/components/ModalHeader/index.js +47 -0
  100. package/admin/src/components/ModalNavWrapper/BaselineAlignment.js +12 -0
  101. package/admin/src/components/ModalNavWrapper/Hr.js +14 -0
  102. package/admin/src/components/ModalNavWrapper/Wrapper.js +8 -0
  103. package/admin/src/components/ModalNavWrapper/index.js +70 -0
  104. package/admin/src/components/ModalSection/index.js +20 -0
  105. package/admin/src/components/ModalTab/Count/Wrapper.js +16 -0
  106. package/admin/src/components/ModalTab/Count/index.js +30 -0
  107. package/admin/src/components/ModalTab/Wrapper.js +37 -0
  108. package/admin/src/components/ModalTab/index.js +60 -0
  109. package/admin/src/components/PlayIcon/Play.js +65 -0
  110. package/admin/src/components/PlayIcon/Wrapper.js +24 -0
  111. package/admin/src/components/PlayIcon/index.js +23 -0
  112. package/admin/src/components/SelectAll/Wrapper.js +19 -0
  113. package/admin/src/components/SelectAll/index.js +26 -0
  114. package/admin/src/components/SelectedAssets/DraggableCard.js +149 -0
  115. package/admin/src/components/SelectedAssets/ListTitleWrapper.js +7 -0
  116. package/admin/src/components/SelectedAssets/ListWrapper.js +7 -0
  117. package/admin/src/components/SelectedAssets/SortableList.js +102 -0
  118. package/admin/src/components/SelectedAssets/Wrapper.js +7 -0
  119. package/admin/src/components/SelectedAssets/index.js +56 -0
  120. package/admin/src/components/SortList/Wrapper.js +19 -0
  121. package/admin/src/components/SortList/index.js +37 -0
  122. package/admin/src/components/SortListItem/Wrapper.js +28 -0
  123. package/admin/src/components/SortListItem/index.js +35 -0
  124. package/admin/src/components/SortPicker/index.js +54 -0
  125. package/admin/src/components/Tag/Wrapper.js +16 -0
  126. package/admin/src/components/Tag/index.js +25 -0
  127. package/admin/src/components/UploadForm/index.js +61 -0
  128. package/admin/src/components/UploadList/ButtonWrapper.js +7 -0
  129. package/admin/src/components/UploadList/Container.js +10 -0
  130. package/admin/src/components/UploadList/CustomModalSection.js +9 -0
  131. package/admin/src/components/UploadList/ListTitle.js +10 -0
  132. package/admin/src/components/UploadList/ListTitleWrapper.js +7 -0
  133. package/admin/src/components/UploadList/RowItem.js +98 -0
  134. package/admin/src/components/UploadList/index.js +90 -0
  135. package/admin/src/components/VideoPlayer/Wrapper.js +24 -0
  136. package/admin/src/components/VideoPlayer/index.js +57 -0
  137. package/admin/src/components/VideoPreview/CanvasWrapper.js +22 -0
  138. package/admin/src/components/VideoPreview/Thumbnail.js +12 -0
  139. package/admin/src/components/VideoPreview/Wrapper.js +15 -0
  140. package/admin/src/components/VideoPreview/index.js +165 -0
  141. package/admin/src/components/VideoPreview/reducer.js +33 -0
  142. package/admin/src/containers/App/index.js +31 -0
  143. package/admin/src/containers/HomePage/HomePageContent/HomePageList.js +98 -0
  144. package/admin/src/containers/HomePage/HomePageContent/HomePageSettings.js +103 -0
  145. package/admin/src/containers/HomePage/HomePageContent/index.js +90 -0
  146. package/admin/src/containers/HomePage/components.js +18 -0
  147. package/admin/src/containers/HomePage/index.js +373 -0
  148. package/admin/src/containers/HomePage/init.js +5 -0
  149. package/admin/src/containers/HomePage/reducer.js +88 -0
  150. package/admin/src/containers/HomePage/utils/generateParamsFromQuery.js +14 -0
  151. package/admin/src/containers/HomePage/utils/generateStringFromParams.js +27 -0
  152. package/admin/src/containers/HomePage/utils/getHeaderLabel.js +13 -0
  153. package/admin/src/containers/HomePage/utils/index.js +2 -0
  154. package/admin/src/containers/Initializer/index.js +44 -0
  155. package/admin/src/containers/InputModalStepper/HeaderSearch.js +12 -0
  156. package/admin/src/containers/InputModalStepper/InputModalStepper.js +480 -0
  157. package/admin/src/containers/InputModalStepper/Search.js +48 -0
  158. package/admin/src/containers/InputModalStepper/index.js +86 -0
  159. package/admin/src/containers/InputModalStepper/stepper.js +52 -0
  160. package/admin/src/containers/InputModalStepperProvider/index.js +564 -0
  161. package/admin/src/containers/InputModalStepperProvider/init.js +5 -0
  162. package/admin/src/containers/InputModalStepperProvider/reducer.js +301 -0
  163. package/admin/src/containers/ModalStepper/index.js +629 -0
  164. package/admin/src/containers/ModalStepper/init.js +5 -0
  165. package/admin/src/containers/ModalStepper/reducer.js +132 -0
  166. package/admin/src/containers/ModalStepper/stepper.js +46 -0
  167. package/admin/src/containers/SettingsPage/Divider.js +11 -0
  168. package/admin/src/containers/SettingsPage/SectionTitleWrapper.js +7 -0
  169. package/admin/src/containers/SettingsPage/Wrapper.js +17 -0
  170. package/admin/src/containers/SettingsPage/index.js +198 -0
  171. package/admin/src/containers/SettingsPage/init.js +5 -0
  172. package/admin/src/containers/SettingsPage/reducer.js +38 -0
  173. package/admin/src/contexts/AppContext/index.js +5 -0
  174. package/admin/src/contexts/InputModal/InputModalDataManager.js +5 -0
  175. package/admin/src/contexts/index.js +2 -0
  176. package/admin/src/hooks/index.js +2 -0
  177. package/admin/src/hooks/useAppContext/index.js +6 -0
  178. package/admin/src/hooks/useModalContext.js +6 -0
  179. package/admin/src/icons/BrokenFile/index.js +91 -0
  180. package/admin/src/icons/Cloud/index.js +35 -0
  181. package/admin/src/icons/DoubleFile/index.js +35 -0
  182. package/admin/src/icons/Download/index.js +36 -0
  183. package/admin/src/icons/File/index.js +35 -0
  184. package/admin/src/index.js +85 -0
  185. package/admin/src/lifecycles.js +13 -0
  186. package/admin/src/permissions.js +40 -0
  187. package/admin/src/pluginId.js +5 -0
  188. package/admin/src/translations/de.json +81 -0
  189. package/admin/src/translations/dk.json +81 -0
  190. package/admin/src/translations/en.json +86 -0
  191. package/admin/src/translations/es.json +81 -0
  192. package/admin/src/translations/fr.json +85 -0
  193. package/admin/src/translations/he.json +81 -0
  194. package/admin/src/translations/index.js +39 -0
  195. package/admin/src/translations/it.json +82 -0
  196. package/admin/src/translations/ja.json +81 -0
  197. package/admin/src/translations/ms.json +73 -0
  198. package/admin/src/translations/pl.json +81 -0
  199. package/admin/src/translations/pt-BR.json +81 -0
  200. package/admin/src/translations/ru.json +81 -0
  201. package/admin/src/translations/sk.json +81 -0
  202. package/admin/src/translations/th.json +81 -0
  203. package/admin/src/translations/uk.json +78 -0
  204. package/admin/src/translations/zh-Hans.json +86 -0
  205. package/admin/src/translations/zh.json +81 -0
  206. package/admin/src/utils/ItemTypes.js +3 -0
  207. package/admin/src/utils/canDownloadFile.js +3 -0
  208. package/admin/src/utils/compactParams.js +13 -0
  209. package/admin/src/utils/createFileToDownloadName.js +9 -0
  210. package/admin/src/utils/createMatrix.js +32 -0
  211. package/admin/src/utils/createNewFilesToDownloadArray.js +57 -0
  212. package/admin/src/utils/createNewFilesToUploadArray.js +25 -0
  213. package/admin/src/utils/formatBytes.js +13 -0
  214. package/admin/src/utils/formatFileForEditing.js +20 -0
  215. package/admin/src/utils/formatFilters.js +23 -0
  216. package/admin/src/utils/generatePageFromStart.js +5 -0
  217. package/admin/src/utils/generateStartFromPage.js +5 -0
  218. package/admin/src/utils/getFileModelTimestamps.js +15 -0
  219. package/admin/src/utils/getFilesToDownload.js +5 -0
  220. package/admin/src/utils/getRequestUrl.js +5 -0
  221. package/admin/src/utils/getTrad.js +5 -0
  222. package/admin/src/utils/getType.js +15 -0
  223. package/admin/src/utils/getYupError.js +17 -0
  224. package/admin/src/utils/index.js +20 -0
  225. package/admin/src/utils/unformatBytes.js +16 -0
  226. package/admin/src/utils/urlYupSchema.js +49 -0
  227. package/config/config.json +8 -0
  228. package/config/functions/bootstrap.js +143 -0
  229. package/config/routes.json +98 -0
  230. package/config/schema.graphql.js +96 -0
  231. package/controllers/Upload.js +103 -0
  232. package/controllers/upload/admin.js +213 -0
  233. package/controllers/upload/api.js +125 -0
  234. package/controllers/validation/settings.js +22 -0
  235. package/controllers/validation/upload.js +27 -0
  236. package/documentation/1.0.0/overrides/upload-File.json +263 -0
  237. package/errors.js +48 -0
  238. package/index.js +7 -0
  239. package/middlewares/upload/defaults.json +5 -0
  240. package/middlewares/upload/index.js +35 -0
  241. package/models/File.js +7 -0
  242. package/models/File.settings.json +86 -0
  243. package/package.json +71 -0
  244. package/services/Upload.js +397 -0
  245. package/services/image-manipulation.js +167 -0
  246. package/utils/file.js +23 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015-present Strapi Solutions SAS
2
+
3
+ Portions of the Strapi software are licensed as follows:
4
+
5
+ * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
6
+
7
+ * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
8
+
9
+ MIT Expat License
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # strapi-plugin-upload
2
+
3
+ ---
4
+
5
+ ## Deprecation Warning :warning:
6
+
7
+ Hello! We have some news to share,
8
+
9
+ We’ve decided it’ll soon be time to end the support for `strapi-plugin-upload`.
10
+
11
+ After years of iterations, Strapi is going to V4 and we won’t maintain V3 packages when it’ll reach its end-of-support milestone (~end of Q3 2022).
12
+
13
+ If you’ve been using `strapi-plugin-upload` and have migrated to V4 (or if you want to), you can find the equivalent and updated version of this package at this [URL](https://github.com/strapi/strapi/tree/master/packages/core/upload) and with the following name on NPM: `@strapi/plugin-upload`.
14
+
15
+ If you’ve contributed to the development of this package, thank you again for that! We hope to see you on the V4 soon.
16
+
17
+ The Akemona team
18
+
19
+ ---
@@ -0,0 +1 @@
1
+ <svg width="30" height="22" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><text font-family="AppleColorEmoji, Apple Color Emoji" font-size="30" fill="#D3E5FF" transform="translate(0 -4)"><tspan x="0" y="30.6">☁️</tspan></text><text font-family="HiraMinProN-W3, Hiragino Mincho ProN" font-size="12" font-weight="300" fill="#768491" transform="translate(0 -4)"><tspan x="9" y="24">⬆︎</tspan></text></g></svg>
@@ -0,0 +1,8 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Wrapper = styled.div`
4
+ width: 100%;
5
+ padding-top: 0.6rem;
6
+ `;
7
+
8
+ export default Wrapper;
@@ -0,0 +1,182 @@
1
+ import React from 'react';
2
+ import { isEmpty } from 'lodash';
3
+ import { PageFooter } from 'strapi-helper-plugin';
4
+ import { Flex, Padded } from '@buffetjs/core';
5
+
6
+ import { generatePageFromStart, generateStartFromPage } from '../../utils';
7
+ import Filters from '../Filters';
8
+ import List from '../List';
9
+ import ListEmpty from '../ListEmpty';
10
+ import SelectAll from '../SelectAll';
11
+ import SortPicker from '../SortPicker';
12
+ import useModalContext from '../../hooks/useModalContext';
13
+ import Wrapper from './Wrapper';
14
+ import CardControl from '../CardControl';
15
+
16
+ const BrowseAssets = () => {
17
+ const {
18
+ allowedActions,
19
+ allowedTypes,
20
+ count,
21
+ files,
22
+ goTo,
23
+ handleAllFilesSelection,
24
+ handleFileSelection,
25
+ handleGoToEditFile,
26
+ multiple,
27
+ noNavigation,
28
+ params,
29
+ removeFilter,
30
+ selectedFiles,
31
+ setParam,
32
+ } = useModalContext();
33
+
34
+ const handleChangeParams = ({ target: { name, value } }) => {
35
+ setParam({ name, value });
36
+ };
37
+
38
+ const handleChangeListParams = ({ target: { name, value } }) => {
39
+ if (name.includes('_page')) {
40
+ handleChangeParams({
41
+ target: { name: '_start', value: generateStartFromPage(value, params._limit) },
42
+ });
43
+ } else {
44
+ handleChangeParams({ target: { name: '_limit', value } });
45
+ }
46
+ };
47
+
48
+ const handleDeleteFilter = index => {
49
+ removeFilter(index);
50
+ };
51
+
52
+ const handleGoToUpload = () => {
53
+ goTo('browse');
54
+ };
55
+
56
+ const limit = parseInt(params._limit, 10) || 10;
57
+ const start = parseInt(params._start, 10) || 0;
58
+ const canSelectFile = multiple === true || (selectedFiles.length < 1 && !multiple);
59
+
60
+ const handleCheckboxChange = ({ target: { name } }) => {
61
+ handleListCardClick(name);
62
+ };
63
+
64
+ const handleListCardClick = id => {
65
+ if (!canSelectFile && id !== selectedFiles[0].id) {
66
+ handleFileSelection({
67
+ target: {
68
+ name: selectedFiles[0].id,
69
+ },
70
+ });
71
+ }
72
+
73
+ handleFileSelection({
74
+ target: {
75
+ name: id,
76
+ },
77
+ });
78
+ };
79
+
80
+ /* eslint-disable indent */
81
+ /* eslint-disable react/jsx-indent */
82
+ const renderCardControl = noNavigation
83
+ ? null
84
+ : id => {
85
+ if (!allowedActions.canUpdate) {
86
+ return null;
87
+ }
88
+
89
+ return (
90
+ <CardControl
91
+ small
92
+ title="edit"
93
+ color="#9EA7B8"
94
+ type="pencil"
95
+ onClick={e => {
96
+ e.stopPropagation();
97
+ handleGoToEditFile(id);
98
+ }}
99
+ />
100
+ );
101
+ };
102
+
103
+ /* eslint-enable indent */
104
+ /* eslint-enable react/jsx-indent */
105
+
106
+ const paginationParams = {
107
+ _limit: parseInt(params._limit, 10) || 10,
108
+ _page: generatePageFromStart(start, limit),
109
+ };
110
+
111
+ const hasSomeCheckboxSelected = files.some(file =>
112
+ selectedFiles.find(selectedFile => file.id === selectedFile.id)
113
+ );
114
+ const areAllCheckboxesSelected =
115
+ files.every(file => selectedFiles.find(selectedFile => file.id === selectedFile.id)) &&
116
+ hasSomeCheckboxSelected;
117
+
118
+ const hasFilters = !isEmpty(params.filters.filter(filter => !filter.isDisabled));
119
+ const hasSearch = !isEmpty(params._q);
120
+ const areResultsEmptyWithSearchOrFilters = isEmpty(files) && (hasSearch || hasFilters);
121
+
122
+ return (
123
+ <>
124
+ <Wrapper>
125
+ <Padded top>
126
+ {allowedActions.canRead && (
127
+ <Flex flexWrap="wrap">
128
+ {multiple && (
129
+ <Padded right size="sm">
130
+ <SelectAll
131
+ checked={areAllCheckboxesSelected}
132
+ onChange={handleAllFilesSelection}
133
+ someChecked={hasSomeCheckboxSelected && !areAllCheckboxesSelected}
134
+ />
135
+ </Padded>
136
+ )}
137
+ <SortPicker onChange={handleChangeParams} value={params._sort} />
138
+ <Padded left size="sm" />
139
+ <Filters
140
+ filters={params.filters}
141
+ onChange={handleChangeParams}
142
+ onClick={handleDeleteFilter}
143
+ />
144
+ </Flex>
145
+ )}
146
+ </Padded>
147
+ {!files || files.length === 0 ? (
148
+ <ListEmpty
149
+ canCreate={allowedActions.canCreate}
150
+ numberOfRows={2}
151
+ onClick={handleGoToUpload}
152
+ hasSearchApplied={areResultsEmptyWithSearchOrFilters}
153
+ />
154
+ ) : (
155
+ <>
156
+ <List
157
+ data={files}
158
+ onChange={handleCheckboxChange}
159
+ selectedItems={selectedFiles}
160
+ onCardClick={handleListCardClick}
161
+ allowedTypes={allowedTypes}
162
+ smallCards
163
+ renderCardControl={renderCardControl}
164
+ />
165
+ <Padded left right>
166
+ <Padded left right size="xs">
167
+ <PageFooter
168
+ context={{ emitEvent: () => {} }}
169
+ count={count}
170
+ onChangeParams={handleChangeListParams}
171
+ params={paginationParams}
172
+ />
173
+ </Padded>
174
+ </Padded>
175
+ </>
176
+ )}
177
+ </Wrapper>
178
+ </>
179
+ );
180
+ };
181
+
182
+ export default BrowseAssets;
@@ -0,0 +1,146 @@
1
+ import React, { memo, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Flex } from '@buffetjs/core';
4
+ import { Tooltip } from '@buffetjs/styles';
5
+ import { getFileExtension, useGlobalContext } from 'strapi-helper-plugin';
6
+ import { formatBytes, getType, getTrad } from '../../utils';
7
+
8
+ import Border from '../CardBorder';
9
+ import CardImgWrapper from '../CardImgWrapper';
10
+ import CardPreview from '../CardPreview';
11
+ import ErrorMessage from '../CardErrorMessage';
12
+ import FileInfos from '../FileInfos';
13
+ import Title from '../CardTitle';
14
+ import Tag from '../Tag';
15
+ import Wrapper from '../CardWrapper';
16
+
17
+ const Card = ({
18
+ children,
19
+ options: {
20
+ checked,
21
+ errorMessage,
22
+ ext,
23
+ hasError,
24
+ height,
25
+ id,
26
+ isDisabled,
27
+ mime,
28
+ name,
29
+ onClick,
30
+ previewUrl,
31
+ small,
32
+ size = 0,
33
+ type,
34
+ url,
35
+ width,
36
+ withFileCaching = true,
37
+ withoutFileInfo,
38
+ },
39
+ }) => {
40
+ const { formatMessage } = useGlobalContext();
41
+ const [tooltipIsDisplayed, setDisplayTooltip] = useState(false);
42
+ const fileSize = formatBytes(size, 0);
43
+ const fileType = mime || type;
44
+ const generatedExtension =
45
+ !ext && name.lastIndexOf('.') !== -1
46
+ ? name.substr(name.lastIndexOf('.') + 1, name.length)
47
+ : getFileExtension(ext);
48
+
49
+ const handleClick = () => {
50
+ if (!isDisabled || checked) {
51
+ onClick(id);
52
+ }
53
+ };
54
+
55
+ const handleTooltipToggle = () => {
56
+ setDisplayTooltip(prev => !prev);
57
+ };
58
+
59
+ return (
60
+ <Wrapper
61
+ title={isDisabled ? formatMessage({ id: getTrad('list.assets.type-not-allowed') }) : null}
62
+ onClick={handleClick}
63
+ >
64
+ <CardImgWrapper checked={checked} small={small}>
65
+ <CardPreview
66
+ extension={generatedExtension}
67
+ hasError={hasError}
68
+ previewUrl={previewUrl}
69
+ url={url}
70
+ type={fileType}
71
+ withFileCaching={withFileCaching}
72
+ />
73
+ <Border color={hasError ? 'orange' : 'mediumBlue'} shown={checked || hasError} />
74
+ {children}
75
+ </CardImgWrapper>
76
+ {!withoutFileInfo && (
77
+ <>
78
+ <Flex>
79
+ <Title
80
+ onMouseEnter={handleTooltipToggle}
81
+ onMouseLeave={handleTooltipToggle}
82
+ data-for={`${id}`}
83
+ data-tip={name}
84
+ >
85
+ {name}
86
+ </Title>
87
+ {tooltipIsDisplayed && <Tooltip id={`${id}`} />}
88
+ <Tag label={getType(fileType)} />
89
+ </Flex>
90
+ <FileInfos extension={generatedExtension} size={fileSize} width={width} height={height} />
91
+ </>
92
+ )}
93
+ {hasError && <ErrorMessage title={errorMessage}>{errorMessage}</ErrorMessage>}
94
+ </Wrapper>
95
+ );
96
+ };
97
+
98
+ Card.defaultProps = {
99
+ children: null,
100
+ options: {
101
+ checked: false,
102
+ errorMessage: null,
103
+ ext: null,
104
+ id: null,
105
+ isDisabled: false,
106
+ hasError: false,
107
+ height: null,
108
+ mime: null,
109
+ name: null,
110
+ onClick: () => {},
111
+ previewUrl: null,
112
+ size: 0,
113
+ small: false,
114
+ type: null,
115
+ url: null,
116
+ width: null,
117
+ withFileCaching: true,
118
+ withoutFileInfo: false,
119
+ },
120
+ };
121
+
122
+ Card.propTypes = {
123
+ children: PropTypes.node,
124
+ options: PropTypes.exact({
125
+ errorMessage: PropTypes.string,
126
+ ext: PropTypes.string,
127
+ hasError: PropTypes.bool,
128
+ height: PropTypes.number,
129
+ mime: PropTypes.string,
130
+ name: PropTypes.string,
131
+ onClick: PropTypes.func,
132
+ previewUrl: PropTypes.string,
133
+ size: PropTypes.number,
134
+ small: PropTypes.bool,
135
+ type: PropTypes.string,
136
+ url: PropTypes.string,
137
+ width: PropTypes.number,
138
+ withFileCaching: PropTypes.bool,
139
+ withoutFileInfo: PropTypes.bool,
140
+ id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
141
+ isDisabled: PropTypes.bool,
142
+ checked: PropTypes.bool,
143
+ }),
144
+ };
145
+
146
+ export default memo(Card);
@@ -0,0 +1,28 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+ import { themePropTypes } from 'strapi-helper-plugin';
4
+
5
+ const CardBorder = styled.div`
6
+ width: 100%;
7
+ height: 100%;
8
+ position: absolute;
9
+ top: 0;
10
+ left: 0;
11
+ display: none;
12
+ ${({ shown }) => shown && 'display: block;'}
13
+ border: 2px solid ${({ theme, color }) => theme.main.colors[color] || color};
14
+ border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
15
+ `;
16
+
17
+ CardBorder.defaultProps = {
18
+ color: 'mediumBlue',
19
+ shown: false,
20
+ };
21
+
22
+ CardBorder.propTypes = {
23
+ color: PropTypes.string,
24
+ shown: PropTypes.bool,
25
+ ...themePropTypes,
26
+ };
27
+
28
+ export default CardBorder;
@@ -0,0 +1,89 @@
1
+ /* eslint-disable indent */
2
+ import styled from 'styled-components';
3
+ import PropTypes from 'prop-types';
4
+ import { themePropTypes } from 'strapi-helper-plugin';
5
+
6
+ const Wrapper = styled.div`
7
+ display: flex;
8
+ justify-content: center;
9
+ align-items: center;
10
+ width: ${({ small }) => (small ? '25px' : '30px')};
11
+ height: ${({ small }) => (small ? '25px' : '30px')};
12
+ margin-left: 5px;
13
+ background-color: ${({ theme }) => theme.main.colors.white};
14
+ border: 1px solid ${({ theme }) => theme.main.colors.darkGrey};
15
+ border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
16
+ cursor: pointer;
17
+ font-size: ${({ small }) => (small ? '11px' : '13px')};
18
+ color: ${({ color }) => color};
19
+
20
+ ${({ type }) =>
21
+ type === 'link' &&
22
+ `
23
+ transform: rotate(90deg)
24
+ `};
25
+
26
+ &:hover {
27
+ ${({ type, theme, color }) => {
28
+ if (type === 'plus') {
29
+ return `
30
+ background-color: ${theme.main.colors.darkBlue};
31
+ border: 1px solid ${theme.main.colors.darkBlue};
32
+ > svg {
33
+ > g, path {
34
+ stroke: ${theme.main.colors.mediumBlue};
35
+ }
36
+ }
37
+ color: ${theme.main.colors.mediumBlue};
38
+ `;
39
+ }
40
+
41
+ if (type === 'check' || type === 'times') {
42
+ return `
43
+ background-color: ${color};
44
+ border: 1px solid ${color};
45
+ > svg {
46
+ > g, path {
47
+ fill: ${theme.main.colors.white};
48
+ }
49
+ }
50
+ color: ${theme.main.colors.white};
51
+ `;
52
+ }
53
+
54
+ if (type === 'trash-alt') {
55
+ return `
56
+ background-color: #FFA784;
57
+ border: 1px solid #FFA784;
58
+ color: #F64D0A;
59
+ `;
60
+ }
61
+
62
+ return `
63
+ background-color: ${theme.main.colors.darkBlue};
64
+ border: 1px solid ${theme.main.colors.darkBlue};
65
+ > svg {
66
+ > g, path {
67
+ fill: ${theme.main.colors.mediumBlue};
68
+ }
69
+ }
70
+ color: ${theme.main.colors.mediumBlue};
71
+ `;
72
+ }};
73
+ }
74
+ `;
75
+
76
+ Wrapper.defaultProps = {
77
+ color: '#b3b5b9',
78
+ type: null,
79
+ small: false,
80
+ };
81
+
82
+ Wrapper.propTypes = {
83
+ color: PropTypes.string,
84
+ small: PropTypes.bool,
85
+ type: PropTypes.string,
86
+ ...themePropTypes,
87
+ };
88
+
89
+ export default Wrapper;
@@ -0,0 +1,61 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Pencil, Plus } from '@buffetjs/icons';
4
+ import { Tooltip } from '@buffetjs/styles';
5
+ import { useGlobalContext } from 'strapi-helper-plugin';
6
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7
+
8
+ import { getTrad } from '../../utils';
9
+ import DownloadIcon from '../../icons/Download';
10
+ import Wrapper from './Wrapper';
11
+
12
+ const CardControl = ({ title, color, onClick, small, type, iconStyle }) => {
13
+ const { formatMessage } = useGlobalContext();
14
+ const [tooltipIsDisplayed, setTooltipIsDisplayed] = useState(false);
15
+
16
+ const handleToggleTooltip = () => {
17
+ setTooltipIsDisplayed(prev => !prev);
18
+ };
19
+
20
+ return (
21
+ <>
22
+ <Wrapper
23
+ onClick={onClick}
24
+ color={color}
25
+ type={type}
26
+ small={small}
27
+ onMouseEnter={handleToggleTooltip}
28
+ onMouseLeave={handleToggleTooltip}
29
+ data-for={type}
30
+ data-tip={formatMessage({ id: getTrad(`control-card.${title}`) })}
31
+ >
32
+ {type === 'pencil' && <Pencil fill={color} />}
33
+ {type === 'plus' && <Plus fill={color} />}
34
+ {type === 'download' && <DownloadIcon fill={color} />}
35
+ {!['pencil', 'clear', 'plus', 'download'].includes(type) && (
36
+ <FontAwesomeIcon style={iconStyle} icon={type} />
37
+ )}
38
+ </Wrapper>
39
+ {tooltipIsDisplayed && <Tooltip id={type} />}
40
+ </>
41
+ );
42
+ };
43
+
44
+ CardControl.defaultProps = {
45
+ color: '#b3b5b9',
46
+ iconStyle: null,
47
+ onClick: () => {},
48
+ small: false,
49
+ type: 'pencil',
50
+ };
51
+
52
+ CardControl.propTypes = {
53
+ color: PropTypes.string,
54
+ iconStyle: PropTypes.object,
55
+ onClick: PropTypes.func,
56
+ small: PropTypes.bool,
57
+ type: PropTypes.string,
58
+ title: PropTypes.string.isRequired,
59
+ };
60
+
61
+ export default CardControl;
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const CardControlsWrapper = styled.div`
5
+ display: flex;
6
+ position: absolute;
7
+ top: 0;
8
+ ${({ leftAlign }) => (leftAlign ? 'left: 0' : 'right: 0')};
9
+ width: fit-content;
10
+ height: auto;
11
+ margin: 10px;
12
+ `;
13
+
14
+ CardControlsWrapper.defaultProps = {
15
+ leftAlign: false,
16
+ };
17
+
18
+ CardControlsWrapper.propTypes = {
19
+ leftAlign: PropTypes.bool,
20
+ };
21
+
22
+ export default CardControlsWrapper;
@@ -0,0 +1,19 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const Bar = styled.div`
5
+ height: 10px;
6
+ width: ${({ small }) => (small ? '64px' : '110px')};
7
+ margin-top: ${({ small }) => (small ? '15px' : '8px')};
8
+ background: #f6f6f6;
9
+ `;
10
+
11
+ Bar.defaultProps = {
12
+ small: false,
13
+ };
14
+
15
+ Bar.propTypes = {
16
+ small: PropTypes.bool,
17
+ };
18
+
19
+ export default Bar;
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Wrapper = styled.div`
4
+ margin-bottom: 35px;
5
+ `;
6
+
7
+ export default Wrapper;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import CardImgWrapper from '../CardImgWrapper';
3
+ import Bar from './Bar';
4
+ import Wrapper from './Wrapper';
5
+
6
+ const CardEmpty = () => {
7
+ return (
8
+ <Wrapper>
9
+ <CardImgWrapper />
10
+ <Bar small />
11
+ <Bar />
12
+ </Wrapper>
13
+ );
14
+ };
15
+
16
+ export default CardEmpty;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { Text } from '@buffetjs/core';
4
+
5
+ const ErrorMessage = styled(props => <Text {...props} color="orange" fontSize="md" ellipsis />)`
6
+ margin-top: 3px;
7
+ `;
8
+
9
+ export default ErrorMessage;
@@ -0,0 +1,52 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const CardImgWrapper = styled.div`
5
+ position: relative;
6
+ width: 100%;
7
+ height: 0;
8
+ margin-bottom: 7px;
9
+ padding-top: ${({ small }) => (small ? '62.8%' : '63.8%')};
10
+ border-radius: 2px;
11
+ background-color: #f6f6f6;
12
+
13
+ @media only screen and (min-width: 1280px) {
14
+ padding-top: ${({ small }) => (small ? '120px' : '138px')};
15
+ }
16
+
17
+ .card-control-wrapper-displayed {
18
+ display: flex;
19
+ z-index: 1045;
20
+ }
21
+
22
+ .card-control-wrapper {
23
+ display: none;
24
+ }
25
+
26
+ &:hover {
27
+ .card-control-wrapper {
28
+ display: flex;
29
+ z-index: 1045;
30
+ }
31
+ }
32
+
33
+ ${({ checked }) =>
34
+ checked &&
35
+ `
36
+ .card-control-wrapper:not(.card-control-wrapper-hidden) {
37
+ display: flex;
38
+ }
39
+ `}
40
+ `;
41
+
42
+ CardImgWrapper.defaultProps = {
43
+ checked: false,
44
+ hasError: false,
45
+ };
46
+
47
+ CardImgWrapper.propTypes = {
48
+ checked: PropTypes.bool,
49
+ hasError: PropTypes.bool,
50
+ };
51
+
52
+ export default CardImgWrapper;