Bug 1101754 - Hide the rooms/contacts view until the Getting Started tour has been accessed or dismissed. r=mikedeboer

This commit is contained in:
Jared Wein 2014-11-21 15:53:54 -05:00
Родитель 30a1fec522
Коммит f5d53a75af
6 изменённых файлов: 57 добавлений и 14 удалений

Просмотреть файл

@ -165,12 +165,11 @@ loop.panel = (function(_, mozL10n) {
});
var GettingStartedView = React.createClass({displayName: 'GettingStartedView',
componentDidMount: function() {
navigator.mozLoop.setLoopPref("gettingStarted.seen", true);
},
handleButtonClick: function() {
navigator.mozLoop.openGettingStartedTour();
navigator.mozLoop.setLoopPref("gettingStarted.seen", true);
var event = new CustomEvent("GettingStartedSeen");
window.dispatchEvent(event);
},
render: function() {
@ -694,6 +693,7 @@ loop.panel = (function(_, mozL10n) {
getInitialState: function() {
return {
userProfile: this.props.userProfile || navigator.mozLoop.userProfile,
gettingStartedSeen: navigator.mozLoop.getLoopPref("gettingStarted.seen"),
};
},
@ -741,6 +741,12 @@ loop.panel = (function(_, mozL10n) {
this.updateServiceErrors();
},
_gettingStartedSeen: function() {
this.setState({
gettingStartedSeen: navigator.mozLoop.getLoopPref("gettingStarted.seen"),
});
},
/**
* The rooms feature is hidden by default for now. Once it gets mainstream,
* this method can be simplified.
@ -750,7 +756,6 @@ loop.panel = (function(_, mozL10n) {
return (
Tab({name: "call"},
React.DOM.div({className: "content-area"},
GettingStartedView(null),
CallUrlResult({client: this.props.client,
notifications: this.props.notifications,
callUrl: this.props.callUrl}),
@ -762,7 +767,6 @@ loop.panel = (function(_, mozL10n) {
return (
Tab({name: "rooms"},
GettingStartedView(null),
RoomList({dispatcher: this.props.dispatcher,
store: this.props.roomStore,
userDisplayName: this._getUserDisplayName()}),
@ -786,10 +790,12 @@ loop.panel = (function(_, mozL10n) {
componentDidMount: function() {
window.addEventListener("LoopStatusChanged", this._onStatusChanged);
window.addEventListener("GettingStartedSeen", this._gettingStartedSeen);
},
componentWillUnmount: function() {
window.removeEventListener("LoopStatusChanged", this._onStatusChanged);
window.removeEventListener("GettingStartedSeen", this._gettingStartedSeen);
},
_getUserDisplayName: function() {
@ -800,6 +806,17 @@ loop.panel = (function(_, mozL10n) {
render: function() {
var NotificationListView = sharedViews.NotificationListView;
if (!this.state.gettingStartedSeen) {
return (
React.DOM.div(null,
NotificationListView({notifications: this.props.notifications,
clearOnDocumentHidden: true}),
GettingStartedView(null),
ToSView(null)
)
);
}
return (
React.DOM.div(null,
NotificationListView({notifications: this.props.notifications,

Просмотреть файл

@ -165,12 +165,11 @@ loop.panel = (function(_, mozL10n) {
});
var GettingStartedView = React.createClass({
componentDidMount: function() {
navigator.mozLoop.setLoopPref("gettingStarted.seen", true);
},
handleButtonClick: function() {
navigator.mozLoop.openGettingStartedTour();
navigator.mozLoop.setLoopPref("gettingStarted.seen", true);
var event = new CustomEvent("GettingStartedSeen");
window.dispatchEvent(event);
},
render: function() {
@ -694,6 +693,7 @@ loop.panel = (function(_, mozL10n) {
getInitialState: function() {
return {
userProfile: this.props.userProfile || navigator.mozLoop.userProfile,
gettingStartedSeen: navigator.mozLoop.getLoopPref("gettingStarted.seen"),
};
},
@ -741,6 +741,12 @@ loop.panel = (function(_, mozL10n) {
this.updateServiceErrors();
},
_gettingStartedSeen: function() {
this.setState({
gettingStartedSeen: navigator.mozLoop.getLoopPref("gettingStarted.seen"),
});
},
/**
* The rooms feature is hidden by default for now. Once it gets mainstream,
* this method can be simplified.
@ -750,7 +756,6 @@ loop.panel = (function(_, mozL10n) {
return (
<Tab name="call">
<div className="content-area">
<GettingStartedView />
<CallUrlResult client={this.props.client}
notifications={this.props.notifications}
callUrl={this.props.callUrl} />
@ -762,7 +767,6 @@ loop.panel = (function(_, mozL10n) {
return (
<Tab name="rooms">
<GettingStartedView />
<RoomList dispatcher={this.props.dispatcher}
store={this.props.roomStore}
userDisplayName={this._getUserDisplayName()}/>
@ -786,10 +790,12 @@ loop.panel = (function(_, mozL10n) {
componentDidMount: function() {
window.addEventListener("LoopStatusChanged", this._onStatusChanged);
window.addEventListener("GettingStartedSeen", this._gettingStartedSeen);
},
componentWillUnmount: function() {
window.removeEventListener("LoopStatusChanged", this._onStatusChanged);
window.removeEventListener("GettingStartedSeen", this._gettingStartedSeen);
},
_getUserDisplayName: function() {
@ -800,6 +806,17 @@ loop.panel = (function(_, mozL10n) {
render: function() {
var NotificationListView = sharedViews.NotificationListView;
if (!this.state.gettingStartedSeen) {
return (
<div>
<NotificationListView notifications={this.props.notifications}
clearOnDocumentHidden={true} />
<GettingStartedView />
<ToSView />
</div>
);
}
return (
<div>
<NotificationListView notifications={this.props.notifications}

Просмотреть файл

@ -107,7 +107,6 @@ body {
#fte-getstarted {
padding-top: 1em;
padding-bottom: 1em;
border-bottom: 1px solid #ccc;
margin-bottom: 1em;
}

Просмотреть файл

@ -175,7 +175,8 @@ describe("loop.panel", function() {
describe("loop.rooms.enabled on", function() {
beforeEach(function() {
navigator.mozLoop.getLoopPref = function(pref) {
if (pref === "rooms.enabled") {
if (pref === "rooms.enabled" ||
pref === "gettingStarted.seen") {
return true;
}
};
@ -208,6 +209,8 @@ describe("loop.panel", function() {
navigator.mozLoop.getLoopPref = function(pref) {
if (pref === "rooms.enabled") {
return false;
} else if (pref === "gettingStarted.seen") {
return true;
}
};
@ -373,6 +376,9 @@ describe("loop.panel", function() {
});
it("should render a GettingStarted view", function() {
navigator.mozLoop.getLoopPref = function(pref) {
return false;
};
var view = createTestPanelView();
TestUtils.findRenderedComponentWithType(view, loop.panel.GettingStartedView);

Просмотреть файл

@ -40,6 +40,7 @@ function* checkFxA401() {
add_task(function* setup() {
Services.prefs.setCharPref("loop.server", BASE_URL);
Services.prefs.setCharPref("services.push.serverURL", "ws://localhost/");
Services.prefs.setBoolPref("loop.gettingStarted.seen", true);
MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
// Normally the same pushUrl would be registered but we change it in the test
// to be able to check for success on the second registration.
@ -51,6 +52,7 @@ add_task(function* setup() {
yield promiseDeletedOAuthParams(BASE_URL);
Services.prefs.clearUserPref("loop.server");
Services.prefs.clearUserPref("services.push.serverURL");
Services.prefs.clearUserPref("loop.gettingStarted.seen");
MozLoopServiceInternal.mocks.pushHandler = undefined;
delete mockPushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA];
delete mockPushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA];

Просмотреть файл

@ -9,11 +9,13 @@
Components.utils.import("resource://gre/modules/Promise.jsm", this);
const {LoopRoomsInternal} = Components.utils.import("resource:///modules/loop/LoopRooms.jsm", {});
Services.prefs.setBoolPref("loop.gettingStarted.seen", true);
registerCleanupFunction(function*() {
MozLoopService.doNotDisturb = false;
MozLoopServiceInternal.fxAOAuthProfile = null;
yield MozLoopServiceInternal.clearError("testing");
Services.prefs.clearUserPref("loop.gettingStarted.seen");
});
add_task(function* test_doNotDisturb() {