mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
Bug 1077996 - Allow disabling Loop FxA support and related items (contacts, direct calling) via loop.fxa.enabled. r=mikedeboer
--HG-- extra : rebase_source : 99b0d348b6725c35c048a491e83c65e5b5e1b13d
This commit is contained in:
parent
9a744908c9
commit
eed68ae1a9
@ -474,6 +474,13 @@ function injectLoopAPI(targetWindow) {
|
||||
}
|
||||
},
|
||||
|
||||
fxAEnabled: {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return MozLoopService.fxAEnabled;
|
||||
},
|
||||
},
|
||||
|
||||
logInToFxA: {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
|
@ -85,6 +85,7 @@ let gPushHandler = null;
|
||||
let gHawkClient = null;
|
||||
let gLocalizedStrings = null;
|
||||
let gInitializeTimer = null;
|
||||
let gFxAEnabled = true;
|
||||
let gFxAOAuthClientPromise = null;
|
||||
let gFxAOAuthClient = null;
|
||||
let gFxAOAuthTokenData = null;
|
||||
@ -1073,6 +1074,13 @@ this.MozLoopService = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Services.prefs.getPrefType("loop.fxa.enabled") == Services.prefs.PREF_BOOL) {
|
||||
gFxAEnabled = Services.prefs.getBoolPref("loop.fxa.enabled");
|
||||
if (!gFxAEnabled) {
|
||||
this.logOutFromFxA();
|
||||
}
|
||||
}
|
||||
|
||||
// If expiresTime is in the future then kick-off registration.
|
||||
if (MozLoopServiceInternal.urlExpiryTimeIsInFuture()) {
|
||||
gInitializeTimerFunc();
|
||||
@ -1260,6 +1268,10 @@ this.MozLoopService = {
|
||||
MozLoopServiceInternal.doNotDisturb = aFlag;
|
||||
},
|
||||
|
||||
get fxAEnabled() {
|
||||
return gFxAEnabled;
|
||||
},
|
||||
|
||||
get userProfile() {
|
||||
return gFxAOAuthProfile;
|
||||
},
|
||||
|
@ -230,6 +230,12 @@ loop.panel = (function(_, mozL10n) {
|
||||
|
||||
render: function() {
|
||||
var cx = React.addons.classSet;
|
||||
|
||||
// For now all of the menu entries require FxA so hide the whole gear if FxA is disabled.
|
||||
if (!navigator.mozLoop.fxAEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
React.DOM.div({className: "settings-menu dropdown"},
|
||||
React.DOM.a({className: "button-settings", onClick: this.showDropdownMenu,
|
||||
@ -248,6 +254,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
__("settings_menu_item_signout") :
|
||||
__("settings_menu_item_signin"),
|
||||
onClick: this.handleClickAuthEntry,
|
||||
displayed: navigator.mozLoop.fxAEnabled,
|
||||
icon: this._isSignedIn() ? "signout" : "signin"})
|
||||
)
|
||||
)
|
||||
@ -405,7 +412,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
},
|
||||
|
||||
render: function() {
|
||||
if (navigator.mozLoop.userProfile) {
|
||||
if (!navigator.mozLoop.fxAEnabled || navigator.mozLoop.userProfile) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
@ -582,6 +589,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
return {
|
||||
init: init,
|
||||
UserIdentity: UserIdentity,
|
||||
AuthLink: AuthLink,
|
||||
AvailabilityDropdown: AvailabilityDropdown,
|
||||
CallUrlResult: CallUrlResult,
|
||||
PanelView: PanelView,
|
||||
|
@ -230,6 +230,12 @@ loop.panel = (function(_, mozL10n) {
|
||||
|
||||
render: function() {
|
||||
var cx = React.addons.classSet;
|
||||
|
||||
// For now all of the menu entries require FxA so hide the whole gear if FxA is disabled.
|
||||
if (!navigator.mozLoop.fxAEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="settings-menu dropdown">
|
||||
<a className="button-settings" onClick={this.showDropdownMenu}
|
||||
@ -248,6 +254,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
__("settings_menu_item_signout") :
|
||||
__("settings_menu_item_signin")}
|
||||
onClick={this.handleClickAuthEntry}
|
||||
displayed={navigator.mozLoop.fxAEnabled}
|
||||
icon={this._isSignedIn() ? "signout" : "signin"} />
|
||||
</ul>
|
||||
</div>
|
||||
@ -405,7 +412,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
},
|
||||
|
||||
render: function() {
|
||||
if (navigator.mozLoop.userProfile) {
|
||||
if (!navigator.mozLoop.fxAEnabled || navigator.mozLoop.userProfile) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
@ -582,6 +589,7 @@ loop.panel = (function(_, mozL10n) {
|
||||
return {
|
||||
init: init,
|
||||
UserIdentity: UserIdentity,
|
||||
AuthLink: AuthLink,
|
||||
AvailabilityDropdown: AvailabilityDropdown,
|
||||
CallUrlResult: CallUrlResult,
|
||||
PanelView: PanelView,
|
||||
|
@ -25,6 +25,7 @@ describe("loop.panel", function() {
|
||||
|
||||
navigator.mozLoop = {
|
||||
doNotDisturb: true,
|
||||
fxAEnabled: true,
|
||||
getStrings: function() {
|
||||
return JSON.stringify({textContent: "fakeText"});
|
||||
},
|
||||
@ -177,8 +178,19 @@ describe("loop.panel", function() {
|
||||
|
||||
sinon.assert.calledOnce(navigator.mozLoop.logInToFxA);
|
||||
});
|
||||
|
||||
it("should be hidden if FxA is not enabled",
|
||||
function() {
|
||||
navigator.mozLoop.fxAEnabled = false;
|
||||
var view = TestUtils.renderIntoDocument(loop.panel.AuthLink());
|
||||
expect(view.getDOMNode()).to.be.null;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
navigator.mozLoop.fxAEnabled = true;
|
||||
});
|
||||
});
|
||||
|
||||
describe("SettingsDropdown", function() {
|
||||
var view;
|
||||
|
||||
@ -188,6 +200,17 @@ describe("loop.panel", function() {
|
||||
navigator.mozLoop.openFxASettings = sandbox.stub();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
navigator.mozLoop.fxAEnabled = true;
|
||||
});
|
||||
|
||||
it("should be hidden if FxA is not enabled",
|
||||
function() {
|
||||
navigator.mozLoop.fxAEnabled = false;
|
||||
var view = TestUtils.renderIntoDocument(loop.panel.SettingsDropdown());
|
||||
expect(view.getDOMNode()).to.be.null;
|
||||
});
|
||||
|
||||
it("should show a signin entry when user is not authenticated",
|
||||
function() {
|
||||
navigator.mozLoop.loggedInToFxA = false;
|
||||
|
Loading…
Reference in New Issue
Block a user