Differential D18523 Diff 44527 src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php
<?php | <?php | ||||
final class DiffusionRepositorySymbolsManagementPanel | final class DiffusionRepositorySymbolsManagementPanel | ||||
extends DiffusionRepositoryManagementPanel { | extends DiffusionRepositoryManagementPanel { | ||||
const PANELKEY = 'symbols'; | const PANELKEY = 'symbols'; | ||||
public function getManagementPanelLabel() { | public function getManagementPanelLabel() { | ||||
return pht('Symbols'); | return pht('Symbols'); | ||||
} | } | ||||
public function getManagementPanelOrder() { | public function getManagementPanelOrder() { | ||||
return 900; | return 900; | ||||
} | } | ||||
public function getManagementPanelIcon() { | public function getManagementPanelIcon() { | ||||
$repository = $this->getRepository(); | return 'fa-bullseye'; | ||||
$has_any = | |||||
$repository->getSymbolLanguages() || | |||||
$repository->getSymbolSources(); | |||||
if ($has_any) { | |||||
return 'fa-link'; | |||||
} else { | |||||
return 'fa-link grey'; | |||||
} | |||||
} | } | ||||
protected function getEditEngineFieldKeys() { | protected function getEditEngineFieldKeys() { | ||||
return array( | return array( | ||||
'symbolLanguages', | 'symbolLanguages', | ||||
'symbolRepositoryPHIDs', | 'symbolRepositoryPHIDs', | ||||
); | ); | ||||
} | } | ||||
public function buildManagementPanelCurtain() { | |||||
$repository = $this->getRepository(); | |||||
$viewer = $this->getViewer(); | |||||
$action_list = $this->getNewActionList(); | |||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$repository, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
$symbols_uri = $this->getEditPageURI(); | |||||
$action_list->addAction( | |||||
id(new PhabricatorActionView()) | |||||
->setIcon('fa-pencil') | |||||
->setName(pht('Edit Symbols')) | |||||
->setHref($symbols_uri) | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit)); | |||||
return $this->getNewCurtainView($action_list); | |||||
} | |||||
public function buildManagementPanelContent() { | public function buildManagementPanelContent() { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$view = id(new PHUIPropertyListView()) | $view = id(new PHUIPropertyListView()) | ||||
->setViewer($viewer); | ->setViewer($viewer); | ||||
$languages = $repository->getSymbolLanguages(); | $languages = $repository->getSymbolLanguages(); | ||||
if ($languages) { | if ($languages) { | ||||
$languages = implode(', ', $languages); | $languages = implode(', ', $languages); | ||||
} else { | } else { | ||||
$languages = phutil_tag('em', array(), pht('Any')); | $languages = phutil_tag('em', array(), pht('Any')); | ||||
} | } | ||||
$view->addProperty(pht('Languages'), $languages); | $view->addProperty(pht('Languages'), $languages); | ||||
$sources = $repository->getSymbolSources(); | $sources = $repository->getSymbolSources(); | ||||
if ($sources) { | if ($sources) { | ||||
$sources = $viewer->renderHandleList($sources); | $sources = $viewer->renderHandleList($sources); | ||||
} else { | } else { | ||||
$sources = phutil_tag('em', array(), pht('This Repository Only')); | $sources = phutil_tag('em', array(), pht('This Repository Only')); | ||||
} | } | ||||
$view->addProperty(pht('Uses Symbols From'), $sources); | $view->addProperty(pht('Uses Symbols From'), $sources); | ||||
return $this->newBox(pht('Symbols'), $view); | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
$viewer, | |||||
$repository, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
$symbols_uri = $this->getEditPageURI(); | |||||
$button = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setIcon('fa-pencil') | |||||
->setText(pht('Edit')) | |||||
->setHref($symbols_uri) | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit); | |||||
return $this->newBox(pht('Symbols'), $view, array($button)); | |||||
} | } | ||||
} | } |