Add 'Restore' option to action dropdown menu

Also moving activate_action method several lines up - correcting logical order of methods.

https://fedorahosted.org/freeipa/ticket/5818

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Pavel Vomacka 2016-08-22 14:45:14 +02:00 committed by Martin Babinsky
parent b232ad463c
commit c3374c6e16
4 changed files with 36 additions and 9 deletions

View File

@ -364,6 +364,26 @@ stageuser.batch_activate_action = function(spec) {
return IPA.batch_items_action(spec);
};
stageuser.activate_action = function(spec) {
spec = spec || {};
spec.name = spec.name || 'activate';
spec.method = spec.method || 'activate';
spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
spec.confirm_msg = spec.confirm_msg || '@i18n:objects.stageuser.activate_one_confirm';
spec.label = spec.label || '@i18n:buttons.activate';
var that = IPA.object_action(spec);
that.on_success = function(facet, data, text_status, xhr) {
IPA.notify_success(data.result.summary);
facet.on_update.notify();
facet.redirect();
};
return that;
};
stageuser.batch_undel_action = function(spec) {
spec = spec || {};
@ -379,18 +399,18 @@ stageuser.batch_undel_action = function(spec) {
return IPA.batch_items_action(spec);
};
stageuser.activate_action = function(spec) {
stageuser.undel_action = function(spec) {
spec = spec || {};
spec.name = spec.name || 'activate';
spec.method = spec.method || 'activate';
spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
spec.confirm_msg = spec.confirm_msg || '@i18n:objects.stageuser.activate_one_confirm';
spec.label = spec.label || '@i18n:buttons.activate';
spec.name = spec.name || 'undel';
spec.method = spec.method || 'undel';
spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm;
spec.confirm_msg = spec.confirm_msg || '@i18n:objects.stageuser.undel_one_confirm';
spec.label = spec.label || '@i18n:buttons.restore';
var that = IPA.object_action(spec);
that.on_success = function(facet, data, text_status, xhr) {
IPA.notify_success(data.result.summary);
facet.on_update.notify();
facet.redirect();
@ -451,8 +471,9 @@ stageuser.register = function() {
var e = reg.entity;
var f = reg.facet;
a.register('batch_activate', stageuser.batch_activate_action);
a.register('batch_undel', stageuser.batch_undel_action);
a.register('activate', stageuser.activate_action);
a.register('batch_undel', stageuser.batch_undel_action);
a.register('undel', stageuser.undel_action);
a.register('batch_stage', stageuser.batch_stage_action);
a.register('stage', stageuser.stage_action);
e.register({type: 'stageuser', spec: stageuser.stageuser_spec});

View File

@ -372,6 +372,10 @@ return {
$type: 'delete',
show_cond: ['preserved-user']
},
{
$type: 'undel',
show_cond: ['preserved-user']
},
{
$type: 'stage',
show_cond: ['preserved-user']
@ -401,7 +405,7 @@ return {
}
],
header_actions: [
'reset_password', 'enable', 'disable', 'stage',
'reset_password', 'enable', 'disable', 'stage', 'undel',
'delete_active_user', 'delete', 'unlock', 'add_otptoken',
'automember_rebuild', 'request_cert'
],

View File

@ -592,6 +592,7 @@
"stage_success": "${count} users(s) staged",
"stage_one_confirm": "Are you sure you want to stage ${object}?",
"undel_confirm": "Are you sure you want to restore selected users?",
"undel_one_confirm": "Are you sure you want to restore ${object}?",
"undel_success": "${count} user(s) restored",
"user_categories": "User categories",
},

View File

@ -744,6 +744,7 @@ class i18n_messages(Command):
"stage_success": _("${count} users(s) staged"),
"stage_one_confirm": _("Are you sure you want to stage ${object}?"),
"undel_confirm": _("Are you sure you want to restore selected users?"),
"undel_one_confirm": _("Are you sure you want to restore ${object}?"),
"undel_success": _("${count} user(s) restored"),
"user_categories": _("User categories"),
},