[Rt-commit] rt branch, 5.0/fix-anonymize-user-modal, created. rt-5.0.0beta1-4-gdb818ac708

Craig Kaiser craig at bestpractical.com
Mon Jul 6 16:02:05 EDT 2020


The branch, 5.0/fix-anonymize-user-modal has been created
        at  db818ac708eeb218ca316abfd9a17ba23c45c829 (commit)

- Log -----------------------------------------------------------------
commit 8a4fde2eba80cd45253bd6291ec53e51ed15204e
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Jul 1 15:36:55 2020 -0400

    Use Bootstrap4 modal for Anonymize User button

diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 5d690c71a4..5a696ead4a 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -321,19 +321,37 @@
 </form>
 
 % if ( $UserObj->Id ) {
-    <& /Elements/Modal, ModalId => "user-info-modal", Method => 'POST', Action => RT->Config->Get('WebPath') . '/Admin/Users/Modify.html', Fields => [
-    { Label   => loc("Are you sure you want to anonymize user: [_1]?", $UserObj->Name) },
-    { Input => 'Hidden', Value => $UserObj->Id, Name => 'id' },
-    { Input => 'Hidden', Value => 1, Name => 'Anonymize' },
-    {
-        Label    => loc("Check to clear user custom fields") . ":",
-        Input    => 'checkbox',
-        Class    => 'checkbox',
-        Name     => 'clear_customfields',
-        Value    => 'On',
-    },
-]
-&>
+<div id="user-info-modal" class="modal">
+  <div class="modal-dialog modal-dialog-centered">
+    <div class="modal-content p-2">
+      <div class="modal-header">
+        <h5 class="modal-title"><&|/l&>Anonymize User</&></h5>
+        <a class="close" data-dismiss="modal" aria-label="Close">
+            <span aria-hidden="true">×</span>
+        </a>
+      </div>
+      <div class="modal-body">
+        <form id="user-info-modal-form" action="<% RT->Config->Get('WebPath') %>/Admin/Users/Modify.html" method="POST">
+          <input type="hidden" name="id" value="<% $UserObj->Id %>" />
+          <input type="hidden" name="Anonymize" value="1" />
+
+          <div class="form-row">
+            <div class="custom-control custom-checkbox">
+              <input class="custom-control-input" type="checkbox" id="clear_customfields" name="clear_customfields" />
+              <label class="custom-control-label" for="clear_customfields"><&|/l&>Check to clear user custom fields</&></label>
+            </div>
+          </div>
+        </div>
+
+        <div class="form-row justify-content-end">
+          <div class="col-auto">
+            <button type="Submit" class="button"><&|/l&>Anonymize</&></button>
+          </div>
+        </form>
+      </div>
+    </div>
+  </div>
+</div>
 % }
 <%INIT>
 
diff --git a/share/html/User/Elements/RelatedData b/share/html/User/Elements/RelatedData
index 20b47f54e1..61f935549f 100644
--- a/share/html/User/Elements/RelatedData
+++ b/share/html/User/Elements/RelatedData
@@ -69,9 +69,9 @@
 
 % if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
     <div class="title"><&|/l&>Remove User Information</&></div>
