fix: prevent deletion of file collection entries by default (#2627)
This commit is contained in:
parent
f87eda6992
commit
8bdfea4728
@ -1,6 +1,7 @@
|
|||||||
import { OrderedMap, fromJS } from 'immutable';
|
import { OrderedMap, fromJS } from 'immutable';
|
||||||
import { configLoaded } from 'Actions/config';
|
import { configLoaded } from 'Actions/config';
|
||||||
import collections from '../collections';
|
import collections, { selectAllowDeletion } from '../collections';
|
||||||
|
import { FILES, FOLDER } from 'Constants/collectionTypes';
|
||||||
|
|
||||||
describe('collections', () => {
|
describe('collections', () => {
|
||||||
it('should handle an empty state', () => {
|
it('should handle an empty state', () => {
|
||||||
@ -29,9 +30,22 @@ describe('collections', () => {
|
|||||||
name: 'posts',
|
name: 'posts',
|
||||||
folder: '_posts',
|
folder: '_posts',
|
||||||
fields: [{ name: 'title', widget: 'string' }],
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -89,7 +89,7 @@ const selectors = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
allowDeletion(collection) {
|
allowDeletion(collection) {
|
||||||
return collection.get('delete', true);
|
return collection.get('delete', false);
|
||||||
},
|
},
|
||||||
templateName(collection, slug) {
|
templateName(collection, slug) {
|
||||||
return slug;
|
return slug;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user