mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 12:12:43 +01:00
61f82bb97b
Summary: This opens up the new action column to have specialized rendering and behavior. Briefly: - Converted applications (right now, only Paste) render a `CurtainView` to build the column content. - This view uses new extensions to build panels (projects, subscribers, tokens). - The panel extension code and rendering can be changed without breaking old stuff. Minor changes: - Token awards now load their tokens, for consistency/simplicity. - Removed the rest of the "fork of" / "forked from" UI in Paste -- I essentially removed these features a while ago, and no one has complained. Test Plan: UI is a bit rough, but works, and it's going to get changed now anyway: {F1160550} {F1160551} Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D15414
117 lines
2.6 KiB
PHP
117 lines
2.6 KiB
PHP
<?php
|
|
|
|
final class PhabricatorTokenGivenQuery
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
private $authorPHIDs;
|
|
private $objectPHIDs;
|
|
private $tokenPHIDs;
|
|
|
|
public function withTokenPHIDs(array $token_phids) {
|
|
$this->tokenPHIDs = $token_phids;
|
|
return $this;
|
|
}
|
|
|
|
public function withObjectPHIDs(array $object_phids) {
|
|
$this->objectPHIDs = $object_phids;
|
|
return $this;
|
|
}
|
|
|
|
public function withAuthorPHIDs(array $author_phids) {
|
|
$this->authorPHIDs = $author_phids;
|
|
return $this;
|
|
}
|
|
|
|
public function newResultObject() {
|
|
return new PhabricatorTokenGiven();
|
|
}
|
|
|
|
protected function loadPage() {
|
|
return $this->loadStandardPage($this->newResultObject());
|
|
}
|
|
|
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
|
$where = parent::buildWhereClauseParts($conn);
|
|
|
|
if ($this->authorPHIDs !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'authorPHID IN (%Ls)',
|
|
$this->authorPHIDs);
|
|
}
|
|
|
|
if ($this->objectPHIDs !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'objectPHID IN (%Ls)',
|
|
$this->objectPHIDs);
|
|
}
|
|
|
|
if ($this->tokenPHIDs !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'tokenPHID IN (%Ls)',
|
|
$this->tokenPHIDs);
|
|
}
|
|
|
|
return $where;
|
|
}
|
|
|
|
protected function willFilterPage(array $results) {
|
|
$viewer = $this->getViewer();
|
|
|
|
$object_phids = mpull($results, 'getObjectPHID');
|
|
|
|
$objects = id(new PhabricatorObjectQuery())
|
|
->setViewer($viewer)
|
|
->withPHIDs($object_phids)
|
|
->execute();
|
|
$objects = mpull($objects, null, 'getPHID');
|
|
|
|
foreach ($results as $key => $result) {
|
|
$object = idx($objects, $result->getObjectPHID());
|
|
|
|
if ($object) {
|
|
if ($object instanceof PhabricatorTokenReceiverInterface) {
|
|
$result->attachObject($object);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
$this->didRejectResult($result);
|
|
unset($results[$key]);
|
|
}
|
|
|
|
if (!$results) {
|
|
return $results;
|
|
}
|
|
|
|
$token_phids = mpull($results, 'getTokenPHID');
|
|
|
|
$tokens = id(new PhabricatorTokenQuery())
|
|
->setViewer($viewer)
|
|
->withPHIDs($token_phids)
|
|
->execute();
|
|
$tokens = mpull($tokens, null, 'getPHID');
|
|
|
|
foreach ($results as $key => $result) {
|
|
$token_phid = $result->getTokenPHID();
|
|
|
|
$token = idx($tokens, $token_phid);
|
|
if (!$token) {
|
|
$this->didRejectResult($result);
|
|
unset($results[$key]);
|
|
continue;
|
|
}
|
|
|
|
$result->attachToken($token);
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
public function getQueryApplicationClass() {
|
|
return 'PhabricatorTokensApplication';
|
|
}
|
|
|
|
}
|