-    <div class="inline-row form-row">
-        <div class="inline-cell col-4">
-            <a class="button btn btn-primary" href="#user-info-modal" rel="modal:open" name="anonymize_user"><&|/l&>Anonymize User</&></a>
+    <div class="form-row">
+        <div class="col-4">
+            <a href="javascript:void(0)" class="button btn btn-primary" data-toggle="modal" data-target="#user-info-modal" name="anonymize_user"><&|/l&>Anonymize User</&></a>
             <i class="label"><&|/l&>Clear core user data, set anonymous username</&></i>
         </div>
 % if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'SuperUser' ) ) {

commit 5953d15cd192acbe23595723878d4943a135fb13
Author: craig kaiser <craig at bestpractical.com>
Date:   Tue Jun 2 09:43:22 2020 -0400

    Remove modal mason component
    
    This is no longer needed as we have the Bootstrap modal.

diff --git a/share/html/Elements/Modal b/share/html/Elements/Modal
deleted file mode 100644
index f749305d11..0000000000
--- a/share/html/Elements/Modal
+++ /dev/null
@@ -1,71 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2020 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<div id="<% $ModalId %>" class="<% $Class %>" align="center">
-    <form action="<% $Action %>" method="<% $Method %>" id="<% $ModalId %>" name="<% $Name %>" >
-% foreach my $field (@Fields) {
-        <p><% $field->{'Label'} %>
-%   if ( $field->{'Input'} ) {
-        <input type="<% $field->{'Input'} %>" class="<% $field->{'Class'} %>" name="<% $field->{'Name'} %>" value="<% $field->{'Value'} %>">
-%   }
-        </p>
-% }
-        <a href="#" rel="modal:close" class="button"><% $Cancel %></a>
-        <button type="Submit" class="button"><% $Accept %></button>
-    </form>
-</div>
-
-<%ARGS>
- at Fields   => ()
-$Name     => ''
-$ModalId  => ''
-$Class    => 'modal'
-$Action   => ''
-$Method   => 'GET'
-$Accept   => loc('OK')
-$Cancel   => loc('Cancel')
-</%ARGS>

commit cb64062314a87d0a79b94c773de5ccfd1d8891c9
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Jul 1 15:38:56 2020 -0400

    Remove unecessary CSS for the RelatedData component

diff --git a/share/html/User/Elements/RelatedData b/share/html/User/Elements/RelatedData
index 61f935549f..faa2b685c3 100644
--- a/share/html/User/Elements/RelatedData
+++ b/share/html/User/Elements/RelatedData
@@ -52,18 +52,30 @@
 
 <div id="manage-user-data">
     <div class="title"><&|/l&>Download User Information</&></div>
-    <div class="download-user-data-buttons inline-row form-row">
-        <div class="inline-cell col-4">
+    <div class="download-user-data-buttons form-row">
+        <div class="col-4">
+          <div class="col-12">
             <a class="button btn btn-primary" href="/User/RelatedData.tsv?Type=User&id=<% $UserObj->id %>"><% $UserDataButton %></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Core user data</&></i>
+          </div>
         </div>
-        <div class="inline-cell col-4">
+        <div class="col-4">
+          <div class="col-12">
             <a class="button btn btn-primary" href="/Search/Results.tsv?UserData=1&Query=Requestor.id=<% $UserObj->id %>&Format=<% $Format | un %>"><% $UserTicketsButton %></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Tickets with this user as a requestor</&></i>
+          </div>
         </div>
-        <div class="inline-cell col-4">
+        <div class="col-4">
+          <div class="col-12">
             <a class="button btn btn-primary" href="/User/RelatedData.tsv?Type=Transaction&id=<% $UserObj->id %>"><% $UserTxnButton %></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Ticket transactions this user created</&></i>
+          </div>
         </div>
     </div>
 
@@ -71,17 +83,29 @@
     <div class="title"><&|/l&>Remove User Information</&></div>
     <div class="form-row">
         <div class="col-4">
+          <div class="col-12">
             <a href="javascript:void(0)" class="button btn btn-primary" data-toggle="modal" data-target="#user-info-modal" name="anonymize_user"><&|/l&>Anonymize User</&></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Clear core user data, set anonymous username</&></i>
+          </div>
         </div>
 % if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'SuperUser' ) ) {
-        <div class="inline-cell col-4">
+        <div class="col-4">
+          <div class="col-12">
             <a class="button btn btn-primary" href="<%RT->Config->Get('WebPath')%>/Admin/Tools/Shredder/index.html?Plugin=Users&Users%3Astatus=<% $UserObj->Disabled ? 'disabled' : 'enabled' %>&Users%3Aname=<% $UserObj->Name %>&Users%3Areplace_relations=Nobody&Search=Search" name="replace-user"><&|/l&>Replace User</&></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Replace this user's activity records with "Nobody" user</&></i>
+          </div>
         </div>
-        <div class="inline-cell col-4">
+        <div class="col-4">
+          <div class="col-12">
             <a class="button btn btn-primary" href="<%RT->Config->Get('WebPath')%>/Admin/Tools/Shredder/index.html?Plugin=Users&Users%3Astatus=<% $UserObj->Disabled ? 'disabled' : 'enabled' %>&Users%3Aname=<% $UserObj->Name %>&Users&Search=Search" name="replace-user"><&|/l&>Delete User</&></a>
+          </div>
+          <div class="col-12">
             <i class="label"><&|/l&>Delete this user, tickets associated with this user must be shredded first</&></i>
+          </div>
         </div>
 % }
     </div>
