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 { } else {
newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />'); newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
} }
if (placeholder.tooltip) {
newElement.attr('title', placeholder.tooltip);
}
highlightInput(newElement); highlightInput(newElement);
$td.append(newElement); $td.append(newElement);
return newElement; return newElement;

View File

@ -48,6 +48,9 @@ class DefinitionParameter implements \JsonSerializable {
/** @var string human-readable parameter text */ /** @var string human-readable parameter text */
private $text; private $text;
/** @var string human-readable parameter tooltip */
private $tooltip = '';
/** @var int value type, see self::VALUE_* constants */ /** @var int value type, see self::VALUE_* constants */
private $type = self::VALUE_TEXT; private $type = self::VALUE_TEXT;
@ -146,6 +149,22 @@ class DefinitionParameter implements \JsonSerializable {
return (bool)($this->flags & $flag); 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 * Serialize into JSON for client-side JS
* *
@ -155,7 +174,8 @@ class DefinitionParameter implements \JsonSerializable {
return [ return [
'value' => $this->getText(), 'value' => $this->getText(),
'flags' => $this->getFlags(), '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([ $this->assertEquals([
'value' => 'bar', 'value' => 'bar',
'flags' => 0, 'flags' => 0,
'type' => 0 'type' => 0,
'tooltip' => '',
], $param->jsonSerialize()); ], $param->jsonSerialize());
$param->setType(Param::VALUE_BOOLEAN); $param->setType(Param::VALUE_BOOLEAN);
$this->assertEquals([ $this->assertEquals([
'value' => 'bar', 'value' => 'bar',
'flags' => 0, 'flags' => 0,
'type' => Param::VALUE_BOOLEAN 'type' => Param::VALUE_BOOLEAN,
'tooltip' => '',
], $param->jsonSerialize()); ], $param->jsonSerialize());
$param->setType(Param::VALUE_PASSWORD); $param->setType(Param::VALUE_PASSWORD);
@ -48,7 +50,8 @@ class DefinitionParameterTest extends \Test\TestCase {
$this->assertEquals([ $this->assertEquals([
'value' => 'bar', 'value' => 'bar',
'flags' => Param::FLAG_OPTIONAL, 'flags' => Param::FLAG_OPTIONAL,
'type' => Param::VALUE_PASSWORD 'type' => Param::VALUE_PASSWORD,
'tooltip' => '',
], $param->jsonSerialize()); ], $param->jsonSerialize());
$param->setType(Param::VALUE_HIDDEN); $param->setType(Param::VALUE_HIDDEN);
@ -56,7 +59,8 @@ class DefinitionParameterTest extends \Test\TestCase {
$this->assertEquals([ $this->assertEquals([
'value' => 'bar', 'value' => 'bar',
'flags' => Param::FLAG_NONE, 'flags' => Param::FLAG_NONE,
'type' => Param::VALUE_HIDDEN 'type' => Param::VALUE_HIDDEN,
'tooltip' => '',
], $param->jsonSerialize()); ], $param->jsonSerialize());
} }