@akemona-org/strapi-plugin-upload 3.7.0 → 3.7.2
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/admin/src/components/BrowseAssets/index.js +8 -8
- package/admin/src/components/Card/index.js +1 -1
- package/admin/src/components/CardControl/index.js +1 -1
- package/admin/src/components/CardErrorMessage/index.js +1 -1
- package/admin/src/components/CardImgWrapper/index.js +1 -1
- package/admin/src/components/CardTitle/index.js +1 -1
- package/admin/src/components/CheckControl/index.js +3 -3
- package/admin/src/components/DragLayer/index.js +1 -1
- package/admin/src/components/DropdownButton/index.js +1 -1
- package/admin/src/components/Duration/utils/formatDuration.js +1 -1
- package/admin/src/components/EditForm/FileDetailsBox.js +1 -1
- package/admin/src/components/EditForm/SizeBox.js +1 -1
- package/admin/src/components/EditForm/index.js +6 -6
- package/admin/src/components/EditForm/utils/isImageType.js +1 -1
- package/admin/src/components/EditForm/utils/isVideoType.js +1 -1
- package/admin/src/components/FileIcon/index.js +1 -1
- package/admin/src/components/FiltersList/utils/formatFilter.js +1 -1
- package/admin/src/components/FiltersPicker/FiltersCard/FilterInput.js +1 -1
- package/admin/src/components/FiltersPicker/FiltersCard/index.js +2 -2
- package/admin/src/components/FiltersPicker/FiltersCard/init.js +1 -1
- package/admin/src/components/FiltersPicker/FiltersCard/reducer.js +1 -7
- package/admin/src/components/FiltersPicker/index.js +2 -2
- package/admin/src/components/FiltersPicker/utils/formatFilter.js +1 -1
- package/admin/src/components/InputFileModal/index.js +2 -2
- package/admin/src/components/InputMedia/index.js +7 -7
- package/admin/src/components/IntlText/index.js +1 -1
- package/admin/src/components/List/index.js +3 -3
- package/admin/src/components/ListEmpty/index.js +2 -2
- package/admin/src/components/ListEmpty/utils/generateRows.js +1 -1
- package/admin/src/components/ListModal/index.js +2 -2
- package/admin/src/components/ModalNavWrapper/index.js +2 -2
- package/admin/src/components/ModalTab/index.js +1 -1
- package/admin/src/components/SelectedAssets/DraggableCard.js +1 -1
- package/admin/src/components/SelectedAssets/SortableList.js +4 -4
- package/admin/src/components/SortList/Wrapper.js +1 -1
- package/admin/src/components/SortList/index.js +1 -1
- package/admin/src/components/SortListItem/Wrapper.js +1 -1
- package/admin/src/components/SortPicker/index.js +3 -3
- package/admin/src/components/UploadForm/index.js +2 -2
- package/admin/src/components/UploadList/ListTitle.js +1 -1
- package/admin/src/components/UploadList/index.js +1 -1
- package/admin/src/components/VideoPreview/index.js +2 -9
- package/admin/src/containers/HomePage/HomePageContent/index.js +4 -4
- package/admin/src/containers/HomePage/index.js +10 -10
- package/admin/src/containers/HomePage/reducer.js +11 -9
- package/admin/src/containers/HomePage/utils/generateParamsFromQuery.js +1 -1
- package/admin/src/containers/HomePage/utils/generateStringFromParams.js +2 -2
- package/admin/src/containers/HomePage/utils/getHeaderLabel.js +1 -1
- package/admin/src/containers/Initializer/index.js +1 -1
- package/admin/src/containers/InputModalStepper/InputModalStepper.js +6 -4
- package/admin/src/containers/InputModalStepper/Search.js +1 -1
- package/admin/src/containers/InputModalStepper/index.js +1 -1
- package/admin/src/containers/InputModalStepperProvider/index.js +17 -17
- package/admin/src/containers/InputModalStepperProvider/init.js +1 -1
- package/admin/src/containers/InputModalStepperProvider/reducer.js +10 -10
- package/admin/src/containers/ModalStepper/index.js +16 -15
- package/admin/src/containers/ModalStepper/init.js +1 -1
- package/admin/src/containers/ModalStepper/reducer.js +15 -18
- package/admin/src/containers/SettingsPage/init.js +1 -1
- package/admin/src/icons/BrokenFile/index.js +1 -1
- package/admin/src/icons/Cloud/index.js +1 -1
- package/admin/src/icons/DoubleFile/index.js +1 -1
- package/admin/src/icons/Download/index.js +1 -1
- package/admin/src/icons/File/index.js +1 -1
- package/admin/src/index.js +1 -1
- package/admin/src/pluginId.js +1 -1
- package/admin/src/utils/canDownloadFile.js +1 -1
- package/admin/src/utils/compactParams.js +2 -2
- package/admin/src/utils/createMatrix.js +1 -1
- package/admin/src/utils/createNewFilesToDownloadArray.js +3 -3
- package/admin/src/utils/createNewFilesToUploadArray.js +1 -1
- package/admin/src/utils/formatFileForEditing.js +1 -1
- package/admin/src/utils/formatFilters.js +1 -1
- package/admin/src/utils/getFileModelTimestamps.js +1 -1
- package/admin/src/utils/getFilesToDownload.js +2 -2
- package/admin/src/utils/getRequestUrl.js +1 -1
- package/admin/src/utils/getTrad.js +1 -1
- package/admin/src/utils/getType.js +1 -1
- package/admin/src/utils/getYupError.js +5 -8
- package/admin/src/utils/unformatBytes.js +1 -1
- package/admin/src/utils/urlYupSchema.js +1 -1
- package/config/functions/bootstrap.js +10 -8
- package/config/schema.graphql.js +2 -2
- package/errors.js +3 -3
- package/middlewares/upload/index.js +2 -2
- package/package.json +5 -5
- package/services/image-manipulation.js +11 -14
- package/utils/file.js +3 -3
|
@@ -22,15 +22,8 @@ const EmptyPreview = styled.div`
|
|
|
22
22
|
const VideoPreview = ({ hasIcon, previewUrl, src }) => {
|
|
23
23
|
const { formatMessage } = useIntl();
|
|
24
24
|
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
dataLoaded,
|
|
28
|
-
isHover,
|
|
29
|
-
metadataLoaded,
|
|
30
|
-
snapshot,
|
|
31
|
-
seeked,
|
|
32
|
-
isError,
|
|
33
|
-
} = reducerState.toJS();
|
|
25
|
+
const { duration, dataLoaded, isHover, metadataLoaded, snapshot, seeked, isError } =
|
|
26
|
+
reducerState.toJS();
|
|
34
27
|
|
|
35
28
|
// Adapted from https://github.com/brothatru/react-video-thumbnail/blob/master/src/components/VideoThumbnail.js
|
|
36
29
|
// And from https://github.com/soupette/poc-video-preview
|
|
@@ -23,13 +23,13 @@ const HomePageContent = ({
|
|
|
23
23
|
const { search } = useLocation();
|
|
24
24
|
const filters = generateFiltersFromSearch(search);
|
|
25
25
|
|
|
26
|
-
const hasSomeCheckboxSelected = data.some(item =>
|
|
27
|
-
dataToDelete.find(itemToDelete => item.id.toString() === itemToDelete.id.toString())
|
|
26
|
+
const hasSomeCheckboxSelected = data.some((item) =>
|
|
27
|
+
dataToDelete.find((itemToDelete) => item.id.toString() === itemToDelete.id.toString())
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
const areAllCheckboxesSelected =
|
|
31
|
-
data.every(item =>
|
|
32
|
-
dataToDelete.find(itemToDelete => item.id.toString() === itemToDelete.id.toString())
|
|
31
|
+
data.every((item) =>
|
|
32
|
+
dataToDelete.find((itemToDelete) => item.id.toString() === itemToDelete.id.toString())
|
|
33
33
|
) && hasSomeCheckboxSelected;
|
|
34
34
|
|
|
35
35
|
const hasFilters = !isEmpty(filters);
|
|
@@ -58,7 +58,7 @@ const HomePage = () => {
|
|
|
58
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
59
|
}, [search]);
|
|
60
60
|
|
|
61
|
-
const deleteMedia = async id => {
|
|
61
|
+
const deleteMedia = async (id) => {
|
|
62
62
|
const requestURL = getRequestUrl(`files/${id}`);
|
|
63
63
|
|
|
64
64
|
try {
|
|
@@ -191,9 +191,9 @@ const HomePage = () => {
|
|
|
191
191
|
push({ search: newSearch });
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
-
const handleClickEditFile = id => {
|
|
194
|
+
const handleClickEditFile = (id) => {
|
|
195
195
|
if (allowedActions.canUpdate) {
|
|
196
|
-
const file = formatFileForEditing(data.find(file => toString(file.id) === toString(id)));
|
|
196
|
+
const file = formatFileForEditing(data.find((file) => toString(file.id) === toString(id)));
|
|
197
197
|
|
|
198
198
|
setFileToEdit(file);
|
|
199
199
|
setModalInitialStep('edit');
|
|
@@ -202,15 +202,15 @@ const HomePage = () => {
|
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
const handleClickToggleModal = (refetch = false) => {
|
|
205
|
-
setIsModalOpen(prev => !prev);
|
|
205
|
+
setIsModalOpen((prev) => !prev);
|
|
206
206
|
setShouldRefetch(refetch);
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
const handleClickTogglePopup = () => {
|
|
210
|
-
setIsPopupOpen(prev => !prev);
|
|
210
|
+
setIsPopupOpen((prev) => !prev);
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
const handleDeleteFilter = index => {
|
|
213
|
+
const handleDeleteFilter = (index) => {
|
|
214
214
|
const filters = generateFiltersFromSearch(search).filter(
|
|
215
215
|
(filter, filterIndex) => filterIndex !== index
|
|
216
216
|
);
|
|
@@ -226,7 +226,7 @@ const HomePage = () => {
|
|
|
226
226
|
dispatch({ type: 'ON_DELETE_MEDIAS' });
|
|
227
227
|
|
|
228
228
|
try {
|
|
229
|
-
await Promise.all(dataToDelete.map(item => deleteMedia(item.id)));
|
|
229
|
+
await Promise.all(dataToDelete.map((item) => deleteMedia(item.id)));
|
|
230
230
|
|
|
231
231
|
dispatch({
|
|
232
232
|
type: 'ON_DELETE_MEDIAS_SUCCEEDED',
|
|
@@ -296,7 +296,7 @@ const HomePage = () => {
|
|
|
296
296
|
label: formatMessage({ id: 'app.utils.delete' }),
|
|
297
297
|
onClick: () => setIsPopupOpen(true),
|
|
298
298
|
type: 'button',
|
|
299
|
-
Component: buttonProps => {
|
|
299
|
+
Component: (buttonProps) => {
|
|
300
300
|
if (!allowedActions.canUpdate) {
|
|
301
301
|
return null;
|
|
302
302
|
}
|
|
@@ -310,7 +310,7 @@ const HomePage = () => {
|
|
|
310
310
|
label: formatMessage({ id: getTrad('header.actions.upload-assets') }),
|
|
311
311
|
onClick: () => handleClickToggleModal(),
|
|
312
312
|
type: 'button',
|
|
313
|
-
Component: buttonProps => {
|
|
313
|
+
Component: (buttonProps) => {
|
|
314
314
|
if (!allowedActions.canCreate) {
|
|
315
315
|
return null;
|
|
316
316
|
}
|
|
@@ -321,7 +321,7 @@ const HomePage = () => {
|
|
|
321
321
|
],
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
-
const handleRemoveFileFromDataToDelete = useCallback(id => {
|
|
324
|
+
const handleRemoveFileFromDataToDelete = useCallback((id) => {
|
|
325
325
|
dispatch({
|
|
326
326
|
type: 'ON_CHANGE_DATA_TO_DELETE',
|
|
327
327
|
id,
|
|
@@ -26,19 +26,19 @@ const reducer = (state, action) => {
|
|
|
26
26
|
const { id } = action;
|
|
27
27
|
const isSelected = state
|
|
28
28
|
.get('dataToDelete')
|
|
29
|
-
.find(item => item.get('id').toString() === id.toString());
|
|
29
|
+
.find((item) => item.get('id').toString() === id.toString());
|
|
30
30
|
|
|
31
31
|
if (!isSelected) {
|
|
32
|
-
const item = state.get('data').find(item => item.get('id').toString() === id.toString());
|
|
32
|
+
const item = state.get('data').find((item) => item.get('id').toString() === id.toString());
|
|
33
33
|
|
|
34
|
-
return state.update('dataToDelete', dataToDelete => {
|
|
34
|
+
return state.update('dataToDelete', (dataToDelete) => {
|
|
35
35
|
return dataToDelete.push(item);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const index = state
|
|
40
40
|
.get('dataToDelete')
|
|
41
|
-
.findIndex(item => item.get('id').toString() === id.toString());
|
|
41
|
+
.findIndex((item) => item.get('id').toString() === id.toString());
|
|
42
42
|
|
|
43
43
|
return state.removeIn(['dataToDelete', index]);
|
|
44
44
|
}
|
|
@@ -63,16 +63,18 @@ const reducer = (state, action) => {
|
|
|
63
63
|
.update('showModalConfirmButtonLoading', () => false);
|
|
64
64
|
}
|
|
65
65
|
case 'TOGGLE_SELECT_ALL': {
|
|
66
|
-
const isSelected = state
|
|
66
|
+
const isSelected = state
|
|
67
|
+
.get('data')
|
|
68
|
+
.every((item) => state.get('dataToDelete').includes(item));
|
|
67
69
|
|
|
68
70
|
if (isSelected) {
|
|
69
|
-
return state.update('dataToDelete', dataToDelete =>
|
|
70
|
-
dataToDelete.filter(item => !state.get('data').includes(item))
|
|
71
|
+
return state.update('dataToDelete', (dataToDelete) =>
|
|
72
|
+
dataToDelete.filter((item) => !state.get('data').includes(item))
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
return state.update('dataToDelete', dataToDelete => {
|
|
75
|
-
const newItems = state.get('data').filter(item => {
|
|
76
|
+
return state.update('dataToDelete', (dataToDelete) => {
|
|
77
|
+
const newItems = state.get('data').filter((item) => {
|
|
76
78
|
return !state.get('dataToDelete').includes(item);
|
|
77
79
|
});
|
|
78
80
|
|
|
@@ -6,10 +6,10 @@ const generateStringFromParams = (query, paramsToFilter = []) => {
|
|
|
6
6
|
const paramsObject = generateParamsFromQuery(query);
|
|
7
7
|
|
|
8
8
|
Object.keys(paramsObject)
|
|
9
|
-
.filter(key => {
|
|
9
|
+
.filter((key) => {
|
|
10
10
|
return !paramsToFilter.includes(key) && !isEmpty(toString(paramsObject[key]));
|
|
11
11
|
})
|
|
12
|
-
.forEach(key => {
|
|
12
|
+
.forEach((key) => {
|
|
13
13
|
const value = paramsObject[key];
|
|
14
14
|
|
|
15
15
|
if (key.includes('mime') && value === 'file') {
|
|
@@ -19,7 +19,7 @@ const Initializer = ({ updatePlugin }) => {
|
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
21
|
const { data } = await request(requestURL, { method: 'GET' });
|
|
22
|
-
const fileModel = data.find(model => model.uid === 'plugins::upload.file');
|
|
22
|
+
const fileModel = data.find((model) => model.uid === 'plugins::upload.file');
|
|
23
23
|
|
|
24
24
|
ref.current(pluginId, 'fileModel', fileModel);
|
|
25
25
|
ref.current(pluginId, 'isReady', true);
|
|
@@ -148,7 +148,7 @@ const InputModalStepper = ({
|
|
|
148
148
|
toggleModalWarning();
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
const handleClickDeleteFileToUpload = fileIndex => {
|
|
151
|
+
const handleClickDeleteFileToUpload = (fileIndex) => {
|
|
152
152
|
handleRemoveFileToUpload(fileIndex);
|
|
153
153
|
|
|
154
154
|
if (currentStep === 'edit-new') {
|
|
@@ -174,13 +174,13 @@ const InputModalStepper = ({
|
|
|
174
174
|
goBack();
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
const handleSubmitEditNewFile = e => {
|
|
177
|
+
const handleSubmitEditNewFile = (e) => {
|
|
178
178
|
e.preventDefault();
|
|
179
179
|
submitEditNewFile();
|
|
180
180
|
goNext();
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
const handleSubmit = e => {
|
|
183
|
+
const handleSubmit = (e) => {
|
|
184
184
|
e.preventDefault();
|
|
185
185
|
onInputMediaChange(multiple ? selectedFiles : selectedFiles[0]);
|
|
186
186
|
goNext();
|
|
@@ -320,7 +320,9 @@ const InputModalStepper = ({
|
|
|
320
320
|
};
|
|
321
321
|
|
|
322
322
|
const shouldDisplayNextButton = currentStep === 'browse' && displayNextButton;
|
|
323
|
-
const isFinishButtonDisabled = filesToUpload.some(
|
|
323
|
+
const isFinishButtonDisabled = filesToUpload.some(
|
|
324
|
+
(file) => file.isDownloading || file.isUploading
|
|
325
|
+
);
|
|
324
326
|
const areButtonsDisabledOnEditExistingFile =
|
|
325
327
|
currentStep === 'edit' && fileToEdit.isUploading === true;
|
|
326
328
|
|
|
@@ -23,7 +23,7 @@ const InputModal = ({
|
|
|
23
23
|
selectedFiles,
|
|
24
24
|
step,
|
|
25
25
|
}) => {
|
|
26
|
-
const singularTypes = allowedTypes.map(type => type.substring(0, type.length - 1));
|
|
26
|
+
const singularTypes = allowedTypes.map((type) => type.substring(0, type.length - 1));
|
|
27
27
|
const permissions = React.useMemo(() => omit(pluginPermissions, 'main'), []);
|
|
28
28
|
const { allowedActions, isLoading } = useUserPermissions(permissions);
|
|
29
29
|
|
|
@@ -41,7 +41,7 @@ const InputModalStepperProvider = ({
|
|
|
41
41
|
const { formatMessage } = useIntl();
|
|
42
42
|
const { emitEvent, plugins } = useGlobalContext();
|
|
43
43
|
const [, updated_at] = getFileModelTimestamps(plugins);
|
|
44
|
-
const [reducerState, dispatch] = useReducer(reducer, initialState, state =>
|
|
44
|
+
const [reducerState, dispatch] = useReducer(reducer, initialState, (state) =>
|
|
45
45
|
init({
|
|
46
46
|
...state,
|
|
47
47
|
allowedTypes,
|
|
@@ -81,7 +81,7 @@ const InputModalStepperProvider = ({
|
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
83
|
await Promise.all(
|
|
84
|
-
files.map(file => {
|
|
84
|
+
files.map((file) => {
|
|
85
85
|
const { source } = file;
|
|
86
86
|
|
|
87
87
|
return axios
|
|
@@ -102,7 +102,7 @@ const InputModalStepperProvider = ({
|
|
|
102
102
|
fileTempId: file.tempId,
|
|
103
103
|
});
|
|
104
104
|
})
|
|
105
|
-
.catch(err => {
|
|
105
|
+
.catch((err) => {
|
|
106
106
|
console.error('fetch file error', err);
|
|
107
107
|
|
|
108
108
|
dispatch({
|
|
@@ -118,14 +118,14 @@ const InputModalStepperProvider = ({
|
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
const handleRemoveFileToUpload = fileIndex => {
|
|
121
|
+
const handleRemoveFileToUpload = (fileIndex) => {
|
|
122
122
|
dispatch({
|
|
123
123
|
type: 'REMOVE_FILE_TO_UPLOAD',
|
|
124
124
|
fileIndex,
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
const handleModalTabChange = to => {
|
|
128
|
+
const handleModalTabChange = (to) => {
|
|
129
129
|
dispatch({
|
|
130
130
|
type: 'ON_CHANGE_MODAL_TAB',
|
|
131
131
|
to,
|
|
@@ -135,7 +135,7 @@ const InputModalStepperProvider = ({
|
|
|
135
135
|
const handleClickNextButton = async () => {
|
|
136
136
|
try {
|
|
137
137
|
await urlSchema.validate(
|
|
138
|
-
{ filesToDownload: filesToDownload.filter(url => !isEmpty(url)) },
|
|
138
|
+
{ filesToDownload: filesToDownload.filter((url) => !isEmpty(url)) },
|
|
139
139
|
{ abortEarly: false }
|
|
140
140
|
);
|
|
141
141
|
|
|
@@ -196,7 +196,7 @@ const InputModalStepperProvider = ({
|
|
|
196
196
|
});
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
const handleEditExistingFile = file => {
|
|
199
|
+
const handleEditExistingFile = (file) => {
|
|
200
200
|
dispatch({
|
|
201
201
|
type: 'EDIT_EXISTING_FILE',
|
|
202
202
|
file,
|
|
@@ -209,7 +209,7 @@ const InputModalStepperProvider = ({
|
|
|
209
209
|
});
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
const removeFilter = index => {
|
|
212
|
+
const removeFilter = (index) => {
|
|
213
213
|
dispatch({
|
|
214
214
|
type: 'REMOVE_FILTER',
|
|
215
215
|
filterToRemove: index,
|
|
@@ -239,21 +239,21 @@ const InputModalStepperProvider = ({
|
|
|
239
239
|
});
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
const setParam = param => {
|
|
242
|
+
const setParam = (param) => {
|
|
243
243
|
dispatch({
|
|
244
244
|
type: 'SET_PARAM',
|
|
245
245
|
param,
|
|
246
246
|
});
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
const goTo = to => {
|
|
249
|
+
const goTo = (to) => {
|
|
250
250
|
dispatch({
|
|
251
251
|
type: 'GO_TO',
|
|
252
252
|
to,
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
-
const handleGoToEditNewFile = fileIndex => {
|
|
256
|
+
const handleGoToEditNewFile = (fileIndex) => {
|
|
257
257
|
dispatch({
|
|
258
258
|
type: 'SET_NEW_FILE_TO_EDIT',
|
|
259
259
|
fileIndex,
|
|
@@ -262,7 +262,7 @@ const InputModalStepperProvider = ({
|
|
|
262
262
|
goTo('edit-new');
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
-
const handleGoToEditFile = fileId => {
|
|
265
|
+
const handleGoToEditFile = (fileId) => {
|
|
266
266
|
dispatch({
|
|
267
267
|
type: 'SET_FILE_TO_EDIT',
|
|
268
268
|
fileId,
|
|
@@ -277,7 +277,7 @@ const InputModalStepperProvider = ({
|
|
|
277
277
|
});
|
|
278
278
|
};
|
|
279
279
|
|
|
280
|
-
const handleSetCropResult = blob => {
|
|
280
|
+
const handleSetCropResult = (blob) => {
|
|
281
281
|
// Emit event : the user cropped a file that is not uploaded
|
|
282
282
|
emitEvent('didCropFile', { duplicatedFile: null, location: 'content-manager' });
|
|
283
283
|
|
|
@@ -287,7 +287,7 @@ const InputModalStepperProvider = ({
|
|
|
287
287
|
});
|
|
288
288
|
};
|
|
289
289
|
|
|
290
|
-
const handleFormDisabled = isFormDisabled => {
|
|
290
|
+
const handleFormDisabled = (isFormDisabled) => {
|
|
291
291
|
dispatch({
|
|
292
292
|
type: 'SET_FORM_DISABLED',
|
|
293
293
|
isFormDisabled,
|
|
@@ -304,7 +304,7 @@ const InputModalStepperProvider = ({
|
|
|
304
304
|
});
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
-
const handleCancelFileToUpload = fileIndex => {
|
|
307
|
+
const handleCancelFileToUpload = (fileIndex) => {
|
|
308
308
|
const fileToCancel = get(filesToUpload, fileIndex, {});
|
|
309
309
|
|
|
310
310
|
const { source } = fileToCancel;
|
|
@@ -392,7 +392,7 @@ const InputModalStepperProvider = ({
|
|
|
392
392
|
});
|
|
393
393
|
};
|
|
394
394
|
|
|
395
|
-
const handleSetFileToEditError = errorMessage => {
|
|
395
|
+
const handleSetFileToEditError = (errorMessage) => {
|
|
396
396
|
dispatch({
|
|
397
397
|
type: 'SET_FILE_TO_EDIT_ERROR',
|
|
398
398
|
errorMessage,
|
|
@@ -430,7 +430,7 @@ const InputModalStepperProvider = ({
|
|
|
430
430
|
false
|
|
431
431
|
);
|
|
432
432
|
|
|
433
|
-
const filesToSelect = uploadedFile.filter(file => {
|
|
433
|
+
const filesToSelect = uploadedFile.filter((file) => {
|
|
434
434
|
const fileType = file.mime.split('/')[0];
|
|
435
435
|
|
|
436
436
|
if (allowedTypes.includes('file') && !['video', 'image'].includes(fileType)) {
|
|
@@ -30,7 +30,7 @@ const initialState = {
|
|
|
30
30
|
|
|
31
31
|
const reducer = (state, action) =>
|
|
32
32
|
// eslint-disable-next-line consistent-return
|
|
33
|
-
produce(state, draftState => {
|
|
33
|
+
produce(state, (draftState) => {
|
|
34
34
|
switch (action.type) {
|
|
35
35
|
case 'ADD_FILES_TO_UPLOAD': {
|
|
36
36
|
draftState.filesToUpload = [
|
|
@@ -74,7 +74,7 @@ const reducer = (state, action) =>
|
|
|
74
74
|
}
|
|
75
75
|
case 'EDIT_EXISTING_FILE': {
|
|
76
76
|
const index = draftState.selectedFiles.findIndex(
|
|
77
|
-
selectedFile => selectedFile.id === action.file.id
|
|
77
|
+
(selectedFile) => selectedFile.id === action.file.id
|
|
78
78
|
);
|
|
79
79
|
|
|
80
80
|
if (index !== -1) {
|
|
@@ -83,7 +83,7 @@ const reducer = (state, action) =>
|
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
case 'FILE_DOWNLOADED': {
|
|
86
|
-
const index = state.filesToUpload.findIndex(file => file.tempId === action.fileTempId);
|
|
86
|
+
const index = state.filesToUpload.findIndex((file) => file.tempId === action.fileTempId);
|
|
87
87
|
|
|
88
88
|
draftState.filesToUpload[index] = {
|
|
89
89
|
...draftState.filesToUpload[index],
|
|
@@ -130,19 +130,19 @@ const reducer = (state, action) =>
|
|
|
130
130
|
case 'ON_FILE_SELECTION': {
|
|
131
131
|
const { id } = action;
|
|
132
132
|
const stringId = toString(id);
|
|
133
|
-
const fileIndex = state.selectedFiles.findIndex(file => toString(file.id) === stringId);
|
|
133
|
+
const fileIndex = state.selectedFiles.findIndex((file) => toString(file.id) === stringId);
|
|
134
134
|
|
|
135
135
|
if (fileIndex !== -1) {
|
|
136
136
|
draftState.selectedFiles.splice(fileIndex, 1);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
|
-
const fileToStore = state.files.find(file => file.id.toString() === stringId);
|
|
139
|
+
const fileToStore = state.files.find((file) => file.id.toString() === stringId);
|
|
140
140
|
|
|
141
141
|
if (fileToStore) {
|
|
142
142
|
draftState.selectedFiles.push(fileToStore);
|
|
143
143
|
}
|
|
144
144
|
// Clean
|
|
145
|
-
draftState.selectedFiles = draftState.selectedFiles.filter(file => file && file.id);
|
|
145
|
+
draftState.selectedFiles = draftState.selectedFiles.filter((file) => file && file.id);
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
case 'ON_SUBMIT_EDIT_NEW_FILE': {
|
|
@@ -167,7 +167,7 @@ const reducer = (state, action) =>
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
const index = draftState.filesToUpload.findIndex(
|
|
170
|
-
fileToUpload => fileToUpload.originalIndex === action.fileIndex
|
|
170
|
+
(fileToUpload) => fileToUpload.originalIndex === action.fileIndex
|
|
171
171
|
);
|
|
172
172
|
draftState.filesToUpload.splice(index, 1);
|
|
173
173
|
break;
|
|
@@ -204,7 +204,7 @@ const reducer = (state, action) =>
|
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
206
|
case 'SET_FILE_TO_DOWNLOAD_ERROR': {
|
|
207
|
-
const index = state.filesToUpload.findIndex(file => file.tempId === action.fileTempId);
|
|
207
|
+
const index = state.filesToUpload.findIndex((file) => file.tempId === action.fileTempId);
|
|
208
208
|
|
|
209
209
|
draftState.filesToUpload[index] = {
|
|
210
210
|
...draftState.filesToUpload[index],
|
|
@@ -218,7 +218,7 @@ const reducer = (state, action) =>
|
|
|
218
218
|
case 'SET_FILE_TO_EDIT': {
|
|
219
219
|
draftState.fileToEdit = formatFileForEditing(
|
|
220
220
|
[...state.files, ...state.selectedFiles].find(
|
|
221
|
-
file => file.id.toString() === action.fileId.toString()
|
|
221
|
+
(file) => file.id.toString() === action.fileId.toString()
|
|
222
222
|
)
|
|
223
223
|
);
|
|
224
224
|
break;
|
|
@@ -276,7 +276,7 @@ const reducer = (state, action) =>
|
|
|
276
276
|
case 'TOGGLE_SELECT_ALL': {
|
|
277
277
|
const allowedFiles =
|
|
278
278
|
state.allowedTypes.length > 0
|
|
279
|
-
? state.files.filter(file => state.allowedTypes.includes(getType(file.mime)))
|
|
279
|
+
? state.files.filter((file) => state.allowedTypes.includes(getType(file.mime)))
|
|
280
280
|
: state.files;
|
|
281
281
|
const comparator = (first, second) => first.id === second.id;
|
|
282
282
|
const isSelected =
|
|
@@ -30,9 +30,8 @@ const ModalStepper = ({
|
|
|
30
30
|
const [displayNextButton, setDisplayNextButton] = useState(false);
|
|
31
31
|
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
|
|
32
32
|
const { currentStep, fileToEdit, filesToDownload, filesToUpload } = reducerState.toJS();
|
|
33
|
-
const { Component, components, headerBreadcrumbs, next, prev, withBackButton } =
|
|
34
|
-
currentStep
|
|
35
|
-
];
|
|
33
|
+
const { Component, components, headerBreadcrumbs, next, prev, withBackButton } =
|
|
34
|
+
stepper[currentStep];
|
|
36
35
|
const filesToUploadLength = filesToUpload.length;
|
|
37
36
|
const toggleRef = useRef(onToggle);
|
|
38
37
|
const editModalRef = useRef();
|
|
@@ -89,7 +88,7 @@ const ModalStepper = ({
|
|
|
89
88
|
|
|
90
89
|
try {
|
|
91
90
|
await Promise.all(
|
|
92
|
-
files.map(file => {
|
|
91
|
+
files.map((file) => {
|
|
93
92
|
const { source } = file;
|
|
94
93
|
|
|
95
94
|
return axios
|
|
@@ -111,7 +110,7 @@ const ModalStepper = ({
|
|
|
111
110
|
fileTempId: file.tempId,
|
|
112
111
|
});
|
|
113
112
|
})
|
|
114
|
-
.catch(err => {
|
|
113
|
+
.catch((err) => {
|
|
115
114
|
console.error('fetch file error', err);
|
|
116
115
|
|
|
117
116
|
dispatch({
|
|
@@ -137,8 +136,8 @@ const ModalStepper = ({
|
|
|
137
136
|
});
|
|
138
137
|
};
|
|
139
138
|
|
|
140
|
-
const handleCancelFileToUpload = fileOriginalIndex => {
|
|
141
|
-
const fileToCancel = filesToUpload.find(file => file.originalIndex === fileOriginalIndex);
|
|
139
|
+
const handleCancelFileToUpload = (fileOriginalIndex) => {
|
|
140
|
+
const fileToCancel = filesToUpload.find((file) => file.originalIndex === fileOriginalIndex);
|
|
142
141
|
const { source } = fileToCancel;
|
|
143
142
|
|
|
144
143
|
// Cancel
|
|
@@ -206,7 +205,7 @@ const ModalStepper = ({
|
|
|
206
205
|
const handleClickNextButton = async () => {
|
|
207
206
|
try {
|
|
208
207
|
await urlSchema.validate(
|
|
209
|
-
{ filesToDownload: filesToDownload.filter(url => !isEmpty(url)) },
|
|
208
|
+
{ filesToDownload: filesToDownload.filter((url) => !isEmpty(url)) },
|
|
210
209
|
{ abortEarly: false }
|
|
211
210
|
);
|
|
212
211
|
|
|
@@ -227,7 +226,7 @@ const ModalStepper = ({
|
|
|
227
226
|
toggleModalWarning();
|
|
228
227
|
};
|
|
229
228
|
|
|
230
|
-
const handleClickDeleteFileToUpload = fileIndex => {
|
|
229
|
+
const handleClickDeleteFileToUpload = (fileIndex) => {
|
|
231
230
|
dispatch({
|
|
232
231
|
type: 'REMOVE_FILE_TO_UPLOAD',
|
|
233
232
|
fileIndex,
|
|
@@ -260,7 +259,7 @@ const ModalStepper = ({
|
|
|
260
259
|
onToggle(shouldRefetch);
|
|
261
260
|
};
|
|
262
261
|
|
|
263
|
-
const handleGoToEditNewFile = fileIndex => {
|
|
262
|
+
const handleGoToEditNewFile = (fileIndex) => {
|
|
264
263
|
dispatch({
|
|
265
264
|
type: 'SET_FILE_TO_EDIT',
|
|
266
265
|
fileIndex,
|
|
@@ -277,7 +276,7 @@ const ModalStepper = ({
|
|
|
277
276
|
goBack();
|
|
278
277
|
};
|
|
279
278
|
|
|
280
|
-
const handleSetCropResult = blob => {
|
|
279
|
+
const handleSetCropResult = (blob) => {
|
|
281
280
|
// Emit event : the user cropped a file that is not uploaded
|
|
282
281
|
emitEvent('didCropFile', { duplicatedFile: null, location: 'upload' });
|
|
283
282
|
|
|
@@ -287,7 +286,7 @@ const ModalStepper = ({
|
|
|
287
286
|
});
|
|
288
287
|
};
|
|
289
288
|
|
|
290
|
-
const handleSubmitEditNewFile = e => {
|
|
289
|
+
const handleSubmitEditNewFile = (e) => {
|
|
291
290
|
e.preventDefault();
|
|
292
291
|
|
|
293
292
|
dispatch({
|
|
@@ -476,7 +475,7 @@ const ModalStepper = ({
|
|
|
476
475
|
goTo(next);
|
|
477
476
|
};
|
|
478
477
|
|
|
479
|
-
const goTo = to => {
|
|
478
|
+
const goTo = (to) => {
|
|
480
479
|
dispatch({
|
|
481
480
|
type: 'GO_TO',
|
|
482
481
|
to,
|
|
@@ -484,11 +483,13 @@ const ModalStepper = ({
|
|
|
484
483
|
};
|
|
485
484
|
|
|
486
485
|
const toggleModalWarning = () => {
|
|
487
|
-
setIsWarningDeleteOpen(prev => !prev);
|
|
486
|
+
setIsWarningDeleteOpen((prev) => !prev);
|
|
488
487
|
};
|
|
489
488
|
|
|
490
489
|
const shouldDisplayNextButton = currentStep === 'browse' && displayNextButton;
|
|
491
|
-
const isFinishButtonDisabled = filesToUpload.some(
|
|
490
|
+
const isFinishButtonDisabled = filesToUpload.some(
|
|
491
|
+
(file) => file.isDownloading || file.isUploading
|
|
492
|
+
);
|
|
492
493
|
const areButtonsDisabledOnEditExistingFile =
|
|
493
494
|
currentStep === 'edit' && fileToEdit.isUploading === true;
|
|
494
495
|
|