mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Modernize Releeph branch edit and create interfaces
Summary: Ref T3092. Fixes T3724. Use modern/flexible UI for these interfaces. Removes the ability to retarget an existing branch (you can just close it and open a new one if you made a mistake). Test Plan: {F54437} {F54438} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3092, T3724 Differential Revision: https://secure.phabricator.com/D6765
This commit is contained in:
parent
210e30c257
commit
bd17fac935
6 changed files with 75 additions and 84 deletions
|
@ -106,4 +106,31 @@ abstract class ReleephProjectController extends ReleephController {
|
|||
return $this->releephRequest;
|
||||
}
|
||||
|
||||
protected function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$project = $this->getReleephProject();
|
||||
$project_id = $project->getID();
|
||||
$project_uri = $this->getApplicationURI("project/{$project_id}/");
|
||||
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setHref($project_uri)
|
||||
->setName($project->getName()));
|
||||
|
||||
try {
|
||||
$branch = $this->getReleephBranch();
|
||||
$branch_uri = $branch->getURI();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setHref($branch_uri)
|
||||
->setName($branch->getDisplayNameWithDetail()));
|
||||
} catch (Exception $ex) {
|
||||
// TODO: This is kind of derps.
|
||||
}
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ final class ReleephBranchCreateController extends ReleephProjectController {
|
|||
$error_view->setTitle(pht('Form Errors'));
|
||||
}
|
||||
|
||||
$project_id = $releeph_project->getID();
|
||||
$project_uri = $this->getApplicationURI("project/{$project_id}/");
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($request->getUser())
|
||||
->appendChild(
|
||||
|
@ -93,15 +96,23 @@ final class ReleephBranchCreateController extends ReleephProjectController {
|
|||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Cut Branch'))
|
||||
->addCancelButton($releeph_project->getURI()));
|
||||
->addCancelButton($project_uri));
|
||||
|
||||
$panel = id(new AphrontPanelView())
|
||||
->appendChild($form)
|
||||
->setHeader(pht('Cut Branch'))
|
||||
->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('New Branch')));
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array($error_view, $panel),
|
||||
array('title' => pht('Cut new branch')));
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$error_view,
|
||||
$form,
|
||||
),
|
||||
array(
|
||||
'title' => pht('New Branch'),
|
||||
'device' => true,
|
||||
'dust' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,59 +5,36 @@ final class ReleephBranchEditController extends ReleephProjectController {
|
|||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$releeph_branch = $this->getReleephBranch();
|
||||
$branch_name = $request->getStr(
|
||||
'branchName',
|
||||
$releeph_branch->getName());
|
||||
$symbolic_name = $request->getStr(
|
||||
'symbolicName',
|
||||
$releeph_branch->getSymbolicName());
|
||||
|
||||
$e_existing_with_same_branch_name = false;
|
||||
$errors = array();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$existing_with_same_branch_name =
|
||||
$existing_with_same_symbolic_name =
|
||||
id(new ReleephBranch())
|
||||
->loadOneWhere(
|
||||
'id != %d AND releephProjectID = %d AND name = %s',
|
||||
'id != %d AND releephProjectID = %d AND symbolicName = %s',
|
||||
$releeph_branch->getID(),
|
||||
$releeph_branch->getReleephProjectID(),
|
||||
$branch_name);
|
||||
$symbolic_name);
|
||||
|
||||
if ($existing_with_same_branch_name) {
|
||||
$errors[] = pht(
|
||||
"The branch name %s is currently taken. Please use another name. ",
|
||||
$branch_name);
|
||||
$e_existing_with_same_branch_name = pht('Error');
|
||||
$releeph_branch->openTransaction();
|
||||
$releeph_branch
|
||||
->setSymbolicName($symbolic_name);
|
||||
|
||||
if ($existing_with_same_symbolic_name) {
|
||||
$existing_with_same_symbolic_name
|
||||
->setSymbolicName(null)
|
||||
->save();
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$existing_with_same_symbolic_name =
|
||||
id(new ReleephBranch())
|
||||
->loadOneWhere(
|
||||
'id != %d AND releephProjectID = %d AND symbolicName = %s',
|
||||
$releeph_branch->getID(),
|
||||
$releeph_branch->getReleephProjectID(),
|
||||
$symbolic_name);
|
||||
$releeph_branch->save();
|
||||
$releeph_branch->saveTransaction();
|
||||
|
||||
$releeph_branch->openTransaction();
|
||||
$releeph_branch
|
||||
->setName($branch_name)
|
||||
->setBasename(last(explode('/', $branch_name)))
|
||||
->setSymbolicName($symbolic_name);
|
||||
|
||||
if ($existing_with_same_symbolic_name) {
|
||||
$existing_with_same_symbolic_name
|
||||
->setSymbolicName(null)
|
||||
->save();
|
||||
}
|
||||
|
||||
$releeph_branch->save();
|
||||
$releeph_branch->saveTransaction();
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/releeph/project/'.$releeph_branch->getReleephProjectID());
|
||||
}
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/releeph/project/'.$releeph_branch->getReleephProjectID());
|
||||
}
|
||||
|
||||
$phids = array();
|
||||
|
@ -74,7 +51,7 @@ final class ReleephBranchEditController extends ReleephProjectController {
|
|||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel(pht('Branch Name'))
|
||||
->setValue($branch_name))
|
||||
->setValue($releeph_branch->getName()))
|
||||
->appendChild(
|
||||
id(new AphrontFormMarkupControl())
|
||||
->setLabel(pht('Cut Point'))
|
||||
|
@ -90,21 +67,6 @@ final class ReleephBranchEditController extends ReleephProjectController {
|
|||
->setValue($symbolic_name)
|
||||
->setCaption(pht('Mutable alternate name, for easy reference, '.
|
||||
'(e.g. "LATEST")')))
|
||||
->appendChild(phutil_tag(
|
||||
'p',
|
||||
array(),
|
||||
pht('In dire situations where the branch name is wrong, ' .
|
||||
'you can edit it in the database by changing the field below. ' .
|
||||
'If you do this, it is very important that you change your ' .
|
||||
'branch\'s name in the VCS to reflect the new name in Releeph, ' .
|
||||
'otherwise a catastrophe of previously unheard-of magnitude ' .
|
||||
'will befall your project.')))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl)
|
||||
->setLabel(pht('New Branch Name'))
|
||||
->setName('branchName')
|
||||
->setValue($branch_name)
|
||||
->setError($e_existing_with_same_branch_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($releeph_branch->getURI())
|
||||
|
@ -122,16 +84,21 @@ final class ReleephBranchEditController extends ReleephProjectController {
|
|||
'Edit Branch %s',
|
||||
$releeph_branch->getDisplayNameWithDetail());
|
||||
|
||||
$panel = id(new AphrontPanelView())
|
||||
->setHeader($title)
|
||||
->appendChild($form)
|
||||
->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit')));
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$error_view,
|
||||
$panel,
|
||||
$form,
|
||||
),
|
||||
array('title' => $title));
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
'dust' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,17 +76,8 @@ final class ReleephBranchViewController extends ReleephProjectController
|
|||
|
||||
public function buildApplicationCrumbs() {
|
||||
$releeph_branch = $this->getReleephBranch();
|
||||
$releeph_project = $this->getReleephProject();
|
||||
|
||||
$crumbs = parent::buildApplicationCrumbs()
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($releeph_project->getName())
|
||||
->setHref($releeph_project->getURI()))
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($releeph_branch->getDisplayNameWithDetail())
|
||||
->setHref($releeph_branch->getURI()));
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
if ($releeph_branch->isActive()) {
|
||||
$create_uri = $releeph_branch->getURI('request/');
|
||||
|
|
|
@ -101,5 +101,4 @@ final class ReleephProjectListController extends ReleephController
|
|||
return $crumbs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -156,10 +156,6 @@ final class ReleephProjectViewController extends ReleephProjectController
|
|||
|
||||
$project = $this->getReleephProject();
|
||||
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($project->getName()));
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setHref($project->getURI('cutbranch'))
|
||||
|
|
Loading…
Reference in a new issue