2013-05-24 21:37:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionRepositoryEditController extends DiffusionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
$drequest = $this->diffusionRequest;
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
2013-10-25 22:57:14 +02:00
|
|
|
$is_svn = false;
|
|
|
|
$is_git = false;
|
|
|
|
$is_hg = false;
|
|
|
|
switch ($repository->getVersionControlSystem()) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
|
|
|
$is_git = true;
|
|
|
|
break;
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
$is_svn = true;
|
|
|
|
break;
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
|
|
|
$is_hg = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$has_branches = ($is_git || $is_hg);
|
|
|
|
|
2013-05-24 21:37:42 +02:00
|
|
|
$crumbs = $this->buildCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Edit')));
|
|
|
|
|
|
|
|
$title = pht('Edit %s', $repository->getName());
|
|
|
|
|
2013-09-22 01:23:35 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-05-24 21:37:42 +02:00
|
|
|
->setHeader($title);
|
2013-09-22 01:23:35 +02:00
|
|
|
if (!$repository->isTracked()) {
|
|
|
|
$header->addTag(
|
|
|
|
id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE)
|
|
|
|
->setName(pht('Inactive'))
|
|
|
|
->setBackgroundColor(PhabricatorTagView::COLOR_BLACK));
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$basic_actions = $this->buildBasicActions($repository);
|
|
|
|
$basic_properties =
|
|
|
|
$this->buildBasicProperties($repository, $basic_actions);
|
2013-09-23 21:53:41 +02:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$policy_actions = $this->buildPolicyActions($repository);
|
|
|
|
$policy_properties =
|
|
|
|
$this->buildPolicyProperties($repository, $policy_actions);
|
2013-05-25 15:30:38 +02:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$encoding_actions = $this->buildEncodingActions($repository);
|
|
|
|
$encoding_properties =
|
|
|
|
$this->buildEncodingProperties($repository, $encoding_actions);
|
2013-05-24 21:37:42 +02:00
|
|
|
|
2013-10-25 22:57:14 +02:00
|
|
|
$branches_properties = null;
|
|
|
|
if ($has_branches) {
|
|
|
|
$branches_properties = $this->buildBranchesProperties(
|
|
|
|
$repository,
|
|
|
|
$this->buildBranchesActions($repository));
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:58:03 +02:00
|
|
|
$subversion_properties = null;
|
|
|
|
if ($is_svn) {
|
|
|
|
$subversion_properties = $this->buildSubversionProperties(
|
|
|
|
$repository,
|
|
|
|
$this->buildSubversionActions($repository));
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:58:15 +02:00
|
|
|
$actions_properties = $this->buildActionsProperties(
|
|
|
|
$repository,
|
|
|
|
$this->buildActionsActions($repository));
|
|
|
|
|
2013-05-24 21:37:42 +02:00
|
|
|
$xactions = id(new PhabricatorRepositoryTransactionQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withObjectPHIDs(array($repository->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
|
|
->setViewer($user);
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
if ($xaction->getComment()) {
|
|
|
|
$engine->addObject(
|
|
|
|
$xaction->getComment(),
|
|
|
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$engine->process();
|
|
|
|
|
|
|
|
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
|
|
|
->setUser($user)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($repository->getPHID())
|
2013-05-24 21:37:42 +02:00
|
|
|
->setTransactions($xactions)
|
|
|
|
->setMarkupEngine($engine);
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$obj_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->addPropertyList($basic_properties)
|
|
|
|
->addPropertyList($policy_properties)
|
|
|
|
->addPropertyList($encoding_properties);
|
2013-05-24 21:37:42 +02:00
|
|
|
|
2013-10-25 22:57:14 +02:00
|
|
|
if ($branches_properties) {
|
|
|
|
$obj_box->addPropertyList($branches_properties);
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:58:03 +02:00
|
|
|
if ($subversion_properties) {
|
|
|
|
$obj_box->addPropertyList($subversion_properties);
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:58:15 +02:00
|
|
|
$obj_box->addPropertyList($actions_properties);
|
|
|
|
|
2013-05-24 21:37:42 +02:00
|
|
|
return $this->buildApplicationPage(
|
2013-10-11 16:53:56 +02:00
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$obj_box,
|
|
|
|
$xaction_view,
|
|
|
|
),
|
2013-05-24 21:37:42 +02:00
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
'device' => true,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildBasicActions(PhabricatorRepository $repository) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
2013-07-12 20:39:47 +02:00
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
2013-05-24 21:37:42 +02:00
|
|
|
->setUser($user);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$user,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Basic Information'))
|
|
|
|
->setHref($this->getRepositoryControllerURI($repository, 'edit/basic/'))
|
2013-09-22 01:23:35 +02:00
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit);
|
2013-05-24 21:37:42 +02:00
|
|
|
$view->addAction($edit);
|
|
|
|
|
2013-09-22 01:23:35 +02:00
|
|
|
$activate = id(new PhabricatorActionView())
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/activate/'))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true);
|
|
|
|
|
|
|
|
if ($repository->isTracked()) {
|
|
|
|
$activate
|
|
|
|
->setIcon('disable')
|
|
|
|
->setName(pht('Deactivate Repository'));
|
|
|
|
} else {
|
|
|
|
$activate
|
|
|
|
->setIcon('enable')
|
|
|
|
->setName(pht('Activate Repository'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction($activate);
|
|
|
|
|
2013-05-24 21:37:42 +02:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
private function buildBasicProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-05-24 21:38:44 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($user)
|
|
|
|
->setActionList($actions);
|
2013-05-24 21:37:42 +02:00
|
|
|
|
|
|
|
$view->addProperty(pht('Name'), $repository->getName());
|
|
|
|
$view->addProperty(pht('ID'), $repository->getID());
|
|
|
|
$view->addProperty(pht('PHID'), $repository->getPHID());
|
|
|
|
|
|
|
|
$type = PhabricatorRepositoryType::getNameForRepositoryType(
|
|
|
|
$repository->getVersionControlSystem());
|
|
|
|
|
|
|
|
$view->addProperty(pht('Type'), $type);
|
|
|
|
$view->addProperty(pht('Callsign'), $repository->getCallsign());
|
|
|
|
|
|
|
|
$description = $repository->getDetail('description');
|
2013-05-24 21:38:44 +02:00
|
|
|
$view->addSectionHeader(pht('Description'));
|
2013-05-24 21:37:42 +02:00
|
|
|
if (!strlen($description)) {
|
2013-05-24 21:38:44 +02:00
|
|
|
$description = phutil_tag('em', array(), pht('No description provided.'));
|
|
|
|
} else {
|
|
|
|
$description = PhabricatorMarkupEngine::renderOneObject(
|
|
|
|
$repository,
|
|
|
|
'description',
|
|
|
|
$user);
|
2013-05-24 21:37:42 +02:00
|
|
|
}
|
2013-05-24 21:38:44 +02:00
|
|
|
$view->addTextContent($description);
|
2013-05-24 21:37:42 +02:00
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-05-25 15:30:38 +02:00
|
|
|
private function buildEncodingActions(PhabricatorRepository $repository) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
2013-07-12 20:39:47 +02:00
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
2013-05-25 15:30:38 +02:00
|
|
|
->setUser($user);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$user,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Text Encoding'))
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/encoding/'))
|
2013-09-23 21:53:41 +02:00
|
|
|
->setWorkflow(!$can_edit)
|
2013-05-25 15:30:38 +02:00
|
|
|
->setDisabled(!$can_edit);
|
|
|
|
$view->addAction($edit);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
private function buildEncodingProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-05-25 15:30:38 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($user)
|
|
|
|
->setActionList($actions)
|
|
|
|
->addSectionHeader(pht('Text Encoding'));
|
2013-05-25 15:30:38 +02:00
|
|
|
|
|
|
|
$encoding = $repository->getDetail('encoding');
|
|
|
|
if (!$encoding) {
|
|
|
|
$encoding = phutil_tag('em', array(), pht('Use Default (UTF-8)'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(pht('Encoding'), $encoding);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-09-23 21:53:41 +02:00
|
|
|
private function buildPolicyActions(PhabricatorRepository $repository) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Policies'))
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/policy/'))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit);
|
|
|
|
$view->addAction($edit);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
private function buildPolicyProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-09-23 21:53:41 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions)
|
|
|
|
->addSectionHeader(pht('Policies'));
|
2013-09-23 21:53:41 +02:00
|
|
|
|
|
|
|
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
|
|
|
$viewer,
|
|
|
|
$repository);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Visible To'),
|
|
|
|
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Editable By'),
|
|
|
|
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
|
2013-05-24 21:37:42 +02:00
|
|
|
|
|
|
|
|
2013-09-23 21:53:41 +02:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:57:14 +02:00
|
|
|
private function buildBranchesActions(PhabricatorRepository $repository) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Branches'))
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/branches/'))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit);
|
|
|
|
$view->addAction($edit);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildBranchesProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions)
|
|
|
|
->addSectionHeader(pht('Branches'));
|
|
|
|
|
|
|
|
$default_branch = nonempty(
|
|
|
|
$repository->getHumanReadableDetail('default-branch'),
|
|
|
|
phutil_tag('em', array(), $repository->getDefaultBranch()));
|
|
|
|
$view->addProperty(pht('Default Branch'), $default_branch);
|
|
|
|
|
|
|
|
$track_only = nonempty(
|
|
|
|
$repository->getHumanReadableDetail('branch-filter'),
|
|
|
|
phutil_tag('em', array(), pht('Track All Branches')));
|
|
|
|
$view->addProperty(pht('Track Only'), $track_only);
|
|
|
|
|
|
|
|
$autoclose_only = nonempty(
|
|
|
|
$repository->getHumanReadableDetail('close-commits-filter'),
|
|
|
|
phutil_tag('em', array(), pht('Autoclose On All Branches')));
|
|
|
|
$view->addProperty(pht('Autoclose Only'), $autoclose_only);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-25 22:58:03 +02:00
|
|
|
private function buildSubversionActions(PhabricatorRepository $repository) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Subversion Info'))
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/subversion/'))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit);
|
|
|
|
$view->addAction($edit);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildSubversionProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions)
|
|
|
|
->addSectionHeader(pht('Subversion'));
|
|
|
|
|
|
|
|
$svn_uuid = nonempty(
|
|
|
|
$repository->getUUID(),
|
|
|
|
phutil_tag('em', array(), pht('Not Configured')));
|
|
|
|
$view->addProperty(pht('Subversion UUID'), $svn_uuid);
|
|
|
|
|
|
|
|
$svn_subpath = nonempty(
|
|
|
|
$repository->getHumanReadableDetail('svn-subpath'),
|
|
|
|
phutil_tag('em', array(), pht('Import Entire Repository')));
|
|
|
|
$view->addProperty(pht('Import Only'), $svn_subpath);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
2013-10-25 22:57:14 +02:00
|
|
|
|
2013-10-25 22:58:15 +02:00
|
|
|
private function buildActionsActions(PhabricatorRepository $repository) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$edit = id(new PhabricatorActionView())
|
|
|
|
->setIcon('edit')
|
|
|
|
->setName(pht('Edit Actions'))
|
|
|
|
->setHref(
|
|
|
|
$this->getRepositoryControllerURI($repository, 'edit/actions/'))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit);
|
|
|
|
$view->addAction($edit);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionsProperties(
|
|
|
|
PhabricatorRepository $repository,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions)
|
|
|
|
->addSectionHeader(pht('Actions'));
|
|
|
|
|
|
|
|
$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 $view;
|
|
|
|
}
|
|
|
|
|
2013-05-24 21:37:42 +02:00
|
|
|
}
|