@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
@@ -0,0 +1,114 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Checkbox } from '@buffetjs/core';
4
+ import { get, pick } from 'lodash';
5
+ import { prefixFileUrlWithBackendUrl } from 'strapi-helper-plugin';
6
+ import { getTrad, getType } from '../../utils';
7
+ import Card from '../Card';
8
+ import CardControlsWrapper from '../CardControlsWrapper';
9
+ import ListWrapper from '../ListWrapper';
10
+ import IntlText from '../IntlText';
11
+ import ListCell from './ListCell';
12
+ import ListRow from './ListRow';
13
+
14
+ const List = ({
15
+ allowedTypes,
16
+ data,
17
+ onChange,
18
+ onCardClick,
19
+ selectedItems,
20
+ smallCards,
21
+ canSelect,
22
+ renderCardControl,
23
+ showCheckbox,
24
+ }) => {
25
+ const selectedAssets = selectedItems.length;
26
+
27
+ const handleCheckboxClick = e => {
28
+ e.stopPropagation();
29
+ };
30
+
31
+ return (
32
+ <ListWrapper>
33
+ {!smallCards && selectedAssets > 0 && (
34
+ <IntlText
35
+ id={getTrad(`list.assets.selected.${selectedAssets > 1 ? 'plural' : 'singular'}`)}
36
+ values={{ number: selectedAssets }}
37
+ lineHeight="18px"
38
+ />
39
+ )}
40
+ <ListRow>
41
+ {data.map(item => {
42
+ const { id } = item;
43
+ const thumbnail = get(item, ['formats', 'small'], item);
44
+ const isAllowed =
45
+ allowedTypes.length > 0 ? allowedTypes.includes(getType(item.mime)) : true;
46
+ const checked = selectedItems.findIndex(file => file.id === id) !== -1;
47
+
48
+ const fileUrl = prefixFileUrlWithBackendUrl(thumbnail.url);
49
+
50
+ const cardOptions = {
51
+ ...pick(item, ['ext', 'name', 'mime', 'height', 'width', 'size', 'previewUrl', 'id']),
52
+ isDisabled: !isAllowed,
53
+ checked,
54
+ url: fileUrl,
55
+ onClick: onCardClick,
56
+ small: smallCards,
57
+ };
58
+
59
+ return (
60
+ <ListCell key={id}>
61
+ <Card options={cardOptions}>
62
+ {(checked || canSelect) && (
63
+ <>
64
+ {(checked || isAllowed) && showCheckbox && (
65
+ <CardControlsWrapper leftAlign className="card-control-wrapper">
66
+ <Checkbox
67
+ name={`${id}`}
68
+ onChange={onChange}
69
+ onClick={handleCheckboxClick}
70
+ value={checked}
71
+ />
72
+ </CardControlsWrapper>
73
+ )}
74
+ {renderCardControl && (
75
+ <CardControlsWrapper className="card-control-wrapper card-control-wrapper-hidden">
76
+ {renderCardControl(id)}
77
+ </CardControlsWrapper>
78
+ )}
79
+ </>
80
+ )}
81
+ </Card>
82
+ </ListCell>
83
+ );
84
+ })}
85
+ </ListRow>
86
+ </ListWrapper>
87
+ );
88
+ };
89
+
90
+ List.defaultProps = {
91
+ allowedTypes: [],
92
+ canSelect: true,
93
+ data: [],
94
+ onChange: () => {},
95
+ onCardClick: () => {},
96
+ renderCardControl: null,
97
+ selectedItems: [],
98
+ smallCards: false,
99
+ showCheckbox: true,
100
+ };
101
+
102
+ List.propTypes = {
103
+ allowedTypes: PropTypes.array,
104
+ canSelect: PropTypes.bool,
105
+ data: PropTypes.array,
106
+ onChange: PropTypes.func,
107
+ onCardClick: PropTypes.func,
108
+ renderCardControl: PropTypes.func,
109
+ selectedItems: PropTypes.array,
110
+ smallCards: PropTypes.bool,
111
+ showCheckbox: PropTypes.bool,
112
+ };
113
+
114
+ export default List;
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Wrapper = styled.div`
4
+ position: relative;
5
+ margin-top: 19px;
6
+ padding: 0;
7
+ .btn-wrapper {
8
+ position: absolute;
9
+ top: 109px;
10
+ width: 100%;
11
+ text-align: center;
12
+ }
13
+ `;
14
+
15
+ export default Wrapper;
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { Button } from '@buffetjs/core';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import PropTypes from 'prop-types';
5
+
6
+ import { getTrad } from '../../utils';
7
+ import generateRows from './utils/generateRows';
8
+
9
+ import CardEmpty from '../CardEmpty';
10
+ import Wrapper from './Wrapper';
11
+ import IntlText from '../IntlText';
12
+
13
+ const ListEmpty = ({ canCreate, hasSearchApplied, onClick, numberOfRows }) => {
14
+ const rows = generateRows(numberOfRows);
15
+ const titleId = hasSearchApplied
16
+ ? 'list.assets-empty.title-withSearch'
17
+ : 'list.assets-empty.title';
18
+ const subtitleId = 'list.assets-empty.subtitle';
19
+ const prefixedTitleId = getTrad(titleId);
20
+ const prefixedSubtitleId = getTrad(subtitleId);
21
+
22
+ return (
23
+ <Wrapper className="container-fluid">
24
+ {rows.map(row => {
25
+ return (
26
+ <div className="row" key={row.key}>
27
+ {row.rows.map(key => {
28
+ return (
29
+ <div className="col-xs-12 col-md-6 col-xl-3" key={key}>
30
+ <CardEmpty />
31
+ </div>
32
+ );
33
+ })}
34
+ </div>
35
+ );
36
+ })}
37
+ {canCreate && (
38
+ <div className="btn-wrapper">
39
+ <IntlText id={prefixedTitleId} fontSize="lg" fontWeight="semiBold" />
40
+
41
+ {!hasSearchApplied && (
42
+ <>
43
+ <IntlText id={prefixedSubtitleId} fontSize="md" lineHeight="19px" />
44
+ <div style={{ paddingBottom: '1.1rem' }} />
45
+ <Button color="primary" onClick={onClick} type="button">
46
+ <FormattedMessage id={getTrad('header.actions.upload-assets')} />
47
+ </Button>
48
+ </>
49
+ )}
50
+ </div>
51
+ )}
52
+ </Wrapper>
53
+ );
54
+ };
55
+
56
+ ListEmpty.defaultProps = {
57
+ canCreate: true,
58
+ hasSearchApplied: false,
59
+ onClick: () => {},
60
+ numberOfRows: 3,
61
+ };
62
+
63
+ ListEmpty.propTypes = {
64
+ canCreate: PropTypes.bool,
65
+ hasSearchApplied: PropTypes.bool,
66
+ onClick: PropTypes.func,
67
+ numberOfRows: PropTypes.number,
68
+ };
69
+
70
+ export default ListEmpty;
@@ -0,0 +1,12 @@
1
+ const generateRows = numberOfRows => {
2
+ const rows = Array.from({ length: numberOfRows }, (_, i) => {
3
+ return {
4
+ key: i,
5
+ rows: Array.from({ length: i === numberOfRows - 1 ? 3 : 4 }, (_, i) => i),
6
+ };
7
+ });
8
+
9
+ return rows;
10
+ };
11
+
12
+ export default generateRows;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+
3
+ // You can see in the index.js file that I used the design system to do the UI integration but
4
+ // sometimes, we need to create some "temporary" custom style to fix the baseline alignment.
5
+ // -----
6
+ // TODO : remove this component. I think that this kind components should not exist in Strapi.
7
+ // I create it to temporary fix the baseline alignment until we have the design system.
8
+ const BaselineAlignmentWrapper = styled.div`
9
+ margin-top: -0.7rem;
10
+ `;
11
+
12
+ export default BaselineAlignmentWrapper;
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { Button } from '@buffetjs/core';
3
+ import { CheckPermissions } from 'strapi-helper-plugin';
4
+ import useModalContext from '../../hooks/useModalContext';
5
+ import { getTrad } from '../../utils';
6
+ import pluginPermissions from '../../permissions';
7
+ import BrowseAssets from '../BrowseAssets';
8
+ import ModalNavWrapper from '../ModalNavWrapper';
9
+ import ModalSection from '../ModalSection';
10
+ import SelectedAssets from '../SelectedAssets';
11
+ import IntlText from '../IntlText';
12
+ import BaselineAlignmentWrapper from './BaselineAlignmentWrapper';
13
+
14
+ const ListModal = () => {
15
+ const { currentTab, goTo, handleModalTabChange, selectedFiles } = useModalContext();
16
+
17
+ const handleClick = to => {
18
+ handleModalTabChange(to);
19
+ };
20
+
21
+ const handleGoToUpload = () => {
22
+ goTo('browse');
23
+ };
24
+
25
+ const renderUploadModalButton = () => (
26
+ <BaselineAlignmentWrapper>
27
+ <CheckPermissions permissions={pluginPermissions.create}>
28
+ <Button type="button" color="primary" onClick={handleGoToUpload}>
29
+ <IntlText
30
+ id={getTrad('modal.upload-list.sub-header.button')}
31
+ fontWeight="bold"
32
+ color="white"
33
+ />
34
+ </Button>
35
+ </CheckPermissions>
36
+ </BaselineAlignmentWrapper>
37
+ );
38
+
39
+ const links = [
40
+ { to: 'browse', label: 'browse', isDisabled: false, onClick: handleClick },
41
+ {
42
+ to: 'selected',
43
+ label: 'selected',
44
+ count: selectedFiles.length,
45
+ isDisabled: false,
46
+ onClick: handleClick,
47
+ },
48
+ ];
49
+
50
+ return (
51
+ <ModalNavWrapper
52
+ initialTab={currentTab}
53
+ links={links}
54
+ renderRightContent={renderUploadModalButton}
55
+ >
56
+ {to => (
57
+ <ModalSection>
58
+ {to === 'browse' && <BrowseAssets />}
59
+ {to === 'selected' && <SelectedAssets />}
60
+ </ModalSection>
61
+ )}
62
+ </ModalNavWrapper>
63
+ );
64
+ };
65
+
66
+ export default ListModal;
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const ListWrapper = styled.div`
5
+ margin-top: ${({ small }) => (small ? '2px' : '7px')};
6
+ `;
7
+
8
+ ListWrapper.defaultProps = {
9
+ small: false,
10
+ };
11
+
12
+ ListWrapper.propTypes = {
13
+ small: PropTypes.bool,
14
+ };
15
+
16
+ export default ListWrapper;
@@ -0,0 +1,44 @@
1
+ import styled, { keyframes } from 'styled-components';
2
+
3
+ const loading = keyframes`
4
+ from {
5
+ left: -100px;
6
+ width: 30%;
7
+ }
8
+ 50% {
9
+ width: 30%;
10
+ }
11
+ 70% {
12
+ width: 70%;
13
+ }
14
+ 80% {
15
+ left: 50%;
16
+ }
17
+ 95% {
18
+ left: 120%;
19
+ }
20
+ to {
21
+ left: 100%;
22
+ }
23
+ `;
24
+
25
+ const LoadingIndicator = styled.div`
26
+ position: relative;
27
+ width: 44%;
28
+ height: 4px;
29
+ overflow: hidden;
30
+ background-color: #515764;
31
+ border-radius: 2px;
32
+ &:before {
33
+ content: '';
34
+ display: block;
35
+ position: absolute;
36
+ left: -100px;
37
+ width: 100px;
38
+ height: 4px;
39
+ background-color: #b3b5b9;
40
+ animation: ${loading} 2s linear infinite;
41
+ }
42
+ `;
43
+
44
+ export default LoadingIndicator;
@@ -0,0 +1,33 @@
1
+ /*
2
+ *
3
+ *
4
+ * BackButton
5
+ *
6
+ */
7
+ import styled from 'styled-components';
8
+
9
+ const BackButton = styled.button`
10
+ height: 5.9rem;
11
+ width: 6.5rem;
12
+ margin-right: 20px;
13
+ margin-left: -30px;
14
+ line-height: 6rem;
15
+ text-align: center;
16
+ color: #81848a;
17
+ border-right: 1px solid #f3f4f4;
18
+ &:before {
19
+ line-height: normal;
20
+ content: '\f053';
21
+ font-family: 'FontAwesome';
22
+ font-size: ${({ theme }) => theme.main.sizes.fonts.lg};
23
+ font-weight: ${({ theme }) => theme.main.fontWeights.bold};
24
+ }
25
+ &:hover {
26
+ background-color: #f3f4f4;
27
+ }
28
+ &:focus {
29
+ outline: none;
30
+ }
31
+ `;
32
+
33
+ export default BackButton;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * NOTE:
3
+ * This component should be put in the strapi-helper-plugin
4
+ * at some point so the other packages can benefits from the updates
5
+ *
6
+ *
7
+ */
8
+
9
+ import styled from 'styled-components';
10
+
11
+ import { themePropTypes } from 'strapi-helper-plugin';
12
+
13
+ const Wrapper = styled.div`
14
+ height: 59px;
15
+ line-height: 59px;
16
+ background-color: ${({ theme }) => theme.main.colors.lightGrey};
17
+ color: ${({ theme }) => theme.main.colors.black};
18
+ font-size: ${({ theme }) => theme.main.sizes.fonts.md};
19
+ font-weight: ${({ theme }) => theme.main.fontWeights.bold};
20
+ `;
21
+
22
+ Wrapper.propTypes = themePropTypes;
23
+
24
+ export default Wrapper;
@@ -0,0 +1,47 @@
1
+ /*
2
+ * NOTE:
3
+ * This component should be put in the strapi-helper-plugin
4
+ * at some point so the other packages can benefits from the updates
5
+ *
6
+ *
7
+ */
8
+
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import { ModalHeader as HeaderModal, useGlobalContext } from 'strapi-helper-plugin';
12
+
13
+ const ModalHeader = ({ goBack, headerBreadcrumbs, withBackButton, HeaderComponent }) => {
14
+ const { emitEvent } = useGlobalContext();
15
+
16
+ const handleClick = () => {
17
+ // Emit event on backButton with hardcoded upload location
18
+ emitEvent('didGoBack', { location: 'upload' });
19
+
20
+ goBack('backButton');
21
+ };
22
+
23
+ return (
24
+ <HeaderModal
25
+ headerBreadcrumbs={headerBreadcrumbs}
26
+ onClickGoBack={handleClick}
27
+ withBackButton={withBackButton}
28
+ HeaderComponent={HeaderComponent}
29
+ />
30
+ );
31
+ };
32
+
33
+ ModalHeader.defaultProps = {
34
+ goBack: () => {},
35
+ headerBreadcrumbs: [],
36
+ withBackButton: false,
37
+ HeaderComponent: null,
38
+ };
39
+
40
+ ModalHeader.propTypes = {
41
+ goBack: PropTypes.func,
42
+ headerBreadcrumbs: PropTypes.array,
43
+ withBackButton: PropTypes.bool,
44
+ HeaderComponent: PropTypes.elementType,
45
+ };
46
+
47
+ export default ModalHeader;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+
3
+ // You can see in the index.js file that I used the design system to do the UI integration but
4
+ // sometimes, we need to create some "temporary" custom style to fix the baseline alignment.
5
+ // -----
6
+ // TODO : remove this component. I think that this kind components should not exist in Strapi.
7
+ // I create it to temporary fix the baseline alignment until we have the design system.
8
+ const BaselineAlignment = styled.div`
9
+ padding-top: 3.4rem;
10
+ `;
11
+
12
+ export default BaselineAlignment;
@@ -0,0 +1,14 @@
1
+ import styled from 'styled-components';
2
+ import { themePropTypes } from 'strapi-helper-plugin';
3
+
4
+ const Hr = styled.hr`
5
+ margin: 0px;
6
+ width: 50%;
7
+ height: 1px;
8
+ border: 0;
9
+ background: ${({ theme }) => theme.main.colors.brightGrey};
10
+ `;
11
+
12
+ Hr.propTypes = themePropTypes;
13
+
14
+ export default Hr;
@@ -0,0 +1,8 @@
1
+ import styled from 'styled-components';
2
+
3
+ const Wrapper = styled.div`
4
+ max-height: 48.3rem;
5
+ overflow: auto;
6
+ `;
7
+
8
+ export default Wrapper;
@@ -0,0 +1,70 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Flex, Padded } from '@buffetjs/core';
4
+
5
+ import ModalSection from '../ModalSection';
6
+ import ModalTab from '../ModalTab';
7
+ import Hr from './Hr';
8
+ import BaselineAlignment from './BaselineAlignment';
9
+ import Wrapper from './Wrapper';
10
+
11
+ const ModalNavWrapper = ({ children, links, renderRightContent, initialTab }) => {
12
+ const [to, setTo] = useState(initialTab || links[0].to);
13
+
14
+ const handleGoTo = link => {
15
+ setTo(link.to);
16
+
17
+ if (link.onClick) {
18
+ link.onClick(link.to);
19
+ }
20
+ };
21
+
22
+ return (
23
+ <Wrapper>
24
+ <Padded left right size="md">
25
+ <BaselineAlignment />
26
+ <Flex justifyContent="space-between">
27
+ <Flex>
28
+ {links.map(link => {
29
+ const isActive = link.to === to;
30
+
31
+ return (
32
+ <ModalTab
33
+ count={link.count}
34
+ isActive={isActive}
35
+ isDisabled={link.isDisabled}
36
+ key={link.to}
37
+ label={link.label}
38
+ onClick={() => handleGoTo(link)}
39
+ to={link.to}
40
+ />
41
+ );
42
+ })}
43
+ </Flex>
44
+ {renderRightContent && renderRightContent()}
45
+ </Flex>
46
+ </Padded>
47
+ <ModalSection>
48
+ <Hr />
49
+ </ModalSection>
50
+ {children(to)}
51
+ </Wrapper>
52
+ );
53
+ };
54
+
55
+ ModalNavWrapper.defaultProps = {
56
+ initialTab: null,
57
+ links: [],
58
+ renderRightContent: null,
59
+ to: '',
60
+ };
61
+
62
+ ModalNavWrapper.propTypes = {
63
+ children: PropTypes.func.isRequired,
64
+ initialTab: PropTypes.string,
65
+ links: PropTypes.array,
66
+ renderRightContent: PropTypes.func,
67
+ to: PropTypes.string,
68
+ };
69
+
70
+ export default ModalNavWrapper;
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+ import { themePropTypes } from 'strapi-helper-plugin';
4
+
5
+ const ModalSection = styled.section`
6
+ display: flex;
7
+ justify-content: ${({ justifyContent }) => justifyContent};
8
+ padding: 0 ${({ theme }) => theme.main.sizes.paddings.md};
9
+ `;
10
+
11
+ ModalSection.defaultProps = {
12
+ justifyContent: 'initial',
13
+ };
14
+
15
+ ModalSection.propTypes = {
16
+ ...themePropTypes,
17
+ justifyContent: PropTypes.string,
18
+ };
19
+
20
+ export default ModalSection;
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { Flex } from '@buffetjs/core';
4
+
5
+ const Wrapper = styled(Flex)`
6
+ width: 1.4rem;
7
+ height: 1.4rem;
8
+ padding: 0 0.2rem;
9
+ margin-top: 0.2rem;
10
+ margin-left: ${({ theme }) => theme.main.sizes.paddings.xs};
11
+ border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
12
+ background-color: ${({ theme, isActive }) =>
13
+ isActive ? theme.main.colors.lightBlue : '#e9eaeb'};
14
+ `;
15
+
16
+ export default Wrapper;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Text } from '@buffetjs/core';
4
+
5
+ import Wrapper from './Wrapper';
6
+
7
+ const Count = ({ count, isActive }) => (
8
+ <Wrapper isActive={isActive} justifyContent="center" alignItems="center">
9
+ <Text
10
+ lineHeight="none"
11
+ fontWeight="bold"
12
+ color={isActive ? 'mediumBlue' : 'grey'}
13
+ fontSize="xs"
14
+ >
15
+ {count}
16
+ </Text>
17
+ </Wrapper>
18
+ );
19
+
20
+ Count.propTypes = {
21
+ count: PropTypes.number,
22
+ isActive: PropTypes.bool,
23
+ };
24
+
25
+ Count.defaultProps = {
26
+ count: 0,
27
+ isActive: false,
28
+ };
29
+
30
+ export default Count;
@@ -0,0 +1,37 @@
1
+ import styled from 'styled-components';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const Wrapper = styled.div(({ isActive, isDisabled, theme }) => {
5
+ const cursor = isDisabled ? 'not-allowed' : 'pointer';
6
+ const baseStyle = {
7
+ color: '#9ea7b8',
8
+ cursor,
9
+ fontSize: theme.main.sizes.fonts.sm,
10
+ fontWeight: theme.main.fontWeights.bold,
11
+ letterSpacing: '0.7px',
12
+ textTransform: 'uppercase',
13
+ height: '3rem',
14
+ };
15
+
16
+ if (isActive) {
17
+ return {
18
+ ...baseStyle,
19
+ borderBottom: '2px solid #007eff',
20
+ zIndex: 99,
21
+ };
22
+ }
23
+
24
+ return baseStyle;
25
+ });
26
+
27
+ Wrapper.defaultProps = {
28
+ isActive: false,
29
+ isDisabled: false,
30
+ };
31
+
32
+ Wrapper.propTypes = {
33
+ isActive: PropTypes.bool,
34
+ isDisabled: PropTypes.bool,
35
+ };
36
+
37
+ export default Wrapper;