3 final class DiffusionRepositoryAutomationManagementPanel
4 extends DiffusionRepositoryManagementPanel
{
6 const PANELKEY
= 'automation';
8 public function getManagementPanelLabel() {
9 return pht('Automation');
12 public function getManagementPanelOrder() {
16 public function getManagementPanelGroupKey() {
17 return DiffusionRepositoryManagementBuildsPanelGroup
::PANELGROUPKEY
;
20 public function shouldEnableForRepository(
21 PhabricatorRepository
$repository) {
22 return $repository->isGit();
25 protected function getEditEngineFieldKeys() {
27 'automationBlueprintPHIDs',
31 public function getManagementPanelIcon() {
32 $repository = $this->getRepository();
34 if (!$repository->canPerformAutomation()) {
35 return 'fa-truck grey';
38 $blueprint_phids = $repository->getAutomationBlueprintPHIDs();
39 if (!$blueprint_phids) {
40 return 'fa-truck grey';
43 $is_authorized = DrydockAuthorizationQuery
::isFullyAuthorized(
44 $repository->getPHID(),
46 if (!$is_authorized) {
47 return 'fa-exclamation-triangle yellow';
53 public function buildManagementPanelCurtain() {
54 $repository = $this->getRepository();
55 $viewer = $this->getViewer();
56 $action_list = $this->newActionList();
58 $can_edit = PhabricatorPolicyFilter
::hasCapability(
61 PhabricatorPolicyCapability
::CAN_EDIT
);
63 $can_test = $can_edit && $repository->canPerformAutomation();
65 $automation_uri = $this->getEditPageURI();
66 $test_uri = $repository->getPathURI('edit/testautomation/');
68 $action_list->addAction(
69 id(new PhabricatorActionView())
70 ->setIcon('fa-pencil')
71 ->setName(pht('Edit Automation'))
72 ->setHref($automation_uri)
73 ->setDisabled(!$can_edit)
74 ->setWorkflow(!$can_edit));
76 $action_list->addAction(
77 id(new PhabricatorActionView())
78 ->setIcon('fa-gamepad')
79 ->setName(pht('Test Configuration'))
81 ->setDisabled(!$can_test)
82 ->setHref($test_uri));
84 return $this->newCurtainView()
85 ->setActionList($action_list);
88 public function buildManagementPanelContent() {
89 $repository = $this->getRepository();
90 $viewer = $this->getViewer();
92 $view = id(new PHUIPropertyListView())
95 $blueprint_phids = $repository->getAutomationBlueprintPHIDs();
96 if (!$blueprint_phids) {
97 $blueprint_view = phutil_tag('em', array(), pht('Not Configured'));
99 $blueprint_view = id(new DrydockObjectAuthorizationView())
101 ->setObjectPHID($repository->getPHID())
102 ->setBlueprintPHIDs($blueprint_phids);
105 $view->addProperty(pht('Automation'), $blueprint_view);
107 return $this->newBox(pht('Automation'), $view);