@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,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FilterButton } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
import formatFilter from './utils/formatFilter';
|
|
6
|
+
|
|
7
|
+
const FiltersList = ({ filters, onClick }) => {
|
|
8
|
+
return filters.map((item, index) => {
|
|
9
|
+
const formattedValue = formatFilter(item);
|
|
10
|
+
const { name, filter, value, isDisabled } = formattedValue;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
!isDisabled && (
|
|
14
|
+
<FilterButton
|
|
15
|
+
onClick={() => onClick(index)}
|
|
16
|
+
key={`${name}${filter}${value}`}
|
|
17
|
+
label={formattedValue}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
FiltersList.defaultProps = {
|
|
25
|
+
filters: [],
|
|
26
|
+
onClick: () => {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
FiltersList.propTypes = {
|
|
30
|
+
onClick: PropTypes.func,
|
|
31
|
+
filters: PropTypes.arrayOf(PropTypes.object),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default FiltersList;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { dateFormats, dateToUtcTime } from 'strapi-helper-plugin';
|
|
3
|
+
import { formatBytes } from '../../../utils';
|
|
4
|
+
|
|
5
|
+
const formatFilter = filterToFormat => {
|
|
6
|
+
const { name, filter, value } = filterToFormat;
|
|
7
|
+
|
|
8
|
+
// Size filter - Convert bites to human-readable format
|
|
9
|
+
if (name === 'size') {
|
|
10
|
+
return {
|
|
11
|
+
...filterToFormat,
|
|
12
|
+
value: formatBytes(value),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Mime filter - Display different wording than the received ones
|
|
17
|
+
if (name === 'mime') {
|
|
18
|
+
return {
|
|
19
|
+
...filterToFormat,
|
|
20
|
+
name: 'type',
|
|
21
|
+
filter: filter === '_contains' ? '=' : '_ne',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Format date to readable format
|
|
26
|
+
if (moment(value)._isValid === true) {
|
|
27
|
+
return {
|
|
28
|
+
...filterToFormat,
|
|
29
|
+
value: dateToUtcTime(value).format(dateFormats.datetime),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return filterToFormat;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default formatFilter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* InputWithAutoFocus that programatically manage the autofocus of another one
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { InputText, Select } from '@buffetjs/core';
|
|
9
|
+
import { DateTime } from '@buffetjs/custom';
|
|
10
|
+
import SizeInput from './SizeInput';
|
|
11
|
+
|
|
12
|
+
const getInputType = type => {
|
|
13
|
+
switch (type) {
|
|
14
|
+
case 'datetime':
|
|
15
|
+
return DateTime;
|
|
16
|
+
case 'integer':
|
|
17
|
+
return SizeInput;
|
|
18
|
+
case 'enum':
|
|
19
|
+
return Select;
|
|
20
|
+
default:
|
|
21
|
+
return InputText;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function Input({ type, ...rest }) {
|
|
26
|
+
const Component = getInputType(type);
|
|
27
|
+
|
|
28
|
+
return <Component {...rest} autoComplete="off" />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Input.propTypes = {
|
|
32
|
+
type: PropTypes.string.isRequired,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Input;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* SizeInput
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import { InputNumber, Select, Padded, Flex } from '@buffetjs/core';
|
|
10
|
+
|
|
11
|
+
function SizeInput({ onChange, value, ...rest }) {
|
|
12
|
+
const options = ['KB', 'MB', 'GB'];
|
|
13
|
+
const [size, setSize] = useState(0);
|
|
14
|
+
const [format, setFormat] = useState('KB');
|
|
15
|
+
|
|
16
|
+
const handleChangeValue = ({ target: { value } }) => {
|
|
17
|
+
setSize(value);
|
|
18
|
+
|
|
19
|
+
onChange({
|
|
20
|
+
target: {
|
|
21
|
+
name: 'value',
|
|
22
|
+
value: `${value}${format}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const handleChangeFormat = ({ target: { value } }) => {
|
|
28
|
+
setFormat(value);
|
|
29
|
+
|
|
30
|
+
onChange({
|
|
31
|
+
target: {
|
|
32
|
+
name: 'value',
|
|
33
|
+
value: `${size}${value}`,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Flex justifyContent="space-between">
|
|
40
|
+
<InputNumber {...rest} name="size_value" onChange={handleChangeValue} value={size} />
|
|
41
|
+
<Padded left />
|
|
42
|
+
<Select name="format_value" onChange={handleChangeFormat} options={options} value={format} />
|
|
43
|
+
</Flex>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
SizeInput.defaultProps = {
|
|
48
|
+
onChange: () => {},
|
|
49
|
+
value: null,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
SizeInput.propTypes = {
|
|
53
|
+
onChange: PropTypes.func,
|
|
54
|
+
value: PropTypes.string,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default SizeInput;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useReducer } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import { Select } from '@buffetjs/core';
|
|
5
|
+
import { getFilterType, useGlobalContext } from 'strapi-helper-plugin';
|
|
6
|
+
import { getTrad, getFileModelTimestamps } from '../../../utils';
|
|
7
|
+
import init from './init';
|
|
8
|
+
import reducer, { initialState } from './reducer';
|
|
9
|
+
|
|
10
|
+
import Wrapper from './Wrapper';
|
|
11
|
+
import InputWrapper from './InputWrapper';
|
|
12
|
+
import FilterButton from './FilterButton';
|
|
13
|
+
import FilterInput from './FilterInput';
|
|
14
|
+
|
|
15
|
+
const FiltersCard = ({ onChange }) => {
|
|
16
|
+
const { plugins } = useGlobalContext();
|
|
17
|
+
const timestamps = getFileModelTimestamps(plugins);
|
|
18
|
+
const [state, dispatch] = useReducer(reducer, initialState, () => init(initialState, timestamps));
|
|
19
|
+
const { name, filter, filtersForm, value } = state.toJS();
|
|
20
|
+
|
|
21
|
+
const type = filtersForm[name].type;
|
|
22
|
+
const filtersOptions = getFilterType(type);
|
|
23
|
+
const options = ['image', 'video', 'file'];
|
|
24
|
+
|
|
25
|
+
const handleChange = ({ target: { name, value } }) => {
|
|
26
|
+
dispatch({
|
|
27
|
+
type: 'ON_CHANGE',
|
|
28
|
+
name,
|
|
29
|
+
value,
|
|
30
|
+
defaultValue: value === 'mime' ? options[0] : null,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const addFilter = () => {
|
|
35
|
+
onChange({ target: { value: { name, filter, value } } });
|
|
36
|
+
|
|
37
|
+
dispatch({
|
|
38
|
+
type: 'RESET_FORM',
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const renderFiltersOptions = () => {
|
|
43
|
+
return filtersOptions.map(({ id, value }) => (
|
|
44
|
+
<FormattedMessage id={id} key={id}>
|
|
45
|
+
{msg => <option value={value}>{msg}</option>}
|
|
46
|
+
</FormattedMessage>
|
|
47
|
+
));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const renderNamesOptions = () => {
|
|
51
|
+
return Object.keys(filtersForm).map(key => {
|
|
52
|
+
return (
|
|
53
|
+
<option key={key} value={key}>
|
|
54
|
+
{key === 'mime' ? 'type' : key}
|
|
55
|
+
</option>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Wrapper>
|
|
62
|
+
<InputWrapper>
|
|
63
|
+
<Select onChange={handleChange} name="name" options={renderNamesOptions()} value={name} />
|
|
64
|
+
</InputWrapper>
|
|
65
|
+
<InputWrapper>
|
|
66
|
+
<Select
|
|
67
|
+
onChange={handleChange}
|
|
68
|
+
name="filter"
|
|
69
|
+
options={renderFiltersOptions()}
|
|
70
|
+
value={filter}
|
|
71
|
+
/>
|
|
72
|
+
</InputWrapper>
|
|
73
|
+
<InputWrapper>
|
|
74
|
+
<FilterInput
|
|
75
|
+
type={type}
|
|
76
|
+
onChange={handleChange}
|
|
77
|
+
name="value"
|
|
78
|
+
options={options}
|
|
79
|
+
value={value}
|
|
80
|
+
/>
|
|
81
|
+
</InputWrapper>
|
|
82
|
+
<FilterButton icon onClick={addFilter}>
|
|
83
|
+
<FormattedMessage id={getTrad('filter.add')} />
|
|
84
|
+
</FilterButton>
|
|
85
|
+
</Wrapper>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
FiltersCard.defaultProps = {
|
|
90
|
+
onChange: () => {},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
FiltersCard.propTypes = {
|
|
94
|
+
onChange: PropTypes.func,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default FiltersCard;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const init = (initialState, timestamps) => {
|
|
2
|
+
const [created_at, updated_at] = timestamps;
|
|
3
|
+
|
|
4
|
+
return initialState
|
|
5
|
+
.update('name', () => created_at)
|
|
6
|
+
.updateIn(['filtersForm'], object => {
|
|
7
|
+
return object.keySeq().reduce((acc, current) => {
|
|
8
|
+
if (current === 'created_at' && created_at !== 'created_at') {
|
|
9
|
+
return acc.set(created_at, object.get('created_at')).remove('created_at');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (current === 'updated_at' && updated_at !== 'updated_at') {
|
|
13
|
+
return acc.set(updated_at, object.get('updated_at')).remove('updated_at');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return acc;
|
|
17
|
+
}, object);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default init;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import { dateToUtcTime } from 'strapi-helper-plugin';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
|
|
5
|
+
import filtersForm from './utils/filtersForm';
|
|
6
|
+
|
|
7
|
+
const initialState = fromJS({
|
|
8
|
+
name: 'created_at',
|
|
9
|
+
filter: '=',
|
|
10
|
+
value: dateToUtcTime(moment()),
|
|
11
|
+
filtersForm,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function reducer(state, action) {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case 'ON_CHANGE': {
|
|
17
|
+
const { name, value, defaultValue } = action;
|
|
18
|
+
|
|
19
|
+
if (name === 'name') {
|
|
20
|
+
return state
|
|
21
|
+
.update(name, () => value)
|
|
22
|
+
.update('filter', () => state.getIn(['filtersForm', value, 'defaultFilter']))
|
|
23
|
+
.update(
|
|
24
|
+
'value',
|
|
25
|
+
() => defaultValue || state.getIn(['filtersForm', value, 'defaultValue'])
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return state.update(name, () => value);
|
|
30
|
+
}
|
|
31
|
+
case 'RESET_FORM':
|
|
32
|
+
return initialState
|
|
33
|
+
.set(
|
|
34
|
+
'name',
|
|
35
|
+
state
|
|
36
|
+
.get('filtersForm')
|
|
37
|
+
.keySeq()
|
|
38
|
+
.first()
|
|
39
|
+
)
|
|
40
|
+
.update('filtersForm', () => state.get('filtersForm'));
|
|
41
|
+
default:
|
|
42
|
+
return state;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default reducer;
|
|
47
|
+
export { initialState };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { dateToUtcTime } from 'strapi-helper-plugin';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
|
|
4
|
+
const filtersForm = {
|
|
5
|
+
created_at: {
|
|
6
|
+
type: 'datetime',
|
|
7
|
+
defaultFilter: '=',
|
|
8
|
+
defaultValue: dateToUtcTime(moment()),
|
|
9
|
+
},
|
|
10
|
+
updated_at: {
|
|
11
|
+
type: 'datetime',
|
|
12
|
+
defaultFilter: '=',
|
|
13
|
+
defaultValue: dateToUtcTime(moment()),
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
type: 'integer',
|
|
17
|
+
defaultFilter: '=',
|
|
18
|
+
defaultValue: '0KB',
|
|
19
|
+
},
|
|
20
|
+
mime: {
|
|
21
|
+
type: 'enum',
|
|
22
|
+
defaultFilter: '_contains',
|
|
23
|
+
defaultValue: 'image',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default filtersForm;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import { FilterIcon } from 'strapi-helper-plugin';
|
|
5
|
+
import { Picker } from '@buffetjs/core';
|
|
6
|
+
import FiltersCard from './FiltersCard';
|
|
7
|
+
|
|
8
|
+
import formatFilter from './utils/formatFilter';
|
|
9
|
+
|
|
10
|
+
const FiltersPicker = ({ onChange }) => {
|
|
11
|
+
const handleChange = ({ target: { value } }) => {
|
|
12
|
+
onChange({ target: { name: 'filters', value: formatFilter(value) } });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Picker
|
|
17
|
+
renderButtonContent={() => (
|
|
18
|
+
<>
|
|
19
|
+
<FilterIcon />
|
|
20
|
+
<FormattedMessage id="app.utils.filters" />
|
|
21
|
+
</>
|
|
22
|
+
)}
|
|
23
|
+
renderSectionContent={onToggle => (
|
|
24
|
+
<FiltersCard
|
|
25
|
+
onChange={e => {
|
|
26
|
+
handleChange(e);
|
|
27
|
+
onToggle();
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
)}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
FiltersPicker.defaultProps = {
|
|
36
|
+
onChange: () => {},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
FiltersPicker.propTypes = {
|
|
40
|
+
onChange: PropTypes.func,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default FiltersPicker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { unformatBytes } from '../../../utils';
|
|
3
|
+
|
|
4
|
+
const formatFilter = filter => {
|
|
5
|
+
const { name, value } = filter;
|
|
6
|
+
|
|
7
|
+
if (value._isAMomentObject === true) {
|
|
8
|
+
return { ...filter, value: moment(value).format() };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (name === 'size') {
|
|
12
|
+
return { ...filter, value: unformatBytes(value) };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return filter;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default formatFilter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const Button = styled.button`
|
|
4
|
+
margin-top: 8px;
|
|
5
|
+
|
|
6
|
+
&:active {
|
|
7
|
+
outline: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&:focus {
|
|
11
|
+
outline: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
> svg {
|
|
15
|
+
margin-top: -1px;
|
|
16
|
+
margin-left: 10px;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export default Button;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled.div`
|
|
5
|
+
position: absolute;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
background-color: ${({ theme }) => theme.main.colors.black};
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
Wrapper.propTypes = {
|
|
15
|
+
...themePropTypes,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default Wrapper;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { ClearIcon } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
import LoadingIndicator from '../LoadingIndicator';
|
|
6
|
+
import IntlText from '../IntlText';
|
|
7
|
+
import Button from './Button';
|
|
8
|
+
import Container from './Container';
|
|
9
|
+
import Wrapper from './Wrapper';
|
|
10
|
+
|
|
11
|
+
const InfiniteLoadingIndicator = ({ onClick }) => {
|
|
12
|
+
return (
|
|
13
|
+
<Wrapper>
|
|
14
|
+
<Container>
|
|
15
|
+
<LoadingIndicator />
|
|
16
|
+
<Button type="button" onClick={onClick}>
|
|
17
|
+
<IntlText
|
|
18
|
+
as="span"
|
|
19
|
+
fontSize="xs"
|
|
20
|
+
fontWeight="semiBold"
|
|
21
|
+
color="grey"
|
|
22
|
+
id="app.components.Button.cancel"
|
|
23
|
+
/>
|
|
24
|
+
<ClearIcon />
|
|
25
|
+
</Button>
|
|
26
|
+
</Container>
|
|
27
|
+
</Wrapper>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
InfiniteLoadingIndicator.defaultProps = {
|
|
32
|
+
onClick: () => {},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
InfiniteLoadingIndicator.propTypes = {
|
|
36
|
+
onClick: PropTypes.func,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default InfiniteLoadingIndicator;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { themePropTypes } from 'strapi-helper-plugin';
|
|
4
|
+
|
|
5
|
+
const Label = styled.label`
|
|
6
|
+
position: relative;
|
|
7
|
+
height: 203px;
|
|
8
|
+
width: 100%;
|
|
9
|
+
margin-top: 36px;
|
|
10
|
+
margin-bottom: 18px;
|
|
11
|
+
padding-top: 46px;
|
|
12
|
+
text-align: center;
|
|
13
|
+
border-radius: ${({ theme }) => theme.main.sizes.borderRadius};
|
|
14
|
+
border: 2px dashed ${({ theme }) => theme.main.colors.darkGrey};
|
|
15
|
+
background-color: ${({ theme }) => theme.main.colors.lightGrey};
|
|
16
|
+
|
|
17
|
+
.dragzone {
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${({ isDragging, theme }) =>
|
|
26
|
+
isDragging &&
|
|
27
|
+
`
|
|
28
|
+
background-color: ${theme.main.colors.lightestBlue};
|
|
29
|
+
border: 2px dashed ${theme.main.colors.darkBlue};
|
|
30
|
+
>svg {
|
|
31
|
+
>g {
|
|
32
|
+
fill: ${theme.main.colors.darkBlue};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
Label.defaultProps = {
|
|
39
|
+
isDragging: false,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Label.propTypes = {
|
|
43
|
+
...themePropTypes,
|
|
44
|
+
isDragging: PropTypes.bool,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default Label;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const P = styled.p`
|
|
4
|
+
margin-top: 5px;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
font-weight: 500;
|
|
7
|
+
|
|
8
|
+
.bold {
|
|
9
|
+
font-weight: 700;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
${({ isDragging, theme }) => isDragging && `color: ${theme.main.colors.mediumBlue};`}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export default P;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { createRef, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Button } from '@buffetjs/core';
|
|
4
|
+
import { useGlobalContext } from 'strapi-helper-plugin';
|
|
5
|
+
import { getTrad } from '../../utils';
|
|
6
|
+
import Cloud from '../../icons/Cloud';
|
|
7
|
+
import Label from './Label';
|
|
8
|
+
import Input from '../Input';
|
|
9
|
+
import P from './P';
|
|
10
|
+
|
|
11
|
+
const InputFileModal = ({ name, onChange }) => {
|
|
12
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
13
|
+
const { formatMessage } = useGlobalContext();
|
|
14
|
+
const ref = createRef();
|
|
15
|
+
|
|
16
|
+
const handleAllowDrop = e => e.preventDefault();
|
|
17
|
+
|
|
18
|
+
const handleChange = ({ target: { files } }) => {
|
|
19
|
+
onChange({ target: { name, value: files } });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const handleClick = () => {
|
|
23
|
+
ref.current.click();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleDragEnter = () => {
|
|
27
|
+
setIsDragging(true);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleDragLeave = () => {
|
|
31
|
+
setIsDragging(false);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleDrop = e => {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
|
|
37
|
+
setIsDragging(false);
|
|
38
|
+
onChange({ target: { name, value: e.dataTransfer.files } });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Label
|
|
43
|
+
htmlFor={name}
|
|
44
|
+
isDragging={isDragging}
|
|
45
|
+
onDragOver={handleAllowDrop}
|
|
46
|
+
onDragEnter={handleDragEnter}
|
|
47
|
+
onDrop={handleDrop}
|
|
48
|
+
>
|
|
49
|
+
<Cloud />
|
|
50
|
+
<P isDragging={isDragging}>
|
|
51
|
+
<span className="bold">{formatMessage({ id: getTrad('input.label-bold') })} </span>
|
|
52
|
+
<span>{formatMessage({ id: getTrad('input.label-normal') })}</span>
|
|
53
|
+
</P>
|
|
54
|
+
<Button type="button" id="button" name="button" color="primary" onClick={handleClick}>
|
|
55
|
+
{formatMessage({ id: getTrad('input.button.label') })}
|
|
56
|
+
</Button>
|
|
57
|
+
<Input ref={ref} type="file" multiple name={name} onChange={handleChange} />
|
|
58
|
+
{isDragging && <div className="dragzone" onDragLeave={handleDragLeave} />}
|
|
59
|
+
</Label>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
InputFileModal.defaultProps = {
|
|
64
|
+
name: 'files',
|
|
65
|
+
onChange: () => {},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
InputFileModal.propTypes = {
|
|
69
|
+
name: PropTypes.string,
|
|
70
|
+
onChange: PropTypes.func,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default InputFileModal;
|