mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Move the repository "Publishing" option to the "Basics" panel in repository management
Summary: Depends on D20424. Ref T13277. Now that the "Actions" panel only has one item ("Publishing"), just move it to the "Basics" panel. Update the UI to show active/publishing status more clearly and relate them to one another and importing state. Test Plan: {F6378087} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13277 Differential Revision: https://secure.phabricator.com/D20425
This commit is contained in:
parent
ec9237fe13
commit
7a4ef2bad8
6 changed files with 191 additions and 78 deletions
|
@ -951,6 +951,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryEditDeleteController' => 'applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php',
|
||||
'DiffusionRepositoryEditEngine' => 'applications/diffusion/editor/DiffusionRepositoryEditEngine.php',
|
||||
'DiffusionRepositoryEditEnormousController' => 'applications/diffusion/controller/DiffusionRepositoryEditEnormousController.php',
|
||||
'DiffusionRepositoryEditPublishingController' => 'applications/diffusion/controller/DiffusionRepositoryEditPublishingController.php',
|
||||
'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php',
|
||||
'DiffusionRepositoryFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionRepositoryFunctionDatasource.php',
|
||||
'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php',
|
||||
|
@ -969,7 +970,6 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
|
||||
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
|
||||
'DiffusionRepositoryProfilePictureController' => 'applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php',
|
||||
'DiffusionRepositoryPublishingManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPublishingManagementPanel.php',
|
||||
'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php',
|
||||
'DiffusionRepositoryRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php',
|
||||
'DiffusionRepositorySearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRepositorySearchConduitAPIMethod.php',
|
||||
|
@ -6602,6 +6602,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryManageController',
|
||||
'DiffusionRepositoryEditEngine' => 'PhabricatorEditEngine',
|
||||
'DiffusionRepositoryEditEnormousController' => 'DiffusionRepositoryManageController',
|
||||
'DiffusionRepositoryEditPublishingController' => 'DiffusionRepositoryManageController',
|
||||
'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryManageController',
|
||||
'DiffusionRepositoryFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
|
@ -6620,7 +6621,6 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryPath' => 'Phobject',
|
||||
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
'DiffusionRepositoryProfilePictureController' => 'DiffusionController',
|
||||
'DiffusionRepositoryPublishingManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
'DiffusionRepositoryRef' => 'Phobject',
|
||||
'DiffusionRepositoryRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'DiffusionRepositorySearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||
|
|
|
@ -86,6 +86,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
|
|||
'enormous/' => 'DiffusionRepositoryEditEnormousController',
|
||||
'delete/' => 'DiffusionRepositoryEditDeleteController',
|
||||
'update/' => 'DiffusionRepositoryEditUpdateController',
|
||||
'publish/' => 'DiffusionRepositoryEditPublishingController',
|
||||
'testautomation/' => 'DiffusionRepositoryTestAutomationController',
|
||||
),
|
||||
'pathtree/(?P<dblob>.*)' => 'DiffusionPathTreeController',
|
||||
|
|
|
@ -334,6 +334,8 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
'fa-clock-o',
|
||||
'indigo',
|
||||
pht('Importing (%s)...', $percentage));
|
||||
} else if ($repository->isPublishingDisabled()) {
|
||||
$header->setStatus('fa-minus', 'bluegrey', pht('Publishing Disabled'));
|
||||
} else {
|
||||
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionRepositoryEditPublishingController
|
||||
extends DiffusionRepositoryManageController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$response = $this->loadDiffusionContextForEdit();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
|
||||
->setRepository($repository)
|
||||
->getPanelURI();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
if ($repository->isPublishingDisabled()) {
|
||||
$new_status = true;
|
||||
} else {
|
||||
$new_status = false;
|
||||
}
|
||||
|
||||
$xaction = id(new PhabricatorRepositoryTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorRepositoryNotifyTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($new_status);
|
||||
|
||||
$editor = id(new PhabricatorRepositoryEditor())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setActor($viewer)
|
||||
->applyTransactions($repository, array($xaction));
|
||||
|
||||
return id(new AphrontReloadResponse())->setURI($panel_uri);
|
||||
}
|
||||
|
||||
$body = array();
|
||||
if (!$repository->isPublishingDisabled()) {
|
||||
$title = pht('Disable Publishing');
|
||||
$body[] = pht(
|
||||
'If you disable publishing for this repository, new commits '.
|
||||
'will not: send email, publish feed stories, trigger audits, or '.
|
||||
'trigger Herald.');
|
||||
|
||||
$body[] = pht(
|
||||
'This option is most commonly used to temporarily allow a major '.
|
||||
'repository maintenance operation (like a history rewrite) to '.
|
||||
'occur with minimal disruption to users.');
|
||||
|
||||
$submit = pht('Disable Publishing');
|
||||
} else {
|
||||
$title = pht('Reactivate Publishing');
|
||||
$body[] = pht(
|
||||
'If you reactivate publishing for this repository, new commits '.
|
||||
'that become reachable from permanent refs will: send email, '.
|
||||
'publish feed stories, trigger audits, and trigger Herald.');
|
||||
|
||||
$body[] = pht(
|
||||
'Commits which became reachable from a permanent ref while '.
|
||||
'publishing was disabled will not trigger these actions '.
|
||||
'retroactively.');
|
||||
|
||||
$submit = pht('Reactivate Publishing');
|
||||
}
|
||||
|
||||
$dialog = $this->newDialog()
|
||||
->setTitle($title)
|
||||
->addSubmitButton($submit)
|
||||
->addCancelButton($panel_uri);
|
||||
|
||||
foreach ($body as $graph) {
|
||||
$dialog->appendParagraph($graph);
|
||||
}
|
||||
|
||||
return $dialog;
|
||||
}
|
||||
|
||||
}
|
|
@ -46,6 +46,7 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
$dangerous_uri = $repository->getPathURI('edit/dangerous/');
|
||||
$enormous_uri = $repository->getPathURI('edit/enormous/');
|
||||
$update_uri = $repository->getPathURI('edit/update/');
|
||||
$publish_uri = $repository->getPathURI('edit/publish/');
|
||||
|
||||
if ($repository->isTracked()) {
|
||||
$activate_icon = 'fa-ban';
|
||||
|
@ -55,6 +56,14 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
$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();
|
||||
if ($should_dangerous) {
|
||||
$dangerous_icon = 'fa-shield';
|
||||
|
@ -109,6 +118,10 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
->setDisabled(!$can_enormous)
|
||||
->setWorkflow(true));
|
||||
|
||||
$action_list->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setType(PhabricatorActionView::TYPE_DIVIDER));
|
||||
|
||||
$action_list->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName($activate_label)
|
||||
|
@ -117,6 +130,14 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
|
||||
$action_list->addAction(
|
||||
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'))
|
||||
|
@ -147,6 +168,9 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
$basics = $this->newBox(pht('Properties'), $basics);
|
||||
|
||||
$repository = $this->getRepository();
|
||||
|
||||
$state = $this->buildStateView($repository);
|
||||
|
||||
$is_new = $repository->isNewlyInitialized();
|
||||
$info_view = null;
|
||||
if ($is_new) {
|
||||
|
@ -180,7 +204,7 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
}
|
||||
$status = $this->buildStatus();
|
||||
|
||||
return array($info_view, $basics, $description, $status);
|
||||
return array($info_view, $state, $basics, $description, $status);
|
||||
}
|
||||
|
||||
private function buildBasics() {
|
||||
|
@ -287,7 +311,7 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
$view->addTextContent($raw_error);
|
||||
}
|
||||
|
||||
return $this->newBox(pht('Status'), $view);
|
||||
return $this->newBox(pht('Working Copy Status'), $view);
|
||||
}
|
||||
|
||||
private function buildRepositoryUpdateInterval(
|
||||
|
@ -720,4 +744,81 @@ final class DiffusionRepositoryBasicsManagementPanel
|
|||
'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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionRepositoryPublishingManagementPanel
|
||||
extends DiffusionRepositoryManagementPanel {
|
||||
|
||||
const PANELKEY = 'publishing';
|
||||
|
||||
public function getManagementPanelLabel() {
|
||||
return pht('Publishing');
|
||||
}
|
||||
|
||||
public function getManagementPanelOrder() {
|
||||
return 1100;
|
||||
}
|
||||
|
||||
public function getManagementPanelIcon() {
|
||||
$repository = $this->getRepository();
|
||||
|
||||
$has_any = $repository->isPublishingDisabled();
|
||||
|
||||
if ($has_any) {
|
||||
return 'fa-flash';
|
||||
} else {
|
||||
return 'fa-flash grey';
|
||||
}
|
||||
}
|
||||
|
||||
protected function getEditEngineFieldKeys() {
|
||||
return array(
|
||||
'publish',
|
||||
);
|
||||
}
|
||||
|
||||
public function buildManagementPanelCurtain() {
|
||||
$repository = $this->getRepository();
|
||||
$viewer = $this->getViewer();
|
||||
$action_list = $this->newActionList();
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$repository,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$publishing_uri = $this->getEditPageURI();
|
||||
|
||||
$action_list->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
->setName(pht('Edit Publishing'))
|
||||
->setHref($publishing_uri)
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
return $this->newCurtainView()
|
||||
->setActionList($action_list);
|
||||
}
|
||||
|
||||
public function buildManagementPanelContent() {
|
||||
$repository = $this->getRepository();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setViewer($viewer);
|
||||
|
||||
$notify = $repository->isPublishingDisabled()
|
||||
? pht('Off')
|
||||
: pht('On');
|
||||
$notify = phutil_tag('em', array(), $notify);
|
||||
$view->addProperty(pht('Publishing'), $notify);
|
||||
|
||||
return $this->newBox(pht('Publishing'), $view);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue