1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02: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:
epriestley 2015-12-05 11:09:05 -08:00
parent 92175488e9
commit 82be07315c
4 changed files with 23 additions and 32 deletions

View file

@ -399,7 +399,7 @@ return array(
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58',
'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/herald-rule-editor.js' => '7ebaeed3',
'rsrc/js/application/maniphest/behavior-batch-editor.js' => '782ab6e7',
@ -554,7 +554,7 @@ return array(
'global-drag-and-drop-css' => '697324ad',
'harbormaster-css' => 'b0758ca5',
'herald-css' => '826075fa',
'herald-rule-editor' => '91a6031b',
'herald-rule-editor' => '5bd8f385',
'herald-test-css' => 'a52e323e',
'inline-comment-summary-css' => '51efda3a',
'javelin-aphlict' => '5359e785',
@ -1225,6 +1225,15 @@ return array(
'javelin-uri',
'javelin-routable',
),
'5bd8f385' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'5c54cbf3' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1533,15 +1542,6 @@ return array(
'javelin-dom',
'javelin-request',
),
'91a6031b' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'93d0c9e3' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -95,9 +95,13 @@ abstract class HeraldAction extends Phobject {
switch ($type) {
case self::STANDARD_PHID_LIST:
$handles = $viewer->loadHandles($target);
$handles = iterator_to_array($handles);
return mpull($handles, 'getName', 'getPHID');
$datasource = $this->getDatasource();
if (!$datasource) {
return array();
}
return $datasource->getWireTokens($target);
}
return $target;

View file

@ -80,24 +80,10 @@ final class HeraldTokenizerFieldValue
$viewer = $this->getViewer();
$value = (array)$value;
// TODO: This should eventually render properly through the datasource
// to get icons and colors.
$datasource = $this->getDatasource()
->setViewer($viewer);
if ($this->valueMap !== null) {
$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;
return $datasource->getWireTokens($value);
}
}

View file

@ -293,7 +293,8 @@ JX.install('HeraldRuleEditor', {
},
function(map) {
for (var k in map) {
build.tokenizer.addToken(k, map[k]);
var v = JX.Prefab.transformDatasourceResults(map[k]);
build.tokenizer.addToken(k, v);
}
}];
},