feat: add hide property to collections (#3618) (#3643)

This commit is contained in:
Shashank Bairy R 2020-04-22 12:32:13 +00:00 committed by GitHub
parent f8603c5d92
commit 88b6c633af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 2 deletions

View File

@ -50,7 +50,12 @@ const ErrorCodeBlock = styled.pre`
`; `;
const getDefaultPath = collections => { const getDefaultPath = collections => {
return `/collections/${collections.first().get('name')}`; const first = collections.filter(collection => collection.get('hide') !== true).first();
if (first) {
return `/collections/${first.get('name')}`;
} else {
throw new Error('Could not find a non hidden collection');
}
}; };
const RouteInCollection = ({ collections, render, ...props }) => { const RouteInCollection = ({ collections, render, ...props }) => {

View File

@ -133,7 +133,12 @@ class Sidebar extends React.Component {
value={query} value={query}
/> />
</SearchContainer> </SearchContainer>
<SidebarNavList>{collections.toList().map(this.renderLink)}</SidebarNavList> <SidebarNavList>
{collections
.toList()
.filter(collection => collection.get('hide') !== true)
.map(this.renderLink)}
</SidebarNavList>
</SidebarContainer> </SidebarContainer>
); );
} }

View File

@ -118,6 +118,7 @@ const getConfigSchema = () => ({
preview_path_date_field: { type: 'string' }, preview_path_date_field: { type: 'string' },
create: { type: 'boolean' }, create: { type: 'boolean' },
publish: { type: 'boolean' }, publish: { type: 'boolean' },
hide: { type: 'boolean' },
editor: { editor: {
type: 'object', type: 'object',
properties: { properties: {

View File

@ -195,6 +195,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it
* `filter`: optional filter for `folder` collections; details in [Collection Types](../collection-types) * `filter`: optional filter for `folder` collections; details in [Collection Types](../collection-types)
* `create`: for `folder` collections only; `true` allows users to create new items in the collection; defaults to `false` * `create`: for `folder` collections only; `true` allows users to create new items in the collection; defaults to `false`
* `publish`: for `publish_mode: editorial_workflow` only; `false` hides UI publishing controls for a collection; defaults to `true` * `publish`: for `publish_mode: editorial_workflow` only; `false` hides UI publishing controls for a collection; defaults to `true`
* `hide`: `true` hides a collection in the CMS UI; defaults to `false`. Useful when using the relation widget to hide referenced collections.
* `delete`: `false` prevents users from deleting items in a collection; defaults to `true` * `delete`: `false` prevents users from deleting items in a collection; defaults to `true`
* `extension`: see detailed description below * `extension`: see detailed description below
* `format`: see detailed description below * `format`: see detailed description below