mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Move more rendering into SearchEngines for panels
Summary: Ref T4986. Getting closer. Nothing out of the ordinary in this group. Test Plan: For each application: - Viewed the normal search results. - Created a panel version and viewed it. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9024
This commit is contained in:
parent
78b89711cb
commit
352d9f6b06
26 changed files with 601 additions and 601 deletions
|
@ -3507,11 +3507,7 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'HeraldTranscriptController' => 'HeraldController',
|
||||
'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector',
|
||||
'HeraldTranscriptListController' =>
|
||||
array(
|
||||
0 => 'HeraldController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'HeraldTranscriptListController' => 'HeraldController',
|
||||
'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'HeraldTranscriptTestCase' => 'PhabricatorTestCase',
|
||||
|
@ -3538,11 +3534,7 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentCommentController' => 'LegalpadController',
|
||||
'LegalpadDocumentEditController' => 'LegalpadController',
|
||||
'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'LegalpadDocumentListController' =>
|
||||
array(
|
||||
0 => 'LegalpadController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'LegalpadDocumentListController' => 'LegalpadController',
|
||||
'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'LegalpadDocumentRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
||||
'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
@ -3777,11 +3769,7 @@ phutil_register_library_map(array(
|
|||
'PassphraseCredentialCreateController' => 'PassphraseController',
|
||||
'PassphraseCredentialDestroyController' => 'PassphraseController',
|
||||
'PassphraseCredentialEditController' => 'PassphraseController',
|
||||
'PassphraseCredentialListController' =>
|
||||
array(
|
||||
0 => 'PassphraseController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PassphraseCredentialListController' => 'PassphraseController',
|
||||
'PassphraseCredentialLockController' => 'PassphraseController',
|
||||
'PassphraseCredentialPublicController' => 'PassphraseController',
|
||||
'PassphraseCredentialQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
@ -3931,11 +3919,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorApplicationXHProf' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationsController' => 'PhabricatorController',
|
||||
'PhabricatorApplicationsListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorApplicationsController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorAsanaConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
||||
'PhabricatorAuditComment' =>
|
||||
|
@ -4456,11 +4440,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMacroDisableController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroEditController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorMacroListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorMacroController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorMacroListController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PhabricatorMacroMemeController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController',
|
||||
|
@ -4493,11 +4473,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorMailingListsController' => 'PhabricatorController',
|
||||
'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController',
|
||||
'PhabricatorMailingListsListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorMailingListsController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController',
|
||||
'PhabricatorMainMenuGroupView' => 'AphrontView',
|
||||
'PhabricatorMainMenuIconView' => 'AphrontView',
|
||||
'PhabricatorMainMenuSearchView' => 'AphrontView',
|
||||
|
@ -4560,11 +4536,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOAuthClientBaseController' => 'PhabricatorOAuthServerController',
|
||||
'PhabricatorOAuthClientDeleteController' => 'PhabricatorOAuthClientBaseController',
|
||||
'PhabricatorOAuthClientEditController' => 'PhabricatorOAuthClientBaseController',
|
||||
'PhabricatorOAuthClientListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorOAuthClientBaseController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientBaseController',
|
||||
'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientBaseController',
|
||||
'PhabricatorOAuthResponse' => 'AphrontResponse',
|
||||
'PhabricatorOAuthServerAccessToken' => 'PhabricatorOAuthServerDAO',
|
||||
|
@ -4758,11 +4730,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectEditMainController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorProjectListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorProjectController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorProjectListController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
|
||||
|
@ -5278,11 +5246,7 @@ phutil_register_library_map(array(
|
|||
'PholioMockEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PholioMockEmbedView' => 'AphrontView',
|
||||
'PholioMockImagesView' => 'AphrontView',
|
||||
'PholioMockListController' =>
|
||||
array(
|
||||
0 => 'PholioController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PholioMockListController' => 'PholioController',
|
||||
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
@ -5396,11 +5360,7 @@ phutil_register_library_map(array(
|
|||
'PhragmentZIPController' => 'PhragmentController',
|
||||
'PhrequentController' => 'PhabricatorController',
|
||||
'PhrequentDAO' => 'PhabricatorLiskDAO',
|
||||
'PhrequentListController' =>
|
||||
array(
|
||||
0 => 'PhrequentController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhrequentListController' => 'PhrequentController',
|
||||
'PhrequentSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhrequentTimeBlock' => 'Phobject',
|
||||
'PhrequentTimeBlockTestCase' => 'PhabricatorTestCase',
|
||||
|
@ -5440,11 +5400,7 @@ phutil_register_library_map(array(
|
|||
'PhrictionDocumentTestCase' => 'PhabricatorTestCase',
|
||||
'PhrictionEditController' => 'PhrictionController',
|
||||
'PhrictionHistoryController' => 'PhrictionController',
|
||||
'PhrictionListController' =>
|
||||
array(
|
||||
0 => 'PhrictionController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhrictionListController' => 'PhrictionController',
|
||||
'PhrictionMoveController' => 'PhrictionController',
|
||||
'PhrictionNewController' => 'PhrictionController',
|
||||
'PhrictionPHIDTypeDocument' => 'PhabricatorPHIDType',
|
||||
|
@ -5496,11 +5452,7 @@ phutil_register_library_map(array(
|
|||
'PonderQuestionEditController' => 'PonderController',
|
||||
'PonderQuestionEditor' => 'PonderEditor',
|
||||
'PonderQuestionHistoryController' => 'PonderController',
|
||||
'PonderQuestionListController' =>
|
||||
array(
|
||||
0 => 'PonderController',
|
||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PonderQuestionListController' => 'PonderController',
|
||||
'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PonderQuestionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PonderQuestionReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class HeraldTranscriptListController extends HeraldController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class HeraldTranscriptListController extends HeraldController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -47,49 +46,4 @@ final class HeraldTranscriptListController extends HeraldController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
|
||||
public function renderResultsList(
|
||||
array $transcripts,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($transcripts, 'HeraldTranscript');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
// Render the table.
|
||||
$handles = array();
|
||||
if ($transcripts) {
|
||||
$phids = mpull($transcripts, 'getObjectPHID', 'getObjectPHID');
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
}
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setCards(true);
|
||||
foreach ($transcripts as $xscript) {
|
||||
$view_href = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/herald/transcript/'.$xscript->getID().'/',
|
||||
),
|
||||
pht('View Full Transcript'));
|
||||
|
||||
$item = new PHUIObjectItemView();
|
||||
$item->setObjectName($xscript->getID());
|
||||
$item->setHeader($view_href);
|
||||
if ($xscript->getDryRun()) {
|
||||
$item->addAttribute(pht('Dry Run'));
|
||||
}
|
||||
$item->addAttribute($handles[$xscript->getObjectPHID()]->renderLink());
|
||||
$item->addAttribute(
|
||||
number_format((int)(1000 * $xscript->getDuration())).' ms');
|
||||
$item->addIcon(
|
||||
'none',
|
||||
phabricator_datetime($xscript->getTime(), $viewer));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class HeraldTranscriptSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationHerald';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
|
@ -89,4 +93,47 @@ final class HeraldTranscriptSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $transcripts,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($transcripts, 'getObjectPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $transcripts,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($transcripts, 'HeraldTranscript');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setCards(true);
|
||||
foreach ($transcripts as $xscript) {
|
||||
$view_href = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/herald/transcript/'.$xscript->getID().'/',
|
||||
),
|
||||
pht('View Full Transcript'));
|
||||
|
||||
$item = new PHUIObjectItemView();
|
||||
$item->setObjectName($xscript->getID());
|
||||
$item->setHeader($view_href);
|
||||
if ($xscript->getDryRun()) {
|
||||
$item->addAttribute(pht('Dry Run'));
|
||||
}
|
||||
$item->addAttribute($handles[$xscript->getObjectPHID()]->renderLink());
|
||||
$item->addAttribute(
|
||||
number_format((int)(1000 * $xscript->getDuration())).' ms');
|
||||
$item->addIcon(
|
||||
'none',
|
||||
phabricator_datetime($xscript->getTime(), $viewer));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group legalpad
|
||||
*/
|
||||
final class LegalpadDocumentListController extends LegalpadController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class LegalpadDocumentListController extends LegalpadController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -22,39 +18,4 @@ final class LegalpadDocumentListController extends LegalpadController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($documents, 'LegalpadDocument');
|
||||
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$contributors = array_mergev(
|
||||
mpull($documents, 'getRecentContributorPHIDs'));
|
||||
$this->loadHandles($contributors);
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($user);
|
||||
foreach ($documents as $document) {
|
||||
$last_updated = phabricator_date($document->getDateModified(), $user);
|
||||
$recent_contributors = $document->getRecentContributorPHIDs();
|
||||
$updater = $this->getHandle(reset($recent_contributors))->renderLink();
|
||||
|
||||
$title = $document->getTitle();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('L'.$document->getID())
|
||||
->setHeader($title)
|
||||
->setHref($this->getApplicationURI('view/'.$document->getID()))
|
||||
->setObject($document)
|
||||
->addIcon('none', pht('Last updated: %s', $last_updated))
|
||||
->addByline(pht('Updated by: %s', $updater))
|
||||
->addAttribute(pht('Versions: %d', $document->getVersions()));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group legalpad
|
||||
*/
|
||||
final class LegalpadDocumentSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationLegalpad';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter(
|
||||
|
@ -103,4 +104,42 @@ final class LegalpadDocumentSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return array_mergev(mpull($documents, 'getRecentContributorPHIDs'));
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($documents, 'LegalpadDocument');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($documents as $document) {
|
||||
$last_updated = phabricator_date($document->getDateModified(), $viewer);
|
||||
$recent_contributors = $document->getRecentContributorPHIDs();
|
||||
$updater = $handles[reset($recent_contributors)]->renderLink();
|
||||
|
||||
$title = $document->getTitle();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('L'.$document->getID())
|
||||
->setHeader($title)
|
||||
->setHref($this->getApplicationURI('view/'.$document->getID()))
|
||||
->setObject($document)
|
||||
->addIcon('none', pht('Last updated: %s', $last_updated))
|
||||
->addByline(pht('Updated by: %s', $updater))
|
||||
->addAttribute(pht('Versions: %d', $document->getVersions()));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMacroListController extends PhabricatorMacroController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class PhabricatorMacroListController extends PhabricatorMacroController {
|
||||
|
||||
private $key;
|
||||
|
||||
|
@ -23,64 +22,4 @@ final class PhabricatorMacroListController extends PhabricatorMacroController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $macros,
|
||||
PhabricatorSavedQuery $query) {
|
||||
|
||||
assert_instances_of($macros, 'PhabricatorFileImageMacro');
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$author_phids = mpull($macros, 'getAuthorPHID', 'getAuthorPHID');
|
||||
$this->loadHandles($author_phids);
|
||||
$author_handles = array_select_keys(
|
||||
$this->getLoadedHandles(),
|
||||
$author_phids);
|
||||
|
||||
$pinboard = new PHUIPinboardView();
|
||||
foreach ($macros as $macro) {
|
||||
$file = $macro->getFile();
|
||||
|
||||
$item = new PHUIPinboardItemView();
|
||||
if ($file) {
|
||||
$item->setImageURI($file->getThumb280x210URI());
|
||||
$item->setImageSize(280, 210);
|
||||
}
|
||||
|
||||
if ($macro->getDateCreated()) {
|
||||
$datetime = phabricator_date($macro->getDateCreated(), $viewer);
|
||||
$item->appendChild(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(),
|
||||
pht('Created on %s', $datetime)));
|
||||
} else {
|
||||
// Very old macros don't have a creation date. Rendering something
|
||||
// keeps all the pins at the same height and avoids flow issues.
|
||||
$item->appendChild(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(),
|
||||
pht('Created in ages long past')));
|
||||
}
|
||||
|
||||
if ($macro->getAuthorPHID()) {
|
||||
$author_handle = $this->getHandle($macro->getAuthorPHID());
|
||||
$item->appendChild(
|
||||
pht('Created by %s', $author_handle->renderLink()));
|
||||
}
|
||||
|
||||
$item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/'));
|
||||
|
||||
$name = $macro->getName();
|
||||
if ($macro->getIsDisabled()) {
|
||||
$name = pht('%s (Disabled)', $name);
|
||||
}
|
||||
$item->setHeader($name);
|
||||
|
||||
$pinboard->addItem($item);
|
||||
}
|
||||
|
||||
return $pinboard;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorMacroSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationMacro';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter(
|
||||
|
@ -153,4 +157,65 @@ final class PhabricatorMacroSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $macros,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($macros, 'getAuthorPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $macros,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
|
||||
assert_instances_of($macros, 'PhabricatorFileImageMacro');
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$pinboard = new PHUIPinboardView();
|
||||
foreach ($macros as $macro) {
|
||||
$file = $macro->getFile();
|
||||
|
||||
$item = new PHUIPinboardItemView();
|
||||
if ($file) {
|
||||
$item->setImageURI($file->getThumb280x210URI());
|
||||
$item->setImageSize(280, 210);
|
||||
}
|
||||
|
||||
if ($macro->getDateCreated()) {
|
||||
$datetime = phabricator_date($macro->getDateCreated(), $viewer);
|
||||
$item->appendChild(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(),
|
||||
pht('Created on %s', $datetime)));
|
||||
} else {
|
||||
// Very old macros don't have a creation date. Rendering something
|
||||
// keeps all the pins at the same height and avoids flow issues.
|
||||
$item->appendChild(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(),
|
||||
pht('Created in ages long past')));
|
||||
}
|
||||
|
||||
if ($macro->getAuthorPHID()) {
|
||||
$author_handle = $handles[$macro->getAuthorPHID()];
|
||||
$item->appendChild(
|
||||
pht('Created by %s', $author_handle->renderLink()));
|
||||
}
|
||||
|
||||
$item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/'));
|
||||
|
||||
$name = $macro->getName();
|
||||
if ($macro->getIsDisabled()) {
|
||||
$name = pht('%s (Disabled)', $name);
|
||||
}
|
||||
$item->setHeader($name);
|
||||
|
||||
$pinboard->addItem($item);
|
||||
}
|
||||
|
||||
return $pinboard;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMailingListsListController
|
||||
extends PhabricatorMailingListsController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhabricatorMailingListsController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -24,28 +23,4 @@ final class PhabricatorMailingListsListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $lists,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($lists, 'PhabricatorMetaMTAMailingList');
|
||||
|
||||
$view = id(new PHUIObjectItemListView());
|
||||
|
||||
foreach ($lists as $list) {
|
||||
$item = new PHUIObjectItemView();
|
||||
|
||||
$item->setHeader($list->getName());
|
||||
$item->setHref($list->getURI());
|
||||
$item->addAttribute($list->getEmail());
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('edit')
|
||||
->setHref($this->getApplicationURI('/edit/'.$list->getID().'/')));
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorMailingListSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationMailingLists';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
|
@ -51,4 +55,29 @@ final class PhabricatorMailingListSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $lists,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($lists, 'PhabricatorMetaMTAMailingList');
|
||||
|
||||
$view = id(new PHUIObjectItemListView());
|
||||
|
||||
foreach ($lists as $list) {
|
||||
$item = new PHUIObjectItemView();
|
||||
|
||||
$item->setHeader($list->getName());
|
||||
$item->setHref($list->getURI());
|
||||
$item->addAttribute($list->getEmail());
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('edit')
|
||||
->setHref($this->getApplicationURI('/edit/'.$list->getID().'/')));
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorApplicationsListController
|
||||
extends PhabricatorApplicationsController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhabricatorApplicationsController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -20,33 +19,4 @@ final class PhabricatorApplicationsListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $applications,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($applications, 'PhabricatorApplication');
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
|
||||
$applications = msort($applications, 'getName');
|
||||
|
||||
foreach ($applications as $application) {
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($application->getName())
|
||||
->setHref('/applications/view/'.get_class($application).'/')
|
||||
->addAttribute($application->getShortDescription());
|
||||
|
||||
if (!$application->isInstalled()) {
|
||||
$item->addIcon('delete', pht('Uninstalled'));
|
||||
}
|
||||
|
||||
if ($application->isBeta()) {
|
||||
$item->addIcon('lint-warning', pht('Beta'));
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorAppSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationApplications';
|
||||
}
|
||||
|
||||
public function getPageSize(PhabricatorSavedQuery $saved) {
|
||||
return INF;
|
||||
}
|
||||
|
@ -124,4 +128,34 @@ final class PhabricatorAppSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $applications,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handle) {
|
||||
assert_instances_of($applications, 'PhabricatorApplication');
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
|
||||
$applications = msort($applications, 'getName');
|
||||
|
||||
foreach ($applications as $application) {
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($application->getName())
|
||||
->setHref('/applications/view/'.get_class($application).'/')
|
||||
->addAttribute($application->getShortDescription());
|
||||
|
||||
if (!$application->isInstalled()) {
|
||||
$item->addIcon('delete', pht('Uninstalled'));
|
||||
}
|
||||
|
||||
if ($application->isBeta()) {
|
||||
$item->addIcon('lint-warning', pht('Beta'));
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorOAuthClientListController
|
||||
extends PhabricatorOAuthClientBaseController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhabricatorOAuthClientBaseController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -24,32 +23,6 @@ final class PhabricatorOAuthClientListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $clients,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($clients, 'PhabricatorOauthServerClient');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
$this->loadHandles(mpull($clients, 'getCreatorPHID'));
|
||||
|
||||
$list = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
foreach ($clients as $client) {
|
||||
$creator = $this->getHandle($client->getCreatorPHID());
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Application %d', $client->getID()))
|
||||
->setHeader($client->getName())
|
||||
->setHref($client->getViewURI())
|
||||
->setObject($client)
|
||||
->addByline(pht('Creator: %s', $creator->renderLink()));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorOAuthServerClientSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationOAuthServer';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
|
@ -76,4 +80,37 @@ final class PhabricatorOAuthServerClientSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $clients,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($clients, 'getCreatorPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $clients,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($clients, 'PhabricatorOauthServerClient');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
foreach ($clients as $client) {
|
||||
$creator = $handles[$client->getCreatorPHID()];
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Application %d', $client->getID()))
|
||||
->setHeader($client->getName())
|
||||
->setHref($client->getViewURI())
|
||||
->setObject($client)
|
||||
->addByline(pht('Creator: %s', $creator->renderLink()));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PassphraseCredentialListController extends PassphraseController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class PassphraseCredentialListController extends PassphraseController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -23,41 +22,4 @@ final class PassphraseCredentialListController extends PassphraseController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $credentials,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($credentials, 'PassphraseCredential');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($credentials as $credential) {
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('K'.$credential->getID())
|
||||
->setHeader($credential->getName())
|
||||
->setHref('/K'.$credential->getID())
|
||||
->setObject($credential);
|
||||
|
||||
$item->addAttribute(
|
||||
pht('Login: %s', $credential->getUsername()));
|
||||
|
||||
if ($credential->getIsDestroyed()) {
|
||||
$item->addIcon('disable', pht('Destroyed'));
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
$type = PassphraseCredentialType::getTypeByConstant(
|
||||
$credential->getCredentialType());
|
||||
if ($type) {
|
||||
$item->addIcon('wrench', $type->getCredentialTypeName());
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PassphraseCredentialSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationPassphrase';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
|
@ -70,4 +74,43 @@ final class PassphraseCredentialSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $credentials,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($credentials, 'PassphraseCredential');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($credentials as $credential) {
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName('K'.$credential->getID())
|
||||
->setHeader($credential->getName())
|
||||
->setHref('/K'.$credential->getID())
|
||||
->setObject($credential);
|
||||
|
||||
$item->addAttribute(
|
||||
pht('Login: %s', $credential->getUsername()));
|
||||
|
||||
if ($credential->getIsDestroyed()) {
|
||||
$item->addIcon('disable', pht('Destroyed'));
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
$type = PassphraseCredentialType::getTypeByConstant(
|
||||
$credential->getCredentialType());
|
||||
if ($type) {
|
||||
$item->addIcon('wrench', $type->getCredentialTypeName());
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PhabricatorApplicationPholio extends PhabricatorApplication {
|
||||
|
||||
public function getBaseURI() {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PholioMockListController
|
||||
extends PholioController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class PholioMockListController extends PholioController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -24,40 +22,4 @@ final class PholioMockListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $mocks,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($mocks, 'PholioMock');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$author_phids = array();
|
||||
foreach ($mocks as $mock) {
|
||||
$author_phids[] = $mock->getAuthorPHID();
|
||||
}
|
||||
$this->loadHandles($author_phids);
|
||||
|
||||
$board = new PHUIPinboardView();
|
||||
foreach ($mocks as $mock) {
|
||||
$item = id(new PHUIPinboardItemView())
|
||||
->setHeader('M'.$mock->getID().' '.$mock->getName())
|
||||
->setURI('/M'.$mock->getID())
|
||||
->setImageURI($mock->getCoverFile()->getThumb280x210URI())
|
||||
->setImageSize(280, 210)
|
||||
->addIconCount('image', count($mock->getImages()))
|
||||
->addIconCount('like', $mock->getTokenCount());
|
||||
|
||||
if ($mock->getAuthorPHID()) {
|
||||
$author_handle = $this->getHandle($mock->getAuthorPHID());
|
||||
$datetime = phabricator_date($mock->getDateCreated(), $viewer);
|
||||
$item->appendChild(
|
||||
pht('By %s on %s', $author_handle->renderLink(), $datetime));
|
||||
}
|
||||
|
||||
$board->addItem($item);
|
||||
}
|
||||
|
||||
return $board;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PholioMockSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationPholio';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter(
|
||||
|
@ -74,4 +78,41 @@ final class PholioMockSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $mocks,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($mocks, 'getAuthorPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $mocks,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($mocks, 'PholioMock');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$board = new PHUIPinboardView();
|
||||
foreach ($mocks as $mock) {
|
||||
$item = id(new PHUIPinboardItemView())
|
||||
->setHeader('M'.$mock->getID().' '.$mock->getName())
|
||||
->setURI('/M'.$mock->getID())
|
||||
->setImageURI($mock->getCoverFile()->getThumb280x210URI())
|
||||
->setImageSize(280, 210)
|
||||
->addIconCount('image', count($mock->getImages()))
|
||||
->addIconCount('like', $mock->getTokenCount());
|
||||
|
||||
if ($mock->getAuthorPHID()) {
|
||||
$author_handle = $handles[$mock->getAuthorPHID()];
|
||||
$datetime = phabricator_date($mock->getDateCreated(), $viewer);
|
||||
$item->appendChild(
|
||||
pht('By %s on %s', $author_handle->renderLink(), $datetime));
|
||||
}
|
||||
|
||||
$board->addItem($item);
|
||||
}
|
||||
|
||||
return $board;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhrequentListController extends PhrequentController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class PhrequentListController extends PhrequentController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -23,86 +22,4 @@ final class PhrequentListController extends PhrequentController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $usertimes,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($usertimes, 'PhrequentUserTime');
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$phids = array();
|
||||
$phids[] = mpull($usertimes, 'getUserPHID');
|
||||
$phids[] = mpull($usertimes, 'getObjectPHID');
|
||||
$phids = array_mergev($phids);
|
||||
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$view = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
|
||||
foreach ($usertimes as $usertime) {
|
||||
$item = new PHUIObjectItemView();
|
||||
|
||||
if ($usertime->getObjectPHID() === null) {
|
||||
$item->setHeader($usertime->getNote());
|
||||
} else {
|
||||
$obj = $handles[$usertime->getObjectPHID()];
|
||||
$item->setHeader($obj->getLinkName());
|
||||
$item->setHref($obj->getURI());
|
||||
}
|
||||
$item->setObject($usertime);
|
||||
|
||||
$item->addByline(
|
||||
pht(
|
||||
'Tracked: %s',
|
||||
$handles[$usertime->getUserPHID()]->renderLink()));
|
||||
|
||||
$started_date = phabricator_date($usertime->getDateStarted(), $viewer);
|
||||
$item->addIcon('none', $started_date);
|
||||
|
||||
if ($usertime->getDateEnded() !== null) {
|
||||
$time_spent = $usertime->getDateEnded() - $usertime->getDateStarted();
|
||||
$time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer);
|
||||
} else {
|
||||
$time_spent = time() - $usertime->getDateStarted();
|
||||
}
|
||||
|
||||
$time_spent = $time_spent == 0 ? 'none' :
|
||||
phabricator_format_relative_time_detailed($time_spent);
|
||||
|
||||
if ($usertime->getDateEnded() !== null) {
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Tracked %s',
|
||||
$time_spent));
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Ended on %s',
|
||||
$time_ended));
|
||||
} else {
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Tracked %s so far',
|
||||
$time_spent));
|
||||
if ($usertime->getObjectPHID() !== null &&
|
||||
$usertime->getUserPHID() === $viewer->getPHID()) {
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('history')
|
||||
->addSigil('phrequent-stop-tracking')
|
||||
->setWorkflow(true)
|
||||
->setRenderNameAsTooltip(true)
|
||||
->setName(pht("Stop"))
|
||||
->setHref(
|
||||
'/phrequent/track/stop/'.
|
||||
$usertime->getObjectPHID().'/'));
|
||||
}
|
||||
$item->setBarColor('green');
|
||||
}
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhrequentSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationPhrequent';
|
||||
}
|
||||
|
||||
public function getPageSize(PhabricatorSavedQuery $saved) {
|
||||
return $saved->getParameter('limit', 1000);
|
||||
}
|
||||
|
@ -110,4 +114,89 @@ final class PhrequentSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $usertimes,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return array_mergev(
|
||||
array(
|
||||
mpull($usertimes, 'getUserPHID'),
|
||||
mpull($usertimes, 'getObjectPHID'),
|
||||
));
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $usertimes,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($usertimes, 'PhrequentUserTime');
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$view = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
|
||||
foreach ($usertimes as $usertime) {
|
||||
$item = new PHUIObjectItemView();
|
||||
|
||||
if ($usertime->getObjectPHID() === null) {
|
||||
$item->setHeader($usertime->getNote());
|
||||
} else {
|
||||
$obj = $handles[$usertime->getObjectPHID()];
|
||||
$item->setHeader($obj->getLinkName());
|
||||
$item->setHref($obj->getURI());
|
||||
}
|
||||
$item->setObject($usertime);
|
||||
|
||||
$item->addByline(
|
||||
pht(
|
||||
'Tracked: %s',
|
||||
$handles[$usertime->getUserPHID()]->renderLink()));
|
||||
|
||||
$started_date = phabricator_date($usertime->getDateStarted(), $viewer);
|
||||
$item->addIcon('none', $started_date);
|
||||
|
||||
if ($usertime->getDateEnded() !== null) {
|
||||
$time_spent = $usertime->getDateEnded() - $usertime->getDateStarted();
|
||||
$time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer);
|
||||
} else {
|
||||
$time_spent = time() - $usertime->getDateStarted();
|
||||
}
|
||||
|
||||
$time_spent = $time_spent == 0 ? 'none' :
|
||||
phabricator_format_relative_time_detailed($time_spent);
|
||||
|
||||
if ($usertime->getDateEnded() !== null) {
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Tracked %s',
|
||||
$time_spent));
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Ended on %s',
|
||||
$time_ended));
|
||||
} else {
|
||||
$item->addAttribute(
|
||||
pht(
|
||||
'Tracked %s so far',
|
||||
$time_spent));
|
||||
if ($usertime->getObjectPHID() !== null &&
|
||||
$usertime->getUserPHID() === $viewer->getPHID()) {
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('history')
|
||||
->addSigil('phrequent-stop-tracking')
|
||||
->setWorkflow(true)
|
||||
->setRenderNameAsTooltip(true)
|
||||
->setName(pht("Stop"))
|
||||
->setHref(
|
||||
'/phrequent/track/stop/'.
|
||||
$usertime->getObjectPHID().'/'));
|
||||
}
|
||||
$item->setBarColor('green');
|
||||
}
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhrictionListController
|
||||
extends PhrictionController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhrictionController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -24,68 +23,4 @@ final class PhrictionListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($documents, 'PhrictionDocument');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$phids = array();
|
||||
foreach ($documents as $document) {
|
||||
$content = $document->getContent();
|
||||
if ($document->hasProject()) {
|
||||
$phids[] = $document->getProject()->getPHID();
|
||||
}
|
||||
$phids[] = $content->getAuthorPHID();
|
||||
}
|
||||
|
||||
$this->loadHandles($phids);
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($documents as $document) {
|
||||
$content = $document->getContent();
|
||||
$slug = $document->getSlug();
|
||||
$author_phid = $content->getAuthorPHID();
|
||||
$slug_uri = PhrictionDocument::getSlugURI($slug);
|
||||
|
||||
$byline = pht(
|
||||
'Edited by %s',
|
||||
$this->getHandle($author_phid)->renderLink());
|
||||
|
||||
$updated = phabricator_datetime(
|
||||
$content->getDateCreated(),
|
||||
$viewer);
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($content->getTitle())
|
||||
->setHref($slug_uri)
|
||||
->addByline($byline)
|
||||
->addIcon('none', $updated);
|
||||
|
||||
if ($document->hasProject()) {
|
||||
$item->addAttribute(
|
||||
$this->getHandle($document->getProject()->getPHID())->renderLink());
|
||||
}
|
||||
|
||||
$item->addAttribute($slug_uri);
|
||||
|
||||
switch ($document->getStatus()) {
|
||||
case PhrictionDocumentStatus::STATUS_DELETED:
|
||||
$item->setDisabled(true);
|
||||
$item->addIcon('delete', pht('Deleted'));
|
||||
break;
|
||||
case PhrictionDocumentStatus::STATUS_MOVED:
|
||||
$item->setDisabled(true);
|
||||
$item->addIcon('arrow-right', pht('Moved Away'));
|
||||
break;
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,4 +109,75 @@ final class PhrictionSearchEngine
|
|||
);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query) {
|
||||
|
||||
$phids = array();
|
||||
foreach ($documents as $document) {
|
||||
$content = $document->getContent();
|
||||
if ($document->hasProject()) {
|
||||
$phids[] = $document->getProject()->getPHID();
|
||||
}
|
||||
$phids[] = $content->getAuthorPHID();
|
||||
}
|
||||
|
||||
return $phids;
|
||||
}
|
||||
|
||||
|
||||
protected function renderResultList(
|
||||
array $documents,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($documents, 'PhrictionDocument');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($documents as $document) {
|
||||
$content = $document->getContent();
|
||||
$slug = $document->getSlug();
|
||||
$author_phid = $content->getAuthorPHID();
|
||||
$slug_uri = PhrictionDocument::getSlugURI($slug);
|
||||
|
||||
$byline = pht(
|
||||
'Edited by %s',
|
||||
$handles[$author_phid]->renderLink());
|
||||
|
||||
$updated = phabricator_datetime(
|
||||
$content->getDateCreated(),
|
||||
$viewer);
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($content->getTitle())
|
||||
->setHref($slug_uri)
|
||||
->addByline($byline)
|
||||
->addIcon('none', $updated);
|
||||
|
||||
if ($document->hasProject()) {
|
||||
$item->addAttribute(
|
||||
$handles[$document->getProject()->getPHID()]->renderLink());
|
||||
}
|
||||
|
||||
$item->addAttribute($slug_uri);
|
||||
|
||||
switch ($document->getStatus()) {
|
||||
case PhrictionDocumentStatus::STATUS_DELETED:
|
||||
$item->setDisabled(true);
|
||||
$item->addIcon('delete', pht('Deleted'));
|
||||
break;
|
||||
case PhrictionDocumentStatus::STATUS_MOVED:
|
||||
$item->setDisabled(true);
|
||||
$item->addIcon('arrow-right', pht('Moved Away'));
|
||||
break;
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PonderQuestionListController extends PonderController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
final class PonderQuestionListController extends PonderController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -23,46 +22,4 @@ final class PonderQuestionListController extends PonderController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $questions,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($questions, 'PonderQuestion');
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$phids = array();
|
||||
$phids[] = mpull($questions, 'getAuthorPHID');
|
||||
$phids = array_mergev($phids);
|
||||
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
|
||||
$view = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
|
||||
foreach ($questions as $question) {
|
||||
$item = new PHUIObjectItemView();
|
||||
$item->setObjectName('Q'.$question->getID());
|
||||
$item->setHeader($question->getTitle());
|
||||
$item->setHref('/Q'.$question->getID());
|
||||
$item->setObject($question);
|
||||
$item->setBarColor(
|
||||
PonderQuestionStatus::getQuestionStatusTagColor(
|
||||
$question->getStatus()));
|
||||
|
||||
$created_date = phabricator_date($question->getDateCreated(), $viewer);
|
||||
$item->addIcon('none', $created_date);
|
||||
$item->addByline(
|
||||
pht(
|
||||
'Asked by %s',
|
||||
$handles[$question->getAuthorPHID()]->renderLink()));
|
||||
|
||||
$item->addAttribute(
|
||||
pht('%d Answer(s)', $question->getAnswerCount()));
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PonderQuestionSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationPonder';
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
|
@ -124,4 +128,47 @@ final class PonderQuestionSearchEngine
|
|||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function getRequiredHandlePHIDsForResultList(
|
||||
array $questions,
|
||||
PhabricatorSavedQuery $query) {
|
||||
return mpull($questions, 'getAuthorPHID');
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $questions,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($questions, 'PonderQuestion');
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$view = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
|
||||
foreach ($questions as $question) {
|
||||
$item = new PHUIObjectItemView();
|
||||
$item->setObjectName('Q'.$question->getID());
|
||||
$item->setHeader($question->getTitle());
|
||||
$item->setHref('/Q'.$question->getID());
|
||||
$item->setObject($question);
|
||||
$item->setBarColor(
|
||||
PonderQuestionStatus::getQuestionStatusTagColor(
|
||||
$question->getStatus()));
|
||||
|
||||
$created_date = phabricator_date($question->getDateCreated(), $viewer);
|
||||
$item->addIcon('none', $created_date);
|
||||
$item->addByline(
|
||||
pht(
|
||||
'Asked by %s',
|
||||
$handles[$question->getAuthorPHID()]->renderLink()));
|
||||
|
||||
$item->addAttribute(
|
||||
pht('%d Answer(s)', $question->getAnswerCount()));
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectListController
|
||||
extends PhabricatorProjectController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
|
@ -24,33 +23,6 @@ final class PhabricatorProjectListController
|
|||
return $this->delegateToController($controller);
|
||||
}
|
||||
|
||||
public function renderResultsList(
|
||||
array $projects,
|
||||
PhabricatorSavedQuery $query) {
|
||||
assert_instances_of($projects, 'PhabricatorProject');
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($projects as $project) {
|
||||
$id = $project->getID();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($project->getName())
|
||||
->setHref($this->getApplicationURI("view/{$id}/"))
|
||||
->setImageURI($project->getProfileImageURI());
|
||||
|
||||
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
|
||||
$item->addIcon('delete-grey', pht('Archived'));
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorProjectSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorApplicationProject';
|
||||
}
|
||||
|
||||
public function getCustomFieldObject() {
|
||||
return new PhabricatorProject();
|
||||
}
|
||||
|
@ -122,4 +126,32 @@ final class PhabricatorProjectSearchEngine
|
|||
);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $projects,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
assert_instances_of($projects, 'PhabricatorProject');
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
foreach ($projects as $project) {
|
||||
$id = $project->getID();
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($project->getName())
|
||||
->setHref($this->getApplicationURI("view/{$id}/"))
|
||||
->setImageURI($project->getProfileImageURI());
|
||||
|
||||
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
|
||||
$item->addIcon('delete-grey', pht('Archived'));
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue