feat(editor-preview): allow to disable editor preview for all collections (#4423)
This commit is contained in:
parent
39a487482c
commit
16399719a0
@ -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', () => {
|
||||
|
@ -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;
|
||||
}),
|
||||
);
|
||||
|
@ -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'] }],
|
||||
|
@ -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`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user