1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-24 21:48:21 +01:00

Respect token limits for "Assign to" and custom datasource fields in Herald

Summary:
See PHI173. Currently, Herald has an "Assign to" action for tasks, and you can specify custom fields with datasource values (like users or projects) that have a limit (like 1 "Owner", or 12 "Jury Members").

Herald doesn't support these limits right now, so you can write `[ Assign to ][ X, Y, Z ]`. This just means "Assign to X", but make it more clear by actually enforcing the limit in the UI.

Test Plan:
  - Created a "projects" custom field with limit 1.
  - Tried to create actions that 'assign to' or 'set custom field to' more than one thing, got helpfully rebuffed by the UI.
  - Created an "add subscribers" action with more than one value.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18887
This commit is contained in:
epriestley 2018-01-19 14:43:20 -08:00
parent 6a62797056
commit fbfcc37531
5 changed files with 24 additions and 16 deletions

View file

@ -416,7 +416,7 @@ return array(
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
'rsrc/js/application/herald/HeraldRuleEditor.js' => '2dff5579',
'rsrc/js/application/herald/HeraldRuleEditor.js' => 'dca75c0e',
'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec',
'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3',
'rsrc/js/application/maniphest/behavior-batch-selector.js' => 'ad54037e',
@ -580,7 +580,7 @@ return array(
'global-drag-and-drop-css' => 'b556a948',
'harbormaster-css' => 'f491c9f4',
'herald-css' => 'cd8d0134',
'herald-rule-editor' => '2dff5579',
'herald-rule-editor' => 'dca75c0e',
'herald-test-css' => 'a52e323e',
'inline-comment-summary-css' => 'f23d4e8f',
'javelin-aphlict' => 'e1d4b11a',
@ -1106,15 +1106,6 @@ return array(
'javelin-install',
'javelin-event',
),
'2dff5579' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'2ee659ce' => array(
'javelin-install',
),
@ -2030,6 +2021,15 @@ return array(
'javelin-util',
'phabricator-shaped-request',
),
'dca75c0e' => array(
'multirow-row-manager',
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-json',
'phabricator-prefab',
),
'de2e896f' => array(
'javelin-behavior',
'javelin-dom',

View file

@ -58,6 +58,7 @@ final class HeraldTokenizerFieldValue
'datasourceURI' => $datasource->getDatasourceURI(),
'browseURI' => $datasource->getBrowseURI(),
'placeholder' => $datasource->getPlaceholderText(),
'limit' => $datasource->getLimit(),
),
);
}

View file

@ -22,9 +22,8 @@ final class ManiphestTaskAssignOtherHeraldAction
}
protected function getDatasource() {
// TODO: Eventually, it would be nice to get "limit = 1" exported from here
// up to the UI.
return new ManiphestAssigneeDatasource();
return id(new ManiphestAssigneeDatasource())
->setLimit(1);
}
public function renderActionDescription($value) {

View file

@ -94,7 +94,14 @@ abstract class PhabricatorStandardCustomFieldTokenizer
}
public function getHeraldActionDatasource() {
return $this->getDatasource();
$datasource = $this->getDatasource();
$limit = $this->getFieldConfigValue('limit');
if ($limit) {
$datasource->setLimit($limit);
}
return $datasource;
}
private function renderHeraldHandleList($value) {

View file

@ -283,7 +283,8 @@ JX.install('HeraldRuleEditor', {
var tokenizerConfig = {
src: spec.datasourceURI,
placeholder: spec.placeholder,
browseURI: spec.browseURI
browseURI: spec.browseURI,
limit: spec.limit
};
var build = JX.Prefab.newTokenizerFromTemplate(