[Rt-commit] rt branch, 5.0/help-basics, created. rt-5.0.1-445-gb2dcd5b085

Steve Burr steve at bestpractical.com
Mon Jun 14 08:34:58 EDT 2021


The branch, 5.0/help-basics has been created
        at  b2dcd5b085a0cf813a33651b428d41469d959b10 (commit)

- Log -----------------------------------------------------------------
commit 724aace869fab34a2b88233e54b91e1bd6c644d2
Merge: dba82ae6e7 d5f6374a33
Author: Steven Burr <steve at bestpractical.com>
Date:   Fri Jun 11 13:43:18 2021 -0400

    Merge branch '5.0/allow-custom-fields-on-article-class' into 5.0/help-basics


commit 7e73b6570b4ca9ba47ae20e412db5081b5825f58
Merge: 724aace869 2c818ce3cb
Author: Steven Burr <steve at bestpractical.com>
Date:   Fri Jun 11 13:43:26 2021 -0400

    Merge branch '5.0/articles-unique-only-within-own-class2' into 5.0/help-basics


commit 4a9ad4f0d06b2c0e5b59bbc6913d1b5fef8aaf0c
Author: Steven Burr <steve at bestpractical.com>
Date:   Fri Jun 11 14:56:06 2021 -0400

    Add popup help capabilities
    
    Help icons can be added anywhere on RT pages. When clicked, they
    will display the contents of an associated Article in a dismissable
    popover dialog. The Article content can be retrieved server-side
    at page rendering time or dynamically when clicked via AJAX.
    
    No help icons or articles are actually added as part of this commit.
    Just the underlying functionality.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 97140de731..aad8e626e6 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -144,6 +144,7 @@ sub JSFiles {
         Chart.min.js
         chartjs-plugin-colorschemes.min.js
         jquery.jgrowl.min.js
+        popup-help.js
         }, RT->Config->Get('JSFiles');
 }
 
@@ -5184,6 +5185,79 @@ sub PreprocessTimeUpdates {
     RT::Interface::Web::PreprocessTimeUpdates(@_);
 }
 
+=head3 GetSystemHelpClass locales
+
+Given a list of locales, find the best article class that has been associated with the
+'RT Help System' custom field. Locales are searched in order. The first Class with an
+'RT Help System' custom field and matching 'Locale' custom field will be returned.
+
+=cut
+
+sub GetSystemHelpClass {
+    my $locales = shift || ['en'];
+
+    # Find the custom field that indicates a Class is participating in the RT Help System
+    my $cf = RT::CustomField->new( RT->SystemUser );
+    my ($ret, $msg) = $cf->Load("RT Help System");
+    unless ($ret and $cf->Id) {
+        RT::Logger->warn("Could not find custom field for 'RT Help System' $msg");
+        return;
+    }
+
+    # Loop over the supplied locales in order. Return the first Class that is participating
+    # in the RT Help System that also has a matching Locale custom field value
+    my $Classes = RT::Classes->new( RT->SystemUser );
+    ($ret, $msg) = $Classes->LimitCustomField( CUSTOMFIELD => $cf->Id, OPERATOR => "=", VALUE => "yes" );
+    if ($ret) {
+        for my $locale (@$locales) {
+            $Classes->GotoFirstItem;
+            while (my $class = $Classes->Next) {
+                my $val = $class->FirstCustomFieldValue('Locale');
+                return $class if $val eq $locale;
+            }
+        }
+    } else {
+        RT::Logger->debug("Could not find a participating help Class $msg");
+    }
+
+    # none found
+    RT::Logger->debug("Could not find a suitable help Class for locales: @$locales");
+    return;
+}
+
+=head3 GetHelpArticleContent class_id, article_name
+
+Returns the raw, unscrubbed and unescaped Content of an Article of the given Class.
+Often, the class_id will come from GetSystemHelpClass, but it does not have to.
+
+=cut
+
+sub GetHelpArticleContent {
+    use Data::Printer;
+    my $class_id = shift || return '';      # required
+    my $article_name = shift || return '';  # required
+
+    # find the article of the given class
+    my $Article = RT::Article->new( RT->SystemUser );
+    my ($ret, $msg) = $Article->LoadByCols( Name => $article_name, Class => $class_id );
+    if ( $Article and $Article->Id ) {
+        RT::Logger->debug("Found help article id: " . $Article->Id);
+        my $class = $Article->ClassObj;
+        my $cfs = $class->ArticleCustomFields;
+        while (my $cf = $cfs->Next) {
+            if ($cf->Name eq 'Content') {
+                my $ocfvs = $Article->CustomFieldValues($cf->Id);
+                my $ocfv = $ocfvs->First;
+                return $ocfv->Content;  # do not escape
+            }
+        }
+    }
+
+    # no match was found
+    RT::Logger->debug("No help article found for '$article_name'");
+    return '';
+}
+
 package RT::Interface::Web;
 RT::Base->_ImportOverlays();
 
