mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 16:00:59 +01:00
Enable Phabricator admin to change the owner of a herald rule
Summary: Added a typeahead in the edit herald rule page that allows an admin or owner to change the current owner of a rule. If the typeahead is emptied, the current owner will remain owner. Test Plan: Created a test rule. Changed the owner. Deleted the owner in the typahead. Verified expected behavior. Reviewers: jungejason, epriestley Reviewed By: epriestley CC: aran, jungejason, epriestley, xela Differential Revision: https://secure.phabricator.com/D1322
This commit is contained in:
parent
42ddad1bc8
commit
14d16eab17
5 changed files with 49 additions and 13 deletions
|
@ -285,7 +285,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'herald-css' =>
|
'herald-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/5051f3ab/rsrc/css/application/herald/herald.css',
|
'uri' => '/res/ed5556e6/rsrc/css/application/herald/herald.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -294,7 +294,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'herald-rule-editor' =>
|
'herald-rule-editor' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/4d6dff2b/rsrc/js/application/herald/HeraldRuleEditor.js',
|
'uri' => '/res/ec9eea63/rsrc/js/application/herald/HeraldRuleEditor.js',
|
||||||
'type' => 'js',
|
'type' => 'js',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -332,14 +332,13 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
0 =>
|
0 =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/b6096fdd/rsrc/js/javelin/lib/__tests__/URI.js',
|
'uri' => '/res/14c48a9f/rsrc/js/javelin/lib/__tests__/behavior.js',
|
||||||
'type' => 'js',
|
'type' => 'js',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-uri',
|
0 => 'javelin-behavior',
|
||||||
1 => 'javelin-php-serializer',
|
|
||||||
),
|
),
|
||||||
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
|
'disk' => '/rsrc/js/javelin/lib/__tests__/behavior.js',
|
||||||
),
|
),
|
||||||
'javelin-behavior-aphront-basic-tokenizer' =>
|
'javelin-behavior-aphront-basic-tokenizer' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -127,9 +127,18 @@ class HeraldRuleController extends HeraldController {
|
||||||
->setError($e_name)
|
->setError($e_name)
|
||||||
->setValue($rule->getName()))
|
->setValue($rule->getName()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormMarkupControl())
|
||||||
->setLabel('Author')
|
->setLabel('Owner')
|
||||||
->setValue($handles[$rule->getAuthorPHID()]->getName()))
|
->setValue('<div id="author-input"/>'))
|
||||||
|
->appendChild(
|
||||||
|
// Build this explicitly so we can add a sigil to it.
|
||||||
|
javelin_render_tag(
|
||||||
|
'input',
|
||||||
|
array(
|
||||||
|
'type' => 'hidden',
|
||||||
|
'name' => 'author',
|
||||||
|
'sigil' => 'author',
|
||||||
|
)))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormMarkupControl())
|
id(new AphrontFormMarkupControl())
|
||||||
->setValue(
|
->setValue(
|
||||||
|
@ -317,6 +326,11 @@ class HeraldRuleController extends HeraldController {
|
||||||
$actions[] = $obj;
|
$actions[] = $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$author = $request->getStr('author');
|
||||||
|
if ($author) {
|
||||||
|
$rule->setAuthorPHID($author);
|
||||||
|
}
|
||||||
|
|
||||||
$rule->attachConditions($conditions);
|
$rule->attachConditions($conditions);
|
||||||
$rule->attachActions($actions);
|
$rule->attachActions($actions);
|
||||||
|
|
||||||
|
@ -427,6 +441,8 @@ class HeraldRuleController extends HeraldController {
|
||||||
'template' => $this->buildTokenizerTemplates() + array(
|
'template' => $this->buildTokenizerTemplates() + array(
|
||||||
'rules' => $all_rules,
|
'rules' => $all_rules,
|
||||||
),
|
),
|
||||||
|
'author' => array($rule->getAuthorPHID() =>
|
||||||
|
$handles[$rule->getAuthorPHID()]->getName()),
|
||||||
'info' => $config_info,
|
'info' => $config_info,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -456,6 +472,7 @@ class HeraldRuleController extends HeraldController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$phids += array($rule->getAuthorPHID());
|
||||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||||
->loadHandles();
|
->loadHandles();
|
||||||
return $handles;
|
return $handles;
|
||||||
|
|
|
@ -25,7 +25,6 @@ phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
||||||
phutil_require_module('phabricator', 'view/control/tokenizer');
|
phutil_require_module('phabricator', 'view/control/tokenizer');
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
phutil_require_module('phabricator', 'view/form/control/markup');
|
phutil_require_module('phabricator', 'view/form/control/markup');
|
||||||
phutil_require_module('phabricator', 'view/form/control/static');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
phutil_require_module('phabricator', 'view/form/control/text');
|
phutil_require_module('phabricator', 'view/form/control/text');
|
||||||
phutil_require_module('phabricator', 'view/form/error');
|
phutil_require_module('phabricator', 'view/form/error');
|
||||||
|
|
|
@ -29,3 +29,7 @@
|
||||||
.herald-action-table td.target {
|
.herald-action-table td.target {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#herald-rule-edit-form #author-input {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ JX.install('HeraldRuleEditor', {
|
||||||
|
|
||||||
this._renderConditions(conditions);
|
this._renderConditions(conditions);
|
||||||
this._renderActions(actions);
|
this._renderActions(actions);
|
||||||
|
this._renderAuthorInput();
|
||||||
},
|
},
|
||||||
|
|
||||||
members : {
|
members : {
|
||||||
|
@ -115,11 +116,16 @@ JX.install('HeraldRuleEditor', {
|
||||||
for (k in this._config.actions) {
|
for (k in this._config.actions) {
|
||||||
this._config.actions[k][1] = this._getActionTarget(k);
|
this._config.actions[k][1] = this._getActionTarget(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
rule.value = JX.JSON.stringify({
|
rule.value = JX.JSON.stringify({
|
||||||
conditions: this._config.conditions,
|
conditions: this._config.conditions,
|
||||||
actions: this._config.actions
|
actions: this._config.actions
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var authorInput = JX.DOM.find(this._root, 'input', 'author');
|
||||||
|
var authorID = JX.keys(this._config.authorGetter())[0];
|
||||||
|
if (authorID) {
|
||||||
|
authorInput.value = authorID;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getConditionValue : function(id) {
|
_getConditionValue : function(id) {
|
||||||
|
@ -236,6 +242,16 @@ JX.install('HeraldRuleEditor', {
|
||||||
return [input, get_fn, set_fn];
|
return [input, get_fn, set_fn];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_renderAuthorInput : function() {
|
||||||
|
var tokenizer = this._newTokenizer('email', 1);
|
||||||
|
input = tokenizer[0];
|
||||||
|
set_fn = tokenizer[2];
|
||||||
|
set_fn(this._config.author);
|
||||||
|
this._config.authorGetter = tokenizer[1];
|
||||||
|
var author_cell = JX.$('author-input');
|
||||||
|
JX.DOM.setContent(author_cell, input);
|
||||||
|
},
|
||||||
|
|
||||||
_renderValueInputForRow : function(row_id) {
|
_renderValueInputForRow : function(row_id) {
|
||||||
var cond = this._config.conditions[row_id];
|
var cond = this._config.conditions[row_id];
|
||||||
var type = this._config.info.values[cond[0]][cond[1]];
|
var type = this._config.info.values[cond[0]][cond[1]];
|
||||||
|
@ -260,7 +276,7 @@ JX.install('HeraldRuleEditor', {
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|
||||||
_newTokenizer : function(type) {
|
_newTokenizer : function(type, limit) {
|
||||||
var template = JX.$N(
|
var template = JX.$N(
|
||||||
'div',
|
'div',
|
||||||
JX.$H(this._config.template.markup));
|
JX.$H(this._config.template.markup));
|
||||||
|
@ -274,6 +290,7 @@ JX.install('HeraldRuleEditor', {
|
||||||
typeahead.setDatasource(datasource);
|
typeahead.setDatasource(datasource);
|
||||||
|
|
||||||
var tokenizer = new JX.Tokenizer(template);
|
var tokenizer = new JX.Tokenizer(template);
|
||||||
|
tokenizer.setLimit(limit);
|
||||||
tokenizer.setTypeahead(typeahead);
|
tokenizer.setTypeahead(typeahead);
|
||||||
tokenizer.start();
|
tokenizer.start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue