replace waffle with site config

This commit is contained in:
Kevin Ngo 2014-10-09 18:13:26 -07:00
Родитель 6a82a68561
Коммит 558b5969f4
4 изменённых файлов: 34 добавлений и 28 удалений

10
dist/core/login.js поставляемый
Просмотреть файл

@ -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.

26
dist/core/site_config.js поставляемый Normal file
Просмотреть файл

@ -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(),
};
});

24
dist/core/waffles.js поставляемый
Просмотреть файл

@ -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'
];