Page MenuHomePhabricator

D19651.id46974.diff
No OneTemporary

D19651.id46974.diff

diff --git a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php b/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
--- a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
+++ b/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
@@ -94,15 +94,6 @@
return idx($this->spec, 'closed');
}
- public static function getStatusNameMap() {
- $map = self::getMap();
- return ipull($map, 'name', 'legacy');
- }
-
- public static function getStatusName($code) {
- return idx(self::getStatusNameMap(), $code, pht('Unknown'));
- }
-
public static function getOpenStatusConstants() {
$constants = array();
foreach (self::getMap() as $map) {
@@ -113,16 +104,22 @@
return $constants;
}
- public static function getStatusColor($code) {
+ public static function newOptions() {
$map = self::getMap();
- $map = ipull($map, 'color', 'legacy');
- return idx($map, $code);
+ return ipull($map, 'name');
}
- public static function getStatusIcon($code) {
+ public static function newDeprecatedOptions() {
$map = self::getMap();
- $map = ipull($map, 'icon', 'legacy');
- return idx($map, $code);
+
+ $results = array();
+ foreach ($map as $key => $spec) {
+ if (isset($spec['legacy'])) {
+ $results[$spec['legacy']] = $key;
+ }
+ }
+
+ return $results;
}
private static function getMap() {
diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php
--- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php
+++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php
@@ -92,7 +92,9 @@
->setLabel(pht('Audit Status'))
->setKey('statuses')
->setAliases(array('status'))
- ->setOptions(PhabricatorAuditCommitStatusConstants::getStatusNameMap())
+ ->setOptions(PhabricatorAuditCommitStatusConstants::newOptions())
+ ->setDeprecatedOptions(
+ PhabricatorAuditCommitStatusConstants::newDeprecatedOptions())
->setDescription(pht('Find commits with given audit statuses.')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Repositories'))
diff --git a/src/applications/conduit/data/ConduitConstantDescription.php b/src/applications/conduit/data/ConduitConstantDescription.php
--- a/src/applications/conduit/data/ConduitConstantDescription.php
+++ b/src/applications/conduit/data/ConduitConstantDescription.php
@@ -4,6 +4,7 @@
private $key;
private $value;
+ private $isDeprecated;
public function setKey($key) {
$this->key = $key;
@@ -23,4 +24,13 @@
return $this->value;
}
+ public function setIsDeprecated($is_deprecated) {
+ $this->isDeprecated = $is_deprecated;
+ return $this;
+ }
+
+ public function getIsDeprecated() {
+ return $this->isDeprecated;
+ }
+
}
diff --git a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
--- a/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
+++ b/src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
@@ -230,9 +230,20 @@
$constants_rows = array();
foreach ($constants as $constant) {
+ if ($constant->getIsDeprecated()) {
+ $icon = id(new PHUIIconView())
+ ->setIcon('fa-exclamation-triangle', 'red');
+ } else {
+ $icon = null;
+ }
+
$constants_rows[] = array(
$constant->getKey(),
- $constant->getValue(),
+ array(
+ $icon,
+ ' ',
+ $constant->getValue(),
+ ),
);
}
@@ -244,7 +255,7 @@
))
->setColumnClasses(
array(
- 'pre',
+ 'mono',
'wide',
));
diff --git a/src/applications/search/field/PhabricatorSearchCheckboxesField.php b/src/applications/search/field/PhabricatorSearchCheckboxesField.php
--- a/src/applications/search/field/PhabricatorSearchCheckboxesField.php
+++ b/src/applications/search/field/PhabricatorSearchCheckboxesField.php
@@ -4,6 +4,7 @@
extends PhabricatorSearchField {
private $options;
+ private $deprecatedOptions = array();
public function setOptions(array $options) {
$this->options = $options;
@@ -14,6 +15,15 @@
return $this->options;
}
+ public function setDeprecatedOptions(array $deprecated_options) {
+ $this->deprecatedOptions = $deprecated_options;
+ return $this;
+ }
+
+ public function getDeprecatedOptions() {
+ return $this->deprecatedOptions;
+ }
+
protected function getDefaultValue() {
return array();
}
@@ -23,11 +33,12 @@
return array();
}
- return $value;
+ return $this->getCanonicalValue($value);
}
protected function getValueFromRequest(AphrontRequest $request, $key) {
- return $this->getListFromRequest($request, $key);
+ $value = $this->getListFromRequest($request, $key);
+ return $this->getCanonicalValue($value);
}
protected function newControl() {
@@ -58,7 +69,29 @@
->setValue($option);
}
+ foreach ($this->getDeprecatedOptions() as $key => $value) {
+ $list[] = id(new ConduitConstantDescription())
+ ->setKey($key)
+ ->setIsDeprecated(true)
+ ->setValue(pht('Deprecated alias for "%s".', $value));
+ }
+
return $list;
}
+ private function getCanonicalValue(array $values) {
+ // Always map the current normal options to themselves.
+ $normal_options = array_fuse(array_keys($this->getOptions()));
+
+ // Map deprecated values to their new values.
+ $deprecated_options = $this->getDeprecatedOptions();
+
+ $map = $normal_options + $deprecated_options;
+ foreach ($values as $key => $value) {
+ $values[$key] = idx($map, $value, $value);
+ }
+
+ return $values;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 5, 7:28 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7224957
Default Alt Text
D19651.id46974.diff (5 KB)

Event Timeline