Merge pull request #20276 from nextcloud/files-external-param-tooltop

allow setting tooltips for external storage config options
This commit is contained in:
Roeland Jago Douma 2020-04-06 16:42:39 +02:00 committed by GitHub
commit 1d62b9786f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 5 deletions

View 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;

View 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(),
];
}

View 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());
}