Differential D17238 Diff 41457 src/applications/differential/application/PhabricatorDifferentialApplication.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/application/PhabricatorDifferentialApplication.php
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | final class PhabricatorDifferentialApplication extends PhabricatorApplication { | ||||
} | } | ||||
public function getRemarkupRules() { | public function getRemarkupRules() { | ||||
return array( | return array( | ||||
new DifferentialRemarkupRule(), | new DifferentialRemarkupRule(), | ||||
); | ); | ||||
} | } | ||||
public static function loadNeedAttentionRevisions(PhabricatorUser $viewer) { | |||||
if (!$viewer->isLoggedIn()) { | |||||
return array(); | |||||
} | |||||
$viewer_phid = $viewer->getPHID(); | |||||
$responsible_phids = id(new DifferentialResponsibleDatasource()) | |||||
->setViewer($viewer) | |||||
->evaluateTokens(array($viewer_phid)); | |||||
$revision_query = id(new DifferentialRevisionQuery()) | |||||
->setViewer($viewer) | |||||
->withStatus(DifferentialRevisionQuery::STATUS_OPEN) | |||||
->withResponsibleUsers($responsible_phids) | |||||
->needReviewerStatus(true) | |||||
->needRelationships(true) | |||||
->needFlags(true) | |||||
->needDrafts(true) | |||||
->setLimit(self::MAX_STATUS_ITEMS); | |||||
$revisions = $revision_query->execute(); | |||||
$query = id(new PhabricatorSavedQuery()) | |||||
->attachParameterMap( | |||||
array( | |||||
'responsiblePHIDs' => $responsible_phids, | |||||
)); | |||||
$groups = id(new DifferentialRevisionRequiredActionResultBucket()) | |||||
->setViewer($viewer) | |||||
->newResultGroups($query, $revisions); | |||||
$include = array(); | |||||
foreach ($groups as $group) { | |||||
switch ($group->getKey()) { | |||||
case DifferentialRevisionRequiredActionResultBucket::KEY_MUSTREVIEW: | |||||
case DifferentialRevisionRequiredActionResultBucket::KEY_SHOULDREVIEW: | |||||
foreach ($group->getObjects() as $object) { | |||||
$include[] = $object; | |||||
} | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
return $include; | |||||
} | |||||
public function loadStatus(PhabricatorUser $user) { | |||||
$revisions = self::loadNeedAttentionRevisions($user); | |||||
$limit = self::MAX_STATUS_ITEMS; | |||||
if (count($revisions) >= $limit) { | |||||
$display_count = ($limit - 1); | |||||
$display_label = pht( | |||||
'%s+ Active Review(s)', | |||||
new PhutilNumber($display_count)); | |||||
} else { | |||||
$display_count = count($revisions); | |||||
$display_label = pht( | |||||
'%s Review(s) Need Attention', | |||||
new PhutilNumber($display_count)); | |||||
} | |||||
$status = array(); | |||||
$status[] = id(new PhabricatorApplicationStatusView()) | |||||
->setType(PhabricatorApplicationStatusView::TYPE_WARNING) | |||||
->setText($display_label) | |||||
->setCount($display_count); | |||||
return $status; | |||||
} | |||||
public function supportsEmailIntegration() { | public function supportsEmailIntegration() { | ||||
return true; | return true; | ||||
} | } | ||||
public function getAppEmailBlurb() { | public function getAppEmailBlurb() { | ||||
return pht( | return pht( | ||||
'Send email to these addresses to create revisions. The body of the '. | 'Send email to these addresses to create revisions. The body of the '. | ||||
'message and / or one or more attachments should be the output of a '. | 'message and / or one or more attachments should be the output of a '. | ||||
Show All 39 Lines |