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);
const handleClick = () => {
if (!isDisabled) {
if (!isDisabled || checked) {
onClick(id);
}
};

View File

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

View File

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

View File

@ -1088,12 +1088,12 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
};
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 = {
type: 'TOGGLE_SELECT_ALL',
};
const state = {
allowedTypes: [],
allowedTypes: ['video'],
selectedFiles: [
{
id: 1,
@ -1160,7 +1160,7 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
],
};
const expected = {
allowedTypes: [],
allowedTypes: ['video'],
selectedFiles: [
{
id: 1,