diff --git a/share/static/css/elevator-light/admin.css b/share/static/css/elevator-light/admin.css
index df5a5e1924..ca5a1c0093 100644
--- a/share/static/css/elevator-light/admin.css
+++ b/share/static/css/elevator-light/admin.css
@@ -83,32 +83,6 @@ table.upgrade-history .upgrade-history-parent .widget a.rolled-up {
     background-image: url(../../../static/images/css/rolldown-arrow.gif);
 }
 
-#manage-user-data div.title {
-    margin-bottom: 5px;
-    font-weight: bold;
-}
-
-div.inline-row {
-    margin-bottom: 10px;
-    display: inline-flex;
-    width: 100%;
-}
-
-div.inline-row div {
-    max-width: 150px;
-    display: block;
-}
-
-div.inline-row a {
-    text-align: center;
-    width: 85%;
-}
-
-div.inline-row i {
-    text-align: left;
-    width: 85%;
-}
-
 #comp-Admin .list-menu {
     float: left
 }
@@ -126,13 +100,6 @@ div.inline-row i {
     padding-bottom: 1em;
 }
 
-#manage-user-data div.form-row i {
-    text-align: left;
-    display: block;
-    font-size: 0.8em;
-    white-space: normal;
-}
-
 #rights-inspector.error .results {
     color: red;
     font-weight: bold;

commit db818ac708eeb218ca316abfd9a17ba23c45c829
Author: craig kaiser <craig at bestpractical.com>
Date:   Mon Jul 6 15:23:39 2020 -0400

    Update remove user info tests for Bootstrap modal

diff --git a/t/web/remove_user_info.t b/t/web/remove_user_info.t
index 4003f32d99..5d727af4c6 100644
--- a/t/web/remove_user_info.t
+++ b/t/web/remove_user_info.t
@@ -33,9 +33,8 @@ $agent->login( 'root' => 'password' );
     my $user_id = $user->id;
 
     $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $user_id );
-    $agent->follow_link_ok( { text => 'Anonymize User' } );
 
-    $agent->submit_form_ok( { form_id => 'user-info-modal', }, "Anonymize user" );
+    $agent->submit_form_ok( { form_id => 'user-info-modal-form', }, "Anonymize user" );
 
     # UserId is still the same, but all other records should be anonimyzed for TestUser
     my ( $ret, $msg ) = $user->Load($user_id);
@@ -75,10 +74,9 @@ $agent->login( 'root' => 'password' );
     is( $user->FirstCustomFieldValue('TestCustomfield'), 'Testing', 'Customfield exists and has value for user.' );
 
     $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $user->id );
-    $agent->follow_link_ok( { text => 'Anonymize User' } );
 
     $agent->submit_form_ok(
-        {   form_id => 'user-info-modal',
+        {   form_id => 'user-info-modal-form',
             fields  => { clear_customfields => 'On' },
         },
         "Anonymize user and customfields"

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


More information about the rt-commit mailing list