From 17530eb42a7f8a12ca912bf1e22ba3702315382f Mon Sep 17 00:00:00 2001 From: Bevan Wentzel Date: Tue, 28 Aug 2018 18:38:56 +0200 Subject: [PATCH] improvement: show quick add dropdown conditionally (#1679) --- .all-contributorsrc | 9 +++++++ README.md | 3 ++- .../src/components/App/Header.js | 25 +++++++++++-------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index a547e0f5..6f4f04e7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1050,6 +1050,15 @@ "contributions": [ "doc" ] + }, + { + "login": "bevanmw", + "name": "Bevan Wentzel", + "avatar_url": "https://avatars0.githubusercontent.com/u/13152809?v=4", + "profile": "https://github.com/bevanmw", + "contributions": [ + "code" + ] } ], "repoType": "github" diff --git a/README.md b/README.md index 54e81f9e..9305d55d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Netlify CMS -[![All Contributors](https://img.shields.io/badge/all_contributors-119-orange.svg)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-120-orange.svg)](#contributors) [![Open Source Helpers](https://www.codetriage.com/netlify/netlify-cms/badges/users.svg)](https://www.codetriage.com/netlify/netlify-cms) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms) @@ -79,6 +79,7 @@ These wonderful folks are responsible for developing and maintaining Netlify CMS | [
Brian Macdonald](https://github.com/brianlmacdonald)
[💻](https://github.com/netlify/netlify-cms/commits?author=brianlmacdonald "Code") | [
John Vandenberg](https://jayvdb.github.io/)
[📖](https://github.com/netlify/netlify-cms/commits?author=jayvdb "Documentation") | [
MarkZither](https://github.com/MarkZither)
[📖](https://github.com/netlify/netlify-cms/commits?author=MarkZither "Documentation") | [
Rob Phoenix](https://www.robphoenix.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=robphoenix "Documentation") | [
Steve Lathrop](https://www.SteLa.io)
[💻](https://github.com/netlify/netlify-cms/commits?author=slathrop "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=slathrop "Documentation") [💡](#example-slathrop "Examples") | [
Maciej Matuszewski](https://github.com/maciejmatu)
[💻](https://github.com/netlify/netlify-cms/commits?author=maciejmatu "Code") | [
Eko Eryanto](https://github.com/ekoeryanto)
[🔌](#plugin-ekoeryanto "Plugin/utility libraries") | | [
Taylor D. Edmiston](http://blog.tedmiston.com/)
[📖](https://github.com/netlify/netlify-cms/commits?author=tedmiston "Documentation") | [
Daniel Mahon](https://www.mahonstudios.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=danielmahon "Code") | [
Evan Hennessy](https://www.hennessyevan.com)
[🔌](#plugin-hennessyevan "Plugin/utility libraries") | [
Hasan Azizul Haque](https://hasanavi.me)
[💻](https://github.com/netlify/netlify-cms/commits?author=hasanavi "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=hasanavi "Documentation") [🤔](#ideas-hasanavi "Ideas, Planning, & Feedback") | [
Robert Karlsson](https://github.com/robertkarlsson)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Arobertkarlsson "Bug reports") | [
Gil Greenberg](http://gilgreenberg.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=gil-- "Code") | [
Tyler Ipson](http://loremipson.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=loremipson "Documentation") | | [
Jake Rayson](https://www.growdigital.org/)
[💻](https://github.com/netlify/netlify-cms/commits?author=growdigital "Code") [📝](#blog-growdigital "Blogposts") [💡](#example-growdigital "Examples") | [
Yashu Mittal](https://mittalyashu.now.sh/)
[📖](https://github.com/netlify/netlify-cms/commits?author=mittalyashu "Documentation") | [
Kurt collins](https://github.com/kurtgcollins)
[📖](https://github.com/netlify/netlify-cms/commits?author=kurtgcollins "Documentation") | [
Cory Williamson-Cardneau](http://cory.williamson-cardneau.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=cory-wc "Documentation") | [
Casey Schroeder](https://github.com/cdschroeder)
[📖](https://github.com/netlify/netlify-cms/commits?author=cdschroeder "Documentation") | [
Mitchell Cash](https://mitchellcash.com)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AMitchellCash "Bug reports") [📖](https://github.com/netlify/netlify-cms/commits?author=MitchellCash "Documentation") | [
Glendon Hodges](https://github.com/g-hodges)
[📖](https://github.com/netlify/netlify-cms/commits?author=g-hodges "Documentation") | +| [
Bevan Wentzel](https://github.com/bevanmw)
[💻](https://github.com/netlify/netlify-cms/commits?author=bevanmw "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! diff --git a/packages/netlify-cms-core/src/components/App/Header.js b/packages/netlify-cms-core/src/components/App/Header.js index 609514f0..0cea304d 100644 --- a/packages/netlify-cms-core/src/components/App/Header.js +++ b/packages/netlify-cms-core/src/components/App/Header.js @@ -127,6 +127,10 @@ export default class Header extends React.Component { displayUrl, } = this.props; + const createableCollections = collections + .filter(collection => collection.get('create')) + .toList(); + return ( @@ -152,23 +156,22 @@ export default class Header extends React.Component { - Quick add} - dropdownTopOverlap="30px" - dropdownWidth="160px" - dropdownPosition="left" - > - {collections - .filter(collection => collection.get('create')) - .toList() - .map(collection => ( + {createableCollections.size > 0 && ( + Quick add} + dropdownTopOverlap="30px" + dropdownWidth="160px" + dropdownPosition="left" + > + {createableCollections.map(collection => ( this.handleCreatePostClick(collection.get('name'))} /> ))} - + + )}