Differential D20425 Diff 48780 src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php
| Show All 40 Lines | public function buildManagementPanelCurtain() { | ||||
| $edit_uri = $this->getEditPageURI(); | $edit_uri = $this->getEditPageURI(); | ||||
| $activate_uri = $repository->getPathURI('edit/activate/'); | $activate_uri = $repository->getPathURI('edit/activate/'); | ||||
| $delete_uri = $repository->getPathURI('edit/delete/'); | $delete_uri = $repository->getPathURI('edit/delete/'); | ||||
| $encoding_uri = $this->getEditPageURI('encoding'); | $encoding_uri = $this->getEditPageURI('encoding'); | ||||
| $dangerous_uri = $repository->getPathURI('edit/dangerous/'); | $dangerous_uri = $repository->getPathURI('edit/dangerous/'); | ||||
| $enormous_uri = $repository->getPathURI('edit/enormous/'); | $enormous_uri = $repository->getPathURI('edit/enormous/'); | ||||
| $update_uri = $repository->getPathURI('edit/update/'); | $update_uri = $repository->getPathURI('edit/update/'); | ||||
| $publish_uri = $repository->getPathURI('edit/publish/'); | |||||
| if ($repository->isTracked()) { | if ($repository->isTracked()) { | ||||
| $activate_icon = 'fa-ban'; | $activate_icon = 'fa-ban'; | ||||
| $activate_label = pht('Deactivate Repository'); | $activate_label = pht('Deactivate Repository'); | ||||
| } else { | } else { | ||||
| $activate_icon = 'fa-check'; | $activate_icon = 'fa-check'; | ||||
| $activate_label = pht('Activate Repository'); | $activate_label = pht('Activate Repository'); | ||||
| } | } | ||||
| if (!$repository->isPublishingDisabled()) { | |||||
| $publish_icon = 'fa-ban'; | |||||
| $publish_label = pht('Disable Publishing'); | |||||
| } else { | |||||
| $publish_icon = 'fa-check'; | |||||
| $publish_label = pht('Enable Publishing'); | |||||
| } | |||||
| $should_dangerous = $repository->shouldAllowDangerousChanges(); | $should_dangerous = $repository->shouldAllowDangerousChanges(); | ||||
| if ($should_dangerous) { | if ($should_dangerous) { | ||||
| $dangerous_icon = 'fa-shield'; | $dangerous_icon = 'fa-shield'; | ||||
| $dangerous_name = pht('Prevent Dangerous Changes'); | $dangerous_name = pht('Prevent Dangerous Changes'); | ||||
| $can_dangerous = $can_edit; | $can_dangerous = $can_edit; | ||||
| } else { | } else { | ||||
| $dangerous_icon = 'fa-exclamation-triangle'; | $dangerous_icon = 'fa-exclamation-triangle'; | ||||
| $dangerous_name = pht('Allow Dangerous Changes'); | $dangerous_name = pht('Allow Dangerous Changes'); | ||||
| Show All 40 Lines | $action_list->addAction( | ||||
| ->setName($enormous_name) | ->setName($enormous_name) | ||||
| ->setHref($enormous_uri) | ->setHref($enormous_uri) | ||||
| ->setIcon($enormous_icon) | ->setIcon($enormous_icon) | ||||
| ->setDisabled(!$can_enormous) | ->setDisabled(!$can_enormous) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $action_list->addAction( | $action_list->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setType(PhabricatorActionView::TYPE_DIVIDER)); | |||||
| $action_list->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName($activate_label) | ->setName($activate_label) | ||||
| ->setHref($activate_uri) | ->setHref($activate_uri) | ||||
| ->setIcon($activate_icon) | ->setIcon($activate_icon) | ||||
| ->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $action_list->addAction( | $action_list->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName($publish_label) | |||||
| ->setHref($publish_uri) | |||||
| ->setIcon($publish_icon) | |||||
| ->setDisabled(!$can_edit) | |||||
| ->setWorkflow(true)); | |||||
| $action_list->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Update Now')) | ->setName(pht('Update Now')) | ||||
| ->setHref($update_uri) | ->setHref($update_uri) | ||||
| ->setIcon('fa-refresh') | ->setIcon('fa-refresh') | ||||
| ->setWorkflow(true) | ->setWorkflow(true) | ||||
| ->setDisabled(!$can_edit)); | ->setDisabled(!$can_edit)); | ||||
| $action_list->addAction( | $action_list->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| Show All 12 Lines | return $this->newCurtainView() | ||||
| ->setActionList($action_list); | ->setActionList($action_list); | ||||
| } | } | ||||
| public function buildManagementPanelContent() { | public function buildManagementPanelContent() { | ||||
| $basics = $this->buildBasics(); | $basics = $this->buildBasics(); | ||||
| $basics = $this->newBox(pht('Properties'), $basics); | $basics = $this->newBox(pht('Properties'), $basics); | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $state = $this->buildStateView($repository); | |||||
| $is_new = $repository->isNewlyInitialized(); | $is_new = $repository->isNewlyInitialized(); | ||||
| $info_view = null; | $info_view = null; | ||||
| if ($is_new) { | if ($is_new) { | ||||
| $messages = array(); | $messages = array(); | ||||
| $messages[] = pht( | $messages[] = pht( | ||||
| 'This newly created repository is not active yet. Configure policies, '. | 'This newly created repository is not active yet. Configure policies, '. | ||||
| 'options, and URIs. When ready, %s the repository.', | 'options, and URIs. When ready, %s the repository.', | ||||
| Show All 17 Lines | public function buildManagementPanelContent() { | ||||
| } | } | ||||
| $description = $this->buildDescription(); | $description = $this->buildDescription(); | ||||
| if ($description) { | if ($description) { | ||||
| $description = $this->newBox(pht('Description'), $description); | $description = $this->newBox(pht('Description'), $description); | ||||
| } | } | ||||
| $status = $this->buildStatus(); | $status = $this->buildStatus(); | ||||
| return array($info_view, $basics, $description, $status); | return array($info_view, $state, $basics, $description, $status); | ||||
| } | } | ||||
| private function buildBasics() { | private function buildBasics() { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $view = id(new PHUIPropertyListView()) | $view = id(new PHUIPropertyListView()) | ||||
| ->setViewer($viewer); | ->setViewer($viewer); | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | private function buildStatus() { | ||||
| $raw_error = $this->buildRepositoryRawError($repository, $messages); | $raw_error = $this->buildRepositoryRawError($repository, $messages); | ||||
| $view->addProperty(pht('Status'), $status); | $view->addProperty(pht('Status'), $status); | ||||
| if ($raw_error) { | if ($raw_error) { | ||||
| $view->addSectionHeader(pht('Raw Error')); | $view->addSectionHeader(pht('Raw Error')); | ||||
| $view->addTextContent($raw_error); | $view->addTextContent($raw_error); | ||||
| } | } | ||||
| return $this->newBox(pht('Status'), $view); | return $this->newBox(pht('Working Copy Status'), $view); | ||||
| } | } | ||||
| private function buildRepositoryUpdateInterval( | private function buildRepositoryUpdateInterval( | ||||
| PhabricatorRepository $repository) { | PhabricatorRepository $repository) { | ||||
| $smart_wait = $repository->loadUpdateInterval(); | $smart_wait = $repository->loadUpdateInterval(); | ||||
| $doc_href = PhabricatorEnv::getDoclink( | $doc_href = PhabricatorEnv::getDoclink( | ||||
| ▲ Show 20 Lines • Show All 416 Lines • ▼ Show 20 Lines | private function getEnvConfigLink() { | ||||
| return phutil_tag( | return phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $config_href, | 'href' => $config_href, | ||||
| ), | ), | ||||
| 'environment.append-paths'); | 'environment.append-paths'); | ||||
| } | } | ||||
| private function buildStateView(PhabricatorRepository $repository) { | |||||
| $viewer = $this->getViewer(); | |||||
| $is_new = $repository->isNewlyInitialized(); | |||||
| $view = id(new PHUIPropertyListView()) | |||||
| ->setViewer($viewer); | |||||
| if (!$repository->isTracked()) { | |||||
| if ($is_new) { | |||||
| $active_icon = 'fa-ban'; | |||||
| $active_color = 'yellow'; | |||||
| $active_label = pht('Not Activated Yet'); | |||||
| $active_note = pht('Complete Setup and Activate Repository'); | |||||
| } else { | |||||
| $active_icon = 'fa-times'; | |||||
| $active_color = 'red'; | |||||
| $active_label = pht('Not Active'); | |||||
| $active_note = pht('Repository Disabled'); | |||||
| } | |||||
| } else if ($repository->isImporting()) { | |||||
| $active_icon = 'fa-hourglass'; | |||||
| $active_color = 'yellow'; | |||||
| $active_label = pht('Importing...'); | |||||
| $active_note = null; | |||||
| } else { | |||||
| $active_icon = 'fa-check'; | |||||
| $active_color = 'green'; | |||||
| $active_label = pht('Repository Active'); | |||||
| $active_note = null; | |||||
| } | |||||
| $active_view = id(new PHUIStatusListView()) | |||||
| ->addItem( | |||||
| id(new PHUIStatusItemView()) | |||||
| ->setIcon($active_icon, $active_color) | |||||
| ->setTarget($active_label) | |||||
| ->setNote($active_note)); | |||||
| if ($repository->isPublishingDisabled()) { | |||||
| $publishing_icon = 'fa-times'; | |||||
| $publishing_color = 'red'; | |||||
| $publishing_label = pht('Not Publishing'); | |||||
| $publishing_note = pht('Publishing Disabled'); | |||||
| } else if (!$repository->isTracked()) { | |||||
| $publishing_icon = 'fa-ban'; | |||||
| $publishing_color = 'yellow'; | |||||
| $publishing_label = pht('Not Publishing'); | |||||
| if ($is_new) { | |||||
| $publishing_note = pht('Repository Not Active Yet'); | |||||
| } else { | |||||
| $publishing_note = pht('Repository Inactive'); | |||||
| } | |||||
| } else if ($repository->isImporting()) { | |||||
| $publishing_icon = 'fa-ban'; | |||||
| $publishing_color = 'yellow'; | |||||
| $publishing_label = pht('Not Publishing'); | |||||
| $publishing_note = pht('Repository Importing'); | |||||
| } else { | |||||
| $publishing_icon = 'fa-check'; | |||||
| $publishing_color = 'green'; | |||||
| $publishing_label = pht('Publishing Active'); | |||||
| $publishing_note = null; | |||||
| } | |||||
| $publishing_view = id(new PHUIStatusListView()) | |||||
| ->addItem( | |||||
| id(new PHUIStatusItemView()) | |||||
| ->setIcon($publishing_icon, $publishing_color) | |||||
| ->setTarget($publishing_label) | |||||
| ->setNote($publishing_note)); | |||||
| $view->addProperty(pht('Active'), $active_view); | |||||
| $view->addProperty(pht('Publishing'), $publishing_view); | |||||
| return $this->newBox(pht('State'), $view); | |||||
| } | |||||
| } | } | ||||