Merge pull request #5825 from strapi/fix/deselect-not-allowed-files

Allow deselect files
This commit is contained in:
cyril lopez 2020-04-16 12:50:22 +02:00 committed by GitHub
commit b10c81b339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View File

@ -44,7 +44,7 @@ const Card = ({
: getFileExtension(ext); : getFileExtension(ext);
const handleClick = () => { const handleClick = () => {
if (!isDisabled) { if (!isDisabled || checked) {
onClick(id); onClick(id);
} }
}; };

View File

@ -57,7 +57,7 @@ const List = ({
> >
{(checked || canSelect) && ( {(checked || canSelect) && (
<> <>
{isAllowed && ( {(checked || isAllowed) && (
<CardControlsWrapper leftAlign className="card-control-wrapper"> <CardControlsWrapper leftAlign className="card-control-wrapper">
<Checkbox <Checkbox
name={`${id}`} name={`${id}`}

View File

@ -276,7 +276,7 @@ const reducer = (state, action) =>
allowedFiles.length; allowedFiles.length;
if (isSelected) { if (isSelected) {
draftState.selectedFiles = differenceWith(state.selectedFiles, allowedFiles, comparator); draftState.selectedFiles = differenceWith(state.selectedFiles, state.files, comparator);
break; break;
} }

View File

@ -1088,12 +1088,12 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
}; };
expect(reducer(state, action)).toEqual(expected); expect(reducer(state, action)).toEqual(expected);
}); });
it('should deselect all files of the current page only', () => { it('should deselect all files of the current page only event if not allowed', () => {
const action = { const action = {
type: 'TOGGLE_SELECT_ALL', type: 'TOGGLE_SELECT_ALL',
}; };
const state = { const state = {
allowedTypes: [], allowedTypes: ['video'],
selectedFiles: [ selectedFiles: [
{ {
id: 1, id: 1,
@ -1160,7 +1160,7 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
], ],
}; };
const expected = { const expected = {
allowedTypes: [], allowedTypes: ['video'],
selectedFiles: [ selectedFiles: [
{ {
id: 1, id: 1,