mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
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
This commit is contained in:
parent
967945e4b4
commit
851aba80ce
4 changed files with 18 additions and 8 deletions
|
@ -13,6 +13,7 @@ final class CelerityStaticResourceResponse extends Phobject {
|
|||
private $packaged;
|
||||
private $metadata = array();
|
||||
private $metadataBlock = 0;
|
||||
private $metadataLocked;
|
||||
private $behaviors = array();
|
||||
private $hasRendered = array();
|
||||
private $postprocessorKey;
|
||||
|
@ -24,6 +25,13 @@ final class CelerityStaticResourceResponse extends Phobject {
|
|||
}
|
||||
|
||||
public function addMetadata($metadata) {
|
||||
if ($this->metadataLocked) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Attempting to add more metadata after metadata has been '.
|
||||
'locked.'));
|
||||
}
|
||||
|
||||
$id = count($this->metadata);
|
||||
$this->metadata[$id] = $metadata;
|
||||
return $this->metadataBlock.'_'.$id;
|
||||
|
@ -189,6 +197,8 @@ final class CelerityStaticResourceResponse extends Phobject {
|
|||
}
|
||||
|
||||
public function renderHTMLFooter() {
|
||||
$this->metadataLocked = true;
|
||||
|
||||
$data = array();
|
||||
if ($this->metadata) {
|
||||
$json_metadata = AphrontResponse::encodeJSONForHTTPResponse(
|
||||
|
|
|
@ -53,5 +53,11 @@ final class PhabricatorActionListView extends AphrontView {
|
|||
$actions);
|
||||
}
|
||||
|
||||
public function getDropdownMenuMetadata() {
|
||||
return array(
|
||||
'items' => (string)hsprintf('%s', $this),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -105,10 +105,7 @@ final class PHUIButtonView extends AphrontTagView {
|
|||
Javelin::initBehavior('phui-dropdown-menu');
|
||||
|
||||
$this->addSigil('phui-dropdown-menu');
|
||||
$this->setMetadata(
|
||||
array(
|
||||
'items' => $actions,
|
||||
));
|
||||
$this->setMetadata($actions->getDropdownMenuMetadata());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -43,10 +43,7 @@ final class PHUIListItemView extends AphrontTagView {
|
|||
Javelin::initBehavior('phui-dropdown-menu');
|
||||
|
||||
$this->addSigil('phui-dropdown-menu');
|
||||
$this->setMetadata(
|
||||
array(
|
||||
'items' => $actions,
|
||||
));
|
||||
$this->setMetadata($actions->getDropdownMenuMetadata());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue