]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow setting tooltips for external storage config options 20276/head
authorRobin Appelman <robin@icewind.nl>
Thu, 2 Apr 2020 15:22:42 +0000 (17:22 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 3 Apr 2020 13:44:53 +0000 (15:44 +0200)
allows explaining non-obvious config options a bit more

Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/js/settings.js
apps/files_external/lib/Lib/DefinitionParameter.php
apps/files_external/tests/DefinitionParameterTest.php

index c7e065063407e66bed175dca4182ef0961a55aac..93a27d5f75dd0752e4acdaea31d6f2325cf10a70 100644 (file)
@@ -999,6 +999,11 @@ MountConfigListView.prototype = _.extend({
                } else {
                        newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
                }
+
+               if (placeholder.tooltip) {
+                       newElement.attr('title', placeholder.tooltip);
+               }
+
                highlightInput(newElement);
                $td.append(newElement);
                return newElement;
index 7250a77e6c1df07417544d2c7acb5b3620961ead..2e1ce7fb1dd02185ad39151d77bc2cac4c495c31 100644 (file)
@@ -48,6 +48,9 @@ class DefinitionParameter implements \JsonSerializable {
        /** @var string human-readable parameter text */
        private $text;
 
+       /** @var string human-readable parameter tooltip */
+       private $tooltip = '';
+
        /** @var int value type, see self::VALUE_* constants */
        private $type = self::VALUE_TEXT;
 
@@ -146,6 +149,22 @@ class DefinitionParameter implements \JsonSerializable {
                return (bool)($this->flags & $flag);
        }
 
+       /**
+        * @return string
+        */
+       public function getTooltip(): string {
+               return $this->tooltip;
+       }
+
+       /**
+        * @param string $tooltip
+        * @return self
+        */
+       public function setTooltip(string $tooltip) {
+               $this->tooltip = $tooltip;
+               return $this;
+       }
+
        /**
         * Serialize into JSON for client-side JS
         *
@@ -155,7 +174,8 @@ class DefinitionParameter implements \JsonSerializable {
                return [
                        'value' => $this->getText(),
                        'flags' => $this->getFlags(),
-                       'type' => $this->getType()
+                       'type' => $this->getType(),
+                       'tooltip' => $this->getTooltip(),
                ];
        }
 
index 4482bdbae259d7aa1973a0200e7aef2579623b35..862d3deb55798646b7f0c302af6f4eece7af3593 100644 (file)
@@ -33,14 +33,16 @@ class DefinitionParameterTest extends \Test\TestCase {
                $this->assertEquals([
                        'value' => 'bar',
                        'flags' => 0,
-                       'type' => 0
+                       'type' => 0,
+                       'tooltip' => '',
                ], $param->jsonSerialize());
 
                $param->setType(Param::VALUE_BOOLEAN);
                $this->assertEquals([
                        'value' => 'bar',
                        'flags' => 0,
-                       'type' => Param::VALUE_BOOLEAN
+                       'type' => Param::VALUE_BOOLEAN,
+                       'tooltip' => '',
                ], $param->jsonSerialize());
 
                $param->setType(Param::VALUE_PASSWORD);
@@ -48,7 +50,8 @@ class DefinitionParameterTest extends \Test\TestCase {
                $this->assertEquals([
                        'value' => 'bar',
                        'flags' => Param::FLAG_OPTIONAL,
-                       'type' => Param::VALUE_PASSWORD
+                       'type' => Param::VALUE_PASSWORD,
+                       'tooltip' => '',
                ], $param->jsonSerialize());
 
                $param->setType(Param::VALUE_HIDDEN);
@@ -56,7 +59,8 @@ class DefinitionParameterTest extends \Test\TestCase {
                $this->assertEquals([
                        'value' => 'bar',
                        'flags' => Param::FLAG_NONE,
-                       'type' => Param::VALUE_HIDDEN
+                       'type' => Param::VALUE_HIDDEN,
+                       'tooltip' => '',
                ], $param->jsonSerialize());
        }