diff --git a/share/html/Elements/Footer b/share/html/Elements/Footer
index 9884c963d7..333ade7c39 100644
--- a/share/html/Elements/Footer
+++ b/share/html/Elements/Footer
@@ -79,6 +79,14 @@
 % }
     </div>
   </body>
+<script>
+jQuery(document).ready(function() {
+    // popup-help.js : any help items that have been queued up via addPopupHelpItems() will
+    // get their popover functionality added at this point, including the default rule
+    // that matches any elements with a 'data-help' attribute
+    renderPopupHelpItems()
+})
+</script>
 </html>
 <%ARGS>
 $Debug => 0
diff --git a/share/html/Elements/PopupHelp b/share/html/Elements/PopupHelp
new file mode 100644
index 0000000000..8d5ea7bef2
--- /dev/null
+++ b/share/html/Elements/PopupHelp
@@ -0,0 +1,20 @@
+<%args>
+$key => ''
+</%args>
+<%init>
+my $has_help;
+my $help_class;
+my $help_content;
+if ($key) {
+    my $lh = $session{'CurrentUser'}->LanguageHandle;
+    my @locs = ( $lh->language_tag(), $lh->fallback_languages() );
+    my $help_class = GetSystemHelpClass( \@locs );
+    if ($help_class && $help_class->Id) {
+        $help_content = GetHelpArticleContent( $help_class->Id, $key );
+    }
+    $has_help = $help_content;
+}
+</%init>
+% if ($has_help) {
+<span data-help="<% $key %>" data-content="<% $help_content %>" data-action="replace" style="display: none;"/>
+% }
diff --git a/share/html/Helpers/HelpTopic b/share/html/Helpers/HelpTopic
new file mode 100644
index 0000000000..a76da0c03b
--- /dev/null
+++ b/share/html/Helpers/HelpTopic
@@ -0,0 +1,15 @@
+<%args>
+$key => '',
+</%args>
+<%init>
+my $help_class;
+my $help_content;
+if ($key) {
+    my $lh = $session{'CurrentUser'}->LanguageHandle;
+    my @locs = ( $lh->language_tag(), $lh->fallback_languages() );
+    my $help_class = GetSystemHelpClass( \@locs );
+    $help_content = GetHelpArticleContent( $help_class->Id, $key ) || "<div class='text-danger'>No help was found for '$key'.</div>";
+    $m->print($help_content);
+}
+$m->abort;
+</%init>
diff --git a/share/static/images/question.svg b/share/static/images/question.svg
new file mode 100644
index 0000000000..89ebf0e2fc
--- /dev/null
+++ b/share/static/images/question.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zM6.92 6.085c.081-.16.19-.299.34-.398.145-.097.371-.187.74-.187.28 0 .553.087.738.225A.613.613 0 019 6.25c0 .177-.04.264-.077.318a.956.956 0 01-.277.245c-.076.051-.158.1-.258.161l-.007.004a7.728 7.728 0 00-.313.195 2.416 2.416 0 00-.692.661.75.75 0 001.248.832.956.956 0 01.276-.245 6.3 6.3 0 01.26-.16l.006-.004c.093-.057.204-.123.313-.195.222-.149.487-.355.692-.662.214-.32.329-.702.329-1.15 0-.76-.36-1.348-.863-1.725A2.76 2.76 0 008 4c-.631 0-1.155.16-1.572.438-.413.276-.68.638-.849.977a.75.75 0 101.342.67z"></path></svg>
\ No newline at end of file
diff --git a/share/static/js/popup-help.js b/share/static/js/popup-help.js
new file mode 100644
index 0000000000..2a9b613f85
--- /dev/null
+++ b/share/static/js/popup-help.js
@@ -0,0 +1,152 @@
+// a list of entries to process for the page
+var pagePopupHelpItems = [
+	{ selector: "[data-help]", action: helpify }  // by default, anything with data-help attributes gets processed
+]
+
+// add one or more items to the list of help entries to process for the page
+function addPopupHelpItems() {
+	const args = [].slice.call(arguments)
+	pagePopupHelpItems = pagePopupHelpItems || []
+	pagePopupHelpItems = pagePopupHelpItems.concat(args)
+}
+
+function applySelectorQueryOrFunc( sel ) {
+	if ( sel ) {
+		if ( typeof(sel) === "string" ) {
+			return jQuery(sel)
+		} else if ( typeof(sel) === "function" ) {
+			return sel(jQuery)
+		}
+	}
+}
+
+function getPopupHelpAction( entry={} ) {
+	entry.action = entry.action || "append"
+	if ( typeof(entry.action) === "string" ) {
+		const funcMap = {
+			"append": appendPopupHelp,
+			"prepend": prependPopupHelp,
+			"offset": offsetPopupHelp,
+			"replace": replacePopupHelp
+		}
+		return funcMap[entry.action]
+	} else if ( typeof(entry.action) === "function" ) {
+		return entry.action
+	}
+}
+
+function getPopupHelpActionArgs( entry={}, $els ) {
+	return entry.actionArgs ? [ $els, entry, entry.actionArgs ] : [ $els, entry ]
+}
+
+function appendPopupHelp( $els, item={}, options={} ) {
+	item.action = options.action = "append"
+	return helpify( $els, item, options )
+}
+
+function prependPopupHelp( $els, item={}, options={} ) {
+	item.action = options.action = "prepend"
+	return helpify( $els, item, options )
+}
+
+function offsetPopupHelp( $els, item={}, options={} ) {
+	item.action = options.action = "offset"
+	return helpify( $els, item, options )
+}
+
+function replacePopupHelp( $els, item={}, options={} ) {
+	item.action = options.action = "replace"
+	return helpify( $els, item, options )
+}
+
+function helpify($els, item={}, options={}) {
+	$els.each(function(index) {
+		const $el = jQuery($els.get(index))
+		const action = $el.data("action") || item.action || options.action
+		const title = $el.data("help") || $el.data("title") || item.title
+		const content = $el.data("content") || item.content
+		switch(action) {
+			case "prepend":
+				$el.parent().prepend( buildPopupHelpHtml( title, content ) )
+				break
+			case "offset":
+				$el.append( buildPopupHelpHtml( title, content ) ).offset( options )
+				break
+			case "replace":
+				$el.replaceWith( buildPopupHelpHtml( title, content ) )
+				break
+			case "append":  // intentionally fallthrough, as 'append' is the default
+			default:
+				$el.parent().append( buildPopupHelpHtml( title, content ) )
+		}
+	})
+}
+
+function buildPopupHelpHtml(title, content) {
+	// TODO configurable glyph
+	const icon = '/static/images/question.svg'
+	const contentAttr = content ? ' data-content="' + content + '" ' : ''
+	return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="focus" ' + contentAttr + '><img src="' + icon + '" /></a>'
+}
+
+function applyPopupHelpAction( entry, $els ) {
+	if ( entry ) {
+		const fn = getPopupHelpAction( entry )
+		const args = getPopupHelpActionArgs( entry, $els )
+		fn.apply(this, args)
+	}
+}
+
+// render all the help icons and popover-ify them
+function renderPopupHelpItems( list ) {
+	const isDefined = function(x) { return typeof x !== "undefined" }
+	const buildUrl = function(key) { return RT.Config.WebHomePath + "/Helpers/HelpTopic?key=" + encodeURIComponent(key) }
+	const boolVal = function(str) {
+		try {
+			return !!JSON.parse(str)
+		}
+		catch {
+			return false
+		}
+	}
+
+	list = list || pagePopupHelpItems
+	if (list && Array.isArray(list) && list.length) {
+		list.forEach(function(entry) {
+			const $els = applySelectorQueryOrFunc(entry.selector)
+			if ( $els ) {
+				applyPopupHelpAction( entry, $els )
+			}
+		})
+        jQuery('[data-toggle="popover"]').popover({
+			trigger: 'focus',
+			html: true,
+			content: function() {
+				const $el = jQuery(this)
+				const title = $el.data("help") || $el.data("title") || $el.data("originalTitle")
+				var content = $el.data("content")
+				if (content) {
+					return content
+				} else {
+					const isAsync = isDefined($el.data("async")) ? boolVal($el.data("async")) : true
+					if (isAsync) {
+						const tmpId = "tmp-id-" + jQuery.now()
+						jQuery.ajax({
+							url: buildUrl(title), dataType: "html",
+							dataType: "html",
+							success: function(response, statusText, xhr) {
+								jQuery("#" + tmpId).html(xhr.responseText)
+							},
+							error: function(e) {
+								jQuery("#" + tmpId).html("<div class='text-danger'>Error loading help for '" + title + "': " + e)
+							}
+						})
+						return "<div id='" + tmpId + "'>Loading...</div>"
+					} else {
+						return "<div class='text-danger'>No help content available for '" + title + "'.</div>"
+					}
+				}
+			}
+		})
+	}
+}

commit 50fee1c33db74953a71659c43e9c28424a709540
Author: Steven Burr <steve at bestpractical.com>
Date:   Fri Jun 11 15:56:28 2021 -0400

    Fix support for dark-mode themes
    
    The help icon will be question.svg in light mode and question-white.svg
    in dark mode themes.

diff --git a/share/static/css/elevator-dark/main.css b/share/static/css/elevator-dark/main.css
index 7ea673931b..08cc59b5a9 100644
--- a/share/static/css/elevator-dark/main.css
+++ b/share/static/css/elevator-dark/main.css
@@ -453,3 +453,11 @@ body.darkmode.IE11 .ui-icon-circle-triangle-e {
     border-color: #717171;
     margin-bottom: 1px;
 }
+
+.darkmode .popover {
+    border: 1px solid rgba(255, 255, 255, 0.6);
+}
+
+.darkmode .popover-header {
+    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
+}
diff --git a/share/static/images/question-white.svg b/share/static/images/question-white.svg
new file mode 100644
index 0000000000..c2bcf3c76b
--- /dev/null
+++ b/share/static/images/question-white.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   viewBox="0 0 16 16"
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg163"
+   sodipodi:docname="question-white.svg"
+   inkscape:version="1.0.1 (c497b03c, 2020-09-10)">
+  <metadata
+     id="metadata169">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs167" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1652"
+     inkscape:window-height="980"
+     id="namedview165"
+     showgrid="false"
+     inkscape:zoom="45.9375"
+     inkscape:cx="8"
+     inkscape:cy="8"
+     inkscape:window-x="0"
+     inkscape:window-y="105"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="svg163" />
+  <path
+     fill-rule="evenodd"
+     d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zM6.92 6.085c.081-.16.19-.299.34-.398.145-.097.371-.187.74-.187.28 0 .553.087.738.225A.613.613 0 019 6.25c0 .177-.04.264-.077.318a.956.956 0 01-.277.245c-.076.051-.158.1-.258.161l-.007.004a7.728 7.728 0 00-.313.195 2.416 2.416 0 00-.692.661.75.75 0 001.248.832.956.956 0 01.276-.245 6.3 6.3 0 01.26-.16l.006-.004c.093-.057.204-.123.313-.195.222-.149.487-.355.692-.662.214-.32.329-.702.329-1.15 0-.76-.36-1.348-.863-1.725A2.76 2.76 0 008 4c-.631 0-1.155.16-1.572.438-.413.276-.68.638-.849.977a.75.75 0 101.342.67z"
+     id="path161" />
+  <path
+     style="fill:#ffffff;stroke-width:0.0217687"
+     d="M 7.4993197,15.975617 C 5.5754804,15.837138 3.8106789,15.05408 2.4519541,13.736054 1.2836555,12.602751 0.49210782,11.163817 0.17464509,9.5961918 0.05430088,9.0019344 0.02562137,8.6947483 0.02562137,8 c 0,-0.6947483 0.02867951,-1.0019344 0.14902372,-1.5961918 C 0.39917024,5.295107 0.90701002,4.1589166 1.5863609,3.2453745 2.3661281,2.1967998 3.3678541,1.3724795 4.5608044,0.79770523 5.3536555,0.41570238 6.1604517,0.18158567 7.0965986,0.06186653 7.5564763,0.00305508 8.4992529,0.0076737 8.9687075,0.0710379 9.9095993,0.1980339 10.660007,0.42082656 11.472109,0.81428608 12.278147,1.2048081 12.92108,1.653682 13.548236,2.2637684 c 0.697339,0.6783577 1.185766,1.350316 1.61408,2.2205853 0.410028,0.8331146 0.634117,1.5751902 0.765807,2.5359887 0.06685,0.4877257 0.06685,1.4715895 0,1.9593152 -0.127122,0.9274706 -0.350941,1.6832734 -0.731652,2.4706824 -0.397248,0.821611 -0.852464,1.472541 -1.482119,2.119336 -0.657719,0.675622 -1.326983,1.162215 -2.176937,1.582755 -0.833431,0.412365 -1.6236
 167,0.651431 -2.5562068,0.773365 -0.3279267,0.04288 -1.1802713,0.07153 -1.4818885,0.04982 z m 1.3704251,-1.521208 c 2.3480742,-0.323949 4.3269062,-1.876342 5.1889572,-4.070736 0.195317,-0.4971898 0.322038,-0.9843644 0.399684,-1.5365784 0.05336,-0.3795256 0.05336,-1.3146636 0,-1.6941892 C 14.297659,6.009824 13.872334,4.971535 13.20027,4.0816327 12.253712,2.8282634 10.902251,1.9647631 9.3695436,1.6340349 8.8912239,1.5308228 8.6174502,1.5042248 8.0217687,1.5030943 7.4346266,1.50198 7.205573,1.5214905 6.7337752,1.6128041 4.3802227,2.0683199 2.4291291,3.8488897 1.754131,6.1572321 1.5891263,6.721511 1.517708,7.1814095 1.4983891,7.8040816 1.4520964,9.296157 1.9003863,10.722822 2.7856189,11.90064 c 0.9704233,1.291166 2.380098,2.178047 3.9517961,2.48623 0.2361541,0.04631 0.4130594,0.07057 0.7945578,0.108982 0.1927645,0.01941 1.1005307,-0.0087 1.337772,-0.04144 z"
