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. -- Petr Vobornik
From 1c7459e8d5d0a3acd416db32b022ba73ad6b7d79 Mon Sep 17 00:00:00 2001 From: Petr Vobornik <[email protected]> Date: Wed, 19 Mar 2014 15:29:58 +0100 Subject: [PATCH] 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. --- install/ui/src/freeipa/app.js | 83 ++-------------------- .../ui/src/freeipa/{app.js => app_container.js} | 40 ++--------- install/ui/src/freeipa/menu.js | 6 +- install/ui/src/freeipa/navigation.js | 45 +++++------- 4 files changed, 31 insertions(+), 143 deletions(-) copy install/ui/src/freeipa/{app.js => app_container.js} (79%) diff --git a/install/ui/src/freeipa/app.js b/install/ui/src/freeipa/app.js index 69bf2e7172adb14192c0030242e4ba0d8423348b..0feed4d44e8fdf88bd67e642fc372c300af6df81 100644 --- a/install/ui/src/freeipa/app.js +++ b/install/ui/src/freeipa/app.js @@ -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.js b/install/ui/src/freeipa/app_container.js similarity index 79% copy from install/ui/src/freeipa/app.js copy to install/ui/src/freeipa/app_container.js index 69bf2e7172adb14192c0030242e4ba0d8423348b..44a06d823efedd2aededbe6bc1446e19cd95952c 100644 --- a/install/ui/src/freeipa/app.js +++ b/install/ui/src/freeipa/app_container.js @@ -1,8 +1,8 @@ -/* Authors: + /* Authors: * Petr Vobornik <[email protected]> * * 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 @@ -19,41 +19,13 @@ */ define([ - //core 'dojo/_base/lang', 'dojo/Deferred', 'dojo/when', './plugin_loader', './phases', - './Application_controller', - 'exports', // for circullar deps - './ipa', - './jquery', - //only entities - './aci', - './automember', - './automount', - './dns', - './group', - './hbac', - './hbactest', - './hostgroup', - './host', - './idrange', - './netgroup', - './otptoken', - './policy', - './radiusproxy', - './realmdomains', - './rule', - './selinux', - './serverconfig', - './service', - './sudo', - './trust', - './user', - 'dojo/domReady!' -],function(lang, Deferred, when, plugin_loader, phases, Application_controller, exports) { + './Application_controller' +],function(lang, Deferred, when, plugin_loader, phases, Application_controller) { /** * Application wrapper @@ -119,7 +91,5 @@ define([ } }; - lang.mixin(exports, app); - - return exports; + 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 3da643890dad9c28fcf0f8fce8562459cab29b49..2cd9bdcd76cf682e761a9f2d563fd821acf323ba 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 8b96d6f975a6a2eaa932614483c6c63ebe27a7be..ef0a0bf3f02bed9b3f158deda8aad56f13887244 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; }); -- 1.8.5.3
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
