feat(editor-preview): allow to disable editor preview for all collections (#4423)

This commit is contained in:
Giacomo Lombardi 2020-10-12 11:59:03 +02:00 committed by GitHub
parent 39a487482c
commit 16399719a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 0 deletions

View File

@ -419,6 +419,34 @@ describe('config', () => {
).toEqual(false);
});
});
describe('editor preview', () => {
it('should set editor preview honoring global config before and specific config after', () => {
const config = applyDefaults(
fromJS({
editor: {
preview: false,
},
collections: [
{
fields: [{ name: 'title' }],
folder: 'foo',
},
{
editor: {
preview: true,
},
fields: [{ name: 'title' }],
folder: 'bar',
},
],
}),
);
expect(config.getIn(['collections', 0, 'editor', 'preview'])).toEqual(false);
expect(config.getIn(['collections', 1, 'editor', 'preview'])).toEqual(true);
});
});
});
test('should convert camel case to snake case', () => {

View File

@ -267,6 +267,10 @@ export function applyDefaults(config) {
);
}
if (map.hasIn(['editor', 'preview']) && !collection.has('editor')) {
collection = collection.setIn(['editor', 'preview'], map.getIn(['editor', 'preview']));
}
return collection;
}),
);

View File

@ -284,6 +284,12 @@ const getConfigSchema = () => ({
},
uniqueItemProperties: ['name'],
},
editor: {
type: 'object',
properties: {
preview: { type: 'boolean' },
},
},
},
required: ['backend', 'collections'],
anyOf: [{ required: ['media_folder'] }, { required: ['media_library'] }],

View File

@ -365,6 +365,8 @@ This setting changes options for the editor view of the collection. It has one o
preview: false
```
**Note**: Setting this as a top level configuration will set the default for all collections
### `summary`
This setting allows the customization of the collection list view. Similar to the `slug` field, a string with templates can be used to include values of different fields, e.g. `{{title}}`. This option over-rides the default of `title` field and `identifier_field`.