Begin transacitonalizing repository edits and provide a more sensible edit interface
Summary:
Ref T2231, T603. Plan of attack here is pretty much:
- Built out a new (currently not linked in the UI) edit interface in Diffusion which is transaction-based and has a sensible layout.
- Build out a new create interface based on PagedForm which dumps into the new edit interface.
- Throw the old stuff away.
- Everyone lives happily ever after.
Test Plan:
{F44163}
{F44164}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2231
Differential Revision: https://secure.phabricator.com/D6029
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
final class DiffusionRepositoryEditController extends DiffusionController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$drequest = $this->diffusionRequest;
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$content = array();
|
||||
|
||||
$crumbs = $this->buildCrumbs();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit')));
|
||||
$content[] = $crumbs;
|
||||
|
||||
$title = pht('Edit %s', $repository->getName());
|
||||
|
||||
$content[] = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$content[] = $this->buildBasicActions($repository);
|
||||
$content[] = $this->buildBasicProperties($repository);
|
||||
|
||||
|
||||
$content[] = id(new PhabricatorHeaderView())
|
||||
->setHeader(pht('Edit History'));
|
||||
|
||||
$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)
|
||||
->setTransactions($xactions)
|
||||
->setMarkupEngine($engine);
|
||||
|
||||
$content[] = $xaction_view;
|
||||
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$content,
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
'dust' => true,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildBasicActions(PhabricatorRepository $repository) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->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/'))
|
||||
->setDisabled(!$can_edit);
|
||||
$view->addAction($edit);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildBasicProperties(PhabricatorRepository $repository) {
|
||||
$view = id(new PhabricatorPropertyListView())
|
||||
->setUser($this->getRequest()->getUser())
|
||||
->setObject($repository);
|
||||
|
||||
$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');
|
||||
if (!strlen($description)) {
|
||||
$description = phutil_tag('em', array(), pht('None'));
|
||||
}
|
||||
$view->addProperty(pht('Description'), $description);
|
||||
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user