mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Add enum option type.
Summary: Might not be the cleanest way to do this, but seems to work. Test Plan: - Saved an option which used the new enum type. - Changed it. - Saw it show up on the list view. Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4572
This commit is contained in:
parent
4f3fafd2e9
commit
bad95c15ce
4 changed files with 40 additions and 3 deletions
|
@ -253,6 +253,7 @@ final class PhabricatorConfigEditController
|
|||
}
|
||||
break;
|
||||
case 'string':
|
||||
case 'enum':
|
||||
$set_value = (string)$value;
|
||||
break;
|
||||
case 'list<string>':
|
||||
|
@ -328,6 +329,7 @@ final class PhabricatorConfigEditController
|
|||
switch ($type) {
|
||||
case 'int':
|
||||
case 'string':
|
||||
case 'enum':
|
||||
return $value;
|
||||
case 'bool':
|
||||
return $value ? 'true' : 'false';
|
||||
|
@ -360,6 +362,15 @@ final class PhabricatorConfigEditController
|
|||
'false' => idx($option->getBoolOptions(), 1),
|
||||
));
|
||||
break;
|
||||
case 'enum':
|
||||
$options = array_mergev(
|
||||
array(
|
||||
array('' => pht('(Use Default)')),
|
||||
$option->getEnumOptions(),
|
||||
));
|
||||
$control = id(new AphrontFormSelectControl())
|
||||
->setOptions($options);
|
||||
break;
|
||||
case 'class':
|
||||
$symbols = id(new PhutilSymbolLoader())
|
||||
->setType('class')
|
||||
|
|
|
@ -53,6 +53,7 @@ final class PhabricatorConfigManagementSetWorkflow
|
|||
switch ($type) {
|
||||
case 'string':
|
||||
case 'class':
|
||||
case 'enum':
|
||||
$value = (string)$value;
|
||||
break;
|
||||
case 'int':
|
||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorConfigOption
|
|||
private $description;
|
||||
private $type;
|
||||
private $boolOptions;
|
||||
private $enumOptions;
|
||||
private $group;
|
||||
private $examples;
|
||||
private $locked;
|
||||
|
@ -115,6 +116,20 @@ final class PhabricatorConfigOption
|
|||
);
|
||||
}
|
||||
|
||||
public function setEnumOptions(array $options) {
|
||||
$this->enumOptions = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEnumOptions() {
|
||||
if ($this->enumOptions) {
|
||||
return $this->enumOptions;
|
||||
}
|
||||
|
||||
throw new Exception(
|
||||
'Call setEnumOptions() before trying to access them!');
|
||||
}
|
||||
|
||||
public function setKey($key) {
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
|
|
|
@ -317,10 +317,20 @@ EODOC
|
|||
->setSummary(
|
||||
pht('Allow Phabricator to use a single mailbox for all replies.'))
|
||||
->setDescription($single_description),
|
||||
// TODO: 'enum'
|
||||
$this->newOption('metamta.user-address-format', 'string', 'full')
|
||||
$this->newOption('metamta.user-address-format', 'enum', 'full')
|
||||
->setEnumOptions(
|
||||
array(
|
||||
'short' => 'short',
|
||||
'real' => 'real',
|
||||
'full' => 'full',
|
||||
))
|
||||
->setSummary(pht('Control how Phabricator renders user names in mail.'))
|
||||
->setDescription($address_description),
|
||||
->setDescription($address_description)
|
||||
->addExample('gwashington <gwashington@example.com>', 'short')
|
||||
->addExample('George Washington <gwashington@example.com>', 'real')
|
||||
->addExample(
|
||||
'gwashington (George Washington) <gwashington@example.com>',
|
||||
'full'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue