1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 17:00:59 +01:00

Fix header display bug on forked pastes.

Summary:
You can only call setHeader() on a Panel once. Otherwise the last sticks. Move the "forks of this paste" stuff to its own panel (only shown if there are, indeed, forks), and make the columns look nicer.

Test Plan:
Viewed previously forked pastes, forked a paste and looked at the original, and looked at a non-forked paste. All looked sane.

Reviewers:
epriestley

CC:

Differential Revision: 700
This commit is contained in:
Ricky Elrod 2011-07-21 02:17:30 -04:00
parent 3eafe9e3bb
commit caa5b050b1

View file

@ -42,18 +42,18 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
} }
$corpus = $this->buildCorpus($paste, $file); $corpus = $this->buildCorpus($paste, $file);
$panel = new AphrontPanelView(); $paste_panel = new AphrontPanelView();
if (strlen($paste->getTitle())) { if (strlen($paste->getTitle())) {
$panel->setHeader( $paste_panel->setHeader(
'Viewing Paste '.$paste->getID().' - '. 'Viewing Paste '.$paste->getID().' - '.
phutil_escape_html($paste->getTitle())); phutil_escape_html($paste->getTitle()));
} else { } else {
$panel->setHeader('Viewing Paste '.$paste->getID()); $paste_panel->setHeader('Viewing Paste '.$paste->getID());
} }
$panel->setWidth(AphrontPanelView::WIDTH_FULL); $paste_panel->setWidth(AphrontPanelView::WIDTH_FULL);
$panel->addButton( $paste_panel->addButton(
phutil_render_tag( phutil_render_tag(
'a', 'a',
array( array(
@ -63,7 +63,7 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
'Fork This')); 'Fork This'));
$raw_uri = PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID()); $raw_uri = PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID());
$panel->addButton( $paste_panel->addButton(
phutil_render_tag( phutil_render_tag(
'a', 'a',
array( array(
@ -72,13 +72,16 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
), ),
'View Raw Text')); 'View Raw Text'));
$panel->appendChild($corpus); $paste_panel->appendChild($corpus);
$forks_panel = null;
$forks_of_this_paste = id(new PhabricatorPaste())->loadAllWhere( $forks_of_this_paste = id(new PhabricatorPaste())->loadAllWhere(
'parentPHID = %s', 'parentPHID = %s',
$paste->getPHID()); $paste->getPHID());
if ($forks_of_this_paste) { if ($forks_of_this_paste) {
$forks_panel = new AphrontPanelView();
$forks_panel->setHeader("Forks of this paste");
$forks = array(); $forks = array();
foreach ($forks_of_this_paste as $fork) { foreach ($forks_of_this_paste as $fork) {
$forks[] = array( $forks[] = array(
@ -92,7 +95,6 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
) )
); );
} }
$forks_table = new AphrontTableView($forks); $forks_table = new AphrontTableView($forks);
$forks_table->setHeaders( $forks_table->setHeaders(
array( array(
@ -100,13 +102,20 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
'Title', 'Title',
) )
); );
$forks_table->setColumnClasses(
$panel->setHeader("Forks of this Paste"); array(
$panel->appendChild($forks_table); null,
'wide pri',
)
);
$forks_panel->appendChild($forks_table);
} }
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
$panel, array(
$paste_panel,
$forks_panel,
),
array( array(
'title' => 'Paste: '.nonempty($paste->getTitle(), 'P'.$paste->getID()), 'title' => 'Paste: '.nonempty($paste->getTitle(), 'P'.$paste->getID()),
'tab' => 'view', 'tab' => 'view',