On 04/15/2016 06:44 PM, Petr Vobornik wrote:
On 04/13/2016 02:56 PM, Pavel Vomacka wrote:
Hello,

This patch adds ability to convert users from preserved to staged state.

Fixes this ticket: https://fedorahosted.org/freeipa/ticket/5371

--
Pavel^3 Vomacka


The patch requires rebase.
Attached rebased patches. I split this one patch into two patches.
>From 8fc33ad7e1dea0a2ca896dd035633580a9ef6eb4 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 20 Apr 2016 18:43:35 +0200
Subject: [PATCH 1/2] Add ability to stage multiple users

Add 'Stage' button on  search page where preserved users are listed.

https://fedorahosted.org/freeipa/ticket/5371
---
 install/ui/ipa.css                  |  4 ++++
 install/ui/src/freeipa/stageuser.js | 29 +++++++++++++++++++++++++++++
 install/ui/test/data/ipa_init.json  |  3 +++
 ipalib/plugins/internal.py          |  3 +++
 4 files changed, 39 insertions(+)

diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index f419eb224252aa03eaf4b25bb03435f4c9a6de9b..7997a71d76e1f8ed7811d68b53a5f12892c49eb4 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -174,6 +174,10 @@ div[name=settings].facet-group li a {
     float: right;
 }
 
+.facet-controls-right .fa.fa-user {
+    opacity: 0.5;
+}
+
 .control-buttons {
     display: inline-block;
 }
