fix: prevent deletion of file collection entries by default (#2627)

This commit is contained in:
melbourne2991 2019-09-06 08:08:07 +10:00 committed by Shawn Erquhart
parent f87eda6992
commit 8bdfea4728
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { OrderedMap, fromJS } from 'immutable';
import { configLoaded } from 'Actions/config';
import collections from '../collections';
import collections, { selectAllowDeletion } from '../collections';
import { FILES, FOLDER } from 'Constants/collectionTypes';
describe('collections', () => {
it('should handle an empty state', () => {
@ -29,9 +30,22 @@ describe('collections', () => {
name: 'posts',
folder: '_posts',
fields: [{ name: 'title', widget: 'string' }],
type: 'folder_based_collection',
type: FOLDER,
}),
}),
);
});
describe('selectAllowDeletions', () => {
it('should not allow deletions for file collections', () => {
expect(
selectAllowDeletion(
fromJS({
name: 'pages',
type: FILES,
}),
),
).toBe(false);
});
});
});

View File

@ -89,7 +89,7 @@ const selectors = {
return false;
},
allowDeletion(collection) {
return collection.get('delete', true);
return collection.get('delete', false);
},
templateName(collection, slug) {
return slug;