mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Port "Actions" to new Repository UI
Summary: Ref T10748. This brings the "Actions" items (publish/notify + autoclose enabled) into the new UI. Test Plan: - Edited this stuff via EditEngine and Conduit. - Viewed via new Manage UI. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15811
This commit is contained in:
parent
4c66a92f92
commit
311de580d6
6 changed files with 119 additions and 8 deletions
|
@ -743,6 +743,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php',
|
'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php',
|
||||||
'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php',
|
'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php',
|
||||||
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
|
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
|
||||||
|
'DiffusionRepositoryActionsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryActionsManagementPanel.php',
|
||||||
'DiffusionRepositoryAutomationManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php',
|
'DiffusionRepositoryAutomationManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php',
|
||||||
'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php',
|
'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php',
|
||||||
'DiffusionRepositoryBranchesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php',
|
'DiffusionRepositoryBranchesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php',
|
||||||
|
@ -4963,6 +4964,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRefTableController' => 'DiffusionController',
|
'DiffusionRefTableController' => 'DiffusionController',
|
||||||
'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||||
'DiffusionRenameHistoryQuery' => 'Phobject',
|
'DiffusionRenameHistoryQuery' => 'Phobject',
|
||||||
|
'DiffusionRepositoryActionsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryAutomationManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryAutomationManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryBranchesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryBranchesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
|
|
|
@ -143,6 +143,9 @@ final class DiffusionRepositoryEditEngine
|
||||||
->setLabel(pht('Allow Dangerous Changes'))
|
->setLabel(pht('Allow Dangerous Changes'))
|
||||||
->setIsCopyable(true)
|
->setIsCopyable(true)
|
||||||
->setIsConduitOnly(true)
|
->setIsConduitOnly(true)
|
||||||
|
->setOptions(
|
||||||
|
pht('Prevent Dangerous Changes'),
|
||||||
|
pht('Allow Dangerous Changes'))
|
||||||
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS)
|
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS)
|
||||||
->setDescription(pht('Permit dangerous changes to be made.'))
|
->setDescription(pht('Permit dangerous changes to be made.'))
|
||||||
->setConduitDescription(pht('Allow or prevent dangerous changes.'))
|
->setConduitDescription(pht('Allow or prevent dangerous changes.'))
|
||||||
|
@ -235,6 +238,32 @@ final class DiffusionRepositoryEditEngine
|
||||||
->setConduitDescription(pht('Change symbol source repositories.'))
|
->setConduitDescription(pht('Change symbol source repositories.'))
|
||||||
->setConduitTypeDescription(pht('New symbol repositories.'))
|
->setConduitTypeDescription(pht('New symbol repositories.'))
|
||||||
->setValue($object->getSymbolSources()),
|
->setValue($object->getSymbolSources()),
|
||||||
|
id(new PhabricatorBoolEditField())
|
||||||
|
->setKey('publish')
|
||||||
|
->setLabel(pht('Publish/Notify'))
|
||||||
|
->setTransactionType(
|
||||||
|
PhabricatorRepositoryTransaction::TYPE_NOTIFY)
|
||||||
|
->setIsCopyable(true)
|
||||||
|
->setOptions(
|
||||||
|
pht('Disable Notifications, Feed, and Herald'),
|
||||||
|
pht('Enable Notifications, Feed, and Herald'))
|
||||||
|
->setDescription(pht('Configure how changes are published.'))
|
||||||
|
->setConduitDescription(pht('Change publishing options.'))
|
||||||
|
->setConduitTypeDescription(pht('New notification setting.'))
|
||||||
|
->setValue(!$object->getDetail('herald-disabled')),
|
||||||
|
id(new PhabricatorBoolEditField())
|
||||||
|
->setKey('autoclose')
|
||||||
|
->setLabel(pht('Autoclose'))
|
||||||
|
->setTransactionType(
|
||||||
|
PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE)
|
||||||
|
->setIsCopyable(true)
|
||||||
|
->setOptions(
|
||||||
|
pht('Disable Autoclose'),
|
||||||
|
pht('Enable Autoclose'))
|
||||||
|
->setDescription(pht('Stop or resume autoclosing in this repository.'))
|
||||||
|
->setConduitDescription(pht('Change autoclose setting.'))
|
||||||
|
->setConduitTypeDescription(pht('New autoclose setting.'))
|
||||||
|
->setValue(!$object->getDetail('disable-autoclose')),
|
||||||
id(new PhabricatorPolicyEditField())
|
id(new PhabricatorPolicyEditField())
|
||||||
->setKey('policy.push')
|
->setKey('policy.push')
|
||||||
->setLabel(pht('Push Policy'))
|
->setLabel(pht('Push Policy'))
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionRepositoryActionsManagementPanel
|
||||||
|
extends DiffusionRepositoryManagementPanel {
|
||||||
|
|
||||||
|
const PANELKEY = 'actions';
|
||||||
|
|
||||||
|
public function getManagementPanelLabel() {
|
||||||
|
return pht('Actions');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getManagementPanelOrder() {
|
||||||
|
return 1100;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildManagementPanelActions() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$repository,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$actions_uri = $repository->getPathURI('edit/actions/');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('fa-pencil')
|
||||||
|
->setName(pht('Edit Actions'))
|
||||||
|
->setHref($actions_uri)
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildManagementPanelContent() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->setActionList($this->newActions());
|
||||||
|
|
||||||
|
$notify = $repository->getDetail('herald-disabled')
|
||||||
|
? pht('Off')
|
||||||
|
: pht('On');
|
||||||
|
$notify = phutil_tag('em', array(), $notify);
|
||||||
|
$view->addProperty(pht('Publish/Notify'), $notify);
|
||||||
|
|
||||||
|
$autoclose = $repository->getDetail('disable-autoclose')
|
||||||
|
? pht('Off')
|
||||||
|
: pht('On');
|
||||||
|
$autoclose = phutil_tag('em', array(), $autoclose);
|
||||||
|
$view->addProperty(pht('Autoclose'), $autoclose);
|
||||||
|
|
||||||
|
return $this->newBox(pht('Branches'), $view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -342,7 +342,7 @@ final class PhabricatorRepositoryEditor
|
||||||
$errors = parent::validateTransaction($object, $type, $xactions);
|
$errors = parent::validateTransaction($object, $type, $xactions);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE:
|
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY:
|
||||||
case PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY:
|
case PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY:
|
||||||
foreach ($xactions as $xaction) {
|
foreach ($xactions as $xaction) {
|
||||||
foreach ($xaction->getNewValue() as $pattern) {
|
foreach ($xaction->getNewValue() as $pattern) {
|
||||||
|
|
|
@ -1808,8 +1808,9 @@ abstract class PhabricatorEditEngine
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
throw new PhutilProxyException(
|
throw new PhutilProxyException(
|
||||||
pht(
|
pht(
|
||||||
'Exception when processing transaction of type "%s".',
|
'Exception when processing transaction of type "%s": %s',
|
||||||
$xaction['type']),
|
$xaction['type'],
|
||||||
|
$ex->getMessage()),
|
||||||
$ex);
|
$ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,32 @@
|
||||||
final class PhabricatorBoolEditField
|
final class PhabricatorBoolEditField
|
||||||
extends PhabricatorEditField {
|
extends PhabricatorEditField {
|
||||||
|
|
||||||
|
private $options;
|
||||||
|
|
||||||
|
public function setOptions($off_label, $on_label) {
|
||||||
|
$this->options = array(
|
||||||
|
'0' => $off_label,
|
||||||
|
'1' => $on_label,
|
||||||
|
);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOptions() {
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newControl() {
|
protected function newControl() {
|
||||||
return id(new AphrontFormSelectControl())
|
$options = $this->getOptions();
|
||||||
->setOptions(
|
|
||||||
array(
|
if (!$options) {
|
||||||
|
$options = array(
|
||||||
'0' => pht('False'),
|
'0' => pht('False'),
|
||||||
'1' => pht('True'),
|
'1' => pht('True'),
|
||||||
));
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id(new AphrontFormSelectControl())
|
||||||
|
->setOptions($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newHTTPParameterType() {
|
protected function newHTTPParameterType() {
|
||||||
|
|
Loading…
Reference in a new issue