This is an automated email from the ASF dual-hosted git repository.

psomogyi pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new e5c6c712822 HBASE-29093 Load userSnapshots.jsp only on master status 
page (#6627) (#7034)
e5c6c712822 is described below

commit e5c6c712822d262046f4d7c96e79dd55ea29c77f
Author: Dávid Paksy <[email protected]>
AuthorDate: Tue May 27 08:33:18 2025 +0200

    HBASE-29093 Load userSnapshots.jsp only on master status page (#6627) 
(#7034)
    
    * HBASE-29093 Load userSnapshots.jsp only on master status page
    
    Before HBase UI always tried to load userSnapshots.jsp with an AJAX request 
on all UI pages - NOK.
    
    This happened even on RegionServer UI or REST UI where this call always 
fail with HTTP 500.
    
    From now on HBase UI only loads userSnapshots.jsp when the Snapshots tab 
(div with tab_userSnapshots ID) exists on the page.
    
    * HBASE-29093 Minor JS improvements
    
    - Use const instead of var as var has so many problems (global context, 
etc).
    - Fixed whitespace.
    
    (cherry picked from commit fa22ba4cfe1d79337c49ec79fc4512b5fba3959b)
    
    Signed-off-by: Duo Zhang <[email protected]>
    Signed-off-by: Nihal Jain <[email protected]
    Signed-off-by: Peter Somogyi <[email protected]
---
 .../src/main/resources/hbase-webapps/static/js/tab.js  | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/hbase-server/src/main/resources/hbase-webapps/static/js/tab.js 
b/hbase-server/src/main/resources/hbase-webapps/static/js/tab.js
index 808882b9f40..1e54f6614bd 100644
--- a/hbase-server/src/main/resources/hbase-webapps/static/js/tab.js
+++ b/hbase-server/src/main/resources/hbase-webapps/static/js/tab.js
@@ -20,19 +20,23 @@
 
 $(document).ready(
   function(){
-    var prefix = "tab_";
-       $('.tabbable .nav-pills a').click(function (e) {
+    const prefix = "tab_";
+    $('.tabbable .nav-pills a').click(function (e) {
         e.preventDefault();
         location.hash = $(e.target).attr('href').substr(1).replace(prefix, "");
         $(this).tab('show');
     });
 
-  $.ajax({url:"/userSnapshots.jsp", success:function(result){
-    $("#tab_userSnapshots").html(result);
-  }});
-            
+    const $userSnapshotsTab = $("#tab_userSnapshots");
+    const isUserSnapshotsTabExists = $userSnapshotsTab.length;
+    if (isUserSnapshotsTabExists) {
+      $.ajax({url:"/userSnapshots.jsp", success:function(result){
+        $userSnapshotsTab.html(result);
+      }});
+    }
+
     if (location.hash !== '') {
-      var tabItem = $('a[href="' + location.hash.replace("#", "#"+prefix) + 
'"]');
+      const tabItem = $('a[href="' + location.hash.replace("#", "#"+prefix) + 
'"]');
       tabItem.tab('show');
       $(document).scrollTop(0);  
       return false;  

Reply via email to