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

Render dropdown metadata earlier

Summary:
Ref T11179. One issue I'm getting with trying to turn actions into dropdowns is that we currently render this menu very late, which can cause us to try to add more metadata after we start resolving metadata. This won't work right now (and making it work seems unreasonably complicated), so stop doing it and fatal if something tries.

(This might make some things fatal but //should// be safe -- anything that fatals should have been broken already.)

Test Plan:
Browsed around looking for fatals, didn't see any.

(This primarily avoids a broken state / fatal in a future diff.)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11179

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

+18 -8
+10
src/applications/celerity/CelerityStaticResourceResponse.php
··· 13 13 private $packaged; 14 14 private $metadata = array(); 15 15 private $metadataBlock = 0; 16 + private $metadataLocked; 16 17 private $behaviors = array(); 17 18 private $hasRendered = array(); 18 19 private $postprocessorKey; ··· 24 25 } 25 26 26 27 public function addMetadata($metadata) { 28 + if ($this->metadataLocked) { 29 + throw new Exception( 30 + pht( 31 + 'Attempting to add more metadata after metadata has been '. 32 + 'locked.')); 33 + } 34 + 27 35 $id = count($this->metadata); 28 36 $this->metadata[$id] = $metadata; 29 37 return $this->metadataBlock.'_'.$id; ··· 189 197 } 190 198 191 199 public function renderHTMLFooter() { 200 + $this->metadataLocked = true; 201 + 192 202 $data = array(); 193 203 if ($this->metadata) { 194 204 $json_metadata = AphrontResponse::encodeJSONForHTTPResponse(
+6
src/view/layout/PhabricatorActionListView.php
··· 53 53 $actions); 54 54 } 55 55 56 + public function getDropdownMenuMetadata() { 57 + return array( 58 + 'items' => (string)hsprintf('%s', $this), 59 + ); 60 + } 61 + 56 62 57 63 }
+1 -4
src/view/phui/PHUIButtonView.php
··· 105 105 Javelin::initBehavior('phui-dropdown-menu'); 106 106 107 107 $this->addSigil('phui-dropdown-menu'); 108 - $this->setMetadata( 109 - array( 110 - 'items' => $actions, 111 - )); 108 + $this->setMetadata($actions->getDropdownMenuMetadata()); 112 109 113 110 return $this; 114 111 }
+1 -4
src/view/phui/PHUIListItemView.php
··· 43 43 Javelin::initBehavior('phui-dropdown-menu'); 44 44 45 45 $this->addSigil('phui-dropdown-menu'); 46 - $this->setMetadata( 47 - array( 48 - 'items' => $actions, 49 - )); 46 + $this->setMetadata($actions->getDropdownMenuMetadata()); 50 47 51 48 return $this; 52 49 }