mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
webui: make navigation module independent on app module
When some module used 'freeipa/navigation' it pulled the entire Web UI because navigation depended on app. This patch splits the app into two modules: app and app_container. App specifies the entities which are part of final application. app_container module represents the application boot classes. Navigation now depends on app_container. Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat
|
||||
* see file 'COPYING'./for use and warranty information
|
||||
* see file 'COPYING' for use and warranty information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,16 +20,8 @@
|
||||
|
||||
define([
|
||||
//core
|
||||
'dojo/_base/lang',
|
||||
'dojo/Deferred',
|
||||
'dojo/when',
|
||||
'./plugin_loader',
|
||||
'./phases',
|
||||
'./Application_controller',
|
||||
'exports', // for circullar deps
|
||||
'./ipa',
|
||||
'./jquery',
|
||||
//only entities
|
||||
'./app_container',
|
||||
//entities
|
||||
'./aci',
|
||||
'./automember',
|
||||
'./automount',
|
||||
@@ -53,73 +45,6 @@ define([
|
||||
'./trust',
|
||||
'./user',
|
||||
'dojo/domReady!'
|
||||
],function(lang, Deferred, when, plugin_loader, phases, Application_controller, exports) {
|
||||
|
||||
/**
|
||||
* Application wrapper
|
||||
*
|
||||
* Prepares application controller and registers phases.
|
||||
*
|
||||
* @class app
|
||||
* @singleton
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Application instance
|
||||
*/
|
||||
app: null,
|
||||
|
||||
/**
|
||||
* Application class
|
||||
*/
|
||||
App_class: Application_controller,
|
||||
|
||||
/**
|
||||
* Phases registration
|
||||
*/
|
||||
register_phases: function() {
|
||||
|
||||
phases.on('init', lang.hitch(this, function() {
|
||||
var app = this.app = new this.App_class();
|
||||
app.init();
|
||||
return app;
|
||||
}));
|
||||
|
||||
phases.on('metadata', lang.hitch(this, function() {
|
||||
var deferred = new Deferred();
|
||||
|
||||
this.app.get_configuration(function(success) {
|
||||
deferred.resolve(success);
|
||||
}, function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}));
|
||||
|
||||
phases.on('profile', lang.hitch(this, function() {
|
||||
this.app.choose_profile();
|
||||
}));
|
||||
|
||||
phases.on('runtime', lang.hitch(this, function() {
|
||||
return this.app.start_runtime();
|
||||
}));
|
||||
|
||||
phases.on('shutdown', lang.hitch(this, function() {
|
||||
return this.app.start_logout();
|
||||
}));
|
||||
},
|
||||
|
||||
run: function() {
|
||||
when(plugin_loader.load_plugins(), lang.hitch(this, function() {
|
||||
this.register_phases();
|
||||
phases.controller.run();
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
lang.mixin(exports, app);
|
||||
|
||||
return exports;
|
||||
],function(app_container) {
|
||||
return app_container;
|
||||
});
|
||||
95
install/ui/src/freeipa/app_container.js
Normal file
95
install/ui/src/freeipa/app_container.js
Normal file
@@ -0,0 +1,95 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat
|
||||
* see file 'COPYING' for use and warranty information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'dojo/_base/lang',
|
||||
'dojo/Deferred',
|
||||
'dojo/when',
|
||||
'./plugin_loader',
|
||||
'./phases',
|
||||
'./Application_controller'
|
||||
],function(lang, Deferred, when, plugin_loader, phases, Application_controller) {
|
||||
|
||||
/**
|
||||
* Application wrapper
|
||||
*
|
||||
* Prepares application controller and registers phases.
|
||||
*
|
||||
* @class app
|
||||
* @singleton
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Application instance
|
||||
*/
|
||||
app: null,
|
||||
|
||||
/**
|
||||
* Application class
|
||||
*/
|
||||
App_class: Application_controller,
|
||||
|
||||
/**
|
||||
* Phases registration
|
||||
*/
|
||||
register_phases: function() {
|
||||
|
||||
phases.on('init', lang.hitch(this, function() {
|
||||
var app = this.app = new this.App_class();
|
||||
app.init();
|
||||
return app;
|
||||
}));
|
||||
|
||||
phases.on('metadata', lang.hitch(this, function() {
|
||||
var deferred = new Deferred();
|
||||
|
||||
this.app.get_configuration(function(success) {
|
||||
deferred.resolve(success);
|
||||
}, function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}));
|
||||
|
||||
phases.on('profile', lang.hitch(this, function() {
|
||||
this.app.choose_profile();
|
||||
}));
|
||||
|
||||
phases.on('runtime', lang.hitch(this, function() {
|
||||
return this.app.start_runtime();
|
||||
}));
|
||||
|
||||
phases.on('shutdown', lang.hitch(this, function() {
|
||||
return this.app.start_logout();
|
||||
}));
|
||||
},
|
||||
|
||||
run: function() {
|
||||
when(plugin_loader.load_plugins(), lang.hitch(this, function() {
|
||||
this.register_phases();
|
||||
phases.controller.run();
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
return app;
|
||||
});
|
||||
@@ -21,15 +21,15 @@
|
||||
|
||||
define([
|
||||
'dojo/_base/lang',
|
||||
'./app', // creates circular dependency
|
||||
'./app_container',
|
||||
'./ipa',
|
||||
'exports' // for handling circular dependency
|
||||
],
|
||||
function(lang, app, IPA, exports) {
|
||||
function(lang, app_container, IPA, exports) {
|
||||
|
||||
|
||||
var get_menu = function() {
|
||||
return app.app.menu;
|
||||
return app_container.app.menu;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
|
||||
define([
|
||||
'dojo/_base/lang',
|
||||
'./app', // creates circular dependency
|
||||
'./ipa',
|
||||
'exports' // for handling circular dependency
|
||||
'./app_container',
|
||||
'./ipa'
|
||||
],
|
||||
function(lang, app, IPA, exports) {
|
||||
function(lang, app_container, IPA) {
|
||||
|
||||
|
||||
var get_router = function() {
|
||||
return app.app.router;
|
||||
},
|
||||
return app_container.app.router;
|
||||
};
|
||||
|
||||
var navigation = {
|
||||
/**
|
||||
* Navigation tells application to show certain facet.
|
||||
*
|
||||
@@ -53,7 +53,7 @@ define([
|
||||
* @param Object params
|
||||
* @param {Object|facet.facet|string|Function} arg
|
||||
*/
|
||||
set_params = function(params, arg) {
|
||||
set_params: function(params, arg) {
|
||||
if (lang.isArray(arg)) {
|
||||
params.pkeys = arg;
|
||||
} else if (typeof arg === 'object') {
|
||||
@@ -86,14 +86,14 @@ define([
|
||||
* @param {Object|facet.facet|string|Function} arg2
|
||||
* @param {Object|facet.facet|string|Function} arg3
|
||||
*/
|
||||
show = function(arg1, arg2, arg3) {
|
||||
show: function(arg1, arg2, arg3) {
|
||||
|
||||
var nav = get_router();
|
||||
var params = {};
|
||||
|
||||
set_params(params, arg1);
|
||||
set_params(params, arg2);
|
||||
set_params(params, arg3);
|
||||
this.set_params(params, arg1);
|
||||
this.set_params(params, arg2);
|
||||
this.set_params(params, arg3);
|
||||
|
||||
var facet = params.facet;
|
||||
|
||||
@@ -129,13 +129,13 @@ define([
|
||||
* @param {Object|facet.facet|string|Function} arg2
|
||||
* @param {Object|facet.facet|string|Function} arg3
|
||||
*/
|
||||
show_entity = function(entity_name, arg1, arg2, arg3) {
|
||||
show_entity: function(entity_name, arg1, arg2, arg3) {
|
||||
var nav = get_router();
|
||||
var params = {};
|
||||
|
||||
set_params(params, arg1);
|
||||
set_params(params, arg2);
|
||||
set_params(params, arg3);
|
||||
this.set_params(params, arg1);
|
||||
this.set_params(params, arg2);
|
||||
this.set_params(params, arg3);
|
||||
return nav.navigate_to_entity_facet(entity_name, params.facet,
|
||||
params.pkeys, params.args);
|
||||
},
|
||||
@@ -144,17 +144,10 @@ define([
|
||||
* Show default facet
|
||||
* @method show_default
|
||||
*/
|
||||
show_default = function() {
|
||||
show_default: function() {
|
||||
// TODO: make configurable
|
||||
return show_entity('user', 'search');
|
||||
};
|
||||
|
||||
// Module export
|
||||
exports = {
|
||||
show: show,
|
||||
show_entity: show_entity,
|
||||
show_default: show_default
|
||||
return this.show_entity('user', 'search');
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
return navigation;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user