+     id="path171" />
+  <path
+     style="fill:#ffffff;stroke-width:0.0217687"
+     d="M 7.7118248,11.941402 C 7.4512974,11.858118 7.220616,11.654074 7.1006254,11.40078 c -0.065428,-0.138114 -0.069333,-0.160459 -0.069333,-0.396698 0,-0.244195 0.002,-0.25452 0.081302,-0.420611 0.3614811,-0.7570487 1.4133305,-0.7570487 1.7748116,0 0.079306,0.166091 0.081302,0.176416 0.081302,0.420611 0,0.236506 -0.00385,0.25847 -0.069692,0.397464 -0.078421,0.165554 -0.2526893,0.362806 -0.3933678,0.445249 -0.23099,0.135369 -0.5480917,0.173161 -0.7938234,0.09461 z"
+     id="path173" />
+  <path
+     style="fill:#ffffff;stroke-width:0.0217687"
+     d="M 7.7893699,8.9495595 C 7.5879097,8.8836778 7.4260958,8.7362527 7.3325199,8.5333333 7.2838245,8.4277375 7.2721956,8.3712514 7.2718047,8.2384163 7.2711218,8.0063767 7.3496573,7.8533701 7.6113976,7.5768054 7.8120712,7.364766 8.0121985,7.2174045 8.5275409,6.9022145 8.7626808,6.7583996 8.9241062,6.6122318 8.9705493,6.5010778 9.0216242,6.3788386 9.0107429,6.0944374 8.9500245,5.9646259 8.8140763,5.6739773 8.4424893,5.4972422 7.9673469,5.4972422 7.470926,5.4972422 7.1708884,5.6497007 6.949601,6.0143907 6.8080869,6.2476114 6.7148448,6.3432007 6.5500735,6.4239756 6.4406494,6.4776181 6.3961418,6.4867984 6.247619,6.4863613 6.0336827,6.4857321 5.8719749,6.4193406 5.7312579,6.2743639 5.5874518,6.1262045 5.5313848,5.9963717 5.5222959,5.7904762 c -0.00986,-0.2233914 0.0331,-0.3420804 0.2335917,-0.6453389 0.4855836,-0.7344821 1.264948,-1.1289757 2.229949,-1.1287412 1.1725236,2.848e-4 2.1268494,0.6481989 2.4206964,1.6434678 0.08266,0.2799802 0.09834,0.7361248 0.0357,1.0384127 C 10.364633,7.0
 727212 10.20693,7.3733353 9.937419,7.6605632 9.7610717,7.8484983 9.5555692,8.0022232 9.1350494,8.2607678 8.8094537,8.4609509 8.7375549,8.5184797 8.5394989,8.7372889 8.404372,8.8865748 8.2410956,8.9623946 8.0338438,8.9720971 c -0.090733,0.00425 -0.190767,-0.00497 -0.2444739,-0.022538 z"
