don't show site switcher if there's only 1 site with no option to add more

This commit is contained in:
Danny van Kooten 2018-10-09 10:00:18 +02:00
parent 41331598b9
commit adb26ad32f

View File

@ -32,15 +32,18 @@ class SiteSwitcher extends Component {
} }
render(props, state) { render(props, state) {
let siteNodes = props.sites.map((s) => (<li class="site-switch"><a href="javascript:void(0);" data-id={s.id} onClick={this.selectSite}>{s.name}</a></li>)) // show nothing if there is only 1 site and no option to add additional sites
let addSiteNode = props.showAdd ? (<li class="add-new"><a href="javascript:void(0);" onClick={this.addSite}>+ Add another site</a></li>) : ''; if(!props.showAdd && props.sites.length == 1) {
return '';
}
// otherwise, render list of sites + add button
return ( return (
<li class="sites"> <li class="sites">
<a href="javascript:void(0)">{props.selectedSite.name}</a> <a href="javascript:void(0)">{props.selectedSite.name}</a>
<ul> <ul>
{siteNodes} {props.sites.map((s) => (<li class="site-switch"><a href="javascript:void(0);" data-id={s.id} onClick={this.selectSite}>{s.name}</a></li>)) }
{addSiteNode} {props.showAdd ? (<li class="add-new"><a href="javascript:void(0);" onClick={this.addSite}>+ Add another site</a></li>) : ''}
</ul> </ul>
</li> </li>
) )