@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix an initialization issue in Herald rules in Chrome

Summary:
Fixes T10646. When you load the page or click "New Condition" or "New Action", we try to add a condition and action with some default values.

Currently, the logic just sets everything to `null` or `'default'`. This technically works in Safari, but is less successful in Chrome. (I think Safari prevents you from picking an invalid value.)

Instead of relying on the browser to pick the right value, set the correct value explicitly.

Test Plan:
- Created a new rule in Chrome, Safari.
- Added fields and conditions in Chrome, Safari.
- Edited existing rules in Chrome, Safari.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10646

Differential Revision: https://secure.phabricator.com/D15507

+73 -50
+11 -11
resources/celerity/map.php
··· 401 401 'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef', 402 402 'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab', 403 403 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 404 - 'rsrc/js/application/herald/HeraldRuleEditor.js' => '746ca158', 404 + 'rsrc/js/application/herald/HeraldRuleEditor.js' => 'd6a7e717', 405 405 'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec', 406 406 'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3', 407 407 'rsrc/js/application/maniphest/behavior-batch-editor.js' => '782ab6e7', ··· 563 563 'global-drag-and-drop-css' => '5c1b47c2', 564 564 'harbormaster-css' => '834879db', 565 565 'herald-css' => 'dc31f6e9', 566 - 'herald-rule-editor' => '746ca158', 566 + 'herald-rule-editor' => 'd6a7e717', 567 567 'herald-test-css' => 'a52e323e', 568 568 'inline-comment-summary-css' => '51efda3a', 569 569 'javelin-aphlict' => '5359e785', ··· 1435 1435 'javelin-vector', 1436 1436 'javelin-dom', 1437 1437 ), 1438 - '746ca158' => array( 1439 - 'multirow-row-manager', 1440 - 'javelin-install', 1441 - 'javelin-util', 1442 - 'javelin-dom', 1443 - 'javelin-stratcom', 1444 - 'javelin-json', 1445 - 'phabricator-prefab', 1446 - ), 1447 1438 '76b9fc3e' => array( 1448 1439 'javelin-behavior', 1449 1440 'javelin-stratcom', ··· 1922 1913 'javelin-behavior', 1923 1914 'javelin-dom', 1924 1915 'javelin-stratcom', 1916 + ), 1917 + 'd6a7e717' => array( 1918 + 'multirow-row-manager', 1919 + 'javelin-install', 1920 + 'javelin-util', 1921 + 'javelin-dom', 1922 + 'javelin-stratcom', 1923 + 'javelin-json', 1924 + 'phabricator-prefab', 1925 1925 ), 1926 1926 'd75709e6' => array( 1927 1927 'javelin-behavior',
+48 -37
src/applications/herald/controller/HeraldRuleController.php
··· 364 364 array $handles, 365 365 HeraldAdapter $adapter) { 366 366 367 - $serial_conditions = array( 368 - array('default', 'default', ''), 369 - ); 370 - 371 - if ($rule->getConditions()) { 372 - $serial_conditions = array(); 373 - foreach ($rule->getConditions() as $condition) { 374 - $value = $adapter->getEditorValueForCondition( 375 - $this->getViewer(), 376 - $condition); 377 - 378 - $serial_conditions[] = array( 379 - $condition->getFieldName(), 380 - $condition->getFieldCondition(), 381 - $value, 382 - ); 383 - } 384 - } 385 - 386 - $serial_actions = array( 387 - array('default', ''), 388 - ); 389 - 390 - if ($rule->getActions()) { 391 - $serial_actions = array(); 392 - foreach ($rule->getActions() as $action) { 393 - $value = $adapter->getEditorValueForAction( 394 - $this->getViewer(), 395 - $action); 396 - 397 - $serial_actions[] = array( 398 - $action->getAction(), 399 - $value, 400 - ); 401 - } 402 - } 403 - 404 367 $all_rules = $this->loadRulesThisRuleMayDependUpon($rule); 405 368 $all_rules = mpull($all_rules, 'getName', 'getPHID'); 406 369 asort($all_rules); ··· 492 455 $config_info['targets'][$action] = $value_key; 493 456 } 494 457 458 + $default_group = head($config_info['fields']); 459 + $default_field = head_key($default_group['options']); 460 + $default_condition = head($config_info['conditionMap'][$default_field]); 461 + $default_actions = head($config_info['actions']); 462 + $default_action = head_key($default_actions['options']); 463 + 464 + if ($rule->getConditions()) { 465 + $serial_conditions = array(); 466 + foreach ($rule->getConditions() as $condition) { 467 + $value = $adapter->getEditorValueForCondition( 468 + $this->getViewer(), 469 + $condition); 470 + 471 + $serial_conditions[] = array( 472 + $condition->getFieldName(), 473 + $condition->getFieldCondition(), 474 + $value, 475 + ); 476 + } 477 + } else { 478 + $serial_conditions = array( 479 + array($default_field, $default_condition, null), 480 + ); 481 + } 482 + 483 + if ($rule->getActions()) { 484 + $serial_actions = array(); 485 + foreach ($rule->getActions() as $action) { 486 + $value = $adapter->getEditorValueForAction( 487 + $this->getViewer(), 488 + $action); 489 + 490 + $serial_actions[] = array( 491 + $action->getAction(), 492 + $value, 493 + ); 494 + } 495 + } else { 496 + $serial_actions = array( 497 + array($default_action, null), 498 + ); 499 + } 500 + 495 501 Javelin::initBehavior( 496 502 'herald-rule-editor', 497 503 array( 498 504 'root' => 'herald-rule-edit-form', 505 + 'default' => array( 506 + 'field' => $default_field, 507 + 'condition' => $default_condition, 508 + 'action' => $default_action, 509 + ), 499 510 'conditions' => (object)$serial_conditions, 500 511 'actions' => (object)$serial_actions, 501 512 'template' => $this->buildTokenizerTemplates() + array(
+14 -2
webroot/rsrc/js/application/herald/HeraldRuleEditor.js
··· 323 323 _newCondition : function(data) { 324 324 var row = this._conditionsRowManager.addRow([]); 325 325 var row_id = this._conditionsRowManager.getRowID(row); 326 - this._config.conditions[row_id] = data || [null, null, '']; 326 + 327 + var default_condition = [ 328 + this._config.default.field, 329 + this._config.default.condition, 330 + null 331 + ]; 332 + this._config.conditions[row_id] = data || default_condition; 333 + 327 334 var r = this._conditionsRowManager.updateRow( 328 335 row_id, 329 336 this._renderCondition(row_id)); ··· 369 376 }, 370 377 371 378 _newAction : function(data) { 372 - data = data || []; 379 + var default_action = [ 380 + this._config.default.action, 381 + null 382 + ]; 383 + 384 + data = data || default_action; 373 385 var temprow = this._actionsRowManager.addRow([]); 374 386 var row_id = this._actionsRowManager.getRowID(temprow); 375 387 this._config.actions[row_id] = data;