[Rt-commit] rt branch, 4.6/tweak-rights-inspector, created. rt-4.4.4-427-g22b4994a6

? sunnavy sunnavy at bestpractical.com
Fri Oct 11 15:44:59 EDT 2019


The branch, 4.6/tweak-rights-inspector has been created
        at  22b4994a6219e2a53726566aca8a937ab59cca47 (commit)

- Log -----------------------------------------------------------------
commit 3b7922dfc8ad48b846903f020252f8e659097413
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 07:22:00 2019 +0800

    Process inspector js only on rights inspector page
    
    This is mainly to get rid of ajax rights search on page load.

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index 37daea935..8d06e1b19 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -1,5 +1,7 @@
 jQuery( function() {
     var form = jQuery('form#rights-inspector');
+    if ( !form.length ) return;
+
     var display = form.find('.results');
     var spinner = form.find('.spinner');
 

commit 1529df47477363591622b860a92e08a2b1d96248
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 10:30:49 2019 +0800

    Make Revoke spinner really work
    
    Previously it appended the hidden spinner to the revoke button, which
    didn't work since it's hidden, not mentioning that the default spinner
    is big and not-inline.
    
    This commit fixes it by using a smaller spinner inside the Revoke
    button instead.

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index 8d06e1b19..cbad09715 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -3,7 +3,6 @@ jQuery( function() {
     if ( !form.length ) return;
 
     var display = form.find('.results');
-    var spinner = form.find('.spinner');
 
     var revoking = {};
     var existingRequest;
@@ -19,7 +18,7 @@ jQuery( function() {
         }
 
         button.addClass('ui-state-disabled').prop('disabled', true);
-        button.after(spinner.clone());
+        button.append(' <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>');
     };
 
     var displayError = function (message) {

commit 381c9e13da0987f593a822d60bf6233e8d759ca1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 10:34:51 2019 +0800

    Clean up obsolete .loading spinner css rules

diff --git a/share/static/css/elevator-light/admin.css b/share/static/css/elevator-light/admin.css
index 103db8575..8fefc5568 100644
--- a/share/static/css/elevator-light/admin.css
+++ b/share/static/css/elevator-light/admin.css
@@ -133,10 +133,6 @@ div.inline-row i {
     white-space: normal;
 }
 
-#rights-inspector .loading {
-    display: none;
-}
-
 #rights-inspector.error .results {
     color: red;
     font-weight: bold;
@@ -146,10 +142,6 @@ div.inline-row i {
     opacity: 0.5;
 }
 
-#rights-inspector.awaiting-first-result .loading, .continuing-load .loading {
-    display: inline;
-}
-
 #rights-inspector .results .result:nth-child(even) .cell {
     background-color: rgb(236, 246, 252);
 }

commit c407339eac06f2bb1715922d073da021e8df345c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 10:53:13 2019 +0800

    Show spinner right before Ajax calls and hide it right after *any* response
    
    Previously when there were errors, the spinner would keep showing up.

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index cbad09715..d8d2473ba 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -40,7 +40,11 @@ jQuery( function() {
             url: form.attr('action'),
             data: search,
             timeout: 30000, /* 30 seconds */
+            beforeSend: function() {
+                jQuery('.spinner').show();
+            },
             success: function (response) {
+                jQuery('.spinner').hide();
                 if (response.error) {
                     displayError(response.error);
                     return;
@@ -76,10 +80,10 @@ jQuery( function() {
                         form.removeClass('awaiting-first-result');
                         display.text('No results');
                     }
-                jQuery('.spinner').hide();
                 }
             },
             error: function (xhr, reason) {
+                jQuery('.spinner').hide();
                 if (reason == 'abort') {
                     return;
                 }
@@ -92,7 +96,6 @@ jQuery( function() {
     var beginSearch = function (delay) {
         form.removeClass('continuing-load').addClass('awaiting-first-result');
         form.find('button').addClass('ui-state-disabled').prop('disabled', true);
-        jQuery('.spinner').show();
 
         var serialized = form.serializeArray();
         var search = {};

commit 02457e58739e04a42e9b745745cd766877d3efe0
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:00:03 2019 +0800

    Localize error/no_results/contains/disabled messages in rights inspector

diff --git a/share/html/Elements/JavascriptConfig b/share/html/Elements/JavascriptConfig
index 1254d838b..f7be9a771 100644
--- a/share/html/Elements/JavascriptConfig
+++ b/share/html/Elements/JavascriptConfig
@@ -72,6 +72,9 @@ my $Catalog = {
     remove => "Remove", #loc
     loading => "Loading...", #loc
     try_again => "Try again", #loc
+    no_results => "No results", # loc
+    contains => "Contains", # loc
+    lower_disabled => "disabled", # loc
     history_scroll_error => "Could not load ticket history. Reason:", #loc
 };
 $_ = loc($_) for values %$Catalog;
diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index d8d2473ba..38892a11b 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -24,7 +24,7 @@ jQuery( function() {
     var displayError = function (message) {
         form.removeClass('awaiting-first-result').removeClass('continuing-load').addClass('error');
         display.empty();
-        display.text('Error: ' + message);
+        display.text(RT.I18N.Catalog.error + ': ' + message);
     }
 
     var requestPage;
@@ -78,7 +78,7 @@ jQuery( function() {
                     if (form.hasClass('awaiting-first-result')) {
                         display.empty();
                         form.removeClass('awaiting-first-result');
-                        display.text('No results');
+                        display.text(RT.I18N.Catalog.no_results);
                     }
                 }
             },
@@ -172,7 +172,7 @@ function render_inspector_record (record) {
         +  '  <span class="detail">'
         +       link_or_text( record.detail_highlighted, record.detail_url)
         +       link_or_text( record.detail_extra, record.detail_extra_url)
-        +       cond_text( record.disabled, '(disabled)')
+        +       cond_text( record.disabled, '(' + RT.I18N.Catalog.lower_disabled + ')')
         +  '  </span>'
         +     render_inspector_primary_record( record.primary_record)
         +  '</span>'
@@ -181,7 +181,7 @@ function render_inspector_record (record) {
 }
 
 function render_inspector_primary_record (primary_record) {
-    return primary_record ? '<span class="primary">Contains ' + render_inspector_record( primary_record) + '</span>'
+    return primary_record ? '<span class="primary">' + RT.I18N.Catalog.contains + render_inspector_record( primary_record) + '</span>'
                           : '';
 }
 

commit 92261bb852874bb7bfd55cf24d75ce4f8cf305f6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:23:50 2019 +0800

    Clean up as returned records do not have highlight/match keys

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index 38892a11b..b26ce9fb0 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -166,7 +166,7 @@ jQuery( function() {
 
 function render_inspector_record (record) {
     return '<span class="record ' + cond_text( record.disabled, 'disabled') + '">'
-        +  '  <span class="name ' + cond_text( record.highlight, record.match) + '">'
+        +  '  <span class="name">'
         +       link_or_text( record.label_highlighted, record.url)
         +  '  </span>'
         +  '  <span class="detail">'

commit 2c374921db2b6ce978d56504578940153e2cfd08
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:25:12 2019 +0800

    Drop default function params as it's unsupported in IE
    
    Besides, it's not actaully necessary here as text is always defined.

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index b26ce9fb0..ab2b27002 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -219,7 +219,7 @@ function revoke_button (item) {
     }
 }
 
-function cond_text (cond, text = '') {
+function cond_text (cond, text) {
     return cond ? text : '';
 }
 

commit bad7ceb1e7e066d905aab7f8f93c61f395c33b83
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:28:33 2019 +0800

    Use consistent margin for headers as record rows

diff --git a/share/html/Admin/Tools/RightsInspector.html b/share/html/Admin/Tools/RightsInspector.html
index 5372af48a..410cb5881 100644
--- a/share/html/Admin/Tools/RightsInspector.html
+++ b/share/html/Admin/Tools/RightsInspector.html
@@ -92,7 +92,7 @@ results if Joe has access due to multiple different reasons.</p>
 
 <&|/Widgets/TitleBox, title => loc("Rights Inspector") &>
 <form action="<%RT->Config->Get('WebPath')%>/Helpers/RightsInspector/Search" id="rights-inspector" class="search">
-  <div class="row">
+  <div class="form-row">
     <input class="col-md-3 form-control" value="<% $ARGS{Principal} %>" type="text" name="principal" placeholder="Principal">
     <input class="col-md-3 form-control" value="<% $ARGS{Object} %>" type="text" name="object" placeholder="Object">
     <input class="col-md-3 form-control" value="<% $ARGS{Right} %>" type="text" name="right" placeholder="Right">

commit e910740bf7081d079575b5c567a6f0024b3a993a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:42:29 2019 +0800

    Localize input placeholders

diff --git a/share/html/Admin/Tools/RightsInspector.html b/share/html/Admin/Tools/RightsInspector.html
index 410cb5881..a25353aef 100644
--- a/share/html/Admin/Tools/RightsInspector.html
+++ b/share/html/Admin/Tools/RightsInspector.html
@@ -93,9 +93,9 @@ results if Joe has access due to multiple different reasons.</p>
 <&|/Widgets/TitleBox, title => loc("Rights Inspector") &>
 <form action="<%RT->Config->Get('WebPath')%>/Helpers/RightsInspector/Search" id="rights-inspector" class="search">
   <div class="form-row">
-    <input class="col-md-3 form-control" value="<% $ARGS{Principal} %>" type="text" name="principal" placeholder="Principal">
-    <input class="col-md-3 form-control" value="<% $ARGS{Object} %>" type="text" name="object" placeholder="Object">
-    <input class="col-md-3 form-control" value="<% $ARGS{Right} %>" type="text" name="right" placeholder="Right">
+    <input class="col-md-3 form-control" value="<% $ARGS{Principal} %>" type="text" name="principal" placeholder="<&|/l&>Principal</&>">
+    <input class="col-md-3 form-control" value="<% $ARGS{Object} %>" type="text" name="object" placeholder="<&|/l&>Object</&>">
+    <input class="col-md-3 form-control" value="<% $ARGS{Right} %>" type="text" name="right" placeholder="<&|/l&>Right</&>">
   </div>
 
   <div class="results">

commit ec83d959928a7c2006c2093fc88c06e2aeeab3d4
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 11:53:00 2019 +0800

    Vertically align cells in rights inspector
    
    Seems the 0.3/0.4em padding-tops tried to center right/revoke columns
    but it didn't look good enough.
    
    The .unused cell is to not fill striped background to left unused ones

diff --git a/share/static/css/elevator-dark/main.css b/share/static/css/elevator-dark/main.css
index f72454792..0c7021063 100644
--- a/share/static/css/elevator-dark/main.css
+++ b/share/static/css/elevator-dark/main.css
@@ -163,10 +163,15 @@
   background: rgba(0, 0, 0, 0) !important; 
 }
 
+.darkmode #rights-inspector .results .result:nth-child(even),
 .darkmode #rights-inspector .results .result:nth-child(even) * {
     background-color: #111 !important;
 }
 
+.darkmode #rights-inspector .results .result:nth-child(even) .unused {
+  background: #171A1F !important;
+}
+
 .darkmode #rights-inspector .results .result .match {
     background-color: #114 !important;
 }
diff --git a/share/static/css/elevator-light/admin.css b/share/static/css/elevator-light/admin.css
index 8fefc5568..6b7d4088b 100644
--- a/share/static/css/elevator-light/admin.css
+++ b/share/static/css/elevator-light/admin.css
@@ -142,10 +142,14 @@ div.inline-row i {
     opacity: 0.5;
 }
 
-#rights-inspector .results .result:nth-child(even) .cell {
+#rights-inspector .results .result:nth-child(even) {
     background-color: rgb(236, 246, 252);
 }
 
+#rights-inspector .results .result:nth-child(even) .unused {
+    background-color: white;
+}
+
 #rights-inspector .results .result .match {
     background-color: rgb(255, 253, 56);
     font-weight: bold;
@@ -180,14 +184,6 @@ div.inline-row i {
     display: none;
 }
 
-#rights-inspector .results .result .right {
-    padding-top: .4em;
-}
-
-#rights-inspector .results .result .revoke {
-    padding-top: .3em;
-}
-
 #rt-help-text kbd {
     color: #111;
     border: 1px dashed #AAA;
diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index ab2b27002..ccbcdc228 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -141,6 +141,7 @@ jQuery( function() {
                     alert(response.msg);
                 }
                 else {
+                    button.closest('.revoke').siblings('.unused').remove();
                     button.closest('.revoke').removeClass('col-md-1').addClass('col-md-3').text(response.msg);
                 }
                 delete revoking[action];
@@ -199,12 +200,13 @@ function link_or_text (text, url) {
 
 function render_inspector_result (item) {
     return '<div class="result form-row">'
-        +  '  <div class="principal cell col-md-3">' + render_inspector_record( item.principal) + '</div>'
-        +  '  <div class="object cell col-md-3">' + render_inspector_record( item.object) + '</div>'
-        +  '  <div class="right cell col-md-3">' + item.right_highlighted + '</div>'
-        +  '  <div class="revoke cell col-md-1">'
+        +  '  <div class="principal cell col-md-3 my-auto">' + render_inspector_record( item.principal) + '</div>'
+        +  '  <div class="object cell col-md-3 my-auto">' + render_inspector_record( item.object) + '</div>'
+        +  '  <div class="right cell col-md-3 my-auto">' + item.right_highlighted + '</div>'
+        +  '  <div class="revoke cell col-md-1 my-auto">'
         +       revoke_button(item)
         + '  </div>'
+        +  '  <div class="unused cell col-md-2" />'
         + '</div>'
     ;
 }

commit 8e96e289549cedb0047ae4b6f13bc3f8ea3f6e7e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 12:03:41 2019 +0800

    Use balanced spaces with ()
    
    "( foo)" is a weird format.

diff --git a/share/static/js/rights-inspector.js b/share/static/js/rights-inspector.js
index ccbcdc228..ca7333e77 100644
--- a/share/static/js/rights-inspector.js
+++ b/share/static/js/rights-inspector.js
@@ -1,4 +1,4 @@
-jQuery( function() {
+jQuery(function() {
     var form = jQuery('form#rights-inspector');
     if ( !form.length ) return;
 
@@ -166,28 +166,28 @@ jQuery( function() {
 // rendering functions
 
 function render_inspector_record (record) {
-    return '<span class="record ' + cond_text( record.disabled, 'disabled') + '">'
+    return '<span class="record ' + cond_text(record.disabled, 'disabled') + '">'
         +  '  <span class="name">'
-        +       link_or_text( record.label_highlighted, record.url)
+        +       link_or_text(record.label_highlighted, record.url)
         +  '  </span>'
         +  '  <span class="detail">'
-        +       link_or_text( record.detail_highlighted, record.detail_url)
-        +       link_or_text( record.detail_extra, record.detail_extra_url)
-        +       cond_text( record.disabled, '(' + RT.I18N.Catalog.lower_disabled + ')')
+        +       link_or_text(record.detail_highlighted, record.detail_url)
+        +       link_or_text(record.detail_extra, record.detail_extra_url)
+        +       cond_text(record.disabled, '(' + RT.I18N.Catalog.lower_disabled + ')')
         +  '  </span>'
-        +     render_inspector_primary_record( record.primary_record)
+        +     render_inspector_primary_record(record.primary_record)
         +  '</span>'
     ;
 
 }
 
 function render_inspector_primary_record (primary_record) {
-    return primary_record ? '<span class="primary">' + RT.I18N.Catalog.contains + render_inspector_record( primary_record) + '</span>'
+    return primary_record ? '<span class="primary">' + RT.I18N.Catalog.contains + render_inspector_record(primary_record) + '</span>'
                           : '';
 }
 
 function link_or_text (text, url) {
-    if( typeof text == 'undefined') {
+    if(typeof text == 'undefined') {
         return '';
     }
     else if( url && url.length > 0 ) {
@@ -200,8 +200,8 @@ function link_or_text (text, url) {
 
 function render_inspector_result (item) {
     return '<div class="result form-row">'
-        +  '  <div class="principal cell col-md-3 my-auto">' + render_inspector_record( item.principal) + '</div>'
-        +  '  <div class="object cell col-md-3 my-auto">' + render_inspector_record( item.object) + '</div>'
+        +  '  <div class="principal cell col-md-3 my-auto">' + render_inspector_record(item.principal) + '</div>'
+        +  '  <div class="object cell col-md-3 my-auto">' + render_inspector_record(item.object) + '</div>'
         +  '  <div class="right cell col-md-3 my-auto">' + item.right_highlighted + '</div>'
         +  '  <div class="revoke cell col-md-1 my-auto">'
         +       revoke_button(item)

commit 22b4994a6219e2a53726566aca8a937ab59cca47
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 11 13:07:43 2019 +0800

    Use the same margin for ajax spinner too
    
    This is to add some space between records and spinner, otherwise the
    spinner is too close to the last record, which doesn't look good.

diff --git a/share/html/Admin/Tools/RightsInspector.html b/share/html/Admin/Tools/RightsInspector.html
index a25353aef..b76769b4a 100644
--- a/share/html/Admin/Tools/RightsInspector.html
+++ b/share/html/Admin/Tools/RightsInspector.html
@@ -100,7 +100,11 @@ results if Joe has access due to multiple different reasons.</p>
 
   <div class="results">
   </div>
-  <& /Widgets/Spinner &>
+  <div class="form-row">
+    <div class="col-12">
+      <& /Widgets/Spinner &>
+    </div>
+  </div>
 </form>
 </&>
 

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


More information about the rt-commit mailing list