@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.
- package/LICENSE +22 -0
- package/README.md +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/BrowseAssets/Wrapper.js +8 -0
- package/admin/src/components/BrowseAssets/index.js +182 -0
- package/admin/src/components/Card/index.js +146 -0
- package/admin/src/components/CardBorder/index.js +28 -0
- package/admin/src/components/CardControl/Wrapper.js +89 -0
- package/admin/src/components/CardControl/index.js +61 -0
- package/admin/src/components/CardControlsWrapper/index.js +22 -0
- package/admin/src/components/CardEmpty/Bar.js +19 -0
- package/admin/src/components/CardEmpty/Wrapper.js +7 -0
- package/admin/src/components/CardEmpty/index.js +16 -0
- package/admin/src/components/CardErrorMessage/index.js +9 -0
- package/admin/src/components/CardImgWrapper/index.js +52 -0
- package/admin/src/components/CardPreview/Image.js +12 -0
- package/admin/src/components/CardPreview/Wrapper.js +25 -0
- package/admin/src/components/CardPreview/index.js +66 -0
- package/admin/src/components/CardTitle/index.js +14 -0
- package/admin/src/components/CardWrapper/index.js +23 -0
- package/admin/src/components/CheckControl/Button.js +49 -0
- package/admin/src/components/CheckControl/CustomDropdownSection.js +9 -0
- package/admin/src/components/CheckControl/Spacer.js +7 -0
- package/admin/src/components/CheckControl/index.js +74 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/ContainerFluid/index.js +12 -0
- package/admin/src/components/ControlsWrapper/index.js +9 -0
- package/admin/src/components/DragLayer/Wrapper.js +13 -0
- package/admin/src/components/DragLayer/index.js +68 -0
- package/admin/src/components/DropdownButton/index.js +63 -0
- package/admin/src/components/DropdownSection/index.js +27 -0
- package/admin/src/components/Duration/index.js +25 -0
- package/admin/src/components/Duration/utils/formatDuration.js +13 -0
- package/admin/src/components/EditForm/CropWrapper.js +21 -0
- package/admin/src/components/EditForm/ErrorMessage.js +10 -0
- package/admin/src/components/EditForm/FileDetailsBox.js +95 -0
- package/admin/src/components/EditForm/FileDetailsBoxWrapper.js +14 -0
- package/admin/src/components/EditForm/FileWrapper.js +41 -0
- package/admin/src/components/EditForm/FormWrapper.js +7 -0
- package/admin/src/components/EditForm/SizeBox.js +13 -0
- package/admin/src/components/EditForm/Wrapper.js +8 -0
- package/admin/src/components/EditForm/index.js +425 -0
- package/admin/src/components/EditForm/utils/form.js +34 -0
- package/admin/src/components/EditForm/utils/isImageType.js +3 -0
- package/admin/src/components/EditForm/utils/isVideoType.js +3 -0
- package/admin/src/components/FileIcon/Wrapper.js +20 -0
- package/admin/src/components/FileIcon/index.js +33 -0
- package/admin/src/components/FileIcon/utils/extensions.json +4 -0
- package/admin/src/components/FileInfos/index.js +32 -0
- package/admin/src/components/Filters/index.js +30 -0
- package/admin/src/components/FiltersList/index.js +34 -0
- package/admin/src/components/FiltersList/utils/formatFilter.js +36 -0
- package/admin/src/components/FiltersPicker/FiltersCard/FilterButton.js +8 -0
- package/admin/src/components/FiltersPicker/FiltersCard/FilterInput.js +35 -0
- package/admin/src/components/FiltersPicker/FiltersCard/InputWrapper.js +10 -0
- package/admin/src/components/FiltersPicker/FiltersCard/SizeInput.js +57 -0
- package/admin/src/components/FiltersPicker/FiltersCard/Wrapper.js +8 -0
- package/admin/src/components/FiltersPicker/FiltersCard/index.js +97 -0
- package/admin/src/components/FiltersPicker/FiltersCard/init.js +21 -0
- package/admin/src/components/FiltersPicker/FiltersCard/reducer.js +47 -0
- package/admin/src/components/FiltersPicker/FiltersCard/utils/filtersForm.js +27 -0
- package/admin/src/components/FiltersPicker/index.js +43 -0
- package/admin/src/components/FiltersPicker/utils/formatFilter.js +18 -0
- package/admin/src/components/InfiniteLoadingIndicator/Button.js +20 -0
- package/admin/src/components/InfiniteLoadingIndicator/Container.js +12 -0
- package/admin/src/components/InfiniteLoadingIndicator/Wrapper.js +18 -0
- package/admin/src/components/InfiniteLoadingIndicator/index.js +39 -0
- package/admin/src/components/Input/index.js +7 -0
- package/admin/src/components/InputFileModal/Label.js +47 -0
- package/admin/src/components/InputFileModal/P.js +15 -0
- package/admin/src/components/InputFileModal/index.js +73 -0
- package/admin/src/components/InputMedia/CardControlWrapper.js +12 -0
- package/admin/src/components/InputMedia/CardPreviewWrapper.js +13 -0
- package/admin/src/components/InputMedia/Chevron/Wrapper.js +10 -0
- package/admin/src/components/InputMedia/Chevron/index.js +21 -0
- package/admin/src/components/InputMedia/EmptyInputMedia.js +60 -0
- package/admin/src/components/InputMedia/EmptyText.js +13 -0
- package/admin/src/components/InputMedia/ErrorMessage.js +12 -0
- package/admin/src/components/InputMedia/IconUpload.js +48 -0
- package/admin/src/components/InputMedia/InputFilePreview.js +37 -0
- package/admin/src/components/InputMedia/Name.js +10 -0
- package/admin/src/components/InputMedia/Wrapper.js +11 -0
- package/admin/src/components/InputMedia/index.js +238 -0
- package/admin/src/components/InputUploadURL/Wrapper.js +13 -0
- package/admin/src/components/InputUploadURL/index.js +46 -0
- package/admin/src/components/IntlText/index.js +26 -0
- package/admin/src/components/List/ListCell.js +19 -0
- package/admin/src/components/List/ListRow.js +8 -0
- package/admin/src/components/List/index.js +114 -0
- package/admin/src/components/ListEmpty/Wrapper.js +15 -0
- package/admin/src/components/ListEmpty/index.js +70 -0
- package/admin/src/components/ListEmpty/utils/generateRows.js +12 -0
- package/admin/src/components/ListModal/BaselineAlignmentWrapper.js +12 -0
- package/admin/src/components/ListModal/index.js +66 -0
- package/admin/src/components/ListWrapper/index.js +16 -0
- package/admin/src/components/LoadingIndicator/index.js +44 -0
- package/admin/src/components/ModalHeader/BackButton.js +33 -0
- package/admin/src/components/ModalHeader/Wrapper.js +24 -0
- package/admin/src/components/ModalHeader/index.js +47 -0
- package/admin/src/components/ModalNavWrapper/BaselineAlignment.js +12 -0
- package/admin/src/components/ModalNavWrapper/Hr.js +14 -0
- package/admin/src/components/ModalNavWrapper/Wrapper.js +8 -0
- package/admin/src/components/ModalNavWrapper/index.js +70 -0
- package/admin/src/components/ModalSection/index.js +20 -0
- package/admin/src/components/ModalTab/Count/Wrapper.js +16 -0
- package/admin/src/components/ModalTab/Count/index.js +30 -0
- package/admin/src/components/ModalTab/Wrapper.js +37 -0
- package/admin/src/components/ModalTab/index.js +60 -0
- package/admin/src/components/PlayIcon/Play.js +65 -0
- package/admin/src/components/PlayIcon/Wrapper.js +24 -0
- package/admin/src/components/PlayIcon/index.js +23 -0
- package/admin/src/components/SelectAll/Wrapper.js +19 -0
- package/admin/src/components/SelectAll/index.js +26 -0
- package/admin/src/components/SelectedAssets/DraggableCard.js +149 -0
- package/admin/src/components/SelectedAssets/ListTitleWrapper.js +7 -0
- package/admin/src/components/SelectedAssets/ListWrapper.js +7 -0
- package/admin/src/components/SelectedAssets/SortableList.js +102 -0
- package/admin/src/components/SelectedAssets/Wrapper.js +7 -0
- package/admin/src/components/SelectedAssets/index.js +56 -0
- package/admin/src/components/SortList/Wrapper.js +19 -0
- package/admin/src/components/SortList/index.js +37 -0
- package/admin/src/components/SortListItem/Wrapper.js +28 -0
- package/admin/src/components/SortListItem/index.js +35 -0
- package/admin/src/components/SortPicker/index.js +54 -0
- package/admin/src/components/Tag/Wrapper.js +16 -0
- package/admin/src/components/Tag/index.js +25 -0
- package/admin/src/components/UploadForm/index.js +61 -0
- package/admin/src/components/UploadList/ButtonWrapper.js +7 -0
- package/admin/src/components/UploadList/Container.js +10 -0
- package/admin/src/components/UploadList/CustomModalSection.js +9 -0
- package/admin/src/components/UploadList/ListTitle.js +10 -0
- package/admin/src/components/UploadList/ListTitleWrapper.js +7 -0
- package/admin/src/components/UploadList/RowItem.js +98 -0
- package/admin/src/components/UploadList/index.js +90 -0
- package/admin/src/components/VideoPlayer/Wrapper.js +24 -0
- package/admin/src/components/VideoPlayer/index.js +57 -0
- package/admin/src/components/VideoPreview/CanvasWrapper.js +22 -0
- package/admin/src/components/VideoPreview/Thumbnail.js +12 -0
- package/admin/src/components/VideoPreview/Wrapper.js +15 -0
- package/admin/src/components/VideoPreview/index.js +165 -0
- package/admin/src/components/VideoPreview/reducer.js +33 -0
- package/admin/src/containers/App/index.js +31 -0
- package/admin/src/containers/HomePage/HomePageContent/HomePageList.js +98 -0
- package/admin/src/containers/HomePage/HomePageContent/HomePageSettings.js +103 -0
- package/admin/src/containers/HomePage/HomePageContent/index.js +90 -0
- package/admin/src/containers/HomePage/components.js +18 -0
- package/admin/src/containers/HomePage/index.js +373 -0
- package/admin/src/containers/HomePage/init.js +5 -0
- package/admin/src/containers/HomePage/reducer.js +88 -0
- package/admin/src/containers/HomePage/utils/generateParamsFromQuery.js +14 -0
- package/admin/src/containers/HomePage/utils/generateStringFromParams.js +27 -0
- package/admin/src/containers/HomePage/utils/getHeaderLabel.js +13 -0
- package/admin/src/containers/HomePage/utils/index.js +2 -0
- package/admin/src/containers/Initializer/index.js +44 -0
- package/admin/src/containers/InputModalStepper/HeaderSearch.js +12 -0
- package/admin/src/containers/InputModalStepper/InputModalStepper.js +480 -0
- package/admin/src/containers/InputModalStepper/Search.js +48 -0
- package/admin/src/containers/InputModalStepper/index.js +86 -0
- package/admin/src/containers/InputModalStepper/stepper.js +52 -0
- package/admin/src/containers/InputModalStepperProvider/index.js +564 -0
- package/admin/src/containers/InputModalStepperProvider/init.js +5 -0
- package/admin/src/containers/InputModalStepperProvider/reducer.js +301 -0
- package/admin/src/containers/ModalStepper/index.js +629 -0
- package/admin/src/containers/ModalStepper/init.js +5 -0
- package/admin/src/containers/ModalStepper/reducer.js +132 -0
- package/admin/src/containers/ModalStepper/stepper.js +46 -0
- package/admin/src/containers/SettingsPage/Divider.js +11 -0
- package/admin/src/containers/SettingsPage/SectionTitleWrapper.js +7 -0
- package/admin/src/containers/SettingsPage/Wrapper.js +17 -0
- package/admin/src/containers/SettingsPage/index.js +198 -0
- package/admin/src/containers/SettingsPage/init.js +5 -0
- package/admin/src/containers/SettingsPage/reducer.js +38 -0
- package/admin/src/contexts/AppContext/index.js +5 -0
- package/admin/src/contexts/InputModal/InputModalDataManager.js +5 -0
- package/admin/src/contexts/index.js +2 -0
- package/admin/src/hooks/index.js +2 -0
- package/admin/src/hooks/useAppContext/index.js +6 -0
- package/admin/src/hooks/useModalContext.js +6 -0
- package/admin/src/icons/BrokenFile/index.js +91 -0
- package/admin/src/icons/Cloud/index.js +35 -0
- package/admin/src/icons/DoubleFile/index.js +35 -0
- package/admin/src/icons/Download/index.js +36 -0
- package/admin/src/icons/File/index.js +35 -0
- package/admin/src/index.js +85 -0
- package/admin/src/lifecycles.js +13 -0
- package/admin/src/permissions.js +40 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/translations/de.json +81 -0
- package/admin/src/translations/dk.json +81 -0
- package/admin/src/translations/en.json +86 -0
- package/admin/src/translations/es.json +81 -0
- package/admin/src/translations/fr.json +85 -0
- package/admin/src/translations/he.json +81 -0
- package/admin/src/translations/index.js +39 -0
- package/admin/src/translations/it.json +82 -0
- package/admin/src/translations/ja.json +81 -0
- package/admin/src/translations/ms.json +73 -0
- package/admin/src/translations/pl.json +81 -0
- package/admin/src/translations/pt-BR.json +81 -0
- package/admin/src/translations/ru.json +81 -0
- package/admin/src/translations/sk.json +81 -0
- package/admin/src/translations/th.json +81 -0
- package/admin/src/translations/uk.json +78 -0
- package/admin/src/translations/zh-Hans.json +86 -0
- package/admin/src/translations/zh.json +81 -0
- package/admin/src/utils/ItemTypes.js +3 -0
- package/admin/src/utils/canDownloadFile.js +3 -0
- package/admin/src/utils/compactParams.js +13 -0
- package/admin/src/utils/createFileToDownloadName.js +9 -0
- package/admin/src/utils/createMatrix.js +32 -0
- package/admin/src/utils/createNewFilesToDownloadArray.js +57 -0
- package/admin/src/utils/createNewFilesToUploadArray.js +25 -0
- package/admin/src/utils/formatBytes.js +13 -0
- package/admin/src/utils/formatFileForEditing.js +20 -0
- package/admin/src/utils/formatFilters.js +23 -0
- package/admin/src/utils/generatePageFromStart.js +5 -0
- package/admin/src/utils/generateStartFromPage.js +5 -0
- package/admin/src/utils/getFileModelTimestamps.js +15 -0
- package/admin/src/utils/getFilesToDownload.js +5 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/getType.js +15 -0
- package/admin/src/utils/getYupError.js +17 -0
- package/admin/src/utils/index.js +20 -0
- package/admin/src/utils/unformatBytes.js +16 -0
- package/admin/src/utils/urlYupSchema.js +49 -0
- package/config/config.json +8 -0
- package/config/functions/bootstrap.js +143 -0
- package/config/routes.json +98 -0
- package/config/schema.graphql.js +96 -0
- package/controllers/Upload.js +103 -0
- package/controllers/upload/admin.js +213 -0
- package/controllers/upload/api.js +125 -0
- package/controllers/validation/settings.js +22 -0
- package/controllers/validation/upload.js +27 -0
- package/documentation/1.0.0/overrides/upload-File.json +263 -0
- package/errors.js +48 -0
- package/index.js +7 -0
- package/middlewares/upload/defaults.json +5 -0
- package/middlewares/upload/index.js +35 -0
- package/models/File.js +7 -0
- package/models/File.settings.json +86 -0
- package/package.json +71 -0
- package/services/Upload.js +397 -0
- package/services/image-manipulation.js +167 -0
- package/utils/file.js +23 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled.div`
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
position: absolute;
|
|
8
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
background-color: ${({ isFile }) => (isFile ? '#F2F3F4' : '#333740')};
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
Wrapper.defaultProps = {
|
|
18
|
+
isFile: false,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Wrapper.propTypes = {
|
|
22
|
+
isFile: PropTypes.bool,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default Wrapper;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { memo, useRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { getType } from '../../utils';
|
|
5
|
+
|
|
6
|
+
import BrokenFile from '../../icons/BrokenFile';
|
|
7
|
+
import FileIcon from '../FileIcon';
|
|
8
|
+
import VideoPreview from '../VideoPreview';
|
|
9
|
+
import Wrapper from './Wrapper';
|
|
10
|
+
import Image from './Image';
|
|
11
|
+
|
|
12
|
+
const CardPreview = ({ extension, hasError, hasIcon, url, previewUrl, type, withFileCaching }) => {
|
|
13
|
+
const isFile = getType(type) === 'file';
|
|
14
|
+
const isVideo = getType(type) === 'video';
|
|
15
|
+
const cacheRef = useRef(performance.now());
|
|
16
|
+
|
|
17
|
+
if (hasError) {
|
|
18
|
+
return (
|
|
19
|
+
<Wrapper isFile>
|
|
20
|
+
<BrokenFile />
|
|
21
|
+
</Wrapper>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isFile) {
|
|
26
|
+
return (
|
|
27
|
+
<Wrapper isFile>
|
|
28
|
+
<FileIcon ext={extension} />
|
|
29
|
+
</Wrapper>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Wrapper>
|
|
35
|
+
{isVideo ? (
|
|
36
|
+
<VideoPreview src={url} previewUrl={previewUrl} hasIcon={hasIcon} />
|
|
37
|
+
) : (
|
|
38
|
+
// Adding performance.now forces the browser no to cache the img
|
|
39
|
+
// https://stackoverflow.com/questions/126772/how-to-force-a-web-browser-not-to-cache-images
|
|
40
|
+
<Image src={`${url}${withFileCaching ? `?${cacheRef.current}` : ''}`} />
|
|
41
|
+
)}
|
|
42
|
+
</Wrapper>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
CardPreview.defaultProps = {
|
|
47
|
+
extension: null,
|
|
48
|
+
hasError: false,
|
|
49
|
+
hasIcon: false,
|
|
50
|
+
previewUrl: null,
|
|
51
|
+
url: null,
|
|
52
|
+
type: '',
|
|
53
|
+
withFileCaching: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
CardPreview.propTypes = {
|
|
57
|
+
extension: PropTypes.string,
|
|
58
|
+
hasError: PropTypes.bool,
|
|
59
|
+
hasIcon: PropTypes.bool,
|
|
60
|
+
previewUrl: PropTypes.string,
|
|
61
|
+
url: PropTypes.string,
|
|
62
|
+
type: PropTypes.string,
|
|
63
|
+
withFileCaching: PropTypes.bool,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default memo(CardPreview);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Text } from '@buffetjs/core';
|
|
4
|
+
|
|
5
|
+
const Title = styled(props => (
|
|
6
|
+
<Text {...props} fontSize="md" fontWeight="bold" color="black" ellipsis />
|
|
7
|
+
))`
|
|
8
|
+
width: 100%;
|
|
9
|
+
margin-bottom: 4px;
|
|
10
|
+
margin-top: 4px;
|
|
11
|
+
margin-right: 5px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export default Title;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled.div`
|
|
5
|
+
width: 100%;
|
|
6
|
+
margin-bottom: 16px;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
&:hover {
|
|
9
|
+
cursor: ${({ isDraggable }) => (isDraggable ? 'move' : 'pointer')};
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
Wrapper.defaultProps = {
|
|
14
|
+
isDisabled: false,
|
|
15
|
+
isDraggable: false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Wrapper.propTypes = {
|
|
19
|
+
isDisabled: PropTypes.bool,
|
|
20
|
+
isDraggable: PropTypes.bool,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default Wrapper;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Text } from '@buffetjs/core';
|
|
3
|
+
|
|
4
|
+
const Button = styled(Text)`
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
height: 36px;
|
|
8
|
+
width: 280px;
|
|
9
|
+
padding: 0 15px 0;
|
|
10
|
+
color: ${({ theme }) => theme.main.colors.black};
|
|
11
|
+
background-color: #fafafb;
|
|
12
|
+
border: 1px solid transparent;
|
|
13
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
14
|
+
text-align: left;
|
|
15
|
+
|
|
16
|
+
&:focus {
|
|
17
|
+
outline: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
height: 36px;
|
|
22
|
+
background-color: ${({ theme }) => theme.main.colors.lightBlue};
|
|
23
|
+
border: 1px solid ${({ theme }) => theme.main.colors.darkBlue};
|
|
24
|
+
color: ${({ theme }) => theme.main.colors.mediumBlue};
|
|
25
|
+
> svg {
|
|
26
|
+
> g {
|
|
27
|
+
fill: ${({ theme }) => theme.main.colors.darkBlue};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
> svg {
|
|
33
|
+
height: 2.1rem;
|
|
34
|
+
margin-right: 15px;
|
|
35
|
+
> g {
|
|
36
|
+
fill: ${({ theme }) => theme.main.colors.grey};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
Button.defaultProps = {
|
|
42
|
+
as: 'button',
|
|
43
|
+
color: '#b4b6ba',
|
|
44
|
+
fontSize: 'md',
|
|
45
|
+
fontWeight: 'bold',
|
|
46
|
+
type: 'button',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Button;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useClickAwayListener } from '@buffetjs/hooks';
|
|
4
|
+
import { useGlobalContext } from 'strapi-helper-plugin';
|
|
5
|
+
import { Padded } from '@buffetjs/core';
|
|
6
|
+
|
|
7
|
+
import DoubleFile from '../../icons/DoubleFile';
|
|
8
|
+
import File from '../../icons/File';
|
|
9
|
+
import Button from './Button';
|
|
10
|
+
import Spacer from './Spacer';
|
|
11
|
+
import CardControl from '../CardControl';
|
|
12
|
+
import CustomDropdownSection from './CustomDropdownSection';
|
|
13
|
+
import { getTrad } from '../../utils';
|
|
14
|
+
|
|
15
|
+
const CheckControl = ({ title, onSubmitEdit }) => {
|
|
16
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
const { formatMessage } = useGlobalContext();
|
|
18
|
+
const dropdownRef = useRef();
|
|
19
|
+
|
|
20
|
+
useClickAwayListener(dropdownRef, () => setIsOpen(false));
|
|
21
|
+
|
|
22
|
+
const handleClick = e => {
|
|
23
|
+
e.persist();
|
|
24
|
+
setIsOpen(false);
|
|
25
|
+
onSubmitEdit(e);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const handleClickDuplicate = e => {
|
|
29
|
+
e.persist();
|
|
30
|
+
setIsOpen(false);
|
|
31
|
+
onSubmitEdit(e, true);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleToggle = () => {
|
|
35
|
+
setIsOpen(v => !v);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div ref={dropdownRef}>
|
|
40
|
+
<CardControl
|
|
41
|
+
color="#6DBB1A"
|
|
42
|
+
onClick={handleToggle}
|
|
43
|
+
type="check"
|
|
44
|
+
title={title}
|
|
45
|
+
iconStyle={{ height: '1.4rem', width: '1.4rem' }}
|
|
46
|
+
/>
|
|
47
|
+
<CustomDropdownSection isOpen={isOpen}>
|
|
48
|
+
<Padded left right bottom top size="15px">
|
|
49
|
+
<Button onClick={handleClick}>
|
|
50
|
+
<File style={{ height: '2rem' }} />
|
|
51
|
+
{formatMessage({ id: getTrad('checkControl.crop-original') })}
|
|
52
|
+
</Button>
|
|
53
|
+
<Spacer />
|
|
54
|
+
<Button onClick={handleClickDuplicate}>
|
|
55
|
+
<DoubleFile style={{ height: '1.8rem' }} />
|
|
56
|
+
{formatMessage({ id: getTrad('checkControl.crop-duplicate') })}
|
|
57
|
+
</Button>
|
|
58
|
+
</Padded>
|
|
59
|
+
</CustomDropdownSection>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
CheckControl.defaultProps = {
|
|
65
|
+
onSubmitEdit: () => {},
|
|
66
|
+
title: null,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
CheckControl.propTypes = {
|
|
70
|
+
onSubmitEdit: PropTypes.func,
|
|
71
|
+
title: PropTypes.string,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default CheckControl;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDragLayer } from 'react-dnd';
|
|
3
|
+
import { Checkbox } from '@buffetjs/core';
|
|
4
|
+
import { ItemTypes } from '../../utils';
|
|
5
|
+
import CardControlsWrapper from '../CardControlsWrapper';
|
|
6
|
+
import CardImgWrapper from '../CardImgWrapper';
|
|
7
|
+
import CardPreview from '../CardPreview';
|
|
8
|
+
import Border from '../CardBorder';
|
|
9
|
+
import Wrapper from './Wrapper';
|
|
10
|
+
|
|
11
|
+
function getItemStyles(initialOffset, currentOffset, mouseOffset) {
|
|
12
|
+
if (!initialOffset || !currentOffset) {
|
|
13
|
+
return { display: 'none' };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { x, y } = mouseOffset;
|
|
17
|
+
const transform = `translate(${x}px, ${y}px)`;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
transform,
|
|
21
|
+
WebkitTransform: transform,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const DragLayer = () => {
|
|
26
|
+
const { itemType, isDragging, item, initialOffset, currentOffset, mouseOffset } = useDragLayer(
|
|
27
|
+
monitor => ({
|
|
28
|
+
item: monitor.getItem(),
|
|
29
|
+
itemType: monitor.getItemType(),
|
|
30
|
+
initialOffset: monitor.getInitialSourceClientOffset(),
|
|
31
|
+
currentOffset: monitor.getSourceClientOffset(),
|
|
32
|
+
isDragging: monitor.isDragging(),
|
|
33
|
+
mouseOffset: monitor.getClientOffset(),
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const renderItem = () => {
|
|
38
|
+
switch (itemType) {
|
|
39
|
+
case ItemTypes.MEDIA_CARD: {
|
|
40
|
+
return (
|
|
41
|
+
<CardImgWrapper checked small>
|
|
42
|
+
<CardPreview url={item.url} type={item.fileType} withFileCaching />
|
|
43
|
+
<Border color="mediumBlue" shown />
|
|
44
|
+
<CardControlsWrapper leftAlign className="card-control-wrapper">
|
|
45
|
+
<Checkbox name="id" onChange={() => {}} onClick={() => {}} value />
|
|
46
|
+
</CardControlsWrapper>
|
|
47
|
+
</CardImgWrapper>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (!isDragging) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Wrapper>
|
|
61
|
+
<div style={getItemStyles(initialOffset, currentOffset, mouseOffset)} className="col-md-2">
|
|
62
|
+
{renderItem()}
|
|
63
|
+
</div>
|
|
64
|
+
</Wrapper>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default DragLayer;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
5
|
+
import { Text } from '@buffetjs/core';
|
|
6
|
+
|
|
7
|
+
const DropdownButton = styled(props => (
|
|
8
|
+
<Text
|
|
9
|
+
as="button"
|
|
10
|
+
fontWeight="semiBold"
|
|
11
|
+
color={props.isActive ? 'mediumBlue' : 'greyDark'}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
))`
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
height: 30px;
|
|
18
|
+
padding: 0 10px;
|
|
19
|
+
background-color: ${({ theme }) => theme.main.colors.white};
|
|
20
|
+
border: 1px solid ${({ theme }) => theme.main.colors.darkGrey};
|
|
21
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
22
|
+
&:active,
|
|
23
|
+
&:focus {
|
|
24
|
+
outline: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
> svg + span,
|
|
28
|
+
> span + svg {
|
|
29
|
+
margin-left: 10px;
|
|
30
|
+
}
|
|
31
|
+
> svg g {
|
|
32
|
+
stroke: ${({ theme }) => theme.main.colors.greyDark};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
${({ isActive, theme }) =>
|
|
36
|
+
isActive
|
|
37
|
+
? `
|
|
38
|
+
background-color: ${theme.main.colors.lightBlue};
|
|
39
|
+
border: 1px solid ${theme.main.colors.darkBlue};
|
|
40
|
+
color: ${theme.main.colors.mediumBlue};
|
|
41
|
+
> svg g {
|
|
42
|
+
stroke: ${theme.main.colors.mediumBlue};
|
|
43
|
+
}
|
|
44
|
+
`
|
|
45
|
+
: `
|
|
46
|
+
&:hover {
|
|
47
|
+
background-color: ${theme.main.colors.lightestGrey};
|
|
48
|
+
}
|
|
49
|
+
`}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
DropdownButton.defaultProps = {
|
|
53
|
+
isActive: false,
|
|
54
|
+
type: 'button',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
DropdownButton.propTypes = {
|
|
58
|
+
isActive: PropTypes.bool,
|
|
59
|
+
type: PropTypes.string,
|
|
60
|
+
...themePropTypes,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default DropdownButton;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
const DropdownSection = styled.div`
|
|
6
|
+
display: none;
|
|
7
|
+
position: absolute;
|
|
8
|
+
top: 38px;
|
|
9
|
+
left: 0;
|
|
10
|
+
z-index: 1046;
|
|
11
|
+
background-color: ${({ theme }) => theme.main.colors.white};
|
|
12
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
13
|
+
border: 1px solid ${({ theme }) => theme.main.colors.darkGrey};
|
|
14
|
+
box-shadow: 0 2px 4px ${({ theme }) => theme.main.colors.greyAlpha};
|
|
15
|
+
${({ isOpen }) => isOpen && 'display: block;'}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
DropdownSection.defaultProps = {
|
|
19
|
+
isOpen: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
DropdownSection.propTypes = {
|
|
23
|
+
isOpen: PropTypes.bool,
|
|
24
|
+
...themePropTypes,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default DropdownSection;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
4
|
+
import { Text } from '@buffetjs/core';
|
|
5
|
+
|
|
6
|
+
import formatDuration from './utils/formatDuration';
|
|
7
|
+
|
|
8
|
+
const Duration = styled(({ duration, ...rest }) => (
|
|
9
|
+
<Text {...rest} color="white" fontSize="md" fontWeight="semiBold">
|
|
10
|
+
{formatDuration(duration)}
|
|
11
|
+
</Text>
|
|
12
|
+
))`
|
|
13
|
+
position: absolute;
|
|
14
|
+
bottom: 10px;
|
|
15
|
+
right: 10px;
|
|
16
|
+
padding: 3px 5px;
|
|
17
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
18
|
+
background-color: ${({ theme }) => theme.main.colors.black};
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
Duration.propTypes = {
|
|
22
|
+
...themePropTypes,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default Duration;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
|
|
3
|
+
const formatDuration = seconds => {
|
|
4
|
+
const duration = moment('1900-01-01 00:00:00').add(seconds, 'seconds');
|
|
5
|
+
|
|
6
|
+
if (seconds >= 3600) {
|
|
7
|
+
return duration.format('HH:mm:ss');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return duration.format('mm:ss');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default formatDuration;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const CropWrapper = styled.div`
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
height: 100%;
|
|
8
|
+
width: 100%;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
> img {
|
|
13
|
+
display: block;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
max-height: 100%;
|
|
16
|
+
width: auto;
|
|
17
|
+
height: auto;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export default CropWrapper;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { dateFormats, dateToUtcTime } from 'strapi-helper-plugin';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { Text, Flex } from '@buffetjs/core';
|
|
7
|
+
|
|
8
|
+
import { formatBytes, getTrad } from '../../utils';
|
|
9
|
+
|
|
10
|
+
import FileDetailsBoxWrapper from './FileDetailsBoxWrapper';
|
|
11
|
+
|
|
12
|
+
const FileDetailsBox = ({ file }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
const fileSize = file.mime ? get(file, 'size', 0) : get(file, 'size', 0) / 1000;
|
|
15
|
+
const sections = [
|
|
16
|
+
{
|
|
17
|
+
key: 0,
|
|
18
|
+
rows: [
|
|
19
|
+
{ label: 'modal.file-details.size', value: formatBytes(fileSize, 0) },
|
|
20
|
+
{
|
|
21
|
+
label: 'modal.file-details.date',
|
|
22
|
+
value: file.created_at ? dateToUtcTime(file.created_at).format(dateFormats.date) : '-',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: 1,
|
|
28
|
+
type: 'spacer',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: 2,
|
|
32
|
+
rows: [
|
|
33
|
+
{
|
|
34
|
+
label: 'modal.file-details.dimensions',
|
|
35
|
+
value: file.width ? `${file.width}×${file.height}` : '-',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'modal.file-details.extension',
|
|
39
|
+
value: file.ext ? file.ext.replace('.', '') : '-',
|
|
40
|
+
textTransform: 'uppercase',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<FileDetailsBoxWrapper>
|
|
48
|
+
{sections.map(({ key, rows, type }) => {
|
|
49
|
+
if (type === 'spacer') {
|
|
50
|
+
return (
|
|
51
|
+
<section key={key}>
|
|
52
|
+
<Text lineHeight="18px"> </Text>
|
|
53
|
+
</section>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Flex justifyContent="space-between" key={key}>
|
|
59
|
+
{rows.map(rowItem => {
|
|
60
|
+
return (
|
|
61
|
+
<div key={rowItem.label} style={{ width: '50%' }}>
|
|
62
|
+
<Text color="grey" fontWeight="bold" textTransform="capitalize" lineHeight="18px">
|
|
63
|
+
{formatMessage({ id: getTrad(rowItem.label) })}
|
|
64
|
+
</Text>
|
|
65
|
+
<Text color="grey" textTransform={rowItem.textTransform || ''} lineHeight="18px">
|
|
66
|
+
{rowItem.value}
|
|
67
|
+
</Text>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</Flex>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</FileDetailsBoxWrapper>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
FileDetailsBox.defaultProps = {
|
|
79
|
+
file: {
|
|
80
|
+
size: 0,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
FileDetailsBox.propTypes = {
|
|
85
|
+
file: PropTypes.shape({
|
|
86
|
+
mime: PropTypes.string,
|
|
87
|
+
created_at: PropTypes.string,
|
|
88
|
+
ext: PropTypes.string,
|
|
89
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
90
|
+
size: PropTypes.number,
|
|
91
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default FileDetailsBox;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
3
|
+
|
|
4
|
+
const FileDetailsBoxWrapper = styled.div`
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-height: 119px;
|
|
7
|
+
padding: 16px;
|
|
8
|
+
background-color: ${({ theme }) => theme.main.colors.lightGrey};
|
|
9
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
FileDetailsBoxWrapper.propTypes = themePropTypes;
|
|
13
|
+
|
|
14
|
+
export default FileDetailsBoxWrapper;
|