From d22bb587943862dd0057cd1fde342361143b59ac Mon Sep 17 00:00:00 2001
From: LucasC <lucas.charpentier@xwiki.com>
Date: Tue, 27 Aug 2024 09:04:28 +0200
Subject: [PATCH] XWIKI-18046: Layout issues on Administration's Rights section
 (#2985)

* Unset the vertical align of radio buttons to pick user/group that caused a weird display due to an unexpected collision
* Limited the size of the first column of the table when there's not many rights along it
* Removed auto wrapping on some elements where it created inconsistencies in UI (still looks good without it)
* Overrode an unexpected collision between xform and the rights table (only for extension rights)
* Moved the line for the unregistered user rights to be just above the actual table lines (looks more consistent than regular line (almost) -> filter -> regular line)
* Tweaked colspans on filter elements to have them display side to side using the whole length of the table
* Added comment to explain empirical value
* Added xml escaping on the $clsname use

---------

Co-authored-by: Manuel Leduc <manuel.leduc@xwiki.com>
---
 .../src/main/resources/XWiki/AdminSheet.xml   | 21 +++++++++++++
 .../src/main/resources/flamingo/rightsUI.vm   | 30 +++++++++++--------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/AdminSheet.xml b/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/AdminSheet.xml
index e056dae41e7..5d77477f3bc 100644
--- a/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/AdminSheet.xml
+++ b/xwiki-platform-core/xwiki-platform-administration/xwiki-platform-administration-ui/src/main/resources/XWiki/AdminSheet.xml
@@ -894,6 +894,10 @@
   vertical-align: middle;
 }
 
+#admin-page-content .usersorgroupsnames label &gt; input[type="radio"] {
+  vertical-align: unset;
+}
+
 /**
  * Category Overview
  */
@@ -937,6 +941,19 @@
   border-color: transparent;
 }
 
+#admin-page-content .usersorgroupsnames {
+  white-space: nowrap;
+  /* Triple of the value for the .right column. This is useful to make sure the columns are somewhat balanced when
+    there is only one right (e.g., extension rights with a default flavor).
+    Keeping them balanced is useful to make sure the filters are displayed properly, which is especially important
+    on a subwiki where we have to find a place to display the scope selector. */
+  width: 27%;
+}
+
+#usersandgroupstable-filters-scope {
+  white-space: nowrap;
+}
+
 #usersandgroupstable-filters #name {
     width: 65%;
 }
@@ -955,6 +972,10 @@
   vertical-align: top;
 }
 
+.xform #usersandgroupstable select {
+  width: unset;
+}
+
 /**
  * Bootstrap's Accordion Menu
  */
diff --git a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/rightsUI.vm b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/rightsUI.vm
index 8e77d834381..58dac076976 100644
--- a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/rightsUI.vm
+++ b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/rightsUI.vm
@@ -205,18 +205,16 @@ $xwiki.ssfx.use('js/xwiki/table/livetable.css', true)
                 #end
               #end
             </tr>
-            <tr id="unregistered">
-              ## Rights for guests, statically displayed outside the livetable
-              <td id="unreguser" data-title="$escapetool.xml($services.localization.render('rightsmanager.username'))">$services.localization.render('rightsmanager.unregisteredusers')</td>
-              #foreach ($i in [0..$maxlevel])
-                #if ($currentAllowed[$i])
-                  <td class="rights" id="td${levelsRights.get($i)}" data-title="$escapetool.xml($services.localization.render("rightsmanager.${levelsRights.get($i)}"))"></td>
-                #end
-              #end
-            </tr>
             <tr id="usersandgroupstable-filters">
               ## Users/groups filter
-              <td><label for="name">$services.localization.render('rightsmanager.searchfilter')</label><input id="name" name="name" type="text"/>
+              ## We split the column amount in between the two objects as evenly as possible.
+              ## This way we can make sure both element have enough space to display correctly.
+              #set ($colsp = ($maxlevel+2)/2)
+              <td colspan="$colsp">
+                <label for="name">$services.localization.render('rightsmanager.searchfilter')</label>
+                <input id="name" name="name" type="text"/>
+              </td>
+              <td colspan="$colsp">
                 #if(!$xcontext.isMainWiki()) #set($mainwk = false) #else #set($mainwk = true) #end
                 #if(!$mainwk) ## display the combobox only in a local wiki
                   <div id="usersandgroupstable-filters-scope">
@@ -230,9 +228,17 @@ $xwiki.ssfx.use('js/xwiki/table/livetable.css', true)
                 #else
                   <input type="hidden" name="wiki" value="local"/>
                 #end
-                #set ($colsp = $maxlevel + 1)
+                <input type="hidden" name="clsname" value="$escapetool.xml($clsname)" />
               </td>
-              <td colspan="$colsp"><input type="hidden" name="clsname" value="$clsname" /></td>
+            </tr>
+            <tr id="unregistered">
+              ## Rights for guests, statically displayed outside the livetable
+              <td id="unreguser" data-title="$escapetool.xml($services.localization.render('rightsmanager.username'))">$services.localization.render('rightsmanager.unregisteredusers')</td>
+              #foreach ($i in [0..$maxlevel])
+                #if ($currentAllowed[$i])
+                  <td class="rights" id="td${levelsRights.get($i)}" data-title="$escapetool.xml($services.localization.render("rightsmanager.${levelsRights.get($i)}"))"></td>
+                #end
+              #end
             </tr>
           </thead>
           ## Livetable placeholder, will be filled in from Javascript
-- 
GitLab