mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
webui: stageusers, display page elements based on user state
Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
This commit is contained in:
parent
52647285f6
commit
99d282d38d
@ -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"
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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'),
|
||||
|
@ -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
|
||||
@ -2794,6 +2795,42 @@ exp.state = IPA.state = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -2926,6 +2963,37 @@ exp.state_evaluator = IPA.state_evaluator = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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) {
|
||||
if (context.context) {
|
||||
obj.context = context.context;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
);
|
||||
|
@ -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
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -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 || {};
|
||||
|
Loading…
Reference in New Issue
Block a user