diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2015-05-14 13:30:49 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2015-05-20 14:04:10 +0200 |
commit | 99d282d38d0c847ebb544140edd49d6572f06cb0 (patch) | |
tree | 71e3bb472ad990d6c675e64b6f42ff6e7e05c472 /install | |
parent | 52647285f6d286c079090b5bff21f5e423076897 (diff) | |
download | freeipa-99d282d38d0c847ebb544140edd49d6572f06cb0.tar.gz freeipa-99d282d38d0c847ebb544140edd49d6572f06cb0.tar.xz freeipa-99d282d38d0c847ebb544140edd49d6572f06cb0.zip |
webui: stageusers, display page elements based on user state
Reviewed-By: David Kupka <dkupka@redhat.com>
Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/doc/categories.json | 6 | ||||
-rw-r--r-- | install/ui/ipa.css | 10 | ||||
-rw-r--r-- | install/ui/src/freeipa/details.js | 11 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 70 | ||||
-rw-r--r-- | install/ui/src/freeipa/field.js | 4 | ||||
-rw-r--r-- | install/ui/src/freeipa/stageuser.js | 28 | ||||
-rw-r--r-- | install/ui/src/freeipa/user.js | 122 |
7 files changed, 222 insertions, 29 deletions
diff --git a/install/ui/doc/categories.json b/install/ui/doc/categories.json index 9de673593..8741d82e1 100644 --- a/install/ui/doc/categories.json +++ b/install/ui/doc/categories.json @@ -144,6 +144,8 @@ "classes": [ "*facet_policy", "IPA.hide_empty_row_policy", + "IPA.user.preserved_user_policy", + "IPA.user.stageuser_sidebar_policy", "aci.permission_target_policy", "aci.permission_managed_policy" ] @@ -158,8 +160,8 @@ "name": "Evaluators & Summaries", "classes": [ "*_evaluator", - "details.enabled_summary_cond", - "details.disabled_summary_cond" + "facet.summary_cond", + "*_summary_cond" ] }, diff --git a/install/ui/ipa.css b/install/ui/ipa.css index 770b98391..f419eb224 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -504,6 +504,16 @@ table.scrollable tbody { margin-right: 5px; } +.facet-title.preserved .header-icon:before { + content: "\f014"; + margin-right: 5px; +} + +.facet-title.staging .header-icon:before { + content: "\f0ad"; + margin-right: 5px; +} + .facet-title.disabled h1, .facet-title.disabled h1 .facet-pkey{ color: gray; diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js index cce19616f..01fcfc565 100644 --- a/install/ui/src/freeipa/details.js +++ b/install/ui/src/freeipa/details.js @@ -34,7 +34,8 @@ define([ './widget', './facet', './add'], - function(lang, builder, IPA, $, phases, reg, rpc, su, text, widget_mod) { + function(lang, builder, IPA, $, phases, reg, rpc, su, text, widget_mod, + facet_mod) { /** * Details module @@ -1957,11 +1958,11 @@ exp.delete_action = IPA.delete_action = function(spec) { * * @class details.enabled_summary_cond * @alternateClassName IPA.enabled_summary_cond + * @extends facet.summary_cond */ exp.enabled_summary_cond = IPA.enabled_summary_cond = function() { - var that = IPA.object(); - lang.mixin(that, { + var that = facet_mod.summary_cond ({ pos: ['enabled'], neg: [], description: text.get('@i18n:status.enabled'), @@ -1975,10 +1976,10 @@ exp.enabled_summary_cond = IPA.enabled_summary_cond = function() { * * @class details.disabled_summary_cond * @alternateClassName IPA.disabled_summary_cond + * @extends facet.summary_cond */ exp.disabled_summary_cond = IPA.disabled_summary_cond = function() { - var that = IPA.object(); - lang.mixin(that, { + var that = facet_mod.summary_cond({ pos: [], neg: ['enabled'], description: text.get('@i18n:status.disabled'), diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 2bb2c4837..e29be7551 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -2716,7 +2716,8 @@ exp.state = IPA.state = function(spec) { * Summary conditions * @property {Array.<Object>} */ - that.summary_conditions = builder.build('', spec.summary_conditions) || []; + that.summary_conditions = builder.build('', spec.summary_conditions, {}, + { $factory: exp.summary_cond }) || []; /** * Initializes evaluators @@ -2795,6 +2796,42 @@ exp.state = IPA.state = function(spec) { }; /** + * Summary condition base class + * + * @class facet.summary_cond + */ +exp.summary_cond = function(spec) { + + var that = IPA.object(); + + /** + * State which must be present in order to be positively evaluated + * @property {string[]} + */ + that.pos = spec.pos || []; + + /** + * State which must not be present in order to be positively evaluated + * @property {string[]} + */ + that.neg = spec.neg || []; + + /** + * States which will be set in positive evaluation + * @property {string[]} + */ + that.state = spec.state || []; + + /** + * Description which will be set in positive evaluation + * @property {string} + */ + that.description = spec.description || ''; + + return that; +}; + +/** * Summary evaluator for {@link facet.state} * @class facet.summary_evaluator * @alternateClassName IPA.summary_evaluator @@ -2927,6 +2964,37 @@ exp.state_evaluator = IPA.state_evaluator = function(spec) { }; /** + * Noop evaluator always sets the state on post_load on the first time + * @class facet.noop_state_evaluator + * @extends facet.state_evaluator + * @alternateClassName IPA.noop_state_evaluator + */ +exp.noop_state_evaluator = IPA.noop_state_evaluator = function(spec) { + + spec = spec || {}; + spec.event = spec.event || 'post_load'; + + var that = IPA.state_evaluator(spec); + that.name = spec.name || 'noop_state_evaluator'; + + /** + * States to be set + * @property {string[]} + */ + that.state = spec.state || []; + + /** + * @inheritDoc + */ + that.on_event = function() { + that.notify_on_change(that.state); + }; + + return that; +}; + + +/** * Sets 'dirty' state when facet is dirty * @class facet.dirty_state_evaluator * @extends facet.state_evaluator diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index 776811430..d8e249b2c 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -1494,7 +1494,9 @@ reg.set('validator', field.validator_builder.registry); field.adapter_builder = builder.get('adapter'); field.adapter_builder.ctor = field.Adapter; field.adapter_builder.post_ops.push(function(obj, spec, context) { - obj.context = context.context; + if (context.context) { + obj.context = context.context; + } return obj; } ); diff --git a/install/ui/src/freeipa/stageuser.js b/install/ui/src/freeipa/stageuser.js index 62a059ce4..ca4e30025 100644 --- a/install/ui/src/freeipa/stageuser.js +++ b/install/ui/src/freeipa/stageuser.js @@ -78,6 +78,9 @@ return { label: '@i18n:buttons.activate', icon: 'fa-check' } + ], + policies: [ + mod_user.stageuser_sidebar_policy ] }, { @@ -209,22 +212,16 @@ return { state: { evaluators: [ { - $factory: IPA.enable_state_evaluator, - field: 'nsaccountlock', - adapter: { $type: 'batch', result_index: 0 }, - invert_value: true - }, - { - $factory: IPA.acl_state_evaluator, - name: 'reset_password_acl_evaluator', - adapter: { $type: 'batch', result_index: 0 }, - attribute: 'userpassword' - }, - IPA.user.self_service_other_user_evaluator + $factory: mod_facet.noop_state_evaluator, + state: ['staging'] + } ], summary_conditions: [ - IPA.enabled_summary_cond, - IPA.disabled_summary_cond + { + pos: ['staging'], + state: ['staging'], + description: 'Staging user' + } ] } } @@ -302,6 +299,9 @@ stageuser.search_preserved_facet_spec = { label: '@i18n:buttons.restore', icon: 'fa-heart' } + ], + policies: [ + mod_user.stageuser_sidebar_policy ] }; diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js index 73124f203..85c9faa81 100644 --- a/install/ui/src/freeipa/user.js +++ b/install/ui/src/freeipa/user.js @@ -117,6 +117,9 @@ return { icon: 'fa-check' } ], + policies: [ + IPA.user.stageuser_sidebar_policy + ], deleter_dialog: { $factory: IPA.user.deleter_dialog } @@ -302,22 +305,40 @@ return { } ], actions: [ - 'add_otptoken', - 'enable', - 'disable', + { + $type: 'add_otptoken', + hide_cond: ['preserved-user'] + }, + { + $type: 'enable', + hide_cond: ['preserved-user'] + }, + { + $type: 'disable', + hide_cond: ['preserved-user'] + }, + { + $type: 'enable', + hide_cond: ['preserved-user'] + }, 'delete', - 'reset_password', + { + $type: 'reset_password', + hide_cond: ['preserved-user'] + }, { $factory: IPA.object_action, name: 'unlock', method: 'unlock', label: '@i18n:objects.user.unlock', needs_confirm: true, + hide_cond: ['preserved-user'], confirm_msg: '@i18n:objects.user.unlock_confirm' }, { $type: 'automember_rebuild', name: 'automember_rebuild', + hide_cond: ['preserved-user'], label: '@i18n:actions.automember_rebuild' } ], @@ -336,13 +357,23 @@ return { adapter: { $type: 'batch', result_index: 0 }, attribute: 'userpassword' }, - IPA.user.self_service_other_user_evaluator + IPA.user.self_service_other_user_evaluator, + IPA.user.preserved_user_evaluator ], summary_conditions: [ + { + pos: ['preserved-user'], + neg: [], + state: ['preserved'], + description: 'Preserved user' + }, IPA.enabled_summary_cond, IPA.disabled_summary_cond ] - } + }, + policies: [ + IPA.user.preserved_user_policy + ] }, { $type: 'association', @@ -695,6 +726,85 @@ IPA.user.self_service_other_user_evaluator = function(spec) { return that; }; +/** + * Evaluates if user is "preserved" user + * @class IPA.user.preserved_user_evaluator + */ +IPA.user.preserved_user_evaluator = function(spec) { + + spec = spec || {}; + spec.event = spec.event || 'post_load'; + + var that = IPA.state_evaluator(spec); + that.name = spec.name || 'preserved_user_evaluator'; + that.param = spec.param || 'dn'; + that.adapter = builder.build('adapter', { $type: 'adapter'}, { context: that }); + + /** + * Evaluates if user is preserved, i.e. is in provisioning tree + */ + that.on_event = function(data) { + + var old_state = that.state; + that.state = []; + + var dn = that.adapter.load(data)[0]; + if (dn.indexOf('cn=provisioning') > 0) { + that.state.push('preserved-user'); + } + + that.notify_on_change(old_state); + }; + + return that; +}; + +/** + * Change breadcrumb navigation and therefore also target facet on first + * navigation item based on user state (active/preserved) + * @class + */ +IPA.user.preserved_user_policy = function(spec) { + + var that = IPA.facet_policy(spec); + that.post_load = function(data) { + var adapter = builder.build('adapter', { + $type: 'adapter', + result_index: 0, + context: { param: 'dn' } + }); + var dn = adapter.load(data)[0]; + var preserved_user = dn.indexOf('cn=provisioning') > 0; + var details_facet = that.container; + details_facet.set_tabs_visible(!preserved_user); + details_facet.redirect_info = { entity: 'user', facet: 'search' }; + if (preserved_user) { + details_facet.redirect_info.facet = 'search_preserved'; + } + details_facet.header.update_breadcrumb(); + }; + + return that; +}; + + +/** + * Display sidebar (facet tabs) only if user can view stage and preserved user. + * Atm. the sidebar is hidden only in self-service. Should be extended by a + * check if user can actually read it. + * @class + */ +IPA.user.stageuser_sidebar_policy = function(spec) { + + var that = IPA.facet_policy(spec); + + that.post_create = function(data) { + that.container.set_tabs_visible(!IPA.is_selfservice); + }; + + return that; +}; + IPA.user.deleter_dialog = function(spec) { spec = spec || {}; |