improvement: show quick add dropdown conditionally (#1679)

This commit is contained in:
Bevan Wentzel 2018-08-28 18:38:56 +02:00 committed by Shawn Erquhart
parent 8c2217720f
commit 17530eb42a
3 changed files with 25 additions and 12 deletions

View File

@ -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"

View File

@ -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
| [<img src="https://avatars0.githubusercontent.com/u/23248886?v=4" width="100px;"/><br /><sub><b>Brian Macdonald</b></sub>](https://github.com/brianlmacdonald)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=brianlmacdonald "Code") | [<img src="https://avatars1.githubusercontent.com/u/15092?v=4" width="100px;"/><br /><sub><b>John Vandenberg</b></sub>](https://jayvdb.github.io/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=jayvdb "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/24911956?v=4" width="100px;"/><br /><sub><b>MarkZither</b></sub>](https://github.com/MarkZither)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=MarkZither "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/9257284?v=4" width="100px;"/><br /><sub><b>Rob Phoenix</b></sub>](https://www.robphoenix.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=robphoenix "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3028764?v=4" width="100px;"/><br /><sub><b>Steve Lathrop</b></sub>](https://www.SteLa.io)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=slathrop "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=slathrop "Documentation") [💡](#example-slathrop "Examples") | [<img src="https://avatars0.githubusercontent.com/u/10004167?v=4" width="100px;"/><br /><sub><b>Maciej Matuszewski</b></sub>](https://github.com/maciejmatu)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=maciejmatu "Code") | [<img src="https://avatars0.githubusercontent.com/u/36023898?v=4" width="100px;"/><br /><sub><b>Eko Eryanto</b></sub>](https://github.com/ekoeryanto)<br />[🔌](#plugin-ekoeryanto "Plugin/utility libraries") |
| [<img src="https://avatars3.githubusercontent.com/u/366688?v=4" width="100px;"/><br /><sub><b>Taylor D. Edmiston</b></sub>](http://blog.tedmiston.com/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=tedmiston "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1088089?v=4" width="100px;"/><br /><sub><b>Daniel Mahon</b></sub>](https://www.mahonstudios.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=danielmahon "Code") | [<img src="https://avatars1.githubusercontent.com/u/16711653?v=4" width="100px;"/><br /><sub><b>Evan Hennessy</b></sub>](https://www.hennessyevan.com)<br />[🔌](#plugin-hennessyevan "Plugin/utility libraries") | [<img src="https://avatars1.githubusercontent.com/u/3259517?v=4" width="100px;"/><br /><sub><b>Hasan Azizul Haque</b></sub>](https://hasanavi.me)<br />[💻](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") | [<img src="https://avatars1.githubusercontent.com/u/5166612?v=4" width="100px;"/><br /><sub><b>Robert Karlsson</b></sub>](https://github.com/robertkarlsson)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Arobertkarlsson "Bug reports") | [<img src="https://avatars2.githubusercontent.com/u/3484527?v=4" width="100px;"/><br /><sub><b>Gil Greenberg</b></sub>](http://gilgreenberg.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=gil-- "Code") | [<img src="https://avatars0.githubusercontent.com/u/649890?v=4" width="100px;"/><br /><sub><b>Tyler Ipson</b></sub>](http://loremipson.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=loremipson "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/1061992?v=4" width="100px;"/><br /><sub><b>Jake Rayson</b></sub>](https://www.growdigital.org/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=growdigital "Code") [📝](#blog-growdigital "Blogposts") [💡](#example-growdigital "Examples") | [<img src="https://avatars1.githubusercontent.com/u/29014463?v=4" width="100px;"/><br /><sub><b>Yashu Mittal</b></sub>](https://mittalyashu.now.sh/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=mittalyashu "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/42543284?v=4" width="100px;"/><br /><sub><b>Kurt collins</b></sub>](https://github.com/kurtgcollins)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=kurtgcollins "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1516558?v=4" width="100px;"/><br /><sub><b>Cory Williamson-Cardneau</b></sub>](http://cory.williamson-cardneau.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=cory-wc "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/31967674?v=4" width="100px;"/><br /><sub><b>Casey Schroeder</b></sub>](https://github.com/cdschroeder)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=cdschroeder "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/8009243?v=4" width="100px;"/><br /><sub><b>Mitchell Cash</b></sub>](https://mitchellcash.com)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AMitchellCash "Bug reports") [📖](https://github.com/netlify/netlify-cms/commits?author=MitchellCash "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/22135379?v=4" width="100px;"/><br /><sub><b>Glendon Hodges</b></sub>](https://github.com/g-hodges)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=g-hodges "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/13152809?v=4" width="100px;"/><br /><sub><b>Bevan Wentzel</b></sub>](https://github.com/bevanmw)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=bevanmw "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View File

@ -127,6 +127,10 @@ export default class Header extends React.Component {
displayUrl,
} = this.props;
const createableCollections = collections
.filter(collection => collection.get('create'))
.toList();
return (
<AppHeaderContainer>
<AppHeader>
@ -152,16 +156,14 @@ export default class Header extends React.Component {
</AppHeaderButton>
</nav>
<AppHeaderActions>
{createableCollections.size > 0 && (
<Dropdown
renderButton={() => <AppHeaderQuickNewButton>Quick add</AppHeaderQuickNewButton>}
dropdownTopOverlap="30px"
dropdownWidth="160px"
dropdownPosition="left"
>
{collections
.filter(collection => collection.get('create'))
.toList()
.map(collection => (
{createableCollections.map(collection => (
<DropdownItem
key={collection.get('name')}
label={collection.get('label_singular') || collection.get('label')}
@ -169,6 +171,7 @@ export default class Header extends React.Component {
/>
))}
</Dropdown>
)}
<SettingsDropdown
displayUrl={displayUrl}
imageUrl={user.get('avatar_url')}