mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +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:
parent
14cfdeca92
commit
84c32dd928
10 changed files with 68 additions and 40 deletions
|
@ -2537,7 +2537,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'phabricator-property-list-view-css' =>
|
'phabricator-property-list-view-css' =>
|
||||||
array(
|
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',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -2585,7 +2585,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'phabricator-source-code-view-css' =>
|
'phabricator-source-code-view-css' =>
|
||||||
array(
|
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',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -892,7 +892,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
|
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
|
||||||
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
|
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
|
||||||
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
|
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
|
||||||
'PhabricatorPasteEditController' => 'applications/paste/controller/PhabricatorPasteEditController.php',
|
|
||||||
'PhabricatorPasteListController' => 'applications/paste/controller/PhabricatorPasteListController.php',
|
'PhabricatorPasteListController' => 'applications/paste/controller/PhabricatorPasteListController.php',
|
||||||
'PhabricatorPasteQuery' => 'applications/paste/query/PhabricatorPasteQuery.php',
|
'PhabricatorPasteQuery' => 'applications/paste/query/PhabricatorPasteQuery.php',
|
||||||
'PhabricatorPasteViewController' => 'applications/paste/controller/PhabricatorPasteViewController.php',
|
'PhabricatorPasteViewController' => 'applications/paste/controller/PhabricatorPasteViewController.php',
|
||||||
|
@ -1992,7 +1991,6 @@ phutil_register_library_map(array(
|
||||||
),
|
),
|
||||||
'PhabricatorPasteController' => 'PhabricatorController',
|
'PhabricatorPasteController' => 'PhabricatorController',
|
||||||
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorPasteEditController' => 'PhabricatorPasteController',
|
|
||||||
'PhabricatorPasteListController' => 'PhabricatorPasteController',
|
'PhabricatorPasteListController' => 'PhabricatorPasteController',
|
||||||
'PhabricatorPasteQuery' => 'PhabricatorCursorPagedPolicyQuery',
|
'PhabricatorPasteQuery' => 'PhabricatorCursorPagedPolicyQuery',
|
||||||
'PhabricatorPasteViewController' => 'PhabricatorPasteController',
|
'PhabricatorPasteViewController' => 'PhabricatorPasteController',
|
||||||
|
|
|
@ -222,4 +222,13 @@ abstract class PhabricatorController extends AphrontController {
|
||||||
->loadHandles();
|
->loadHandles();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function renderHandleList(array $phids) {
|
||||||
|
$items = array();
|
||||||
|
foreach ($phids as $phid) {
|
||||||
|
$items[] = $this->getHandle($phid)->renderLink();
|
||||||
|
}
|
||||||
|
return implode('<br />', $items);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,18 +38,4 @@ abstract class PhabricatorPasteController extends PhabricatorController {
|
||||||
return $nav;
|
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());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,6 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||||
$side_nav = $this->buildSideNavView();
|
$side_nav = $this->buildSideNavView();
|
||||||
$side_nav->selectFilter($this->getFilter());
|
$side_nav->selectFilter($this->getFilter());
|
||||||
|
|
||||||
|
|
||||||
if ($this->getErrorView()) {
|
if ($this->getErrorView()) {
|
||||||
$side_nav->appendChild($this->getErrorView());
|
$side_nav->appendChild($this->getErrorView());
|
||||||
}
|
}
|
||||||
|
@ -132,9 +131,11 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||||
|
|
||||||
$this->loadHandles(mpull($paste_list, 'getAuthorPHID'));
|
$this->loadHandles(mpull($paste_list, 'getAuthorPHID'));
|
||||||
|
|
||||||
$side_nav->appendChild(
|
$list = $this->buildPasteList($paste_list);
|
||||||
$this->renderPasteList($paste_list, $header, $pager));
|
$list->setHeader($header);
|
||||||
|
$list->setPager($pager);
|
||||||
|
|
||||||
|
$side_nav->appendChild($list);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$side_nav,
|
$side_nav,
|
||||||
|
@ -288,18 +289,17 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||||
return $create_panel;
|
return $create_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderPasteList(array $pastes, $header, $pager) {
|
private function buildPasteList(array $pastes) {
|
||||||
assert_instances_of($pastes, 'PhabricatorPaste');
|
assert_instances_of($pastes, 'PhabricatorPaste');
|
||||||
|
|
||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
$list = new PhabricatorObjectItemListView();
|
$list = new PhabricatorObjectItemListView();
|
||||||
$list->setHeader($header);
|
|
||||||
foreach ($pastes as $paste) {
|
foreach ($pastes as $paste) {
|
||||||
$created = phabricator_datetime($paste->getDateCreated(), $user);
|
$created = phabricator_datetime($paste->getDateCreated(), $user);
|
||||||
|
|
||||||
$item = id(new PhabricatorObjectItemView())
|
$item = id(new PhabricatorObjectItemView())
|
||||||
->setHeader('P'.$paste->getID().' '.$paste->getTitle())
|
->setHeader($paste->getFullName())
|
||||||
->setHref('/P'.$paste->getID())
|
->setHref('/P'.$paste->getID())
|
||||||
->addDetail(
|
->addDetail(
|
||||||
pht('Author'),
|
pht('Author'),
|
||||||
|
@ -309,8 +309,7 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||||
$list->addItem($item);
|
$list->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$list->setPager($pager);
|
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,32 +44,40 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||||
return new Aphront400Response();
|
return new Aphront400Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$forks = id(new PhabricatorPasteQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withParentPHIDs(array($paste->getPHID()))
|
||||||
|
->execute();
|
||||||
|
$fork_phids = mpull($forks, 'getPHID');
|
||||||
|
|
||||||
$this->loadHandles(
|
$this->loadHandles(
|
||||||
|
array_merge(
|
||||||
array(
|
array(
|
||||||
$paste->getAuthorPHID(),
|
$paste->getAuthorPHID(),
|
||||||
$paste->getParentPHID(),
|
$paste->getParentPHID(),
|
||||||
));
|
),
|
||||||
|
$fork_phids));
|
||||||
|
|
||||||
$header = $this->buildHeaderView($paste);
|
$header = $this->buildHeaderView($paste);
|
||||||
$actions = $this->buildActionView($paste, $file);
|
$actions = $this->buildActionView($paste, $file);
|
||||||
$properties = $this->buildPropertyView($paste);
|
$properties = $this->buildPropertyView($paste, $fork_phids);
|
||||||
$source_code = $this->buildSourceCodeView($paste, $file);
|
$source_code = $this->buildSourceCodeView($paste, $file);
|
||||||
|
|
||||||
$nav = $this->buildSideNavView($paste);
|
$nav = $this->buildSideNavView($paste);
|
||||||
$nav->selectFilter('paste');
|
$nav->selectFilter('paste');
|
||||||
|
|
||||||
$nav->appendChild(
|
$nav->appendChild(
|
||||||
array(
|
array(
|
||||||
$header,
|
$header,
|
||||||
$actions,
|
$actions,
|
||||||
$properties,
|
$properties,
|
||||||
$source_code,
|
$source_code,
|
||||||
// $forks_panel,
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
$nav,
|
||||||
array(
|
array(
|
||||||
'title' => 'P'.$paste->getID().' '.$paste->getTitle(),
|
'title' => $paste->getFullName(),
|
||||||
'device' => true,
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +105,10 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||||
->setHref($file->getBestURI()));
|
->setHref($file->getBestURI()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPropertyView(PhabricatorPaste $paste) {
|
private function buildPropertyView(
|
||||||
|
PhabricatorPaste $paste,
|
||||||
|
array $child_phids) {
|
||||||
|
|
||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
$properties = new PhabricatorPropertyListView();
|
$properties = new PhabricatorPropertyListView();
|
||||||
|
|
||||||
|
@ -115,6 +126,12 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||||
$this->getHandle($paste->getParentPHID())->renderLink());
|
$this->getHandle($paste->getParentPHID())->renderLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($child_phids) {
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Forks'),
|
||||||
|
$this->renderHandleList($child_phids));
|
||||||
|
}
|
||||||
|
|
||||||
return $properties;
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
|
||||||
private $ids;
|
private $ids;
|
||||||
private $phids;
|
private $phids;
|
||||||
private $authorPHIDs;
|
private $authorPHIDs;
|
||||||
|
private $parentPHIDs;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
|
@ -37,6 +38,11 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withParentPHIDs(array $phids) {
|
||||||
|
$this->parentPHIDs = $phids;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function loadPage() {
|
public function loadPage() {
|
||||||
$table = new PhabricatorPaste();
|
$table = new PhabricatorPaste();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn_r = $table->establishConnection('r');
|
||||||
|
@ -80,6 +86,13 @@ final class PhabricatorPasteQuery extends PhabricatorCursorPagedPolicyQuery {
|
||||||
$this->authorPHIDs);
|
$this->authorPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->parentPHIDs) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'parentPHID IN (%Ls)',
|
||||||
|
$this->parentPHIDs);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,4 +51,12 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
|
||||||
return ($user->getPHID() == $this->getAuthorPHID());
|
return ($user->getPHID() == $this->getAuthorPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullName() {
|
||||||
|
$title = $this->getTitle();
|
||||||
|
if (!$title) {
|
||||||
|
$title = 'Untitled Masterwork';
|
||||||
|
}
|
||||||
|
return 'P'.$this->getID().' '.$title;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,11 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device-desktop .phabricator-property-list-view,
|
.device-desktop .phabricator-property-list-view {
|
||||||
.device-tablet .phabricator-property-list-view {
|
|
||||||
padding: 1em 0 0.75em;
|
padding: 1em 0 0.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.device-tablet .phabricator-property-list-view,
|
||||||
.device-phone .phabricator-property-list-view {
|
.device-phone .phabricator-property-list-view {
|
||||||
padding: .5em;
|
padding: .5em;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,6 @@
|
||||||
margin-bottom: .5em;
|
margin-bottom: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.device-tablet .phabricator-property-value,
|
.device-tablet .phabricator-property-value,
|
||||||
.device-phone .phabricator-property-value {
|
.device-phone .phabricator-property-value {
|
||||||
padding-left: 1.5em;
|
padding-left: 1.5em;
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
.phabricator-source-code {
|
.phabricator-source-code {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
padding: 3px 8px;
|
padding: 2px 8px 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.phabricator-source-line {
|
.phabricator-source-line {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 3px 6px 3px 12px;
|
padding: 2px 6px 1px 12px;
|
||||||
|
|
||||||
border-right: 1px solid #dbdbdb;
|
border-right: 1px solid #dbdbdb;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
Loading…
Reference in a new issue