Hello,

this patch adds 'Activate' option to actions menu on stage user detail page.

Ticket: https://fedorahosted.org/freeipa/ticket/5369

--
Pavel^3 Vomacka
>From 2dc5ab2381bcef11c8a7ff7a532932953eba18e7 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Sun, 10 Apr 2016 19:27:40 +0200
Subject: [PATCH] Add activate option to stage user details page

Add activate option to the action menu on stage user details page.

https://fedorahosted.org/freeipa/ticket/5369
---
 install/ui/src/freeipa/stageuser.js | 30 +++++++++++++++++++++++++++++-
 install/ui/test/data/ipa_init.json  |  1 +
 ipalib/plugins/internal.py          |  1 +
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/stageuser.js b/install/ui/src/freeipa/stageuser.js
index ca4e30025a14853a287e4a29478f80a843ab1c27..9d26ef1fa1a86aef5835af51b7abd2369e4c7223 100644
--- a/install/ui/src/freeipa/stageuser.js
+++ b/install/ui/src/freeipa/stageuser.js
@@ -48,6 +48,12 @@ return {
             source_facet: 'search',
             dest_entity: 'user',
             dest_facet: 'search'
+        },
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'user',
+            dest_facet: 'search'
         }
     ],
     facets: [
@@ -206,9 +212,10 @@ return {
                 }
             ],
             actions: [
+                'activate',
                 'delete'
             ],
-            header_actions: ['delete'],
+            header_actions: ['activate', 'delete'],
             state: {
                 evaluators: [
                     {
@@ -358,6 +365,26 @@ stageuser.batch_undel_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;
+};
+
 /**
  * Stage user entity specification object
  * @member stageuser
@@ -374,6 +401,7 @@ stageuser.register = function() {
     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);
     e.register({type: 'stageuser', spec: stageuser.stageuser_spec});
     f.register_from_spec('user_search_preserved', stageuser.search_preserved_facet_spec);
 };
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 852b953736da0ccb8a7803259e2bd5d4c4108ab9..7bd74dc815273e697b8dddb2b250b286410ba845 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -537,6 +537,7 @@
                         },
                         "stageuser": {
                             "activate_confirm": "Are you sure you want to activate selected users?",
+                            "activate_one_confirm": "Are you sure you want to activate ${object}?",
                             "activate_success": "${count} user(s) activated",
                             "label": "Stage users",
                             "preserved_label": "Preserved users",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 7156d4f47004dd702d3896ca736cc1f42227a321..2c0d8b1109da6c760cde14f4c4decff869be3cf5 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -683,6 +683,7 @@ class i18n_messages(Command):
             },
             "stageuser": {
                 "activate_confirm": _("Are you sure you want to activate selected users?"),
+                "activate_one_confirm": _("Are you sure you want to activate ${object}?"),
                 "activate_success": _("${count} user(s) activated"),
                 "label": _("Stage users"),
                 "preserved_label": _("Preserved users"),
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to