summaryrefslogtreecommitdiffstats
path: root/install/ui
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-03-19 15:29:58 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-03-27 12:44:40 +0100
commite7bfac1e63360993aea2be91082ca69c478f3cf1 (patch)
treec5e1d2161fd27498f9faadf6c9fb651159a7e061 /install/ui
parente04da74626dbaef9990833cf1def23da51981a93 (diff)
downloadfreeipa-e7bfac1e63360993aea2be91082ca69c478f3cf1.tar.gz
freeipa-e7bfac1e63360993aea2be91082ca69c478f3cf1.tar.xz
freeipa-e7bfac1e63360993aea2be91082ca69c478f3cf1.zip
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>
Diffstat (limited to 'install/ui')
-rw-r--r--install/ui/src/freeipa/app.js85
-rw-r--r--install/ui/src/freeipa/app_container.js95
-rw-r--r--install/ui/src/freeipa/menu.js6
-rw-r--r--install/ui/src/freeipa/navigation.js45
4 files changed, 122 insertions, 109 deletions
diff --git a/install/ui/src/freeipa/app.js b/install/ui/src/freeipa/app.js
index 69bf2e717..8ffc0e09c 100644
--- a/install/ui/src/freeipa/app.js
+++ b/install/ui/src/freeipa/app.js
@@ -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;
}); \ No newline at end of file
diff --git a/install/ui/src/freeipa/app_container.js b/install/ui/src/freeipa/app_container.js
new file mode 100644
index 000000000..c56fc3bfe
--- /dev/null
+++ b/install/ui/src/freeipa/app_container.js
@@ -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;
+}); \ No newline at end of file
diff --git a/install/ui/src/freeipa/menu.js b/install/ui/src/freeipa/menu.js
index 3da643890..2cd9bdcd7 100644
--- a/install/ui/src/freeipa/menu.js
+++ b/install/ui/src/freeipa/menu.js
@@ -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;
},
/**
diff --git a/install/ui/src/freeipa/navigation.js b/install/ui/src/freeipa/navigation.js
index 8b96d6f97..ef0a0bf3f 100644
--- a/install/ui/src/freeipa/navigation.js
+++ b/install/ui/src/freeipa/navigation.js
@@ -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;
});