Differential D20495 Diff 48996 src/applications/project/menuitem/PhabricatorProjectReportsProfileMenuItem.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/menuitem/PhabricatorProjectReportsProfileMenuItem.php
- This file was added.
<?php | |||||
final class PhabricatorProjectReportsProfileMenuItem | |||||
extends PhabricatorProfileMenuItem { | |||||
const MENUITEMKEY = 'project.reports'; | |||||
public function getMenuItemTypeName() { | |||||
return pht('Project Reports'); | |||||
} | |||||
private function getDefaultName() { | |||||
return pht('Reports (Prototype)'); | |||||
} | |||||
public function getMenuItemTypeIcon() { | |||||
return 'fa-area-chart'; | |||||
} | |||||
public function canMakeDefault( | |||||
PhabricatorProfileMenuItemConfiguration $config) { | |||||
return true; | |||||
} | |||||
public function shouldEnableForObject($object) { | |||||
$viewer = $this->getViewer(); | |||||
if (!PhabricatorEnv::getEnvConfig('phabricator.show-prototypes')) { | |||||
return false; | |||||
} | |||||
$class = 'PhabricatorManiphestApplication'; | |||||
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
public function getDisplayName( | |||||
PhabricatorProfileMenuItemConfiguration $config) { | |||||
$name = $config->getMenuItemProperty('name'); | |||||
if (strlen($name)) { | |||||
return $name; | |||||
} | |||||
return $this->getDefaultName(); | |||||
} | |||||
public function buildEditEngineFields( | |||||
PhabricatorProfileMenuItemConfiguration $config) { | |||||
return array( | |||||
id(new PhabricatorTextEditField()) | |||||
->setKey('name') | |||||
->setLabel(pht('Name')) | |||||
->setPlaceholder($this->getDefaultName()) | |||||
->setValue($config->getMenuItemProperty('name')), | |||||
); | |||||
} | |||||
protected function newMenuItemViewList( | |||||
PhabricatorProfileMenuItemConfiguration $config) { | |||||
$project = $config->getProfileObject(); | |||||
$id = $project->getID(); | |||||
$uri = $project->getReportsURI(); | |||||
$name = $this->getDisplayName($config); | |||||
$item = $this->newItemView() | |||||
->setURI($uri) | |||||
->setName($name) | |||||
->setIcon('fa-area-chart'); | |||||
return array( | |||||
$item, | |||||
); | |||||
} | |||||
} |