7e1b55
From 10418b7f3ea8c682961fc201545169663d507bf6 Mon Sep 17 00:00:00 2001
7e1b55
From: Serhii Tsymbaliuk <stsymbal@redhat.com>
7e1b55
Date: Thu, 17 Jun 2021 13:56:19 +0200
7e1b55
Subject: [PATCH] WebUI: Improve subordinate ids user workflow
7e1b55
7e1b55
- add "Subordinate ID Statistics" page
7e1b55
- add button for generating subid in "Subordinate ids" tab of user details page
7e1b55
- allow to navigate directly to owner details from subordinate id page
7e1b55
- adjust i18n strings
7e1b55
7e1b55
Ticket: https://pagure.io/freeipa/issue/8361
7e1b55
Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
7e1b55
Reviewed-By: Francois Cami <fcami@redhat.com>
7e1b55
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7e1b55
Reviewed-By: Francois Cami <fcami@redhat.com>
7e1b55
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7e1b55
---
7e1b55
 install/ui/src/freeipa/details.js             |  8 ++-
7e1b55
 .../ui/src/freeipa/navigation/menu_spec.js    | 19 ++++++-
7e1b55
 install/ui/src/freeipa/subid.js               | 43 +++++++++++++++-
7e1b55
 install/ui/src/freeipa/user.js                | 49 +++++++++++++++----
7e1b55
 ipaserver/plugins/internal.py                 | 22 ++++++---
7e1b55
 5 files changed, 121 insertions(+), 20 deletions(-)
7e1b55
7e1b55
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
7e1b55
index b557bbcef9a427a87eee3216f4345fc853cbaaff..2704cbd0ba98efa877cf5ec8a878e688ee6807e9 100644
7e1b55
--- a/install/ui/src/freeipa/details.js
7e1b55
+++ b/install/ui/src/freeipa/details.js
7e1b55
@@ -602,6 +602,12 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
7e1b55
      */
7e1b55
     that.facet_group = spec.facet_group || 'settings';
7e1b55
 
7e1b55
+    /**
7e1b55
+     * Indicates if the details facet depends on pkey
7e1b55
+     * @property {boolean}
7e1b55
+     */
7e1b55
+    that.require_pkey = spec.require_pkey !== undefined ? spec.require_pkey : true;
7e1b55
+
7e1b55
     /**
7e1b55
      * Widgets
7e1b55
      * @property {IPA.widget_container}
7e1b55
@@ -1105,7 +1111,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
7e1b55
      */
7e1b55
     that.refresh = function(on_success, on_error) {
7e1b55
 
7e1b55
-        if (!that.get_pkey() && that.entity.redirect_facet) {
7e1b55
+        if (that.require_pkey && !that.get_pkey() && that.entity.redirect_facet) {
7e1b55
             that.redirect();
7e1b55
             return;
7e1b55
         }
7e1b55
diff --git a/install/ui/src/freeipa/navigation/menu_spec.js b/install/ui/src/freeipa/navigation/menu_spec.js
7e1b55
index 6ccd06919fbe04c7e8d2034ff7a1f644f373c607..a205dfade2f9508edbdc23ee6f7247508cc0479c 100644
7e1b55
--- a/install/ui/src/freeipa/navigation/menu_spec.js
7e1b55
+++ b/install/ui/src/freeipa/navigation/menu_spec.js
7e1b55
@@ -104,7 +104,24 @@ var nav = {};
7e1b55
                         }
7e1b55
                     ]
7e1b55
                 },
7e1b55
-                { entity: 'subid' }
7e1b55
+                {
7e1b55
+                    name: 'subid',
7e1b55
+                    label: '@i18n:tabs.subid',
7e1b55
+                    children: [
7e1b55
+                        {
7e1b55
+                            name: 'subid',
7e1b55
+                            entity: 'subid',
7e1b55
+                            facet: 'search',
7e1b55
+                            label: '@i18n:tabs.subid'
7e1b55
+                        },
7e1b55
+                        {
7e1b55
+                            name: 'subid-stats',
7e1b55
+                            entity: 'subid',
7e1b55
+                            facet: 'stats',
7e1b55
+                            label: '@i18n:objects.subid.stats'
7e1b55
+                        }
7e1b55
+                    ]
7e1b55
+                }
7e1b55
             ]
7e1b55
         },
7e1b55
         {
7e1b55
diff --git a/install/ui/src/freeipa/subid.js b/install/ui/src/freeipa/subid.js
7e1b55
index f286165070b08badf77cac6c30e93cab916c2acc..32f75bb7854cd3e84417a66870e99d34d49617e3 100644
7e1b55
--- a/install/ui/src/freeipa/subid.js
7e1b55
+++ b/install/ui/src/freeipa/subid.js
7e1b55
@@ -31,6 +31,7 @@ return {
7e1b55
         },
7e1b55
         {
7e1b55
             $type: 'details',
7e1b55
+            disable_facet_tabs: true,
7e1b55
             sections: [
7e1b55
                 {
7e1b55
                     name: 'details',
7e1b55
@@ -38,9 +39,11 @@ return {
7e1b55
                         'ipauniqueid',
7e1b55
                         'description',
7e1b55
                         {
7e1b55
+                            $type: 'link',
7e1b55
                             name: 'ipaowner',
7e1b55
                             label: '@i18n:objects.subid.ipaowner',
7e1b55
-                            title: '@mo-param:subid:ipaowner:label'
7e1b55
+                            title: '@mo-param:subid:ipaowner:label',
7e1b55
+                            other_entity: 'user'
7e1b55
                         },
7e1b55
                         {
7e1b55
                             name: 'ipasubgidnumber',
7e1b55
@@ -65,6 +68,44 @@ return {
7e1b55
                     ]
7e1b55
                 }
7e1b55
             ]
7e1b55
+        },
7e1b55
+        {
7e1b55
+            $type: 'details',
7e1b55
+            name: 'stats',
7e1b55
+            label: '@i18n:objects.subid.stats',
7e1b55
+            refresh_command_name: 'stats',
7e1b55
+            check_rights: false,
7e1b55
+            no_update: true,
7e1b55
+            disable_facet_tabs: true,
7e1b55
+            disable_breadcrumb: true,
7e1b55
+            require_pkey: false,
7e1b55
+            fields: [
7e1b55
+                {
7e1b55
+                    name: 'assigned_subids',
7e1b55
+                    label: '@i18n:objects.subid.assigned_subids',
7e1b55
+                    read_only: true
7e1b55
+                },
7e1b55
+                {
7e1b55
+                    name: 'baseid',
7e1b55
+                    label: '@i18n:objects.subid.baseid',
7e1b55
+                    read_only: true
7e1b55
+                },
7e1b55
+                {
7e1b55
+                    name: 'dna_remaining',
7e1b55
+                    label: '@i18n:objects.subid.dna_remaining',
7e1b55
+                    read_only: true
7e1b55
+                },
7e1b55
+                {
7e1b55
+                    name: 'rangesize',
7e1b55
+                    label: '@i18n:objects.subid.rangesize',
7e1b55
+                    read_only: true
7e1b55
+                },
7e1b55
+                {
7e1b55
+                    name: 'remaining_subids',
7e1b55
+                    label: '@i18n:objects.subid.remaining_subids',
7e1b55
+                    read_only: true
7e1b55
+                }
7e1b55
+            ]
7e1b55
         }
7e1b55
     ],
7e1b55
     adder_dialog: {
7e1b55
diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
7e1b55
index 56bb6f4feffb637d33a57aecf9a98f08d4639550..6a56320c580f58a1aba84e598736631986421113 100644
7e1b55
--- a/install/ui/src/freeipa/user.js
7e1b55
+++ b/install/ui/src/freeipa/user.js
7e1b55
@@ -464,7 +464,7 @@ return {
7e1b55
                 },
7e1b55
                 {
7e1b55
                     $type: 'subid_generate',
7e1b55
-                    hide_cond: ['preserved-user'],
7e1b55
+                    hide_cond: ['preserved-user', 'self-service-other'],
7e1b55
                     enable_cond: ['no-subid']
7e1b55
                 }
7e1b55
             ],
7e1b55
@@ -556,8 +556,35 @@ return {
7e1b55
         {
7e1b55
             $type: 'association',
7e1b55
             name: 'memberof_subid',
7e1b55
+            columns: [
7e1b55
+                'ipauniqueid',
7e1b55
+                'ipasubuidnumber',
7e1b55
+                'ipasubgidnumber'
7e1b55
+            ],
7e1b55
             associator: IPA.serial_associator,
7e1b55
-            read_only: true
7e1b55
+            read_only: true,
7e1b55
+            state: {
7e1b55
+                evaluators: [
7e1b55
+                    IPA.user.self_service_other_user_evaluator,
7e1b55
+                    IPA.user.preserved_user_evaluator,
7e1b55
+                    IPA.user.has_subid_evaluator
7e1b55
+                ]
7e1b55
+            },
7e1b55
+            actions: [
7e1b55
+                {
7e1b55
+                    $type: 'subid_generate',
7e1b55
+                    name: 'subid_generate',
7e1b55
+                    hide_cond: ['preserved-user', 'self-service-other'],
7e1b55
+                    enable_cond: ['no-subid']
7e1b55
+                }
7e1b55
+            ],
7e1b55
+            control_buttons: [
7e1b55
+                {
7e1b55
+                    name: 'subid_generate',
7e1b55
+                    label: '@i18n:objects.user.auto_subid',
7e1b55
+                    icon: 'fa-plus'
7e1b55
+                }
7e1b55
+            ]
7e1b55
         }
7e1b55
     ],
7e1b55
     standard_association_facets: {
7e1b55
@@ -1216,14 +1243,16 @@ IPA.user.subid_generate_action = function(spec) {
7e1b55
     var that = IPA.action(spec);
7e1b55
 
7e1b55
     that.execute_action = function(facet) {
7e1b55
-
7e1b55
-        var subid_e = reg.entity.get('subid');
7e1b55
-        var dialog = subid_e.get_dialog('add');
7e1b55
-        dialog.open();
7e1b55
-        if (!IPA.is_selfservice) {
7e1b55
-            var owner = facet.get_pkey();
7e1b55
-            dialog.get_field('ipaowner').set_value([owner]);
7e1b55
-        }
7e1b55
+        var owner = facet.get_pkey();
7e1b55
+        var command = rpc.command({
7e1b55
+            entity: 'subid',
7e1b55
+            method: 'generate'
7e1b55
+        });
7e1b55
+        command.set_option('ipaowner', owner);
7e1b55
+        command.on_success = function(data, text_status, xhr) {
7e1b55
+            facet.refresh();
7e1b55
+        };
7e1b55
+        command.execute();
7e1b55
     };
7e1b55
 
7e1b55
     return that;
7e1b55
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
7e1b55
index 5ef940c2b88cc2b132a15d619772349b30731306..29e09f0067ec60d014e61c49313455d64478ef22 100644
7e1b55
--- a/ipaserver/plugins/internal.py
7e1b55
+++ b/ipaserver/plugins/internal.py
7e1b55
@@ -1364,6 +1364,20 @@ class i18n_messages(Command):
7e1b55
                 "undel_success": _("${count} user(s) restored"),
7e1b55
                 "user_categories": _("User categories"),
7e1b55
             },
7e1b55
+            "subid": {
7e1b55
+                "add": _("Add subid"),
7e1b55
+                "assigned_subids": _("Assigned subids"),
7e1b55
+                "baseid": _("Base ID"),
7e1b55
+                "dna_remaining": _("DNA remaining"),
7e1b55
+                "ipaowner": _("Owner"),
7e1b55
+                "ipasubgidcount": _("SubGID range size"),
7e1b55
+                "ipasubgidnumber": _("SubGID range start"),
7e1b55
+                "ipasubuidcount": _("SubUID range size"),
7e1b55
+                "ipasubuidnumber": _("SubUID range start"),
7e1b55
+                "rangesize": _("Range size"),
7e1b55
+                "remaining_subids": _("Remaining subids"),
7e1b55
+                "stats": _("Subordinate ID Statistics"),
7e1b55
+            },
7e1b55
             "sudocmd": {
7e1b55
                 "add": _("Add sudo command"),
7e1b55
                 "add_into_sudocmdgroups": _(
7e1b55
@@ -1547,13 +1561,6 @@ class i18n_messages(Command):
7e1b55
                     "Drive to mount a home directory"
7e1b55
                 ),
7e1b55
             },
7e1b55
-            "subid": {
7e1b55
-                "identity": _("Subordinate user and group id"),
7e1b55
-                "subuidnumber": _("Subordinate user id"),
7e1b55
-                "subuidcount": _("Subordinate user id count"),
7e1b55
-                "subgidnumber": _("Subordinate group id"),
7e1b55
-                "subgidcount": _("Subordinate group id count"),
7e1b55
-            },
7e1b55
             "trustconfig": {
7e1b55
                 "options": _("Options"),
7e1b55
             },
7e1b55
@@ -1942,6 +1949,7 @@ class i18n_messages(Command):
7e1b55
             "network_services": _("Network Services"),
7e1b55
             "policy": _("Policy"),
7e1b55
             "role": _("Role-Based Access Control"),
7e1b55
+            "subid": _("Subordinate IDs"),
7e1b55
             "sudo": _("Sudo"),
7e1b55
             "topology": _("Topology"),
7e1b55
             "trust": _("Trusts"),
7e1b55
-- 
7e1b55
2.26.3
7e1b55