Differential D19826 Diff 47381 src/applications/diffusion/management/DiffusionRepositoryActionsManagementPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/management/DiffusionRepositoryActionsManagementPanel.php
<?php | <?php | ||||
final class DiffusionRepositoryActionsManagementPanel | final class DiffusionRepositoryActionsManagementPanel | ||||
extends DiffusionRepositoryManagementPanel { | extends DiffusionRepositoryManagementPanel { | ||||
const PANELKEY = 'actions'; | const PANELKEY = 'actions'; | ||||
public function getManagementPanelLabel() { | public function getManagementPanelLabel() { | ||||
return pht('Actions'); | return pht('Actions'); | ||||
} | } | ||||
public function getManagementPanelOrder() { | public function getManagementPanelOrder() { | ||||
return 1100; | return 1100; | ||||
} | } | ||||
public function getManagementPanelIcon() { | public function getManagementPanelIcon() { | ||||
$repository = $this->getRepository(); | |||||
$has_any = | |||||
$repository->getDetail('herald-disabled') || | |||||
$repository->getDetail('disable-autoclose'); | |||||
// NOTE: Any value here really means something is disabled, so try to | |||||
// hint that a little bit with the icon. | |||||
if ($has_any) { | |||||
return 'fa-flash'; | return 'fa-flash'; | ||||
} else { | |||||
return 'fa-flash grey'; | |||||
} | |||||
} | } | ||||
protected function getEditEngineFieldKeys() { | protected function getEditEngineFieldKeys() { | ||||
return array( | return array( | ||||
'publish', | 'publish', | ||||
'autoclose', | 'autoclose', | ||||
); | ); | ||||
} | } | ||||
public function buildManagementPanelCurtain() { | |||||
$repository = $this->getRepository(); | |||||
$viewer = $this->getViewer(); | |||||
$action_list = $this->newActionList(); | |||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$repository, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
$actions_uri = $this->getEditPageURI(); | |||||
$action_list->addAction( | |||||
id(new PhabricatorActionView()) | |||||
->setIcon('fa-pencil') | |||||
->setName(pht('Edit Actions')) | |||||
->setHref($actions_uri) | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit)); | |||||
return $this->newCurtainView() | |||||
->setActionList($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); | ||||
$notify = $repository->getDetail('herald-disabled') | $notify = $repository->getDetail('herald-disabled') | ||||
? pht('Off') | ? pht('Off') | ||||
: pht('On'); | : pht('On'); | ||||
$notify = phutil_tag('em', array(), $notify); | $notify = phutil_tag('em', array(), $notify); | ||||
$view->addProperty(pht('Publish/Notify'), $notify); | $view->addProperty(pht('Publish/Notify'), $notify); | ||||
$autoclose = $repository->getDetail('disable-autoclose') | $autoclose = $repository->getDetail('disable-autoclose') | ||||
? pht('Off') | ? pht('Off') | ||||
: pht('On'); | : pht('On'); | ||||
$autoclose = phutil_tag('em', array(), $autoclose); | $autoclose = phutil_tag('em', array(), $autoclose); | ||||
$view->addProperty(pht('Autoclose'), $autoclose); | $view->addProperty(pht('Autoclose'), $autoclose); | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | return $this->newBox(pht('Actions'), $view); | ||||
$viewer, | |||||
$repository, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
$actions_uri = $this->getEditPageURI(); | |||||
$button = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setIcon('fa-pencil') | |||||
->setText(pht('Edit')) | |||||
->setHref($actions_uri) | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit); | |||||
return $this->newBox(pht('Actions'), $view, array($button)); | |||||
} | } | ||||
} | } |