Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/module/PhabricatorConfigCollectorsModule.php
| Show All 11 Lines | final class PhabricatorConfigCollectorsModule extends PhabricatorConfigModule { | ||||
| public function renderModuleStatus(AphrontRequest $request) { | public function renderModuleStatus(AphrontRequest $request) { | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $collectors = PhabricatorGarbageCollector::getAllCollectors(); | $collectors = PhabricatorGarbageCollector::getAllCollectors(); | ||||
| $collectors = msort($collectors, 'getCollectorConstant'); | $collectors = msort($collectors, 'getCollectorConstant'); | ||||
| $rows = array(); | $rows = array(); | ||||
| $rowc = array(); | |||||
| foreach ($collectors as $key => $collector) { | foreach ($collectors as $key => $collector) { | ||||
| $class = null; | |||||
| if ($collector->hasAutomaticPolicy()) { | if ($collector->hasAutomaticPolicy()) { | ||||
| $policy_view = phutil_tag('em', array(), pht('Automatic')); | $policy_view = phutil_tag('em', array(), pht('Automatic')); | ||||
| } else { | } else { | ||||
| $policy = $collector->getDefaultRetentionPolicy(); | $policy = $collector->getRetentionPolicy(); | ||||
| if ($policy === null) { | if ($policy === null) { | ||||
| $policy_view = pht('Indefinite'); | $policy_view = pht('Indefinite'); | ||||
| } else { | } else { | ||||
| $days = ceil($policy / phutil_units('1 day in seconds')); | $days = ceil($policy / phutil_units('1 day in seconds')); | ||||
| $policy_view = pht( | $policy_view = pht( | ||||
| '%s Day(s)', | '%s Day(s)', | ||||
| new PhutilNumber($days)); | new PhutilNumber($days)); | ||||
| } | } | ||||
| $default = $collector->getDefaultRetentionPolicy(); | |||||
| if ($policy !== $default) { | |||||
| $class = 'highlighted'; | |||||
| $policy_view = phutil_tag('strong', array(), $policy_view); | |||||
| } | |||||
| } | } | ||||
| $rowc[] = $class; | |||||
| $rows[] = array( | $rows[] = array( | ||||
| $collector->getCollectorConstant(), | $collector->getCollectorConstant(), | ||||
| $collector->getCollectorName(), | $collector->getCollectorName(), | ||||
| $policy_view, | $policy_view, | ||||
| ); | ); | ||||
| } | } | ||||
| $table = id(new AphrontTableView($rows)) | $table = id(new AphrontTableView($rows)) | ||||
| ->setRowClasses($rowc) | |||||
| ->setHeaders( | ->setHeaders( | ||||
| array( | array( | ||||
| pht('Constant'), | pht('Constant'), | ||||
| pht('Name'), | pht('Name'), | ||||
| pht('Retention Policy'), | pht('Retention Policy'), | ||||
| )) | )) | ||||
| ->setColumnClasses( | ->setColumnClasses( | ||||
| array( | array( | ||||
| null, | null, | ||||
| 'pri wide', | 'pri wide', | ||||
| null, | null, | ||||
| )); | )); | ||||
| $header = id(new PHUIHeaderView()) | |||||
| ->setHeader(pht('Garbage Collectors')) | |||||
| ->setSubheader( | |||||
| pht( | |||||
| 'Collectors with custom policies are highlighted. Use '. | |||||
| '%s to change retention policies.', | |||||
| phutil_tag('tt', array(), 'bin/garbage set-policy'))); | |||||
| return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
| ->setHeaderText(pht('Garbage Collectors')) | ->setHeader($header) | ||||
| ->setTable($table); | ->setTable($table); | ||||
| } | } | ||||
| } | } | ||||