mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-31 06:28:13 +02: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;
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
|
case 'enum':
|
||||||
$set_value = (string)$value;
|
$set_value = (string)$value;
|
||||||
break;
|
break;
|
||||||
case 'list<string>':
|
case 'list<string>':
|
||||||
|
@ -328,6 +329,7 @@ final class PhabricatorConfigEditController
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'string':
|
case 'string':
|
||||||
|
case 'enum':
|
||||||
return $value;
|
return $value;
|
||||||
case 'bool':
|
case 'bool':
|
||||||
return $value ? 'true' : 'false';
|
return $value ? 'true' : 'false';
|
||||||
|
@ -360,6 +362,15 @@ final class PhabricatorConfigEditController
|
||||||
'false' => idx($option->getBoolOptions(), 1),
|
'false' => idx($option->getBoolOptions(), 1),
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
case 'enum':
|
||||||
|
$options = array_mergev(
|
||||||
|
array(
|
||||||
|
array('' => pht('(Use Default)')),
|
||||||
|
$option->getEnumOptions(),
|
||||||
|
));
|
||||||
|
$control = id(new AphrontFormSelectControl())
|
||||||
|
->setOptions($options);
|
||||||
|
break;
|
||||||
case 'class':
|
case 'class':
|
||||||
$symbols = id(new PhutilSymbolLoader())
|
$symbols = id(new PhutilSymbolLoader())
|
||||||
->setType('class')
|
->setType('class')
|
||||||
|
|
|
@ -53,6 +53,7 @@ final class PhabricatorConfigManagementSetWorkflow
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'class':
|
case 'class':
|
||||||
|
case 'enum':
|
||||||
$value = (string)$value;
|
$value = (string)$value;
|
||||||
break;
|
break;
|
||||||
case 'int':
|
case 'int':
|
||||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorConfigOption
|
||||||
private $description;
|
private $description;
|
||||||
private $type;
|
private $type;
|
||||||
private $boolOptions;
|
private $boolOptions;
|
||||||
|
private $enumOptions;
|
||||||
private $group;
|
private $group;
|
||||||
private $examples;
|
private $examples;
|
||||||
private $locked;
|
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) {
|
public function setKey($key) {
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -317,10 +317,20 @@ EODOC
|
||||||
->setSummary(
|
->setSummary(
|
||||||
pht('Allow Phabricator to use a single mailbox for all replies.'))
|
pht('Allow Phabricator to use a single mailbox for all replies.'))
|
||||||
->setDescription($single_description),
|
->setDescription($single_description),
|
||||||
// TODO: 'enum'
|
$this->newOption('metamta.user-address-format', 'enum', 'full')
|
||||||
$this->newOption('metamta.user-address-format', 'string', 'full')
|
->setEnumOptions(
|
||||||
|
array(
|
||||||
|
'short' => 'short',
|
||||||
|
'real' => 'real',
|
||||||
|
'full' => 'full',
|
||||||
|
))
|
||||||
->setSummary(pht('Control how Phabricator renders user names in mail.'))
|
->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…
Add table
Reference in a new issue