[Rt-commit] rt branch, 5.0/user-admin-updates, created. rt-5.0.1-238-g46b83f9aef

Jim Brandt jbrandt at bestpractical.com
Wed Apr 14 13:40:19 EDT 2021


The branch, 5.0/user-admin-updates has been created
        at  46b83f9aef6a92f3a6ade94c4920080e1da4efca (commit)

- Log -----------------------------------------------------------------
commit a3ba1f81d3eb057e08636e1fbbd25c24beaae72f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Apr 12 17:16:10 2021 -0400

    Add callbacks to user admin index page
    
    These allow a developer to add a custom component to the
    form and then act on it in the init section.

diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index 4bcfc2e95e..e819b3393d 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -129,6 +129,8 @@ jQuery(function(){
     </div>
   </div>
 
+% $m->callback( %ARGS, UsersObj => $users, CallbackName => 'InUsersAdminForm' );
+
   <div class="form-row">
     <div class="col-12 text-right">
       <input type="submit" class="button btn btn-primary" value="<&|/l&>Go!</&>" name="Go" />
@@ -159,6 +161,8 @@ my $caption;
 my $users = RT::Users->new( $session{'CurrentUser'} );
 $users->FindAllRows if $FindDisabledUsers;
 
+$m->callback( UsersObj => $users, ARGSRef => \%ARGS, CallbackName => 'Initial' );
+
 $caption = loc("Users matching search criteria");
 my @users_queries = ();
 push @users_queries, { field => $UserField, op => $UserOp, string => $UserString } if length $UserString;

commit 7059c0b91ce9fdeb2e22d1eb7730a0f5f9d2cef2
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Apr 12 17:09:49 2021 -0400

    Provide a way to select privileged and unprivileged users in admin
    
    It's a common confusion that the user admin page, by default,
    shows only privileged users. When you search, you can get
    unprivileged users in results, which can also be a bit
    confusing.
    
    Add a dropdown to allow the admin to explicitly select the
    set of users they want to see. It defaults to privileged, which
    was the previous behavior.
    
    Also add the system group to search results so it is clear which
    system group each user is in.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index e9aba3fa32..9abf52a08d 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -3617,7 +3617,7 @@ Set(%AdminSearchResultFormat,
     Users =>
         q{'<a href="__WebPath__/Admin/Users/Modify.html?id=__id__">__id__</a>/TITLE:#'}
         .q{,'<a href="__WebPath__/Admin/Users/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
-        .q{,__RealName__, __EmailAddress__,__Disabled__},
+        .q{,__RealName__, __EmailAddress__,__SystemGroup__,__Disabled__},
 
     CustomFields =>
         q{'<a href="__WebPath__/Admin/CustomFields/Modify.html?id=__id__">__id__</a>/TITLE:#'}
diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index e819b3393d..390e39ab65 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -83,6 +83,24 @@ jQuery(function(){
 %     next unless defined $ARGS{ $field } && length $ARGS{ $field };
 <input type="hidden" name="<% $field %>" value="<% $ARGS{ $field } %>" />
 % }
+
+    <div class="form-row">
+      <div class="label col-3 text-left">
+        <&|/l&>Include</&>
+      </div>
+      <div class="col-3">
+        <select name="IncludeSystemGroups" class="selectpicker form-control">
+% my $group_selected;
+% for my $group_value ( qw(Privileged Unprivileged All) ) {
+%   $group_selected = '';
+%   if ( $group_value eq $IncludeSystemGroups ) {
+%     $group_selected = 'selected="selected"';
+%   }
+          <option value="<% $group_value %>" <% $group_selected |n %>><% loc($group_value) %></option>
+% }
+        </select>
+      </div>
+    </div>
     <div class="form-row">
       <div class="label col-3 text-left">
         <&|/l&>Find all users whose</&>
@@ -200,10 +218,19 @@ if ( scalar @users_queries ) {
     RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Admin/Users/Modify.html?id=".$users->First->id)
           if $users->Count == 1;
 }
-else {
+
+if ( $IncludeSystemGroups eq 'Privileged' ) {
     $caption = loc("Privileged users");
     $users->LimitToPrivileged;
 }
+elsif ( $IncludeSystemGroups eq 'Unprivileged' ) {
+    $caption = loc("Unprivileged users");
+    $users->LimitToUnprivileged;
+}
+else {
+    # Must be all
+    $caption = loc("All users");
+}
 
 $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Users'};
 my $Rows = RT->Config->Get('AdminSearchResultRows')->{'Users'} || 50;
@@ -248,4 +275,5 @@ $IdLike => undef
 $EmailLike => undef
 
 $FindDisabledUsers => 0
+$IncludeSystemGroups => 'Privileged'
 </%ARGS>
diff --git a/share/html/Elements/RT__User/ColumnMap b/share/html/Elements/RT__User/ColumnMap
index 58b21e7337..6597e84fb3 100644
--- a/share/html/Elements/RT__User/ColumnMap
+++ b/share/html/Elements/RT__User/ColumnMap
@@ -151,6 +151,10 @@ my $COLUMN_MAP = {
         attribute => 'Timezone',
         value     => sub { return $_[0]->Timezone },
     },
+    SystemGroup => {
+        title     => 'System Group', # loc
+        value     => sub { return $_[0]->Privileged ? $_[0]->loc('Privileged'): $_[0]->loc('Unprivileged') },
+    },
 };
 
 </%ONCE>

commit 46b83f9aef6a92f3a6ade94c4920080e1da4efca
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Apr 14 13:29:47 2021 -0400

    Restyle admin user select page with a bare titlebox
    
    This centers the form elements rather than rendering pushed
    against the left side.
    
    This change removes some previous divs, so many of the changed
    lines are whitespace changes to align the indents.

diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index 390e39ab65..a686e34422 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -47,27 +47,24 @@
 %# END BPS TAGGED BLOCK }}}
 <& /Admin/Elements/Header, Title => loc('Select a user') &>
 <& /Elements/Tabs &>
-    
-<h1><% $caption %></h1>
-
-<form method="post" action="<% RT->Config->Get('WebPath') %>/Admin/Users/index.html">
+<div class="container">
+<&| /Widgets/TitleBox, hideable => 0, class => 'admin-select-user', content_class => 'mx-auto width-md' &>
+  <form method="post" action="<% RT->Config->Get('WebPath') %>/Admin/Users/index.html" class="mx-auto">
 % foreach my $field( qw(Format Rows Page Order OrderBy) ) {
 %     next unless defined $ARGS{ $field } && length $ARGS{ $field };
 <input type="hidden" name="<% $field %>" value="<% $ARGS{ $field } %>" />
 % }
-<input type="hidden" name="UserField" value="Name" />
-<input type="hidden" name="UserOp" value="LIKE" />
+  <input type="hidden" name="UserField" value="Name" />
+  <input type="hidden" name="UserOp" value="LIKE" />
 
-<div class="row">
-  <div class="col-xl-6">
-    <div class="form-row">
-      <div class="label col-3 text-left">
-        <&|/l&>Go to user</&>
-      </div>
-      <div class="col-3">
-        <input type="text" class="form-control" name="UserString" value="" data-autocomplete="Users" data-autocomplete-return="Name" id="autocomplete-UserString" />
-      </div>
+  <div class="form-row">
+    <div class="label col-4 text-left">
+      <&|/l&>Go to user</&>
+    </div>
+    <div class="col-8">
+      <input type="text" class="form-control" name="UserString" value="" data-autocomplete="Users" data-autocomplete-return="Name" id="autocomplete-UserString" />
     </div>
+  </div>
 <script type="text/javascript">
 jQuery(function(){
     // Jump directly to the page if a user is chosen
@@ -76,20 +73,22 @@ jQuery(function(){
     });
 });
 </script>
-</form>
+  </form>
+  <hr />
+  <p class="font-weight-bold">Additional search options</p>
+  <form method="post" action="<% RT->Config->Get('WebPath') %>/Admin/Users/index.html" name="UsersAdmin" class="mx-auto max-width-md">
 
-<form method="post" action="<% RT->Config->Get('WebPath') %>/Admin/Users/index.html" name="UsersAdmin">
 % foreach my $field( qw(Format Rows Page Order OrderBy) ) {
 %     next unless defined $ARGS{ $field } && length $ARGS{ $field };
 <input type="hidden" name="<% $field %>" value="<% $ARGS{ $field } %>" />
 % }
 
-    <div class="form-row">
-      <div class="label col-3 text-left">
-        <&|/l&>Include</&>
-      </div>
-      <div class="col-3">
-        <select name="IncludeSystemGroups" class="selectpicker form-control">
+  <div class="form-row">
+    <div class="label col-3 text-left">
+      <&|/l&>Include</&>
+    </div>
+    <div class="col-3">
+      <select name="IncludeSystemGroups" class="selectpicker form-control">
 % my $group_selected;
 % for my $group_value ( qw(Privileged Unprivileged All) ) {
 %   $group_selected = '';
@@ -98,45 +97,43 @@ jQuery(function(){
 %   }
           <option value="<% $group_value %>" <% $group_selected |n %>><% loc($group_value) %></option>
 % }
-        </select>
-      </div>
+      </select>
     </div>
-    <div class="form-row">
-      <div class="label col-3 text-left">
-        <&|/l&>Find all users whose</&>
-      </div>
-      <& /Elements/SelectUsers, %ARGS, Fields => \@fields &>
+  </div>
+  <div class="form-row">
+    <div class="label col-3 text-left">
+      <&|/l&>Find all users whose</&>
     </div>
+      <& /Elements/SelectUsers, %ARGS, Fields => \@fields &>
+  </div>
 
-    <div class="form-row">
-      <div class="label col-3 text-left">
-        <&|/l&>And all users whose</&>
-      </div>
-      <& /Elements/SelectUsers, %ARGS, Fields => \@fields,
-          SelectFieldName => 'UserField2',
-          SelectOpName    => 'UserOp2',
-          InputStringName => 'UserString2',
-          UserField       => $UserField2,
-          UserOp          => $UserOp2,
-          UserString      => $UserString2,
-      &>
+  <div class="form-row">
+    <div class="label col-3 text-left">
+      <&|/l&>And all users whose</&>
     </div>
+    <& /Elements/SelectUsers, %ARGS, Fields => \@fields,
+        SelectFieldName => 'UserField2',
+        SelectOpName    => 'UserOp2',
+        InputStringName => 'UserString2',
+        UserField       => $UserField2,
+        UserOp          => $UserOp2,
+        UserString      => $UserString2,
+    &>
+  </div>
 
-    <div class="form-row">
-      <div class="label col-3 text-left">
-        <&|/l&>And all users whose</&>
-      </div>
-      <& /Elements/SelectUsers, %ARGS, Fields => \@fields,
-          SelectFieldName => 'UserField3',
-          SelectOpName    => 'UserOp3',
-          InputStringName => 'UserString3',
-          UserField       => $UserField3,
-          UserOp          => $UserOp3,
-          UserString      => $UserString3,
-      &>
+  <div class="form-row">
+    <div class="label col-3 text-left">
+      <&|/l&>And all users whose</&>
     </div>
+    <& /Elements/SelectUsers, %ARGS, Fields => \@fields,
+        SelectFieldName => 'UserField3',
+        SelectOpName    => 'UserOp3',
+        InputStringName => 'UserString3',
+        UserField       => $UserField3,
+        UserOp          => $UserOp3,
+        UserString      => $UserString3,
+    &>
   </div>
-</div>
 
   <div class="form-row">
     <div class="col-12">
@@ -154,10 +151,12 @@ jQuery(function(){
       <input type="submit" class="button btn btn-primary" value="<&|/l&>Go!</&>" name="Go" />
     </div>
   </div>
-</form>
-
+  </form>
+</&>
+</div>
+<br />
 % unless ( $users->Count ) {
-<em><&|/l&>No users matching search criteria found.</&></em>
+<p class="font-weight-bold"><&|/l&>No users matching search criteria found.</&></p>
 % } else {
 <p><&|/l&>Select a user</&>:</p>
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list