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

at upstream/main 91 lines 2.6 kB view raw
1<?php 2 3final class PhabricatorApplicationTransactionNoEffectResponse 4 extends AphrontProxyResponse { 5 6 private $viewer; 7 private $exception; 8 private $cancelURI; 9 10 public function setCancelURI($cancel_uri) { 11 $this->cancelURI = $cancel_uri; 12 return $this; 13 } 14 15 public function setException( 16 PhabricatorApplicationTransactionNoEffectException $exception) { 17 $this->exception = $exception; 18 return $this; 19 } 20 21 protected function buildProxy() { 22 return new AphrontDialogResponse(); 23 } 24 25 public function reduceProxyResponse() { 26 $request = $this->getRequest(); 27 28 $ex = $this->exception; 29 $xactions = $ex->getTransactions(); 30 31 $type_comment = PhabricatorTransactions::TYPE_COMMENT; 32 $only_empty_comment = (count($xactions) == 1) && 33 (head($xactions)->getTransactionType() == $type_comment); 34 35 $count = phutil_count($xactions); 36 37 if ($ex->hasAnyEffect()) { 38 $title = pht('%s Action(s) With No Effect', $count); 39 $head = pht('%s of your actions have no effect:', $count); 40 $tail = pht('Apply remaining actions?'); 41 $continue = pht('Apply Remaining Actions'); 42 } else if ($ex->hasComment()) { 43 $title = pht('Post as Comment'); 44 $head = pht('The %s action(s) you are taking have no effect:', $count); 45 $tail = pht('Do you want to post your comment anyway?'); 46 $continue = pht('Post Comment'); 47 } else if ($only_empty_comment) { 48 // Special case this since it's common and we can give the user a nicer 49 // dialog than "Action Has No Effect". 50 $title = pht('Empty Comment'); 51 $head = null; 52 $tail = null; 53 $continue = null; 54 } else { 55 $title = pht('%s Action(s) Have No Effect', $count); 56 $head = pht('The %s action(s) you are taking have no effect:', $count); 57 $tail = null; 58 $continue = null; 59 } 60 61 $dialog = id(new AphrontDialogView()) 62 ->setUser($request->getUser()) 63 ->setTitle($title); 64 65 $dialog->appendChild($head); 66 67 $list = array(); 68 foreach ($xactions as $xaction) { 69 $list[] = $xaction->getNoEffectDescription(); 70 } 71 72 if ($list) { 73 $dialog->appendList($list); 74 } 75 $dialog->appendChild($tail); 76 77 if ($continue) { 78 $passthrough = $request->getPassthroughRequestParameters(); 79 foreach ($passthrough as $key => $value) { 80 $dialog->addHiddenInput($key, $value); 81 } 82 $dialog->addHiddenInput('__continue__', 1); 83 $dialog->addSubmitButton($continue); 84 } 85 86 $dialog->addCancelButton($this->cancelURI); 87 88 return $this->getProxy()->setDialog($dialog); 89 } 90 91}