@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,41 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
import CardImgWrapper from '../CardImgWrapper';
|
|
6
|
+
|
|
7
|
+
const FileWrapper = styled(CardImgWrapper)`
|
|
8
|
+
height: 401px;
|
|
9
|
+
width: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
position: relative;
|
|
12
|
+
background-color: ${({ theme }) => theme.main.colors.black};
|
|
13
|
+
${({ hasError, theme }) => hasError && `border: 2px solid ${theme.main.colors.orange};`}
|
|
14
|
+
|
|
15
|
+
.cropper-view-box {
|
|
16
|
+
outline-color: ${({ theme }) => theme.main.colors.white};
|
|
17
|
+
}
|
|
18
|
+
.cropper-point {
|
|
19
|
+
background-color: ${({ theme }) => theme.main.colors.white};
|
|
20
|
+
border-radius: 50%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.point-se {
|
|
24
|
+
&:before {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
height: 5px;
|
|
28
|
+
width: 5px;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
FileWrapper.defaultProps = {
|
|
33
|
+
hasError: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
FileWrapper.propTypes = {
|
|
37
|
+
hasError: PropTypes.bool,
|
|
38
|
+
...themePropTypes,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default FileWrapper;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Text } from '@buffetjs/core';
|
|
4
|
+
|
|
5
|
+
const SizeBox = styled(props => <Text {...props} fontSize="md" color="white" as="div" />)`
|
|
6
|
+
position: absolute;
|
|
7
|
+
bottom: 0;
|
|
8
|
+
right: 0;
|
|
9
|
+
background: #000000;
|
|
10
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export default SizeBox;
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
2
|
+
/* eslint-disable react/jsx-fragments */
|
|
3
|
+
import React, {
|
|
4
|
+
Fragment,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useState,
|
|
7
|
+
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useImperativeHandle,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
12
|
+
import axios from 'axios';
|
|
13
|
+
import { get } from 'lodash';
|
|
14
|
+
import PropTypes from 'prop-types';
|
|
15
|
+
import { Row } from 'reactstrap';
|
|
16
|
+
import { Inputs } from '@buffetjs/custom';
|
|
17
|
+
import { useGlobalContext, prefixFileUrlWithBackendUrl } from 'strapi-helper-plugin';
|
|
18
|
+
import Cropper from 'cropperjs';
|
|
19
|
+
import 'cropperjs/dist/cropper.css';
|
|
20
|
+
import { createFileToDownloadName } from '../../utils';
|
|
21
|
+
import CardControl from '../CardControl';
|
|
22
|
+
import CardControlsWrapper from '../CardControlsWrapper';
|
|
23
|
+
import CardPreview from '../CardPreview';
|
|
24
|
+
import InfiniteLoadingIndicator from '../InfiniteLoadingIndicator';
|
|
25
|
+
import ModalSection from '../ModalSection';
|
|
26
|
+
import VideoPlayer from '../VideoPlayer';
|
|
27
|
+
import CropWrapper from './CropWrapper';
|
|
28
|
+
import FileDetailsBox from './FileDetailsBox';
|
|
29
|
+
import FileWrapper from './FileWrapper';
|
|
30
|
+
import FormWrapper from './FormWrapper';
|
|
31
|
+
import SizeBox from './SizeBox';
|
|
32
|
+
import Wrapper from './Wrapper';
|
|
33
|
+
import ErrorMessage from './ErrorMessage';
|
|
34
|
+
import form from './utils/form';
|
|
35
|
+
import isImageType from './utils/isImageType';
|
|
36
|
+
import isVideoType from './utils/isVideoType';
|
|
37
|
+
|
|
38
|
+
const EditForm = forwardRef(
|
|
39
|
+
(
|
|
40
|
+
{
|
|
41
|
+
canCopyLink,
|
|
42
|
+
canDownload,
|
|
43
|
+
components,
|
|
44
|
+
fileToEdit,
|
|
45
|
+
isEditingUploadedFile,
|
|
46
|
+
isFormDisabled,
|
|
47
|
+
onAbortUpload,
|
|
48
|
+
onChange,
|
|
49
|
+
onClickDeleteFileToUpload,
|
|
50
|
+
onSubmitEdit,
|
|
51
|
+
setCropResult,
|
|
52
|
+
toggleDisableForm,
|
|
53
|
+
},
|
|
54
|
+
ref
|
|
55
|
+
) => {
|
|
56
|
+
const { formatMessage } = useGlobalContext();
|
|
57
|
+
const [isCropping, setIsCropping] = useState(false);
|
|
58
|
+
const [infos, setInfos] = useState({ width: null, height: null });
|
|
59
|
+
const [src, setSrc] = useState(null);
|
|
60
|
+
const cacheRef = useRef(performance.now());
|
|
61
|
+
|
|
62
|
+
const fileURL = get(fileToEdit, ['file', 'url'], null);
|
|
63
|
+
const prefixedFileURL = fileURL
|
|
64
|
+
? prefixFileUrlWithBackendUrl(`${fileURL}?${cacheRef.current}`)
|
|
65
|
+
: null;
|
|
66
|
+
const downloadFileName = createFileToDownloadName(fileToEdit);
|
|
67
|
+
const mimeType =
|
|
68
|
+
get(fileToEdit, ['file', 'type'], null) || get(fileToEdit, ['file', 'mime'], '');
|
|
69
|
+
const isImg = isImageType(mimeType);
|
|
70
|
+
const isVideo = isVideoType(mimeType);
|
|
71
|
+
const canCrop = isImg && !mimeType.includes('svg') && !mimeType.includes('gif');
|
|
72
|
+
const aRef = useRef();
|
|
73
|
+
const imgRef = useRef();
|
|
74
|
+
const inputRef = useRef();
|
|
75
|
+
const cropper = useRef();
|
|
76
|
+
|
|
77
|
+
useImperativeHandle(ref, () => ({
|
|
78
|
+
click: () => {
|
|
79
|
+
inputRef.current.click();
|
|
80
|
+
setIsCropping(false);
|
|
81
|
+
},
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (isImg || isVideo) {
|
|
86
|
+
if (prefixedFileURL) {
|
|
87
|
+
setSrc(prefixedFileURL);
|
|
88
|
+
} else {
|
|
89
|
+
setSrc(URL.createObjectURL(fileToEdit.file));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [isImg, isVideo, fileToEdit, prefixedFileURL]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (isCropping) {
|
|
96
|
+
cropper.current = new Cropper(imgRef.current, {
|
|
97
|
+
modal: true,
|
|
98
|
+
initialAspectRatio: 16 / 9,
|
|
99
|
+
movable: true,
|
|
100
|
+
zoomable: false,
|
|
101
|
+
cropBoxResizable: true,
|
|
102
|
+
background: false,
|
|
103
|
+
crop: handleResize,
|
|
104
|
+
});
|
|
105
|
+
} else if (cropper.current) {
|
|
106
|
+
cropper.current.destroy();
|
|
107
|
+
|
|
108
|
+
setInfos({ width: null, height: null });
|
|
109
|
+
toggleDisableForm(false);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
if (cropper.current) {
|
|
114
|
+
cropper.current.destroy();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
+
}, [cropper, isCropping]);
|
|
119
|
+
|
|
120
|
+
const handleResize = ({ detail: { height, width } }) => {
|
|
121
|
+
const roundedDataHeight = Math.round(height);
|
|
122
|
+
const roundedDataWidth = Math.round(width);
|
|
123
|
+
|
|
124
|
+
setInfos({ width: roundedDataWidth, height: roundedDataHeight });
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleToggleCropMode = () => {
|
|
128
|
+
setIsCropping(prev => {
|
|
129
|
+
if (!prev && isEditingUploadedFile) {
|
|
130
|
+
toggleDisableForm(true);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return !prev;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const handleChange = ({ target: { files } }) => {
|
|
138
|
+
if (files[0]) {
|
|
139
|
+
onChange({ target: { name: 'file', value: files[0] } });
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const handleClick = async () => {
|
|
144
|
+
const cropResult = await getCroppedResult();
|
|
145
|
+
|
|
146
|
+
setCropResult(cropResult);
|
|
147
|
+
|
|
148
|
+
setIsCropping(false);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const getCroppedResult = () => {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
try {
|
|
154
|
+
const canvas = cropper.current.getCroppedCanvas();
|
|
155
|
+
|
|
156
|
+
canvas.toBlob(
|
|
157
|
+
async blob => {
|
|
158
|
+
const {
|
|
159
|
+
file: { lastModifiedDate, lastModified, name },
|
|
160
|
+
} = fileToEdit;
|
|
161
|
+
|
|
162
|
+
resolve(
|
|
163
|
+
new File([blob], name, {
|
|
164
|
+
type: mimeType,
|
|
165
|
+
lastModified,
|
|
166
|
+
lastModifiedDate,
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
},
|
|
170
|
+
mimeType,
|
|
171
|
+
1
|
|
172
|
+
);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
reject();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const handleClickEditCroppedFile = async (e, shouldDuplicate = false) => {
|
|
180
|
+
try {
|
|
181
|
+
const file = await getCroppedResult();
|
|
182
|
+
|
|
183
|
+
onSubmitEdit(e, shouldDuplicate, file, true);
|
|
184
|
+
} catch (err) {
|
|
185
|
+
// Silent
|
|
186
|
+
} finally {
|
|
187
|
+
setIsCropping(false);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const handleClickDelete = () => {
|
|
192
|
+
onClickDeleteFileToUpload(fileToEdit.originalIndex);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const handleCopy = () => {
|
|
196
|
+
strapi.notification.toggle({
|
|
197
|
+
type: 'info',
|
|
198
|
+
message: { id: 'notification.link-copied' },
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const handleClickDownload = () => {
|
|
203
|
+
axios
|
|
204
|
+
.get(prefixFileUrlWithBackendUrl(fileURL), {
|
|
205
|
+
responseType: 'blob',
|
|
206
|
+
})
|
|
207
|
+
.then(({ data }) => {
|
|
208
|
+
const blobUrl = URL.createObjectURL(data);
|
|
209
|
+
|
|
210
|
+
aRef.current.download = downloadFileName;
|
|
211
|
+
aRef.current.href = blobUrl;
|
|
212
|
+
|
|
213
|
+
aRef.current.click();
|
|
214
|
+
})
|
|
215
|
+
.catch(err => {
|
|
216
|
+
console.error(err);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const handleSubmit = e => {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
|
|
223
|
+
onSubmitEdit(e);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const CheckButton = components.CheckControl;
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<form onSubmit={handleSubmit}>
|
|
230
|
+
<ModalSection>
|
|
231
|
+
<Wrapper>
|
|
232
|
+
<div className="row">
|
|
233
|
+
<div className="col-6">
|
|
234
|
+
<FileWrapper hasError={fileToEdit.hasError}>
|
|
235
|
+
{fileToEdit.isUploading ? (
|
|
236
|
+
<InfiniteLoadingIndicator onClick={onAbortUpload} />
|
|
237
|
+
) : (
|
|
238
|
+
<Fragment>
|
|
239
|
+
<CardControlsWrapper className="card-control-wrapper-displayed">
|
|
240
|
+
{!isCropping ? (
|
|
241
|
+
<>
|
|
242
|
+
<CardControl
|
|
243
|
+
color="#9EA7B8"
|
|
244
|
+
type="trash-alt"
|
|
245
|
+
onClick={handleClickDelete}
|
|
246
|
+
title="delete"
|
|
247
|
+
/>
|
|
248
|
+
{fileURL && (
|
|
249
|
+
<>
|
|
250
|
+
{canDownload && (
|
|
251
|
+
<CardControl
|
|
252
|
+
color="#9EA7B8"
|
|
253
|
+
onClick={handleClickDownload}
|
|
254
|
+
type="download"
|
|
255
|
+
title="download"
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
258
|
+
<a
|
|
259
|
+
title={fileToEdit.fileInfo.name}
|
|
260
|
+
style={{ display: 'none' }}
|
|
261
|
+
ref={aRef}
|
|
262
|
+
>
|
|
263
|
+
hidden
|
|
264
|
+
</a>
|
|
265
|
+
{canCopyLink && (
|
|
266
|
+
<CopyToClipboard
|
|
267
|
+
onCopy={handleCopy}
|
|
268
|
+
text={prefixFileUrlWithBackendUrl(fileURL)}
|
|
269
|
+
>
|
|
270
|
+
<CardControl color="#9EA7B8" type="link" title="copy-link" />
|
|
271
|
+
</CopyToClipboard>
|
|
272
|
+
)}
|
|
273
|
+
</>
|
|
274
|
+
)}
|
|
275
|
+
{canCrop && (
|
|
276
|
+
<CardControl
|
|
277
|
+
color="#9EA7B8"
|
|
278
|
+
onClick={handleToggleCropMode}
|
|
279
|
+
type="crop"
|
|
280
|
+
title="crop"
|
|
281
|
+
/>
|
|
282
|
+
)}
|
|
283
|
+
</>
|
|
284
|
+
) : (
|
|
285
|
+
<>
|
|
286
|
+
<CardControl
|
|
287
|
+
color="#F64D0A"
|
|
288
|
+
onClick={handleToggleCropMode}
|
|
289
|
+
type="times"
|
|
290
|
+
title="cancel"
|
|
291
|
+
iconStyle={{ height: '1.6rem', width: '1.6rem' }}
|
|
292
|
+
/>
|
|
293
|
+
<CheckButton
|
|
294
|
+
color="#6DBB1A"
|
|
295
|
+
onClick={handleClick}
|
|
296
|
+
onSubmitEdit={handleClickEditCroppedFile}
|
|
297
|
+
type="check"
|
|
298
|
+
title="save"
|
|
299
|
+
/>
|
|
300
|
+
</>
|
|
301
|
+
)}
|
|
302
|
+
</CardControlsWrapper>
|
|
303
|
+
{isImg ? (
|
|
304
|
+
<CropWrapper>
|
|
305
|
+
<img
|
|
306
|
+
src={src}
|
|
307
|
+
alt={get(fileToEdit, ['file', 'name'], '')}
|
|
308
|
+
ref={isCropping ? imgRef : null}
|
|
309
|
+
/>
|
|
310
|
+
</CropWrapper>
|
|
311
|
+
) : (
|
|
312
|
+
<>
|
|
313
|
+
{isVideo ? (
|
|
314
|
+
<VideoPlayer src={src} />
|
|
315
|
+
) : (
|
|
316
|
+
<CardPreview type={mimeType} url={src} />
|
|
317
|
+
)}
|
|
318
|
+
</>
|
|
319
|
+
)}
|
|
320
|
+
|
|
321
|
+
{isCropping && infos.width !== null && (
|
|
322
|
+
<SizeBox>
|
|
323
|
+
|
|
324
|
+
{infos.width} x {infos.height}
|
|
325
|
+
|
|
326
|
+
</SizeBox>
|
|
327
|
+
)}
|
|
328
|
+
</Fragment>
|
|
329
|
+
)}
|
|
330
|
+
</FileWrapper>
|
|
331
|
+
{fileToEdit.hasError && (
|
|
332
|
+
<ErrorMessage title={fileToEdit.errorMessage}>
|
|
333
|
+
{fileToEdit.errorMessage}
|
|
334
|
+
</ErrorMessage>
|
|
335
|
+
)}
|
|
336
|
+
</div>
|
|
337
|
+
<div className="col-6">
|
|
338
|
+
<FileDetailsBox file={fileToEdit.file} />
|
|
339
|
+
<FormWrapper>
|
|
340
|
+
{form.map(({ key, inputs }) => {
|
|
341
|
+
return (
|
|
342
|
+
<Row key={key}>
|
|
343
|
+
{inputs.map(input => {
|
|
344
|
+
return (
|
|
345
|
+
<div className="col-12" key={input.name}>
|
|
346
|
+
<Inputs
|
|
347
|
+
{...input}
|
|
348
|
+
disabled={isFormDisabled}
|
|
349
|
+
description={
|
|
350
|
+
input.description ? formatMessage(input.description) : null
|
|
351
|
+
}
|
|
352
|
+
label={formatMessage(input.label)}
|
|
353
|
+
onChange={onChange}
|
|
354
|
+
type="text"
|
|
355
|
+
value={get(fileToEdit, input.name, '')}
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
);
|
|
359
|
+
})}
|
|
360
|
+
</Row>
|
|
361
|
+
);
|
|
362
|
+
})}
|
|
363
|
+
</FormWrapper>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</Wrapper>
|
|
367
|
+
<input
|
|
368
|
+
ref={inputRef}
|
|
369
|
+
type="file"
|
|
370
|
+
multiple={false}
|
|
371
|
+
onChange={handleChange}
|
|
372
|
+
style={{ display: 'none' }}
|
|
373
|
+
accept={mimeType
|
|
374
|
+
.split('/')
|
|
375
|
+
.map((v, i) => {
|
|
376
|
+
if (i === 1) {
|
|
377
|
+
return '*';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return v;
|
|
381
|
+
})
|
|
382
|
+
.join('/')}
|
|
383
|
+
/>
|
|
384
|
+
<button type="submit" style={{ display: 'none' }}>
|
|
385
|
+
hidden button to make to get the native form event
|
|
386
|
+
</button>
|
|
387
|
+
</ModalSection>
|
|
388
|
+
</form>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
EditForm.defaultProps = {
|
|
394
|
+
canCopyLink: true,
|
|
395
|
+
canDownload: true,
|
|
396
|
+
components: {
|
|
397
|
+
CheckControl: CardControl,
|
|
398
|
+
},
|
|
399
|
+
fileToEdit: null,
|
|
400
|
+
isEditingUploadedFile: false,
|
|
401
|
+
isFormDisabled: false,
|
|
402
|
+
onAbortUpload: () => {},
|
|
403
|
+
onChange: () => {},
|
|
404
|
+
onClickDeleteFileToUpload: () => {},
|
|
405
|
+
onSubmitEdit: e => e.preventDefault(),
|
|
406
|
+
setCropResult: () => {},
|
|
407
|
+
toggleDisableForm: () => {},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
EditForm.propTypes = {
|
|
411
|
+
canCopyLink: PropTypes.bool,
|
|
412
|
+
canDownload: PropTypes.bool,
|
|
413
|
+
onAbortUpload: PropTypes.func,
|
|
414
|
+
components: PropTypes.object,
|
|
415
|
+
fileToEdit: PropTypes.object,
|
|
416
|
+
isEditingUploadedFile: PropTypes.bool,
|
|
417
|
+
isFormDisabled: PropTypes.bool,
|
|
418
|
+
onChange: PropTypes.func,
|
|
419
|
+
onClickDeleteFileToUpload: PropTypes.func,
|
|
420
|
+
onSubmitEdit: PropTypes.func,
|
|
421
|
+
setCropResult: PropTypes.func,
|
|
422
|
+
toggleDisableForm: PropTypes.func,
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export default EditForm;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getTrad } from '../../../utils';
|
|
2
|
+
|
|
3
|
+
const form = [
|
|
4
|
+
{
|
|
5
|
+
key: 1,
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
label: { id: getTrad('form.input.label.file-name') },
|
|
9
|
+
name: 'fileInfo.name',
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: 2,
|
|
15
|
+
inputs: [
|
|
16
|
+
{
|
|
17
|
+
description: { id: getTrad('form.input.description.file-alt') },
|
|
18
|
+
label: { id: getTrad('form.input.label.file-alt') },
|
|
19
|
+
name: 'fileInfo.alternativeText',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 3,
|
|
25
|
+
inputs: [
|
|
26
|
+
{
|
|
27
|
+
label: { id: getTrad('form.input.label.file-caption') },
|
|
28
|
+
name: 'fileInfo.caption',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export default form;
|
|
@@ -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 Wrapper = styled.div`
|
|
6
|
+
font-size: 54px;
|
|
7
|
+
color: ${({ theme, colored }) =>
|
|
8
|
+
colored ? theme.main.colors.lightOrange : theme.main.colors.grey};
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
Wrapper.defaultProps = {
|
|
12
|
+
colored: false,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Wrapper.propTypes = {
|
|
16
|
+
colored: PropTypes.bool,
|
|
17
|
+
...themePropTypes,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default Wrapper;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*
|
|
4
|
+
* FileIcon
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
|
+
|
|
11
|
+
import extensions from './utils/extensions.json';
|
|
12
|
+
|
|
13
|
+
import Wrapper from './Wrapper';
|
|
14
|
+
|
|
15
|
+
const FileIcon = ({ ext }) => {
|
|
16
|
+
const iconName = Object.keys(extensions).find(key => extensions[key].includes(ext)) || 'alt';
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Wrapper type="file" colored={iconName === 'pdf'}>
|
|
20
|
+
<FontAwesomeIcon icon={['far', `file-${iconName}`]} />
|
|
21
|
+
</Wrapper>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
FileIcon.defaultProps = {
|
|
26
|
+
ext: 'alt',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
FileIcon.propTypes = {
|
|
30
|
+
ext: PropTypes.string,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default FileIcon;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { upperCase } from 'lodash';
|
|
4
|
+
|
|
5
|
+
import { Text } from '@buffetjs/core';
|
|
6
|
+
|
|
7
|
+
const FileInfos = ({ extension, height, size, width }) => {
|
|
8
|
+
return (
|
|
9
|
+
<Text color="grey" fontSize="xs" ellipsis>
|
|
10
|
+
{upperCase(extension)}
|
|
11
|
+
—
|
|
12
|
+
{width && height && `${width}×${height}\u00A0\u2014\u00A0`}
|
|
13
|
+
{size}
|
|
14
|
+
</Text>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
FileInfos.defaultProps = {
|
|
19
|
+
height: null,
|
|
20
|
+
extension: null,
|
|
21
|
+
width: null,
|
|
22
|
+
size: null,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
FileInfos.propTypes = {
|
|
26
|
+
height: PropTypes.number,
|
|
27
|
+
extension: PropTypes.string,
|
|
28
|
+
size: PropTypes.string,
|
|
29
|
+
width: PropTypes.number,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default FileInfos;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Padded } from '@buffetjs/core';
|
|
4
|
+
|
|
5
|
+
import FiltersList from '../FiltersList';
|
|
6
|
+
import FiltersPicker from '../FiltersPicker';
|
|
7
|
+
|
|
8
|
+
const Filters = ({ onChange, onClick, filters }) => {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<FiltersPicker onChange={onChange} />
|
|
12
|
+
<Padded left size="sm" />
|
|
13
|
+
<FiltersList filters={filters} onClick={onClick} />
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Filters.defaultProps = {
|
|
19
|
+
filters: [],
|
|
20
|
+
onChange: () => {},
|
|
21
|
+
onClick: () => {},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
Filters.propTypes = {
|
|
25
|
+
filters: PropTypes.arrayOf(PropTypes.object),
|
|
26
|
+
onChange: PropTypes.func,
|
|
27
|
+
onClick: PropTypes.func,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default Filters;
|