зеркало из https://github.com/mozilla/commonplace.git
replace waffle with site config
This commit is contained in:
Родитель
6a82a68561
Коммит
558b5969f4
|
@ -1,6 +1,10 @@
|
|||
define('login',
|
||||
['cache', 'capabilities', 'defer', 'jquery', 'log', 'notification', 'settings', 'storage', 'underscore', 'urls', 'user', 'utils', 'requests', 'waffles', 'z'],
|
||||
function(cache, capabilities, defer, $, log, notification, settings, storage, _, urls, user, utils, requests, waffles, z) {
|
||||
['cache', 'capabilities', 'defer', 'jquery', 'log', 'notification',
|
||||
'settings', 'site_config', 'storage', 'underscore', 'urls', 'user',
|
||||
'utils', 'requests', 'z'],
|
||||
function(cache, capabilities, defer, $, log, notification,
|
||||
settings, siteConfig, storage, _, urls, user,
|
||||
utils, requests, z) {
|
||||
|
||||
var console = log('login');
|
||||
var persona_def = defer.Deferred();
|
||||
|
@ -291,7 +295,7 @@ define('login',
|
|||
return persona_loaded;
|
||||
}
|
||||
|
||||
waffles.promise.done(function() {
|
||||
siteConfig.promise.done(function(data) {
|
||||
if (!capabilities.fallbackFxA()) {
|
||||
// Try to load persona. This is used by persona native/fallback
|
||||
// implementation, as well as fxa native.
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Get Zamboni site configuration data, including waffle switches and FXA
|
||||
info.
|
||||
*/
|
||||
define('site_config', ['defer', 'requests', 'settings', 'urls'],
|
||||
function(defer, requests, settings, urls) {
|
||||
|
||||
function fetch() {
|
||||
var def = defer.Deferred();
|
||||
requests.get(urls.api.url('site-config')).done(function(data) {
|
||||
settings.fxa_auth_url = data.fxa.fxa_auth_url;
|
||||
settings.fxa_auth_state = data.fxa.fxa_auth_state;
|
||||
settings.switches = data.waffle.switches || [];
|
||||
def.resolve(data);
|
||||
}).always(function() {
|
||||
def.resolve();
|
||||
});
|
||||
|
||||
return def.promise();
|
||||
}
|
||||
|
||||
return {
|
||||
'fetch': fetch,
|
||||
'promise': fetch(),
|
||||
};
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
Get Zamboni waffle switches and store it into the cache.
|
||||
On a clean cache, the promise will block on the request.
|
||||
On subsequent page loads, the promise will resolve from the cache.
|
||||
*/
|
||||
define('waffles', ['defer', 'requests', 'settings', 'urls'],
|
||||
function(defer, requests, settings, urls) {
|
||||
|
||||
function fetch() {
|
||||
var def = defer.Deferred();
|
||||
requests.get(urls.api.url('waffles')).done(function(waffle) {
|
||||
settings.switches = waffle.switches || [];
|
||||
}).always(function() {
|
||||
def.resolve();
|
||||
});
|
||||
|
||||
return def.promise();
|
||||
}
|
||||
|
||||
return {
|
||||
'fetch': fetch,
|
||||
'promise': fetch(),
|
||||
};
|
||||
});
|
|
@ -22,12 +22,12 @@ var CORE_MODULES = [
|
|||
'nunjucks',
|
||||
'nunjucks.compat',
|
||||
'requests',
|
||||
'site_config',
|
||||
'storage',
|
||||
'urls',
|
||||
'user',
|
||||
'utils',
|
||||
'views',
|
||||
'waffles',
|
||||
'z'
|
||||
];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче