1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Show add reviewer typehead when user selects resign as a reviewer.

Summary:
1. Show add reviewer typehead when user selects resign as a reviewer.
2. Change the label for add reviewers typehead when user selects resign as a reviewer.

Test Plan:
1. Add yourself as a reviewer in a diff.
2. Select "Resign as Reviewer" in comment editor.
Add reviewer typehead should display, with label "Suggest Another Reviewer".
Add reviewer typehead is also displayed after user refreshed the page with "Resign as Reviewer"
selected.

Reviewers: wez, epriestley

Reviewed By: epriestley

CC: aran, epriestley, akramer, person

Differential Revision: https://secure.phabricator.com/D6340
This commit is contained in:
Bian Jiang 2013-07-10 11:05:53 -07:00
parent fe76729af5
commit c977168797
4 changed files with 29 additions and 4 deletions

View file

@ -74,7 +74,8 @@ final class DifferentialAction {
public static function allowReviewers($action) {
if ($action == DifferentialAction::ACTION_ADDREVIEWERS ||
$action == DifferentialAction::ACTION_REQUEST) {
$action == DifferentialAction::ACTION_REQUEST ||
$action == DifferentialAction::ACTION_RESIGN) {
return true;
}
return false;

View file

@ -139,6 +139,13 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
"You can not resign from this revision because you are not ".
"a reviewer.");
}
list($added_reviewers, $ignored) = $this->alterReviewers();
if ($added_reviewers) {
$key = DifferentialComment::METADATA_ADDED_REVIEWERS;
$metadata[$key] = $added_reviewers;
}
DifferentialRevisionEditor::alterReviewers(
$revision,
$reviewer_phids,

View file

@ -61,6 +61,10 @@ final class DifferentialAddCommentView extends AphrontView {
$enable_reviewers = DifferentialAction::allowReviewers($action);
$enable_ccs = ($action == DifferentialAction::ACTION_ADDCCS);
$add_reviewers_labels = array(
'add_reviewers' => pht('Add Reviewers'),
'resign' => pht('Suggest Reviewers'),
);
$form = new AphrontFormView();
$form
@ -78,7 +82,8 @@ final class DifferentialAddCommentView extends AphrontView {
->setOptions($this->actions))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Add Reviewers'))
->setLabel($enable_reviewers ? $add_reviewers_labels[$action] :
$add_reviewers_labels['add_reviewers'])
->setName('reviewers')
->setControlID('add-reviewers')
->setControlStyle($enable_reviewers ? null : 'display: none')
@ -108,11 +113,16 @@ final class DifferentialAddCommentView extends AphrontView {
array(
'dynamic' => array(
'add-reviewers-tokenizer' => array(
'actions' => array('request_review' => 1, 'add_reviewers' => 1),
'actions' => array(
'request_review' => 1,
'add_reviewers' => 1,
'resign' => 1,
),
'src' => '/typeahead/common/users/',
'value' => $this->reviewers,
'row' => 'add-reviewers',
'ondemand' => PhabricatorEnv::getEnvConfig('tokenizer.ondemand'),
'labels' => $add_reviewers_labels,
'placeholder' => pht('Type a user name...'),
),
'add-ccs-tokenizer' => array(

View file

@ -18,7 +18,8 @@ JX.behavior('differential-add-reviewers-and-ccs', function(config) {
dynamic[k] = {
row : JX.$(props.row),
tokenizer : tokenizer,
actions : props.actions
actions : props.actions,
labels: props.labels
};
}
@ -31,6 +32,12 @@ JX.behavior('differential-add-reviewers-and-ccs', function(config) {
for (var k in dynamic) {
if (dynamic[k].actions[v]) {
JX.DOM.show(dynamic[k].row);
if (dynamic[k].labels) {
var label_node = JX.DOM.find(dynamic[k].row, 'label');
if (label_node) {
JX.DOM.setContent(label_node, dynamic[k].labels[v]);
}
}
dynamic[k].tokenizer.refresh();
} else {
JX.DOM.hide(dynamic[k].row);