From 4f624a9f2d77abd85f727bc4b3cf65c966532a5f Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Wed, 10 Dec 2014 12:05:49 +0100 Subject: [PATCH] Bug 1106010: make sure enough UI elements are always visible when not signed in to FxA. r=Niko --- browser/components/loop/content/js/panel.js | 20 +++++++++++++------ browser/components/loop/content/js/panel.jsx | 20 +++++++++++++------ .../loop/content/shared/css/panel.css | 1 + 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/browser/components/loop/content/js/panel.js b/browser/components/loop/content/js/panel.js index de81cb0c9df..7e630b38ff4 100644 --- a/browser/components/loop/content/js/panel.js +++ b/browser/components/loop/content/js/panel.js @@ -23,14 +23,14 @@ loop.panel = (function(_, mozL10n) { var TabView = React.createClass({displayName: 'TabView', propTypes: { - buttonsHidden: React.PropTypes.bool, + buttonsHidden: React.PropTypes.array, // The selectedTab prop is used by the UI showcase. selectedTab: React.PropTypes.string }, getDefaultProps: function() { return { - buttonsHidden: false + buttonsHidden: [] }; }, @@ -60,6 +60,9 @@ loop.panel = (function(_, mozL10n) { return; } var tabName = tab.props.name; + if (this.props.buttonsHidden.indexOf(tabName) > -1) { + return; + } var isSelected = (this.state.selectedTab == tabName); if (!tab.props.hidden) { tabButtons.push( @@ -77,9 +80,7 @@ loop.panel = (function(_, mozL10n) { }, this); return ( React.DOM.div({className: "tab-view-container"}, - !this.props.buttonsHidden - ? React.DOM.ul({className: "tab-view"}, tabButtons) - : null, + React.DOM.ul({className: "tab-view"}, tabButtons), tabs ) ); @@ -782,6 +783,7 @@ loop.panel = (function(_, mozL10n) { // Mostly used for UI components showcase and unit tests callUrl: React.PropTypes.string, userProfile: React.PropTypes.object, + // Used only for unit tests. showTabButtons: React.PropTypes.bool, selectedTab: React.PropTypes.string, dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired, @@ -929,12 +931,18 @@ loop.panel = (function(_, mozL10n) { ); } + // Determine which buttons to NOT show. + var hideButtons = []; + if (!this.state.userProfile && !this.props.showTabButtons) { + hideButtons.push("contacts"); + } + return ( React.DOM.div(null, NotificationListView({notifications: this.props.notifications, clearOnDocumentHidden: true}), TabView({ref: "tabView", selectedTab: this.props.selectedTab, - buttonsHidden: !this.state.userProfile && !this.props.showTabButtons}, + buttonsHidden: hideButtons}, this._renderRoomsOrCallTab(), Tab({name: "contacts"}, ContactsList({selectTab: this.selectTab, diff --git a/browser/components/loop/content/js/panel.jsx b/browser/components/loop/content/js/panel.jsx index 0c05e8e7546..67b03a3d048 100644 --- a/browser/components/loop/content/js/panel.jsx +++ b/browser/components/loop/content/js/panel.jsx @@ -23,14 +23,14 @@ loop.panel = (function(_, mozL10n) { var TabView = React.createClass({ propTypes: { - buttonsHidden: React.PropTypes.bool, + buttonsHidden: React.PropTypes.array, // The selectedTab prop is used by the UI showcase. selectedTab: React.PropTypes.string }, getDefaultProps: function() { return { - buttonsHidden: false + buttonsHidden: [] }; }, @@ -60,6 +60,9 @@ loop.panel = (function(_, mozL10n) { return; } var tabName = tab.props.name; + if (this.props.buttonsHidden.indexOf(tabName) > -1) { + return; + } var isSelected = (this.state.selectedTab == tabName); if (!tab.props.hidden) { tabButtons.push( @@ -77,9 +80,7 @@ loop.panel = (function(_, mozL10n) { }, this); return (
- {!this.props.buttonsHidden - ? - : null} + {tabs}
); @@ -782,6 +783,7 @@ loop.panel = (function(_, mozL10n) { // Mostly used for UI components showcase and unit tests callUrl: React.PropTypes.string, userProfile: React.PropTypes.object, + // Used only for unit tests. showTabButtons: React.PropTypes.bool, selectedTab: React.PropTypes.string, dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired, @@ -929,12 +931,18 @@ loop.panel = (function(_, mozL10n) { ); } + // Determine which buttons to NOT show. + var hideButtons = []; + if (!this.state.userProfile && !this.props.showTabButtons) { + hideButtons.push("contacts"); + } + return (
+ buttonsHidden={hideButtons}> {this._renderRoomsOrCallTab()}