Bug 1074681 - When Loop "rooms" are enabled, hide the old call url generation UI. r=mikedeboer

This commit is contained in:
Mark Banner 2014-11-17 14:18:46 +00:00
parent 631f035cb1
commit e7b2f9f103
4 changed files with 64 additions and 45 deletions

View File

@ -31,13 +31,19 @@ loop.panel = (function(_, mozL10n) {
getDefaultProps: function() {
return {
buttonsHidden: false,
selectedTab: "call"
buttonsHidden: false
};
},
getInitialState: function() {
return {selectedTab: this.props.selectedTab};
// XXX Work around props.selectedTab being undefined initially.
// When we don't need to rely on the pref, this can move back to
// getDefaultProps (bug 1100258).
return {
selectedTab: this.props.selectedTab ||
(navigator.mozLoop.getLoopBoolPref("rooms.enabled") ?
"rooms" : "call")
};
},
handleSelectTab: function(event) {
@ -678,13 +684,17 @@ loop.panel = (function(_, mozL10n) {
}
},
_roomsEnabled: function() {
return navigator.mozLoop.getLoopBoolPref("rooms.enabled");
},
_onStatusChanged: function() {
var profile = navigator.mozLoop.userProfile;
var currUid = this.state.userProfile ? this.state.userProfile.uid : null;
var newUid = profile ? profile.uid : null;
if (currUid != newUid) {
// On profile change (login, logout), switch back to the default tab.
this.selectTab("call");
this.selectTab(this._roomsEnabled() ? "rooms" : "call");
this.setState({userProfile: profile});
}
this.updateServiceErrors();
@ -692,17 +702,28 @@ loop.panel = (function(_, mozL10n) {
/**
* The rooms feature is hidden by default for now. Once it gets mainstream,
* this method can be safely removed.
* this method can be simplified.
*/
_renderRoomsTab: function() {
if (!navigator.mozLoop.getLoopBoolPref("rooms.enabled")) {
return null;
_renderRoomsOrCallTab: function() {
if (!this._roomsEnabled()) {
return (
Tab({name: "call"},
React.DOM.div({className: "content-area"},
CallUrlResult({client: this.props.client,
notifications: this.props.notifications,
callUrl: this.props.callUrl}),
ToSView(null)
)
)
);
}
return (
Tab({name: "rooms"},
RoomList({dispatcher: this.props.dispatcher,
store: this.props.roomStore,
userDisplayName: this._getUserDisplayName()})
userDisplayName: this._getUserDisplayName()}),
ToSView(null)
)
);
},
@ -735,21 +756,14 @@ loop.panel = (function(_, mozL10n) {
render: function() {
var NotificationListView = sharedViews.NotificationListView;
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},
Tab({name: "call"},
React.DOM.div({className: "content-area"},
CallUrlResult({client: this.props.client,
notifications: this.props.notifications,
callUrl: this.props.callUrl}),
ToSView(null)
)
),
this._renderRoomsTab(),
this._renderRoomsOrCallTab(),
Tab({name: "contacts"},
ContactsList({selectTab: this.selectTab,
startForm: this.startForm})

View File

@ -31,13 +31,19 @@ loop.panel = (function(_, mozL10n) {
getDefaultProps: function() {
return {
buttonsHidden: false,
selectedTab: "call"
buttonsHidden: false
};
},
getInitialState: function() {
return {selectedTab: this.props.selectedTab};
// XXX Work around props.selectedTab being undefined initially.
// When we don't need to rely on the pref, this can move back to
// getDefaultProps (bug 1100258).
return {
selectedTab: this.props.selectedTab ||
(navigator.mozLoop.getLoopBoolPref("rooms.enabled") ?
"rooms" : "call")
};
},
handleSelectTab: function(event) {
@ -678,13 +684,17 @@ loop.panel = (function(_, mozL10n) {
}
},
_roomsEnabled: function() {
return navigator.mozLoop.getLoopBoolPref("rooms.enabled");
},
_onStatusChanged: function() {
var profile = navigator.mozLoop.userProfile;
var currUid = this.state.userProfile ? this.state.userProfile.uid : null;
var newUid = profile ? profile.uid : null;
if (currUid != newUid) {
// On profile change (login, logout), switch back to the default tab.
this.selectTab("call");
this.selectTab(this._roomsEnabled() ? "rooms" : "call");
this.setState({userProfile: profile});
}
this.updateServiceErrors();
@ -692,17 +702,28 @@ loop.panel = (function(_, mozL10n) {
/**
* The rooms feature is hidden by default for now. Once it gets mainstream,
* this method can be safely removed.
* this method can be simplified.
*/
_renderRoomsTab: function() {
if (!navigator.mozLoop.getLoopBoolPref("rooms.enabled")) {
return null;
_renderRoomsOrCallTab: function() {
if (!this._roomsEnabled()) {
return (
<Tab name="call">
<div className="content-area">
<CallUrlResult client={this.props.client}
notifications={this.props.notifications}
callUrl={this.props.callUrl} />
<ToSView />
</div>
</Tab>
);
}
return (
<Tab name="rooms">
<RoomList dispatcher={this.props.dispatcher}
store={this.props.roomStore}
userDisplayName={this._getUserDisplayName()}/>
<ToSView />
</Tab>
);
},
@ -735,21 +756,14 @@ loop.panel = (function(_, mozL10n) {
render: function() {
var NotificationListView = sharedViews.NotificationListView;
return (
<div>
<NotificationListView notifications={this.props.notifications}
clearOnDocumentHidden={true} />
<TabView ref="tabView" selectedTab={this.props.selectedTab}
buttonsHidden={!this.state.userProfile && !this.props.showTabButtons}>
<Tab name="call">
<div className="content-area">
<CallUrlResult client={this.props.client}
notifications={this.props.notifications}
callUrl={this.props.callUrl} />
<ToSView />
</div>
</Tab>
{this._renderRoomsTab()}
{this._renderRoomsOrCallTab()}
<Tab name="contacts">
<ContactsList selectTab={this.selectTab}
startForm={this.startForm} />

View File

@ -140,7 +140,6 @@ body {
/* Rooms */
.rooms {
background: #f5f5f5;
min-height: 100px;
}

View File

@ -184,7 +184,7 @@ describe("loop.panel", function() {
view = createTestPanelView();
[callTab, roomsTab, contactsTab] =
[roomsTab, contactsTab] =
TestUtils.scryRenderedDOMComponentsWithClass(view, "tab");
});
@ -203,14 +203,6 @@ describe("loop.panel", function() {
expect(roomsTab.getDOMNode().classList.contains("selected"))
.to.be.true;
});
it("should select call tab when clicking tab button", function() {
TestUtils.Simulate.click(
view.getDOMNode().querySelector("li[data-tab-name=\"call\"]"));
expect(callTab.getDOMNode().classList.contains("selected"))
.to.be.true;
});
});
describe("loop.rooms.enabled off", function() {