+     id="path175" />
+</svg>
diff --git a/share/static/js/popup-help.js b/share/static/js/popup-help.js
index 2a9b613f85..2d35130110 100644
--- a/share/static/js/popup-help.js
+++ b/share/static/js/popup-help.js
@@ -84,7 +84,8 @@ function helpify($els, item={}, options={}) {
 
 function buildPopupHelpHtml(title, content) {
 	// TODO configurable glyph
-	const icon = '/static/images/question.svg'
+	var icon = '/static/images/question'
+	icon += (RT.Config.WebDefaultStylesheet.match(/-dark$/)) ? '-white.svg' : '.svg'
 	const contentAttr = content ? ' data-content="' + content + '" ' : ''
 	return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="focus" ' + contentAttr + '><img src="' + icon + '" /></a>'
 }

commit b2dcd5b085a0cf813a33651b428d41469d959b10
Author: Steven Burr <steve at bestpractical.com>
Date:   Fri Jun 11 17:22:42 2021 -0400

    Add config setting for $ShowInlineHelp
    
    The (user-overridable) $ShowInlineHelp setting governs whether the
    help icons for inline popup help topics are displayed or not.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 6372e60527..7383eec0fc 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1998,6 +1998,16 @@ our %META;
     SelfServiceRegex => {
         Immutable => 1,
     },
+    ShowInlineHelp => {
+        Section         => 'General',
+        Overridable     => 1,
+        Description     => 'Show Inline Help',
+        Widget          => '/Widgets/Form/Boolean',
+        WidgetArguments => {
+            Description => 'Show inline help?', # loc
+            Hints       => 'Displays icons for help topics' #loc
+        },
+    },
 );
 my %OPTIONS = ();
 my @LOADED_CONFIGS = ();
diff --git a/share/html/Elements/PopupHelp b/share/html/Elements/PopupHelp
index 8d5ea7bef2..874e5d08ff 100644
--- a/share/html/Elements/PopupHelp
+++ b/share/html/Elements/PopupHelp
@@ -15,6 +15,6 @@ if ($key) {
     $has_help = $help_content;
 }
 </%init>
-% if ($has_help) {
+% if (RT->Config->Get('ShowInlineHelp', $session{CurrentUser}) && $has_help) {
 <span data-help="<% $key %>" data-content="<% $help_content %>" data-action="replace" style="display: none;"/>
 % }

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


More information about the rt-commit mailing list