diff --git a/install/ui/src/freeipa/stageuser.js b/install/ui/src/freeipa/stageuser.js
index 9d26ef1fa1a86aef5835af51b7abd2369e4c7223..12debed301a3ddbc166abcb3f444dd4775b40407 100644
--- a/install/ui/src/freeipa/stageuser.js
+++ b/install/ui/src/freeipa/stageuser.js
@@ -298,6 +298,9 @@ stageuser.search_preserved_facet_spec = {
     actions: [
         {
             $type: 'batch_undel'
+        },
+        {
+            $type: 'batch_stage'
         }
     ],
     control_buttons: [
@@ -305,6 +308,11 @@ stageuser.search_preserved_facet_spec = {
             name: 'undel',
             label: '@i18n:buttons.restore',
             icon: 'fa-heart'
+        },
+        {
+            name: 'batch_stage',
+            label: '@i18n:buttons.stage',
+            icon: 'fa-user'
         }
     ],
     policies: [
@@ -323,6 +331,12 @@ mod_user.entity_spec.policies.push(
     {
         $factory: IPA.facet_update_policy,
         source_facet: 'search_preserved',
+        dest_entity: 'stageuser',
+        dest_facet: 'search'
+    },
+    {
+        $factory: IPA.facet_update_policy,
+        source_facet: 'search_preserved',
         dest_entity: 'user',
         dest_facet: 'search'
     },
@@ -385,6 +399,20 @@ stageuser.activate_action = function(spec) {
     return that;
 };
 
+stageuser.batch_stage_action = function(spec) {
+
+    spec = spec || {};
+
+    spec.name = spec.name || 'batch_stage';
+    spec.method = spec.method || 'stage';
+    spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm;
+    spec.enable_cond = spec.enable_cond || ['item-selected'];
+    spec.success_msg = spec.success_msg || '@i18n:objects.stageuser.stage_success';
+    spec.confirm_msg = spec.confirm_msg || '@i18n:objects.stageuser.stage_confirm';
+
+    return IPA.batch_items_action(spec);
+};
+
 /**
  * Stage user entity specification object
  * @member stageuser
@@ -402,6 +430,7 @@ stageuser.register = function() {
     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_stage', stageuser.batch_stage_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 7bd74dc815273e697b8dddb2b250b286410ba845..246bb380dd34097f3f6557bf71b6cffa322118fa 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -89,6 +89,7 @@
                         "save": "Save",
                         "set": "Set",
                         "show": "Show",
+                        "stage": "Stage",
                         "unapply": "Un-apply",
                         "update": "Update",
                         "view": "View"
@@ -541,6 +542,8 @@
                             "activate_success": "${count} user(s) activated",
                             "label": "Stage users",
                             "preserved_label": "Preserved users",
+                            "stage_confirm": "Are you sure you want to stage selected users?",
+                            "stage_success": "${count} users(s) staged",
                             "undel_confirm": "Are you sure you want to restore selected users?",
                             "undel_success": "${count} user(s) restored",
                             "user_categories": "User categories",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 2c0d8b1109da6c760cde14f4c4decff869be3cf5..aefdd2e32f66354e4e1cb5d476036a702092ef28 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -232,6 +232,7 @@ class i18n_messages(Command):
             "save": _("Save"),
             "set": _("Set"),
             "show": _("Show"),
+            "stage": _("Stage"),
             "unapply": ("Un-apply"),
             "update": _("Update"),
             "view": _("View"),
@@ -687,6 +688,8 @@ class i18n_messages(Command):
                 "activate_success": _("${count} user(s) activated"),
                 "label": _("Stage users"),
                 "preserved_label": _("Preserved users"),
+                "stage_confirm": _("Are you sure you want to stage selected users?"),
+                "stage_success": _("${count} users(s) staged"),
                 "undel_confirm": _("Are you sure you want to restore selected users?"),
                 "undel_success": _("${count} user(s) restored"),
                 "user_categories": _("User categories"),
-- 
2.5.5

>From 8b1d4239affa256ab405f86b019678af6095ed16 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 20 Apr 2016 18:47:53 +0200
Subject: [PATCH 2/2] Add option to stage user from details page

Add 'stage' option to the activity dropdown menu on preserved user details page.

https://fedorahosted.org/freeipa/ticket/5371
---
 install/ui/src/freeipa/stageuser.js | 24 ++++++++++++++++++++++++
 install/ui/src/freeipa/user.js      | 20 ++++++++++++++++++--
 install/ui/test/data/ipa_init.json  |  1 +
 ipalib/plugins/internal.py          |  1 +
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/stageuser.js b/install/ui/src/freeipa/stageuser.js
index 12debed301a3ddbc166abcb3f444dd4775b40407..bd563847b9b2fb81180d6f2a24a3d1aa59661972 100644
--- a/install/ui/src/freeipa/stageuser.js
+++ b/install/ui/src/freeipa/stageuser.js
@@ -413,6 +413,29 @@ stageuser.batch_stage_action = function(spec) {
     return IPA.batch_items_action(spec);
 };
 
+stageuser.stage_action = function(spec) {
+
+    spec = spec || {};
+
+    spec.name = spec.name || 'stage';
+    spec.method = spec.method || 'stage';
+    spec.show_cond = spec.show_cond || ['preserved_user'];
+    spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
+    spec.confirm_msg = spec.confirm_msg || '@i18n:objects.stageuser.stage_one_confirm';
+    spec.label = spec.label || '@i18n:buttons.stage';
+
+    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
@@ -431,6 +454,7 @@ stageuser.register = function() {
     a.register('batch_undel', stageuser.batch_undel_action);
     a.register('activate', stageuser.activate_action);
     a.register('batch_stage', stageuser.batch_stage_action);
+    a.register('stage', stageuser.stage_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/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index a9727f57d69e7126d87707f541786ffab4d0c999..a871dd509125bc64f51bad7fc5a04fff94eed9c6 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -61,7 +61,19 @@ return {
     name: 'user',
     policies: [
         IPA.search_facet_update_policy,
-        IPA.details_facet_update_policy
+        IPA.details_facet_update_policy,
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'user',
+            dest_facet: 'search_preserved'
+        },
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'stageuser',
+            dest_facet: 'search'
+        }
     ],
     facets: [
         {
@@ -329,6 +341,10 @@ return {
                     $type: 'enable',
                     hide_cond: ['preserved-user']
                 },
+                {
+                    $type: 'stage',
+                    show_cond: ['preserved-user']
+                },
                 'delete',
                 {
                     $type: 'reset_password',
@@ -355,7 +371,7 @@ return {
                 }
             ],
             header_actions: [
-                'reset_password', 'enable', 'disable', 'delete',
+                'reset_password', 'enable', 'disable', 'stage', 'delete',
                 'unlock', 'add_otptoken', 'automember_rebuild', 'request_cert'
             ],
             state: {
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 246bb380dd34097f3f6557bf71b6cffa322118fa..defc3d3563db7bfa6c629be2d610e65caf9015be 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -544,6 +544,7 @@
                             "preserved_label": "Preserved users",
                             "stage_confirm": "Are you sure you want to stage selected users?",
                             "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_success": "${count} user(s) restored",
                             "user_categories": "User categories",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index aefdd2e32f66354e4e1cb5d476036a702092ef28..20ddc4ab4fa965c3f19c828855aa346f85ce294f 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -690,6 +690,7 @@ class i18n_messages(Command):
                 "preserved_label": _("Preserved users"),
                 "stage_confirm": _("Are you sure you want to stage selected users?"),
                 "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_success": _("${count} user(s) restored"),
                 "user_categories": _("User categories"),
-- 
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