@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.

Improve some commenting/editing behaviors for recurring events

Summary:
Ref T11809. Currently, commenting on a recurring event hits the same "one or all?" dialog that other edits do.

For comments and edits submitted via the comment widget, we can safely assume that you mean "just this one", since it doesn't really make sense to try to bulk-edit an event from that UI.

Test Plan: Commented on a recurring event parent and an event in the series.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11809

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

+68 -6
+11 -2
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 34 34 ->addCancelButton($cancel_uri); 35 35 } 36 36 } else if ($event->getIsRecurring()) { 37 - $mode = $request->getStr('mode'); 37 + 38 + // If the user submits a comment or makes an edit via comment actions, 39 + // always target only the current event. It doesn't make sense to add 40 + // comments to every instance of an event, and the other actions don't 41 + // make much sense to apply to all instances either. 42 + if ($engine->isCommentAction()) { 43 + $mode = PhabricatorCalendarEventEditEngine::MODE_THIS; 44 + } else { 45 + $mode = $request->getStr('mode'); 46 + } 47 + 38 48 if (!$mode) { 39 49 $form = id(new AphrontFormView()) 40 50 ->setViewer($viewer) ··· 60 70 ->addSubmitButton(pht('Continue')) 61 71 ->addCancelButton($cancel_uri) 62 72 ->setDisableWorkflowOnSubmit(true); 63 - 64 73 } 65 74 66 75 $engine
+34 -2
src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
··· 295 295 296 296 protected function willApplyTransactions($object, array $xactions) { 297 297 $viewer = $this->getViewer(); 298 - $this->rawTransactions = $xactions; 298 + $this->rawTransactions = $this->cloneTransactions($xactions); 299 299 300 300 $is_parent = $object->isParentEvent(); 301 301 $is_child = $object->isChildEvent(); ··· 304 304 $must_fork = ($is_child && $is_future) || 305 305 ($is_parent && !$is_future); 306 306 307 + if ($is_parent && !$is_future) { 308 + // We don't necessarily need to fork if whatever we're editing is not 309 + // inherited by children. For example, we can add a comment to the parent 310 + // event without needing to fork. Test all the stuff we're doing and see 311 + // if anything is actually inherited. 312 + 313 + $inherited_edit = false; 314 + foreach ($xactions as $xaction) { 315 + $modular_type = $xaction->getTransactionImplementation(); 316 + if ($modular_type instanceof PhabricatorCalendarEventTransactionType) { 317 + $inherited_edit = $modular_type->isInheritedEdit(); 318 + if ($inherited_edit) { 319 + break; 320 + } 321 + } 322 + } 323 + 324 + // Nothing the user is trying to do requires us to fork, so we can just 325 + // apply the changes normally. 326 + if (!$inherited_edit) { 327 + $must_fork = false; 328 + } 329 + } 330 + 307 331 if ($must_fork) { 308 332 $fork_target = $object->loadForkTarget($viewer); 309 333 if ($fork_target) { ··· 340 364 } 341 365 342 366 foreach ($targets as $target) { 343 - $apply = clone $this->rawTransactions; 367 + $apply = $this->cloneTransactions($this->rawTransactions); 344 368 $this->applyTransactions($target, $apply); 345 369 } 346 370 } ··· 364 388 } catch (PhabricatorApplicationTransactionValidationException $ex) { 365 389 // Just ignore any issues we run into. 366 390 } 391 + } 392 + 393 + private function cloneTransactions(array $xactions) { 394 + $result = array(); 395 + foreach ($xactions as $xaction) { 396 + $result[] = clone $xaction; 397 + } 398 + return $result; 367 399 } 368 400 369 401 }
+4
src/applications/calendar/xaction/PhabricatorCalendarEventReplyTransaction.php
··· 8 8 return $object->getUserInviteStatus($actor_phid); 9 9 } 10 10 11 + public function isInheritedEdit() { 12 + return false; 13 + } 14 + 11 15 public function applyExternalEffects($object, $value) { 12 16 $acting_phid = $this->getActingAsPHID(); 13 17
+7 -1
src/applications/calendar/xaction/PhabricatorCalendarEventTransactionType.php
··· 1 1 <?php 2 2 3 3 abstract class PhabricatorCalendarEventTransactionType 4 - extends PhabricatorModularTransactionType {} 4 + extends PhabricatorModularTransactionType { 5 + 6 + public function isInheritedEdit() { 7 + return true; 8 + } 9 + 10 + }
+12 -1
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 780 780 $controller = $this->getController(); 781 781 $request = $controller->getRequest(); 782 782 783 - $action = $request->getURIData('editAction'); 783 + $action = $this->getEditAction(); 784 784 785 785 $capabilities = array(); 786 786 $use_default = false; ··· 2097 2097 $this, 2098 2098 PhabricatorPolicyCapability::CAN_EDIT); 2099 2099 } 2100 + 2101 + public function isCommentAction() { 2102 + return ($this->getEditAction() == 'comment'); 2103 + } 2104 + 2105 + public function getEditAction() { 2106 + $controller = $this->getController(); 2107 + $request = $controller->getRequest(); 2108 + return $request->getURIData('editAction'); 2109 + } 2110 + 2100 2111 2101 2112 /* -( Form Pages )--------------------------------------------------------- */ 2102 2113