From bd17fac9352c4637ab8c59ab4a17e92a368012b3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 16 Aug 2013 18:58:26 -0700 Subject: [PATCH] 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 --- .../controller/ReleephProjectController.php | 27 ++++++ .../branch/ReleephBranchCreateController.php | 27 ++++-- .../branch/ReleephBranchEditController.php | 89 ++++++------------- .../branch/ReleephBranchViewController.php | 11 +-- .../project/ReleephProjectListController.php | 1 - .../project/ReleephProjectViewController.php | 4 - 6 files changed, 75 insertions(+), 84 deletions(-) diff --git a/src/applications/releeph/controller/ReleephProjectController.php b/src/applications/releeph/controller/ReleephProjectController.php index 5b93b04172..c7530e1d79 100644 --- a/src/applications/releeph/controller/ReleephProjectController.php +++ b/src/applications/releeph/controller/ReleephProjectController.php @@ -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; + } + + } diff --git a/src/applications/releeph/controller/branch/ReleephBranchCreateController.php b/src/applications/releeph/controller/branch/ReleephBranchCreateController.php index 3f53d24650..8e9391f68c 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchCreateController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchCreateController.php @@ -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, + )); } } diff --git a/src/applications/releeph/controller/branch/ReleephBranchEditController.php b/src/applications/releeph/controller/branch/ReleephBranchEditController.php index 0d1439c498..fe0b491688 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchEditController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchEditController.php @@ -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, + )); } } diff --git a/src/applications/releeph/controller/branch/ReleephBranchViewController.php b/src/applications/releeph/controller/branch/ReleephBranchViewController.php index aa8ecf2b77..517ae7d50b 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchViewController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchViewController.php @@ -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/'); diff --git a/src/applications/releeph/controller/project/ReleephProjectListController.php b/src/applications/releeph/controller/project/ReleephProjectListController.php index 66c5e263cd..93a491a1f8 100644 --- a/src/applications/releeph/controller/project/ReleephProjectListController.php +++ b/src/applications/releeph/controller/project/ReleephProjectListController.php @@ -101,5 +101,4 @@ final class ReleephProjectListController extends ReleephController return $crumbs; } - } diff --git a/src/applications/releeph/controller/project/ReleephProjectViewController.php b/src/applications/releeph/controller/project/ReleephProjectViewController.php index 1ae62b0175..5941c7400c 100644 --- a/src/applications/releeph/controller/project/ReleephProjectViewController.php +++ b/src/applications/releeph/controller/project/ReleephProjectViewController.php @@ -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'))