mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Improve rendering of tokenizer tokens in Herald when editing rules
Summary: Fixes T7848. @jasonfsmitty discussed an issue in great detail there and in D14359, and I completely missed it. Specifically: - If you save a "Change status to: Open" rule in Maniphest, and then edit it again, the token shows "Unknown Object (???)" instead of the correct token. - That's because loadHandles() has no idea what to do with the value "open", since it's not a real PHID. The way we render tokenizer tokens in Herald is quite hacky right now. Fortunately, I wrote a //slightly// better way for EditEngine yesterday or the day before. Use the slightly better way to fix the issue with D14359. This could still be better than it is, but the badness is mostly hidden now and can be cleaned up later without impacting anything. Test Plan: Edited a Herald rule with projects and status changes, saw proper tokens. Reviewers: chad Reviewed By: chad Subscribers: jasonfsmitty Maniphest Tasks: T7848 Differential Revision: https://secure.phabricator.com/D14682
This commit is contained in:
parent
92175488e9
commit
82be07315c
4 changed files with 23 additions and 32 deletions
|
@ -399,7 +399,7 @@ return array(
|
||||||
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
|
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
|
||||||
'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58',
|
'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58',
|
||||||
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
|
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
|
||||||
'rsrc/js/application/herald/HeraldRuleEditor.js' => '91a6031b',
|
'rsrc/js/application/herald/HeraldRuleEditor.js' => '5bd8f385',
|
||||||
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
|
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
|
||||||
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
|
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
|
||||||
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '782ab6e7',
|
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '782ab6e7',
|
||||||
|
@ -554,7 +554,7 @@ return array(
|
||||||
'global-drag-and-drop-css' => '697324ad',
|
'global-drag-and-drop-css' => '697324ad',
|
||||||
'harbormaster-css' => 'b0758ca5',
|
'harbormaster-css' => 'b0758ca5',
|
||||||
'herald-css' => '826075fa',
|
'herald-css' => '826075fa',
|
||||||
'herald-rule-editor' => '91a6031b',
|
'herald-rule-editor' => '5bd8f385',
|
||||||
'herald-test-css' => 'a52e323e',
|
'herald-test-css' => 'a52e323e',
|
||||||
'inline-comment-summary-css' => '51efda3a',
|
'inline-comment-summary-css' => '51efda3a',
|
||||||
'javelin-aphlict' => '5359e785',
|
'javelin-aphlict' => '5359e785',
|
||||||
|
@ -1225,6 +1225,15 @@ return array(
|
||||||
'javelin-uri',
|
'javelin-uri',
|
||||||
'javelin-routable',
|
'javelin-routable',
|
||||||
),
|
),
|
||||||
|
'5bd8f385' => array(
|
||||||
|
'multirow-row-manager',
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-stratcom',
|
||||||
|
'javelin-json',
|
||||||
|
'phabricator-prefab',
|
||||||
|
),
|
||||||
'5c54cbf3' => array(
|
'5c54cbf3' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
@ -1533,15 +1542,6 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'javelin-request',
|
'javelin-request',
|
||||||
),
|
),
|
||||||
'91a6031b' => array(
|
|
||||||
'multirow-row-manager',
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-stratcom',
|
|
||||||
'javelin-json',
|
|
||||||
'phabricator-prefab',
|
|
||||||
),
|
|
||||||
'93d0c9e3' => array(
|
'93d0c9e3' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
|
|
@ -95,9 +95,13 @@ abstract class HeraldAction extends Phobject {
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case self::STANDARD_PHID_LIST:
|
case self::STANDARD_PHID_LIST:
|
||||||
$handles = $viewer->loadHandles($target);
|
$datasource = $this->getDatasource();
|
||||||
$handles = iterator_to_array($handles);
|
|
||||||
return mpull($handles, 'getName', 'getPHID');
|
if (!$datasource) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $datasource->getWireTokens($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $target;
|
return $target;
|
||||||
|
|
|
@ -80,24 +80,10 @@ final class HeraldTokenizerFieldValue
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$value = (array)$value;
|
$value = (array)$value;
|
||||||
|
|
||||||
// TODO: This should eventually render properly through the datasource
|
$datasource = $this->getDatasource()
|
||||||
// to get icons and colors.
|
->setViewer($viewer);
|
||||||
|
|
||||||
if ($this->valueMap !== null) {
|
return $datasource->getWireTokens($value);
|
||||||
$map = array();
|
|
||||||
foreach ($value as $v) {
|
|
||||||
$map[$v] = idx($this->valueMap, $v, $v);
|
|
||||||
}
|
|
||||||
return $map;
|
|
||||||
}
|
|
||||||
|
|
||||||
$handles = $viewer->loadHandles($value);
|
|
||||||
|
|
||||||
$map = array();
|
|
||||||
foreach ($value as $v) {
|
|
||||||
$map[$v] = $handles[$v]->getName();
|
|
||||||
}
|
|
||||||
return $map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,8 @@ JX.install('HeraldRuleEditor', {
|
||||||
},
|
},
|
||||||
function(map) {
|
function(map) {
|
||||||
for (var k in map) {
|
for (var k in map) {
|
||||||
build.tokenizer.addToken(k, map[k]);
|
var v = JX.Prefab.transformDatasourceResults(map[k]);
|
||||||
|
build.tokenizer.addToken(k, v);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue