From: Robin Appelman Date: Thu, 2 Apr 2020 15:22:42 +0000 (+0200) Subject: allow setting tooltips for external storage config options X-Git-Tag: v19.0.0beta2~21^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=857957b45e563b9ac789adec0374d486c71a96ed;p=nextcloud-server.git allow setting tooltips for external storage config options allows explaining non-obvious config options a bit more Signed-off-by: Robin Appelman --- diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index c7e06506340..93a27d5f75d 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -999,6 +999,11 @@ MountConfigListView.prototype = _.extend({ } else { newElement = $(''); } + + if (placeholder.tooltip) { + newElement.attr('title', placeholder.tooltip); + } + highlightInput(newElement); $td.append(newElement); return newElement; diff --git a/apps/files_external/lib/Lib/DefinitionParameter.php b/apps/files_external/lib/Lib/DefinitionParameter.php index 7250a77e6c1..2e1ce7fb1dd 100644 --- a/apps/files_external/lib/Lib/DefinitionParameter.php +++ b/apps/files_external/lib/Lib/DefinitionParameter.php @@ -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(), ]; } diff --git a/apps/files_external/tests/DefinitionParameterTest.php b/apps/files_external/tests/DefinitionParameterTest.php index 4482bdbae25..862d3deb557 100644 --- a/apps/files_external/tests/DefinitionParameterTest.php +++ b/apps/files_external/tests/DefinitionParameterTest.php @@ -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()); }