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

Smooth out Phortune purchase completion flow

Summary:
Ref T2787. Currently, we dump the user back into the application. Instead, give them a confirmation screen and then let them continue.

Also fix a couple of unit tests I adjusted the underlying behavior of somewhat-recently in libphutil.

Test Plan: {F215498}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

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

+58 -21
+4
src/applications/fund/phortune/FundBackerCart.php
··· 81 81 return '/'.$this->getInitiative()->getMonogram(); 82 82 } 83 83 84 + public function getDoneActionName(PhortuneCart $cart) { 85 + return pht('Return to Initiative'); 86 + } 87 + 84 88 }
+4
src/applications/phortune/cart/PhortuneCartImplementation.php
··· 16 16 abstract public function getCancelURI(PhortuneCart $cart); 17 17 abstract public function getDoneURI(PhortuneCart $cart); 18 18 19 + public function getDoneActionName(PhortuneCart $cart) { 20 + return pht('Return to Application'); 21 + } 22 + 19 23 public function assertCanCancelOrder(PhortuneCart $cart) { 20 24 switch ($cart->getStatus()) { 21 25 case PhortuneCart::STATUS_PURCHASED:
+1 -1
src/applications/phortune/controller/PhortuneCartCheckoutController.php
··· 102 102 103 103 $cart->didApplyCharge($charge); 104 104 105 - $done_uri = $cart->getDoneURI(); 105 + $done_uri = $cart->getCheckoutURI(); 106 106 return id(new AphrontRedirectResponse())->setURI($done_uri); 107 107 } 108 108 }
+26 -1
src/applications/phortune/controller/PhortuneCartViewController.php
··· 35 35 PhabricatorPolicyCapability::CAN_EDIT); 36 36 37 37 $errors = array(); 38 + $error_view = null; 38 39 $resume_uri = null; 39 40 switch ($cart->getStatus()) { 40 41 case PhortuneCart::STATUS_PURCHASING: ··· 71 72 phutil_tag('strong', array(), pht('Update Status'))); 72 73 } 73 74 break; 75 + case PhortuneCart::STATUS_PURCHASED: 76 + $error_view = id(new AphrontErrorView()) 77 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 78 + ->appendChild(pht('This purchase has been completed.')); 79 + 80 + break; 74 81 } 75 82 76 83 $properties = $this->buildPropertyListView($cart); ··· 85 92 ->setUser($viewer) 86 93 ->setHeader(pht('Order Detail')); 87 94 95 + if ($cart->getStatus() == PhortuneCart::STATUS_PURCHASED) { 96 + $done_uri = $cart->getDoneURI(); 97 + if ($done_uri) { 98 + $header->addActionLink( 99 + id(new PHUIButtonView()) 100 + ->setTag('a') 101 + ->setHref($done_uri) 102 + ->setIcon(id(new PHUIIconView()) 103 + ->setIconFont('fa-check-square green')) 104 + ->setText($cart->getDoneActionName())); 105 + } 106 + } 107 + 88 108 $cart_box = id(new PHUIObjectBoxView()) 89 109 ->setHeader($header) 90 - ->setFormErrors($errors) 91 110 ->appendChild($properties) 92 111 ->appendChild($cart_table); 112 + 113 + if ($errors) { 114 + $cart_box->setFormErrors($errors); 115 + } else if ($error_view) { 116 + $cart_box->setErrorView($error_view); 117 + } 93 118 94 119 $charges = id(new PhortuneChargeQuery()) 95 120 ->setViewer($viewer)
+1 -1
src/applications/phortune/provider/PhortunePayPalPaymentProvider.php
··· 450 450 if ($success) { 451 451 $cart->didApplyCharge($charge); 452 452 $response = id(new AphrontRedirectResponse())->setURI( 453 - $cart->getDoneURI()); 453 + $cart->getCheckoutURI()); 454 454 } else if ($hold) { 455 455 $cart->didHoldCharge($charge); 456 456
+1 -1
src/applications/phortune/provider/PhortuneWePayPaymentProvider.php
··· 349 349 $cart->didApplyCharge($charge); 350 350 351 351 $response = id(new AphrontRedirectResponse())->setURI( 352 - $cart->getDoneURI()); 352 + $cart->getCheckoutURI()); 353 353 break; 354 354 default: 355 355 // It's not clear if we can ever get here on the web workflow,
+4
src/applications/phortune/storage/PhortuneCart.php
··· 332 332 return $this->getImplementation()->getDoneURI($this); 333 333 } 334 334 335 + public function getDoneActionName() { 336 + return $this->getImplementation()->getDoneActionName($this); 337 + } 338 + 335 339 public function getCancelURI() { 336 340 return $this->getImplementation()->getCancelURI($this); 337 341 }
+16 -16
src/view/__tests__/PhabricatorUnitsTestCase.php
··· 7 7 8 8 public function testByteFormatting() { 9 9 $tests = array( 10 - 1 => '1 B', 11 - 1000 => '1 KB', 12 - 1000000 => '1 MB', 13 - 10000000 => '10 MB', 14 - 100000000 => '100 MB', 15 - 1000000000 => '1 GB', 16 - 999 => '999 B', 10 + 1 => '1 B', 11 + 1024 => '1 KB', 12 + 1024 * 1024 => '1 MB', 13 + 10 * 1024 * 1024 => '10 MB', 14 + 100 * 1024 * 1024 => '100 MB', 15 + 1024 * 1024 * 1024 => '1 GB', 16 + 999 => '999 B', 17 17 ); 18 18 19 19 foreach ($tests as $input => $expect) { ··· 27 27 public function testByteParsing() { 28 28 $tests = array( 29 29 '1' => 1, 30 - '1k' => 1000, 31 - '1K' => 1000, 32 - '1kB' => 1000, 33 - '1Kb' => 1000, 34 - '1KB' => 1000, 35 - '1MB' => 1000000, 36 - '1GB' => 1000000000, 37 - '1.5M' => 1500000, 30 + '1k' => 1024, 31 + '1K' => 1024, 32 + '1kB' => 1024, 33 + '1Kb' => 1024, 34 + '1KB' => 1024, 35 + '1MB' => 1024 * 1024, 36 + '1GB' => 1024 * 1024 * 1024, 37 + '1.5M' => (int)(1024 * 1024 * 1.5), 38 38 '1 000' => 1000, 39 - '1,234.56 KB' => 1234560, 39 + '1,234.56 KB' => (int)(1024 * 1234.56), 40 40 ); 41 41 42 42 foreach ($tests as $input => $expect) {
+1 -1
src/view/phui/PHUIObjectBoxView.php
··· 85 85 } 86 86 87 87 public function setFormErrors(array $errors, $title = null) { 88 - if (nonempty($errors)) { 88 + if ($errors) { 89 89 $this->formErrors = id(new AphrontErrorView()) 90 90 ->setTitle($title) 91 91 ->setErrors($errors);