Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980929
D15507.id37378.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D15507.id37378.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -401,7 +401,7 @@
'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' => '746ca158',
+ 'rsrc/js/application/herald/HeraldRuleEditor.js' => 'd6a7e717',
'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',
@@ -563,7 +563,7 @@
'global-drag-and-drop-css' => '5c1b47c2',
'harbormaster-css' => '834879db',
'herald-css' => 'dc31f6e9',
- 'herald-rule-editor' => '746ca158',
+ 'herald-rule-editor' => 'd6a7e717',
'herald-test-css' => 'a52e323e',
'inline-comment-summary-css' => '51efda3a',
'javelin-aphlict' => '5359e785',
@@ -1435,15 +1435,6 @@
'javelin-vector',
'javelin-dom',
),
- '746ca158' => array(
- 'multirow-row-manager',
- 'javelin-install',
- 'javelin-util',
- 'javelin-dom',
- 'javelin-stratcom',
- 'javelin-json',
- 'phabricator-prefab',
- ),
'76b9fc3e' => array(
'javelin-behavior',
'javelin-stratcom',
@@ -1923,6 +1914,15 @@
'javelin-dom',
'javelin-stratcom',
),
+ 'd6a7e717' => array(
+ 'multirow-row-manager',
+ 'javelin-install',
+ 'javelin-util',
+ 'javelin-dom',
+ 'javelin-stratcom',
+ 'javelin-json',
+ 'phabricator-prefab',
+ ),
'd75709e6' => array(
'javelin-behavior',
'javelin-workflow',
diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php
--- a/src/applications/herald/controller/HeraldRuleController.php
+++ b/src/applications/herald/controller/HeraldRuleController.php
@@ -364,43 +364,6 @@
array $handles,
HeraldAdapter $adapter) {
- $serial_conditions = array(
- array('default', 'default', ''),
- );
-
- if ($rule->getConditions()) {
- $serial_conditions = array();
- foreach ($rule->getConditions() as $condition) {
- $value = $adapter->getEditorValueForCondition(
- $this->getViewer(),
- $condition);
-
- $serial_conditions[] = array(
- $condition->getFieldName(),
- $condition->getFieldCondition(),
- $value,
- );
- }
- }
-
- $serial_actions = array(
- array('default', ''),
- );
-
- if ($rule->getActions()) {
- $serial_actions = array();
- foreach ($rule->getActions() as $action) {
- $value = $adapter->getEditorValueForAction(
- $this->getViewer(),
- $action);
-
- $serial_actions[] = array(
- $action->getAction(),
- $value,
- );
- }
- }
-
$all_rules = $this->loadRulesThisRuleMayDependUpon($rule);
$all_rules = mpull($all_rules, 'getName', 'getPHID');
asort($all_rules);
@@ -492,10 +455,58 @@
$config_info['targets'][$action] = $value_key;
}
+ $default_group = head($config_info['fields']);
+ $default_field = head_key($default_group['options']);
+ $default_condition = head($config_info['conditionMap'][$default_field]);
+ $default_actions = head($config_info['actions']);
+ $default_action = head_key($default_actions['options']);
+
+ if ($rule->getConditions()) {
+ $serial_conditions = array();
+ foreach ($rule->getConditions() as $condition) {
+ $value = $adapter->getEditorValueForCondition(
+ $this->getViewer(),
+ $condition);
+
+ $serial_conditions[] = array(
+ $condition->getFieldName(),
+ $condition->getFieldCondition(),
+ $value,
+ );
+ }
+ } else {
+ $serial_conditions = array(
+ array($default_field, $default_condition, null),
+ );
+ }
+
+ if ($rule->getActions()) {
+ $serial_actions = array();
+ foreach ($rule->getActions() as $action) {
+ $value = $adapter->getEditorValueForAction(
+ $this->getViewer(),
+ $action);
+
+ $serial_actions[] = array(
+ $action->getAction(),
+ $value,
+ );
+ }
+ } else {
+ $serial_actions = array(
+ array($default_action, null),
+ );
+ }
+
Javelin::initBehavior(
'herald-rule-editor',
array(
'root' => 'herald-rule-edit-form',
+ 'default' => array(
+ 'field' => $default_field,
+ 'condition' => $default_condition,
+ 'action' => $default_action,
+ ),
'conditions' => (object)$serial_conditions,
'actions' => (object)$serial_actions,
'template' => $this->buildTokenizerTemplates() + array(
diff --git a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
--- a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
+++ b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
@@ -323,7 +323,14 @@
_newCondition : function(data) {
var row = this._conditionsRowManager.addRow([]);
var row_id = this._conditionsRowManager.getRowID(row);
- this._config.conditions[row_id] = data || [null, null, ''];
+
+ var default_condition = [
+ this._config.default.field,
+ this._config.default.condition,
+ null
+ ];
+ this._config.conditions[row_id] = data || default_condition;
+
var r = this._conditionsRowManager.updateRow(
row_id,
this._renderCondition(row_id));
@@ -369,7 +376,12 @@
},
_newAction : function(data) {
- data = data || [];
+ var default_action = [
+ this._config.default.action,
+ null
+ ];
+
+ data = data || default_action;
var temprow = this._actionsRowManager.addRow([]);
var row_id = this._actionsRowManager.getRowID(temprow);
this._config.actions[row_id] = data;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 1:22 PM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6715737
Default Alt Text
D15507.id37378.diff (6 KB)
Attached To
Mode
D15507: Fix an initialization issue in Herald rules in Chrome
Attached
Detach File
Event Timeline
Log In to Comment