1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Restore "Forks" to Paste

Summary:
I just put them in the property table instead of a list at the foot, they looked weird down there and were too bulky relative to their importance.

This won't scale great if someone forks a paste ten thousand times or whatever, but we can deal with that when we get there.

Also clean up a few things and tweak some styles,

Test Plan: Looked at forked, unforked pastes.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3295
This commit is contained in:
epriestley 2012-08-15 13:45:53 -07:00
parent 14cfdeca92
commit 84c32dd928
10 changed files with 68 additions and 40 deletions

View file

@ -2537,7 +2537,7 @@ celerity_register_resource_map(array(
),
'phabricator-property-list-view-css' =>
array(
'uri' => '/res/4a2b2d85/rsrc/css/layout/phabricator-property-list-view.css',
'uri' => '/res/598fccad/rsrc/css/layout/phabricator-property-list-view.css',
'type' => 'css',
'requires' =>
array(
@ -2585,7 +2585,7 @@ celerity_register_resource_map(array(
),
'phabricator-source-code-view-css' =>
array(
'uri' => '/res/631aa90a/rsrc/css/layout/phabricator-source-code-view.css',
'uri' => '/res/cf0c566c/rsrc/css/layout/phabricator-source-code-view.css',
'type' => 'css',
'requires' =>
array(

View file

@ -892,7 +892,6 @@ phutil_register_library_map(array(
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
'PhabricatorPasteEditController' => 'applications/paste/controller/PhabricatorPasteEditController.php',
'PhabricatorPasteListController' => 'applications/paste/controller/PhabricatorPasteListController.php',
'PhabricatorPasteQuery' => 'applications/paste/query/PhabricatorPasteQuery.php',
'PhabricatorPasteViewController' => 'applications/paste/controller/PhabricatorPasteViewController.php',
@ -1992,7 +1991,6 @@ phutil_register_library_map(array(
),
'PhabricatorPasteController' => 'PhabricatorController',
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
'PhabricatorPasteEditController' => 'PhabricatorPasteController',
'PhabricatorPasteListController' => 'PhabricatorPasteController',
'PhabricatorPasteQuery' => 'PhabricatorCursorPagedPolicyQuery',
'PhabricatorPasteViewController' => 'PhabricatorPasteController',

View file

@ -222,4 +222,13 @@ abstract class PhabricatorController extends AphrontController {
->loadHandles();
return $this;
}
protected function renderHandleList(array $phids) {
$items = array();
foreach ($phids as $phid) {
$items[] = $this->getHandle($phid)->renderLink();
}
return implode('<br />', $items);
}
}

View file

@ -38,18 +38,4 @@ abstract class PhabricatorPasteController extends PhabricatorController {
return $nav;
}
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName('Paste');
$page->setBaseURI('/paste/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9C\x8E");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
}

View file

@ -105,7 +105,6 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$side_nav = $this->buildSideNavView();
$side_nav->selectFilter($this->getFilter());
if ($this->getErrorView()) {
$side_nav->appendChild($this->getErrorView());
}
@ -132,9 +131,11 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$this->loadHandles(mpull($paste_list, 'getAuthorPHID'));
$side_nav->appendChild(
$this->renderPasteList($paste_list, $header, $pager));
$list = $this->buildPasteList($paste_list);
$list->setHeader($header);
$list->setPager($pager);
$side_nav->appendChild($list);
return $this->buildApplicationPage(
$side_nav,
@ -288,18 +289,17 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
return $create_panel;
}
private function renderPasteList(array $pastes, $header, $pager) {
private function buildPasteList(array $pastes) {
assert_instances_of($pastes, 'PhabricatorPaste');
$user = $this->getRequest()->getUser();
$list = new PhabricatorObjectItemListView();
$list->setHeader($header);
foreach ($pastes as $paste) {
$created = phabricator_datetime($paste->getDateCreated(), $user);
$item = id(new PhabricatorObjectItemView())
->setHeader('P'.$paste->getID().' '.$paste->getTitle())
->setHeader($paste->getFullName())
->setHref('/P'.$paste->getID())
->addDetail(
pht('Author'),
@ -309,8 +309,7 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$list->addItem($item);
}
$list->setPager($pager);
return $list;
}
}

View file

@ -44,32 +44,40 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
return new Aphront400Response();
}
$forks = id(new PhabricatorPasteQuery())
->setViewer($user)
->withParentPHIDs(array($paste->getPHID()))
->execute();
$fork_phids = mpull($forks, 'getPHID');
$this->loadHandles(
array(
$paste->getAuthorPHID(),
$paste->getParentPHID(),
));
array_merge(
array(
$paste->getAuthorPHID(),
$paste->getParentPHID(),
),
$fork_phids));
$header = $this->buildHeaderView($paste);
$actions = $this->buildActionView($paste, $file);
$properties = $this->buildPropertyView($paste);
$properties = $this->buildPropertyView($paste, $fork_phids);
$source_code = $this->buildSourceCodeView($paste, $file);
$nav = $this->buildSideNavView($paste);
$nav->selectFilter('paste');
$nav->appendChild(
array(
$header,
$actions,
$properties,
$source_code,
// $forks_panel,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => 'P'.$paste->getID().' '.$paste->getTitle(),
'title' => $paste->getFullName(),
'device' => true,
));
}
@ -97,7 +105,10 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
->setHref($file->getBestURI()));
}
private function buildPropertyView(PhabricatorPaste $paste) {
private function buildPropertyView(
PhabricatorPaste $paste,
array $child_phids) {
$user = $this->getRequest()->getUser();
$properties = new PhabricatorPropertyListView();
@ -115,6 +126,12 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
$this->getHandle($paste->getParentPHID())->renderLink());
}
if ($child_phids) {
$properties->addProperty(
pht('Forks'),
$this->renderHandleList($child_phids));
}
return $properties;
}

View file

@ -21,6 +21,7 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
private $ids;
private $phids;
private $authorPHIDs;
private $parentPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -37,6 +38,11 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
return $this;
}
public function withParentPHIDs(array $phids) {
$this->parentPHIDs = $phids;
return $this;
}
public function loadPage() {
$table = new PhabricatorPaste();
$conn_r = $table->establishConnection('r');
@ -80,6 +86,13 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
$this->authorPHIDs);
}
if ($this->parentPHIDs) {
$where[] = qsprintf(
$conn_r,
'parentPHID IN (%Ls)',
$this->parentPHIDs);
}
return $this->formatWhereClause($where);
}

View file

@ -51,4 +51,12 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
return ($user->getPHID() == $this->getAuthorPHID());
}
public function getFullName() {
$title = $this->getTitle();
if (!$title) {
$title = 'Untitled Masterwork';
}
return 'P'.$this->getID().' '.$title;
}
}

View file

@ -11,12 +11,11 @@
overflow: hidden;
}
.device-desktop .phabricator-property-list-view,
.device-tablet .phabricator-property-list-view {
.device-desktop .phabricator-property-list-view {
padding: 1em 0 0.75em;
}
.device-tablet .phabricator-property-list-view,
.device-phone .phabricator-property-list-view {
padding: .5em;
}
@ -51,7 +50,6 @@
margin-bottom: .5em;
}
.device-tablet .phabricator-property-value,
.device-phone .phabricator-property-value {
padding-left: 1.5em;

View file

@ -4,12 +4,12 @@
.phabricator-source-code {
white-space: pre-wrap;
padding: 3px 8px;
padding: 2px 8px 1px;
}
.phabricator-source-line {
text-align: right;
padding: 3px 6px 3px 12px;
padding: 2px 6px 1px 12px;
border-right: 1px solid #dbdbdb;
font-weight: bold;