From 18c05154400015e03e8a2816bc062c3b5890e83a Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 4 Feb 2011 22:45:42 -0800 Subject: [PATCH] Add reviewers workflow fixes. --- src/__celerity_resource_map__.php | 64 +++++++++++-------- .../comment/DifferentialCommentEditor.php | 12 ++-- .../differential/editor/comment/__init__.php | 1 + .../addcomment/DifferentialAddCommentView.php | 17 +++++ .../form/control/base/AphrontFormControl.php | 40 +++++++++--- .../tokenizer/AphrontFormTokenizerControl.php | 24 +++++-- .../differential/behavior-add-reviewers.js | 31 +++++++++ 7 files changed, 142 insertions(+), 47 deletions(-) create mode 100644 webroot/rsrc/js/application/differential/behavior-add-reviewers.js diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 190cd9ad09..4ea5cbaa1c 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -136,7 +136,7 @@ celerity_register_resource_map(array( ), 'differential-revision-comment-css' => array( - 'uri' => '/res/274eb3f1/rsrc/css/application/differential/revision-comment.css', + 'uri' => '/res/678be39a/rsrc/css/application/differential/revision-comment.css', 'type' => 'css', 'requires' => array( @@ -181,7 +181,7 @@ celerity_register_resource_map(array( ), 'phabricator-core-buttons-css' => array( - 'uri' => '/res/6e348ba4/rsrc/css/core/buttons.css', + 'uri' => '/res/fe74ba44/rsrc/css/core/buttons.css', 'type' => 'css', 'requires' => array( @@ -243,6 +243,16 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/core/behavior-tokenizer.js', ), + 'javelin-behavior-differential-add-reviewers' => + array( + 'uri' => '/res/330154e4/rsrc/js/application/differential/behavior-add-reviewers.js', + 'type' => 'js', + 'requires' => + array( + 0 => 'javelin-lib-dev', + ), + 'disk' => '/rsrc/js/application/differential/behavior-add-reviewers.js', + ), 'javelin-behavior-differential-feedback-preview' => array( 'uri' => '/res/8695d8b8/rsrc/js/application/differential/behavior-comment-preview.js', @@ -368,7 +378,7 @@ celerity_register_resource_map(array( ), array ( 'packages' => array ( - '85861df3' => + '20cc4391' => array ( 'name' => 'core.pkg.css', 'symbols' => @@ -387,10 +397,10 @@ celerity_register_resource_map(array( 11 => 'phabricator-remarkup-css', 12 => 'syntax-highlighting-css', ), - 'uri' => '/res/pkg/85861df3/core.pkg.css', + 'uri' => '/res/pkg/20cc4391/core.pkg.css', 'type' => 'css', ), - '86498b42' => + '33e57258' => array ( 'name' => 'differential.pkg.css', 'symbols' => @@ -404,7 +414,7 @@ celerity_register_resource_map(array( 6 => 'differential-revision-add-comment-css', 7 => 'differential-revision-comment-list-css', ), - 'uri' => '/res/pkg/86498b42/differential.pkg.css', + 'uri' => '/res/pkg/33e57258/differential.pkg.css', 'type' => 'css', ), '30d594cf' => @@ -424,27 +434,27 @@ celerity_register_resource_map(array( ), 'reverse' => array ( - 'phabricator-core-css' => '85861df3', - 'phabricator-core-buttons-css' => '85861df3', - 'phabricator-standard-page-view' => '85861df3', - 'aphront-dialog-view-css' => '85861df3', - 'aphront-form-view-css' => '85861df3', - 'aphront-panel-view-css' => '85861df3', - 'aphront-side-nav-view-css' => '85861df3', - 'aphront-table-view-css' => '85861df3', - 'aphront-tokenizer-control-css' => '85861df3', - 'aphront-typeahead-control-css' => '85861df3', - 'phabricator-directory-css' => '85861df3', - 'phabricator-remarkup-css' => '85861df3', - 'syntax-highlighting-css' => '85861df3', - 'differential-core-view-css' => '86498b42', - 'differential-changeset-view-css' => '86498b42', - 'differential-revision-detail-css' => '86498b42', - 'differential-revision-history-css' => '86498b42', - 'differential-table-of-contents-css' => '86498b42', - 'differential-revision-comment-css' => '86498b42', - 'differential-revision-add-comment-css' => '86498b42', - 'differential-revision-comment-list-css' => '86498b42', + 'phabricator-core-css' => '20cc4391', + 'phabricator-core-buttons-css' => '20cc4391', + 'phabricator-standard-page-view' => '20cc4391', + 'aphront-dialog-view-css' => '20cc4391', + 'aphront-form-view-css' => '20cc4391', + 'aphront-panel-view-css' => '20cc4391', + 'aphront-side-nav-view-css' => '20cc4391', + 'aphront-table-view-css' => '20cc4391', + 'aphront-tokenizer-control-css' => '20cc4391', + 'aphront-typeahead-control-css' => '20cc4391', + 'phabricator-directory-css' => '20cc4391', + 'phabricator-remarkup-css' => '20cc4391', + 'syntax-highlighting-css' => '20cc4391', + 'differential-core-view-css' => '33e57258', + 'differential-changeset-view-css' => '33e57258', + 'differential-revision-detail-css' => '33e57258', + 'differential-revision-history-css' => '33e57258', + 'differential-table-of-contents-css' => '33e57258', + 'differential-revision-comment-css' => '33e57258', + 'differential-revision-add-comment-css' => '33e57258', + 'differential-revision-comment-list-css' => '33e57258', 'javelin-behavior-differential-feedback-preview' => '30d594cf', 'javelin-behavior-differential-edit-inline-comments' => '30d594cf', 'javelin-behavior-differential-populate' => '30d594cf', diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index 6a3e22960c..fd2f42eb04 100755 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -134,7 +134,7 @@ class DifferentialCommentEditor { ->save(); if (!isset($reviewer_phids[$actor_phid])) { - DifferentialRevisionEditor::addReviewers( + DifferentialRevisionEditor::alterReviewers( $revision, $reviewer_phids, $rem = array(), @@ -170,7 +170,7 @@ class DifferentialCommentEditor { } if (!isset($reviewer_phids[$actor_phid])) { - DifferentialRevisionEditor::addReviewers( + DifferentialRevisionEditor::alterReviewers( $revision, $reviewer_phids, $rem = array(), @@ -214,16 +214,16 @@ class DifferentialCommentEditor { $added_reviewers = array_unique($added_reviewers); if ($added_reviewers) { - DifferentialRevisionEditor::addReviewers( + DifferentialRevisionEditor::alterReviewers( $revision, $reviewer_phids, $rem = array(), $add = $added_reviewers, $actor_phid); -// TODO -// $unixnames = unixname_multi($added_reviewers); - $usernames = $added_reviewers; + $handles = id(new PhabricatorObjectHandleData($added_reviewers)) + ->loadHandles(); + $usernames = mpull($handles, 'getName'); $this->message = 'Added reviewers: '.implode(', ', $usernames)."\n\n". diff --git a/src/applications/differential/editor/comment/__init__.php b/src/applications/differential/editor/comment/__init__.php index 1d14ca7092..11fbcdc6ba 100644 --- a/src/applications/differential/editor/comment/__init__.php +++ b/src/applications/differential/editor/comment/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/differential/editor/revision' phutil_require_module('phabricator', 'applications/differential/mail/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/view/addcomment/DifferentialAddCommentView.php b/src/applications/differential/view/addcomment/DifferentialAddCommentView.php index a84e27ae51..b7f4a72895 100644 --- a/src/applications/differential/view/addcomment/DifferentialAddCommentView.php +++ b/src/applications/differential/view/addcomment/DifferentialAddCommentView.php @@ -63,6 +63,14 @@ final class DifferentialAddCommentView extends AphrontView { ->setName('action') ->setID('comment-action') ->setOptions($actions)) + ->appendChild( + id(new AphrontFormTokenizerControl()) + ->setLabel('Add Reviewers') + ->setName('reviewers') + ->setControlID('add-reviewers') + ->setControlStyle('display: none') + ->setID('add-reviewers-tokenizer') + ->setDisableBehavior(true)) ->appendChild( id(new AphrontFormTextAreaControl()) ->setName('comment') @@ -72,6 +80,15 @@ final class DifferentialAddCommentView extends AphrontView { id(new AphrontFormSubmitControl()) ->setValue('Comment')); + Javelin::initBehavior( + 'differential-add-reviewers', + array( + 'src' => '/typeahead/common/users/', + 'tokenizer' => 'add-reviewers-tokenizer', + 'select' => 'comment-action', + 'row' => 'add-reviewers', + )); + $rev_id = $revision->getID(); Javelin::initBehavior( diff --git a/src/view/form/control/base/AphrontFormControl.php b/src/view/form/control/base/AphrontFormControl.php index 48c494b2d8..c90054cbde 100755 --- a/src/view/form/control/base/AphrontFormControl.php +++ b/src/view/form/control/base/AphrontFormControl.php @@ -25,6 +25,8 @@ abstract class AphrontFormControl extends AphrontView { private $value; private $disabled; private $id; + private $controlID; + private $controlStyle; public function setID($id) { $this->id = $id; @@ -35,6 +37,24 @@ abstract class AphrontFormControl extends AphrontView { return $this->id; } + public function setControlID($control_id) { + $this->controlID = $control_id; + return $this; + } + + public function getControlID() { + return $this->controlID; + } + + public function setControlStyle($control_style) { + $this->controlStyle = $control_style; + return $this; + } + + public function getControlStyle() { + return $this->controlStyle; + } + public function setLabel($label) { $this->label = $label; return $this; @@ -143,13 +163,17 @@ abstract class AphrontFormControl extends AphrontView { $caption = null; } - return - '
'. - $error. - $label. - $input. - $caption. - '
'. - '
'; + return phutil_render_tag( + 'div', + array( + 'class' => "aphront-form-control {$custom_class}", + 'id' => $this->controlID, + 'style' => $this->controlStyle, + ), + $error. + $label. + $input. + $caption. + '
'); } } diff --git a/src/view/form/control/tokenizer/AphrontFormTokenizerControl.php b/src/view/form/control/tokenizer/AphrontFormTokenizerControl.php index c51e56f44a..bb0e272334 100755 --- a/src/view/form/control/tokenizer/AphrontFormTokenizerControl.php +++ b/src/view/form/control/tokenizer/AphrontFormTokenizerControl.php @@ -19,12 +19,18 @@ class AphrontFormTokenizerControl extends AphrontFormControl { private $datasource; + private $disableBehvaior; public function setDatasource($datasource) { $this->datasource = $datasource; return $this; } + public function setDisableBehavior($disable) { + $this->disableBehavior = $disable; + return $this; + } + protected function getCustomControlClass() { return 'aphront-form-control-tokenizer'; } @@ -53,13 +59,19 @@ class AphrontFormTokenizerControl extends AphrontFormControl { 'type' => 'text', )); - $id = celerity_generate_unique_node_id(); + if ($this->getID()) { + $id = $this->getID(); + } else { + $id = celerity_generate_unique_node_id(); + } - Javelin::initBehavior('aphront-basic-tokenizer', array( - 'id' => $id, - 'src' => $this->datasource, - 'value' => $values, - )); + if (!$this->disableBehavior) { + Javelin::initBehavior('aphront-basic-tokenizer', array( + 'id' => $id, + 'src' => $this->datasource, + 'value' => $values, + )); + } return phutil_render_tag( 'div', diff --git a/webroot/rsrc/js/application/differential/behavior-add-reviewers.js b/webroot/rsrc/js/application/differential/behavior-add-reviewers.js new file mode 100644 index 0000000000..43d245bf6a --- /dev/null +++ b/webroot/rsrc/js/application/differential/behavior-add-reviewers.js @@ -0,0 +1,31 @@ +/** + * @provides javelin-behavior-differential-add-reviewers + * @requires javelin-lib-dev + */ + +JX.behavior('differential-add-reviewers', function(config) { + + var root = JX.$(config.tokenizer); + var datasource = new JX.TypeaheadPreloadedSource(config.src); + + var typeahead = new JX.Typeahead(root); + typeahead.setDatasource(datasource); + + var tokenizer = new JX.Tokenizer(root); + tokenizer.setTypeahead(typeahead); + tokenizer.start(); + + JX.DOM.listen( + JX.$(config.select), + 'change', + null, + function(e) { + if (JX.$(config.select).value == 'add_reviewers') { + JX.DOM.show(JX.$(config.row)); + tokenizer.refresh(); + } else { + JX.DOM.hide(JX.$(config.row)); + } + }); +}); +