Mailing List Archive

rt branch, 5.0/user-admin-callbacks, created. rt-5.0.1-237-gaf31273e6f
The branch, 5.0/user-admin-callbacks has been created
at af31273e6f15cf18f981ecb17c5349d03120c709 (commit)

- Log -----------------------------------------------------------------
commit ae953d77f664895e1c1a3063775a80fe8e530d1e
Author: Jim Brandt <jbrandt@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 4bcfc2e95e..103a12e107 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</&>
@@ -196,10 +214,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;
@@ -244,4 +271,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 af31273e6f15cf18f981ecb17c5349d03120c709
Author: Jim Brandt <jbrandt@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 103a12e107..390e39ab65 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -147,6 +147,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" />
@@ -177,6 +179,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;

-----------------------------------------------------------------------
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit