diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -98,12 +98,12 @@ 'rsrc/css/application/releeph/releeph-branch.css' => 'b8821d2d', 'rsrc/css/application/releeph/releeph-colors.css' => '2d2d6aa8', 'rsrc/css/application/releeph/releeph-core.css' => '140b959d', - 'rsrc/css/application/releeph/releeph-intents.css' => '7364ac97', - 'rsrc/css/application/releeph/releeph-preview-branch.css' => '0e383ca3', + 'rsrc/css/application/releeph/releeph-intents.css' => '39065521', + 'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5', 'rsrc/css/application/releeph/releeph-project.css' => 'ee1f9f57', 'rsrc/css/application/releeph/releeph-request-differential-create-dialog.css' => '8d8b92cd', 'rsrc/css/application/releeph/releeph-request-typeahead.css' => '667a48ae', - 'rsrc/css/application/releeph/releeph-status.css' => 'a20631d9', + 'rsrc/css/application/releeph/releeph-status.css' => 'd119a005', 'rsrc/css/application/search/search-results.css' => 'f240504c', 'rsrc/css/application/settings/settings.css' => 'ea8f5915', 'rsrc/css/application/slowvote/slowvote.css' => '266df6a1', @@ -777,12 +777,12 @@ 'releeph-branch' => 'b8821d2d', 'releeph-colors' => '2d2d6aa8', 'releeph-core' => '140b959d', - 'releeph-intents' => '7364ac97', - 'releeph-preview-branch' => '0e383ca3', + 'releeph-intents' => '39065521', + 'releeph-preview-branch' => 'b7a6f4a5', 'releeph-project' => 'ee1f9f57', 'releeph-request-differential-create-dialog' => '8d8b92cd', 'releeph-request-typeahead-css' => '667a48ae', - 'releeph-status' => 'a20631d9', + 'releeph-status' => 'd119a005', 'setup-issue-css' => '69e640e7', 'sprite-actions-css' => '969ad0e5', 'sprite-apps-css' => '6973a52b', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2542,12 +2542,12 @@ 'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php', 'ReleephProductViewController' => 'applications/releeph/controller/project/ReleephProductViewController.php', 'ReleephProject' => 'applications/releeph/storage/ReleephProject.php', - 'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php', 'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.php', 'ReleephReasonFieldSpecification' => 'applications/releeph/field/specification/ReleephReasonFieldSpecification.php', 'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php', 'ReleephRequestActionController' => 'applications/releeph/controller/request/ReleephRequestActionController.php', 'ReleephRequestCommentController' => 'applications/releeph/controller/request/ReleephRequestCommentController.php', + 'ReleephRequestController' => 'applications/releeph/controller/request/ReleephRequestController.php', 'ReleephRequestDifferentialCreateController' => 'applications/releeph/controller/request/ReleephRequestDifferentialCreateController.php', 'ReleephRequestEditController' => 'applications/releeph/controller/request/ReleephRequestEditController.php', 'ReleephRequestHeaderListView' => 'applications/releeph/view/request/header/ReleephRequestHeaderListView.php', @@ -5527,7 +5527,7 @@ 'ReleephPHIDTypeRequest' => 'PhabricatorPHIDType', 'ReleephProductActionController' => 'ReleephProductController', 'ReleephProductController' => 'ReleephController', - 'ReleephProductCreateController' => 'ReleephProjectController', + 'ReleephProductCreateController' => 'ReleephProductController', 'ReleephProductEditController' => 'ReleephProductController', 'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor', 'ReleephProductHistoryController' => 'ReleephProductController', @@ -5549,7 +5549,6 @@ 0 => 'ReleephDAO', 1 => 'PhabricatorPolicyInterface', ), - 'ReleephProjectController' => 'ReleephController', 'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', 'ReleephRequest' => @@ -5558,10 +5557,11 @@ 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorCustomFieldInterface', ), - 'ReleephRequestActionController' => 'ReleephProjectController', - 'ReleephRequestCommentController' => 'ReleephProjectController', - 'ReleephRequestDifferentialCreateController' => 'ReleephProjectController', - 'ReleephRequestEditController' => 'ReleephProjectController', + 'ReleephRequestActionController' => 'ReleephRequestController', + 'ReleephRequestCommentController' => 'ReleephRequestController', + 'ReleephRequestController' => 'ReleephController', + 'ReleephRequestDifferentialCreateController' => 'ReleephController', + 'ReleephRequestEditController' => 'ReleephBranchController', 'ReleephRequestHeaderListView' => 'AphrontView', 'ReleephRequestHeaderView' => 'AphrontView', 'ReleephRequestIntentsView' => 'AphrontView', @@ -5576,7 +5576,7 @@ 'ReleephRequestTransactionalEditor' => 'PhabricatorApplicationTransactionEditor', 'ReleephRequestTypeaheadControl' => 'AphrontFormControl', 'ReleephRequestTypeaheadController' => 'PhabricatorTypeaheadDatasourceController', - 'ReleephRequestViewController' => 'ReleephProjectController', + 'ReleephRequestViewController' => 'ReleephBranchController', 'ReleephRequestorFieldSpecification' => 'ReleephFieldSpecification', 'ReleephRevisionFieldSpecification' => 'ReleephFieldSpecification', 'ReleephSeverityFieldSpecification' => 'ReleephLevelFieldSpecification', diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php --- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php +++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php @@ -31,7 +31,13 @@ public function getRoutes() { return array( + '/Y(?P[1-9]\d*)' => 'ReleephRequestViewController', + + // TODO: Remove these older routes eventually. '/RQ(?P[1-9]\d*)' => 'ReleephRequestViewController', + '/releeph/request/(?P[1-9]\d*)/' + => 'ReleephRequestViewController', + '/releeph/' => array( '' => 'ReleephProductListController', 'project/' => array( @@ -45,6 +51,7 @@ 'history/' => 'ReleephProductHistoryController', ), ), + 'branch/' => array( 'edit/(?P[1-9]\d*)/' => 'ReleephBranchEditController', @@ -55,9 +62,11 @@ 'history/' => 'ReleephBranchHistoryController', '(?:query/(?P[^/]+)/)?' => 'ReleephBranchViewController', ), + 'pull/(?P[1-9]\d*)/' => + 'ReleephRequestEditController', ), + 'request/' => array( - '(?P[1-9]\d*)/' => 'ReleephRequestViewController', 'create/' => 'ReleephRequestEditController', 'differentialcreate/' => array( 'D(?P[1-9]\d*)' => @@ -72,14 +81,6 @@ 'comment/(?P[1-9]\d*)/' => 'ReleephRequestCommentController', ), - - // Branch navigation made pretty, as it's the most common: - '(?P[^/]+)/(?P[^/]+)/' => array( - '(?:query/(?P[^/]+)/)?' => 'ReleephBranchViewController', - 'edit/' => 'ReleephBranchEditController', - 'request/' => 'ReleephRequestEditController', - '(?Pclose|re-open)/' => 'ReleephBranchAccessController', - ), ) ); } diff --git a/src/applications/releeph/controller/ReleephProjectController.php b/src/applications/releeph/controller/ReleephProjectController.php deleted file mode 100644 --- a/src/applications/releeph/controller/ReleephProjectController.php +++ /dev/null @@ -1,155 +0,0 @@ -getRequest()->getUser(); - - // Project - $project = null; - $project_id = idx($data, 'projectID'); - $project_name = idx($data, 'projectName'); - if ($project_id) { - $project = id(new ReleephProjectQuery()) - ->setViewer($viewer) - ->withIDs(array($project_id)) - ->executeOne(); - if (!$project) { - throw new Exception( - "ReleephProject with id '{$project_id}' not found!"); - } - } elseif ($project_name) { - $project = id(new ReleephProject()) - ->loadOneWhere('name = %s', $project_name); - if (!$project) { - throw new Exception( - "ReleephProject with name '{$project_name}' not found!"); - } - } - - // Branch - $branch = null; - $branch_id = idx($data, 'branchID'); - $branch_name = idx($data, 'branchName'); - if ($branch_id) { - $branch = id(new ReleephBranchQuery()) - ->setViewer($viewer) - ->withIDs(array($branch_id)) - ->executeOne(); - if (!$branch) { - throw new Exception("Branch with id '{$branch_id}' not found!"); - } - } elseif ($branch_name) { - if (!$project) { - throw new Exception( - "You cannot refer to a branch by name without also referring ". - "to a ReleephProject (branch names are only unique in projects)."); - } - $branch = id(new ReleephBranch())->loadOneWhere( - 'basename = %s AND releephProjectID = %d', - $branch_name, - $project->getID()); - if (!$branch) { - throw new Exception( - "ReleephBranch with basename '{$branch_name}' not found ". - "in project '{$project->getName()}'!"); - } - // Do the branch query again, properly, to hit policies and load attached - // data. - // TODO: Clean this up with T3657. - $branch = id(new ReleephBranchQuery()) - ->setViewer($viewer) - ->withIDs(array($branch->getID())) - ->executeOne(); - if (!$branch) { - throw new Exception('404!'); - } - } - - // Request - $request = null; - $request_id = idx($data, 'requestID'); - if ($request_id) { - $request = id(new ReleephRequest())->load($request_id); - if (!$request) { - throw new Exception( - "ReleephRequest with id '{$request_id}' not found!"); - } - } - - // Fill in the gaps - if ($request && !$branch) { - $branch = $request->loadReleephBranch(); - } - - if ($branch && !$project) { - $project = $branch->loadReleephProject(); - } - - // Set! - $this->releephProject = $project; - $this->releephBranch = $branch; - $this->releephRequest = $request; - } - - protected function getReleephProject() { - if (!$this->releephProject) { - throw new Exception( - 'This controller did not load a ReleephProject from the URL $data.'); - } - return $this->releephProject; - } - - protected function getReleephBranch() { - if (!$this->releephBranch) { - throw new Exception( - 'This controller did not load a ReleephBranch from the URL $data.'); - } - return $this->releephBranch; - } - - protected function getReleephRequest() { - if (!$this->releephRequest) { - throw new Exception( - 'This controller did not load a ReleephRequest from the URL $data.'); - } - return $this->releephRequest; - } - - protected function buildApplicationCrumbs() { - $crumbs = parent::buildApplicationCrumbs(); - - // TODO: The massive amount of derps here should be fixed once URIs get - // sorted out; see T3657. - - try { - $project = $this->getReleephProject(); - $project_id = $project->getID(); - $project_uri = $this->getApplicationURI("project/{$project_id}/"); - - $crumbs->addTextCrumb($project->getName(), $project_uri); - } catch (Exception $ex) { - // TODO: This is derps. - } - - try { - $branch = $this->getReleephBranch(); - $branch_uri = $branch->getURI(); - $crumbs->addTextCrumb($branch->getDisplayNameWithDetail(), $branch_uri); - } catch (Exception $ex) { - // TODO: This is also derps. - } - - return $crumbs; - } - - -} diff --git a/src/applications/releeph/controller/branch/ReleephBranchViewController.php b/src/applications/releeph/controller/branch/ReleephBranchViewController.php --- a/src/applications/releeph/controller/branch/ReleephBranchViewController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchViewController.php @@ -52,7 +52,6 @@ $requests); $list = id(new ReleephRequestHeaderListView()) - ->setOriginType('branch') ->setUser($viewer) ->setAphrontRequest($this->getRequest()) ->setReleephProject($branch->getProduct()) @@ -87,10 +86,10 @@ $crumbs = parent::buildApplicationCrumbs(); $branch = $this->getBranch(); - $create_uri = $branch->getURI('request/'); + $crumbs->addAction( id(new PHUIListItemView()) - ->setHref($create_uri) + ->setHref($this->getApplicationURI('branch/pull/'.$branch->getID().'/')) ->setName(pht('New Pull Request')) ->setIcon('create') ->setDisabled(!$branch->isActive())); diff --git a/src/applications/releeph/controller/project/ReleephProductCreateController.php b/src/applications/releeph/controller/project/ReleephProductCreateController.php --- a/src/applications/releeph/controller/project/ReleephProductCreateController.php +++ b/src/applications/releeph/controller/project/ReleephProductCreateController.php @@ -1,6 +1,6 @@ getRequest(); diff --git a/src/applications/releeph/controller/request/ReleephRequestActionController.php b/src/applications/releeph/controller/request/ReleephRequestActionController.php --- a/src/applications/releeph/controller/request/ReleephRequestActionController.php +++ b/src/applications/releeph/controller/request/ReleephRequestActionController.php @@ -1,32 +1,39 @@ action = $data['action']; + $this->requestID = $data['requestID']; } public function processRequest() { $request = $this->getRequest(); + $viewer = $request->getUser(); + + $pull = id(new ReleephRequestQuery()) + ->setViewer($viewer) + ->withIDs(array($this->requestID)) + ->executeOne(); + if (!$pull) { + return new Aphront404Response(); + } - $releeph_project = $this->getReleephProject(); - $releeph_branch = $this->getReleephBranch(); - $releeph_request = $this->getReleephRequest(); + $branch = $pull->getBranch(); + $product = $branch->getProduct(); - $releeph_branch->populateReleephRequestHandles( - $request->getUser(), array($releeph_request)); + $branch->populateReleephRequestHandles($viewer, array($pull)); $action = $this->action; - $user = $request->getUser(); - - $origin_uri = $releeph_request->loadReleephBranch()->getURI(); + $origin_uri = '/'.$pull->getMonogram(); $editor = id(new ReleephRequestTransactionalEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); @@ -43,15 +50,15 @@ ->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT) ->setMetadataValue( 'isAuthoritative', - $releeph_project->isAuthoritative($user)) + $product->isAuthoritative($viewer)) ->setNewValue($intent); break; case 'mark-manually-picked': case 'mark-manually-reverted': if ( - $releeph_request->getRequestUserPHID() === $user->getPHID() || - $releeph_project->isAuthoritative($user)) { + $pull->getRequestUserPHID() === $viewer->getPHID() || + $product->isAuthoritative($viewer)) { // We're all good! } else { @@ -84,25 +91,24 @@ throw new Exception("unknown or unimplemented action {$action}"); } - $editor->applyTransactions($releeph_request, $xactions); + $editor->applyTransactions($pull, $xactions); // If we're adding a new user to userIntents, we'll have to re-populate // request handles to load that user's data. // // This is cheap enough to do every time. - $this->getReleephBranch()->populateReleephRequestHandles( - $user, array($releeph_request)); + $branch->populateReleephRequestHandles($viewer, array($pull)); $list = id(new ReleephRequestHeaderListView()) - ->setReleephProject($this->getReleephProject()) - ->setReleephBranch($this->getReleephBranch()) - ->setReleephRequests(array($releeph_request)) - ->setUser($request->getUser()) - ->setAphrontRequest($this->getRequest()) - ->setOriginType('request'); - - return id(new AphrontAjaxResponse())->setContent(array( - 'markup' => head($list->renderInner()) - )); + ->setReleephProject($product) + ->setReleephBranch($branch) + ->setReleephRequests(array($pull)) + ->setUser($viewer) + ->setAphrontRequest($request); + + return id(new AphrontAjaxResponse())->setContent( + array( + 'markup' => hsprintf('%s', $list->renderInner()), + )); } } diff --git a/src/applications/releeph/controller/request/ReleephRequestCommentController.php b/src/applications/releeph/controller/request/ReleephRequestCommentController.php --- a/src/applications/releeph/controller/request/ReleephRequestCommentController.php +++ b/src/applications/releeph/controller/request/ReleephRequestCommentController.php @@ -1,22 +1,34 @@ requestID = $data['requestID']; + } public function processRequest() { $request = $this->getRequest(); - $user = $request->getUser(); - - $rq = $this->getReleephRequest(); + $viewer = $request->getUser(); if (!$request->isFormPost()) { return new Aphront400Response(); } + $pull = id(new ReleephRequestQuery()) + ->setViewer($viewer) + ->withIDs(array($this->requestID)) + ->executeOne(); + if (!$pull) { + return new Aphront404Response(); + } + $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); - $view_uri = $this->getApplicationURI('/RQ'.$rq->getID()); + $view_uri = $this->getApplicationURI('/'.$pull->getMonogram()); $xactions = array(); $xactions[] = id(new ReleephRequestTransaction()) @@ -26,13 +38,13 @@ ->setContent($request->getStr('comment'))); $editor = id(new ReleephRequestTransactionalEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect($request->isContinueRequest()) ->setContentSourceFromRequest($request) ->setIsPreview($is_preview); try { - $xactions = $editor->applyTransactions($rq, $xactions); + $xactions = $editor->applyTransactions($pull, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse()) ->setCancelURI($view_uri) @@ -45,7 +57,7 @@ if ($request->isAjax()) { return id(new PhabricatorApplicationTransactionResponse()) - ->setViewer($user) + ->setViewer($viewer) ->setTransactions($xactions) ->setIsPreview($is_preview) ->setAnchorOffset($request->getStr('anchor')); diff --git a/src/applications/releeph/controller/request/ReleephRequestController.php b/src/applications/releeph/controller/request/ReleephRequestController.php new file mode 100644 --- /dev/null +++ b/src/applications/releeph/controller/request/ReleephRequestController.php @@ -0,0 +1,5 @@ +id = idx($data, 'requestID'); - parent::willProcessRequest($data); + $this->requestID = idx($data, 'requestID'); + $this->branchID = idx($data, 'branchID'); } public function processRequest() { $request = $this->getRequest(); - $user = $request->getUser(); + $viewer = $request->getUser(); - $releeph_project = $this->getReleephProject(); - $releeph_branch = $this->getReleephBranch(); - - $request_identifier = $request->getStr('requestIdentifierRaw'); - $e_request_identifier = true; - - // Load the RQ we're editing, or create a new one - if ($this->id) { - $rq = id(new ReleephRequestQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + if ($this->requestID) { + $pull = id(new ReleephRequestQuery()) + ->setViewer($viewer) + ->withIDs(array($this->requestID)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); + if (!$pull) { + return new Aphront404Response(); + } + + $branch = $pull->getBranch(); + $is_edit = true; } else { - $is_edit = false; - $rq = id(new ReleephRequest()) - ->setRequestUserPHID($user->getPHID()) - ->setBranchID($releeph_branch->getID()) + $branch = id(new ReleephBranchQuery()) + ->setViewer($viewer) + ->withIDs(array($this->branchID)) + ->executeOne(); + if (!$branch) { + return new Aphront404Response(); + } + + $pull = id(new ReleephRequest()) + ->setRequestUserPHID($viewer->getPHID()) + ->setBranchID($branch->getID()) ->setInBranch(0); + + $is_edit = false; } + $this->setBranch($branch); + + $product = $branch->getProduct(); + + $request_identifier = $request->getStr('requestIdentifierRaw'); + $e_request_identifier = true; // Load all the ReleephFieldSpecifications - $selector = $this->getReleephProject()->getReleephFieldSelector(); + $selector = $branch->getProduct()->getReleephFieldSelector(); $fields = $selector->getFieldSpecifications(); foreach ($fields as $field) { $field - ->setReleephProject($releeph_project) - ->setReleephBranch($releeph_branch) - ->setReleephRequest($rq); + ->setReleephProject($product) + ->setReleephBranch($branch) + ->setReleephRequest($pull); } $field_list = PhabricatorCustomField::getObjectFields( - $rq, + $pull, PhabricatorCustomField::ROLE_EDIT); foreach ($field_list->getFields() as $field) { $field - ->setReleephProject($releeph_project) - ->setReleephBranch($releeph_branch) - ->setReleephRequest($rq); + ->setReleephProject($product) + ->setReleephBranch($branch) + ->setReleephRequest($pull); } - $field_list->readFieldsFromStorage($rq); - - - // epriestley: Is it common to pass around a referer URL to - // return from whence one came? [...] - // If you only have two places, maybe consider some parameter - // rather than the full URL. - switch ($request->getStr('origin')) { - case 'request': - $origin_uri = '/RQ'.$rq->getID(); - break; - - case 'branch': - default: - $origin_uri = $releeph_branch->getURI(); - break; + $field_list->readFieldsFromStorage($pull); + + + if ($this->branchID) { + $cancel_uri = $this->getApplicationURI('branch/'.$this->branchID.'/'); + } else { + $cancel_uri = '/'.$pull->getMonogram(); } // Make edits @@ -91,8 +97,8 @@ } else { $pr_commit = null; $finder = id(new ReleephCommitFinder()) - ->setUser($user) - ->setReleephProject($releeph_project); + ->setUser($viewer) + ->setReleephProject($product); try { $pr_commit = $finder->fromPartial($request_identifier); } catch (Exception $e) { @@ -115,7 +121,7 @@ if (!$errors) { $existing = id(new ReleephRequest()) ->loadOneWhere('requestCommitPHID = %s AND branchID = %d', - $pr_commit->getPHID(), $releeph_branch->getID()); + $pr_commit->getPHID(), $branch->getID()); if ($existing) { return id(new AphrontRedirectResponse()) ->setURI('/releeph/request/edit/'.$existing->getID(). @@ -130,10 +136,10 @@ ->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT) // To help hide these implicit intents... ->setMetadataValue('isRQCreate', true) - ->setMetadataValue('userPHID', $user->getPHID()) + ->setMetadataValue('userPHID', $viewer->getPHID()) ->setMetadataValue( 'isAuthoritative', - $releeph_project->isAuthoritative($user)) + $product->isAuthoritative($viewer)) ->setNewValue(ReleephRequest::INTENT_WANT); } } @@ -164,21 +170,21 @@ if (!$errors) { $editor = id(new ReleephRequestTransactionalEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); - $editor->applyTransactions($rq, $xactions); - return id(new AphrontRedirectResponse())->setURI($origin_uri); + $editor->applyTransactions($pull, $xactions); + return id(new AphrontRedirectResponse())->setURI($cancel_uri); } } - $releeph_branch->populateReleephRequestHandles($user, array($rq)); - $handles = $rq->getHandles(); + $branch->populateReleephRequestHandles($viewer, array($pull)); + $handles = $pull->getHandles(); $age_string = ''; if ($is_edit) { $age_string = phabricator_format_relative_time( - time() - $rq->getDateCreated()) . ' ago'; + time() - $pull->getDateCreated()) . ' ago'; } // Warn the user if we've been redirected here because we tried to @@ -190,24 +196,15 @@ hsprintf( "Requested %s by %s", $age_string, - $handles[$rq->getRequestUserPHID()]->renderLink()) + $handles[$pull->getRequestUserPHID()]->renderLink()) ); $notice_view = id(new AphrontErrorView()) ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) ->setErrors($notice_messages); } - /** - * Build the rest of the page - */ - $error_view = null; - if ($errors) { - $error_view = new AphrontErrorView(); - $error_view->setErrors($errors); - } - $form = id(new AphrontFormView()) - ->setUser($user); + ->setUser($viewer); if ($is_edit) { $form @@ -215,20 +212,20 @@ id(new AphrontFormMarkupControl()) ->setLabel('Original Commit') ->setValue( - $handles[$rq->getRequestCommitPHID()]->renderLink())) + $handles[$pull->getRequestCommitPHID()]->renderLink())) ->appendChild( id(new AphrontFormMarkupControl()) ->setLabel('Requestor') ->setValue(hsprintf( '%s %s', - $handles[$rq->getRequestUserPHID()]->renderLink(), + $handles[$pull->getRequestUserPHID()]->renderLink(), $age_string))); } else { $origin = null; $diff_rev_id = $request->getStr('D'); if ($diff_rev_id) { $diff_rev = id(new DifferentialRevisionQuery()) - ->setViewer($user) + ->setViewer($viewer) ->withIDs(array($diff_rev_id)) ->executeOne(); $origin = '/D'.$diff_rev->getID(); @@ -243,12 +240,12 @@ ->setLabel('Diff') ->setValue($title)); } else { - $origin = $releeph_branch->getURI(); - $repo = $releeph_project->loadPhabricatorRepository(); + $origin = $branch->getURI(); + $repo = $product->loadPhabricatorRepository(); $branch_cut_point = id(new PhabricatorRepositoryCommit()) ->loadOneWhere( 'phid = %s', - $releeph_branch->getCutPointCommitPHID()); + $branch->getCutPointCommitPHID()); $form->appendChild( id(new ReleephRequestTypeaheadControl()) ->setName('requestIdentifierRaw') @@ -268,32 +265,37 @@ $crumbs = $this->buildApplicationCrumbs(); if ($is_edit) { - $title = pht('Edit Releeph Request'); + $title = pht('Edit Pull Request'); $submit_name = pht('Save'); - $crumbs->addTextCrumb('RQ'.$rq->getID(), '/RQ'.$rq->getID()); + $crumbs->addTextCrumb($pull->getMonogram(), '/'.$pull->getMonogram()); $crumbs->addTextCrumb(pht('Edit')); - } else { - $title = pht('Create Releeph Request'); - $submit_name = pht('Create'); - $crumbs->addTextCrumb(pht('New Request')); + $title = pht('Create Pull Request'); + $submit_name = pht('Create Pull Request'); + + $crumbs->addTextCrumb(pht('New Pull Request')); } $form->appendChild( id(new AphrontFormSubmitControl()) - ->addCancelButton($origin_uri, 'Cancel') + ->addCancelButton($cancel_uri, 'Cancel') ->setValue($submit_name)); + $box = id(new PHUIObjectBoxView()) + ->setHeaderText($title) + ->setFormErrors($errors) + ->appendChild($form); + return $this->buildApplicationPage( array( $crumbs, $notice_view, - $error_view, - $form, + $box, ), array( 'title' => $title, + 'device' => true, )); } } diff --git a/src/applications/releeph/controller/request/ReleephRequestViewController.php b/src/applications/releeph/controller/request/ReleephRequestViewController.php --- a/src/applications/releeph/controller/request/ReleephRequestViewController.php +++ b/src/applications/releeph/controller/request/ReleephRequestViewController.php @@ -1,95 +1,93 @@ requestID = $data['requestID']; + } public function processRequest() { $request = $this->getRequest(); - - $uri_path = $request->getRequestURI()->getPath(); - $legacy_prefix = '/releeph/request/'; - if (strncmp($uri_path, $legacy_prefix, strlen($legacy_prefix)) === 0) { - return id(new AphrontRedirectResponse()) - ->setURI('/RQ'.$this->getReleephRequest()->getID()); + $viewer = $request->getUser(); + + $pull = id(new ReleephRequestQuery()) + ->setViewer($viewer) + ->withIDs(array($this->requestID)) + ->executeOne(); + if (!$pull) { + return new Aphront404Response(); + } + $this->setBranch($pull->getBranch()); + + // Redirect older URIs to new "Y" URIs. + // TODO: Get rid of this eventually. + $actual_path = $request->getRequestURI()->getPath(); + $expect_path = '/'.$pull->getMonogram(); + if ($actual_path != $expect_path) { + return id(new AphrontRedirectResponse())->setURI($expect_path); } - $releeph_request = $this->getReleephRequest(); - $releeph_branch = $this->getReleephBranch(); - $releeph_project = $this->getReleephProject(); - - $releeph_branch->populateReleephRequestHandles( - $request->getUser(), array($releeph_request)); + // TODO: Break this 1:1 stuff? + $branch = $pull->getBranch(); - $rq_view = - id(new ReleephRequestHeaderListView()) - ->setReleephProject($releeph_project) - ->setReleephBranch($releeph_branch) - ->setReleephRequests(array($releeph_request)) - ->setUser($request->getUser()) - ->setAphrontRequest($this->getRequest()) - ->setReloadOnStateChange(true) - ->setOriginType('request'); + // TODO: Very gross. + $branch->populateReleephRequestHandles( + $viewer, + array($pull)); - $user = $request->getUser(); + $rq_view = id(new ReleephRequestHeaderListView()) + ->setReleephProject($branch->getProduct()) + ->setReleephBranch($branch) + ->setReleephRequests(array($pull)) + ->setUser($viewer) + ->setAphrontRequest($request) + ->setReloadOnStateChange(true); $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($user); + ->setViewer($viewer); $xactions = id(new ReleephRequestTransactionQuery()) - ->setViewer($user) - ->withObjectPHIDs(array($releeph_request->getPHID())) + ->setViewer($viewer) + ->withObjectPHIDs(array($pull->getPHID())) ->execute(); - foreach ($xactions as $xaction) { - if ($xaction->getComment()) { - $engine->addObject( - $xaction->getComment(), - PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); - } - } - $engine->process(); - $timeline = id(new PhabricatorApplicationTransactionView()) ->setUser($request->getUser()) - ->setObjectPHID($releeph_request->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + ->setObjectPHID($pull->getPHID()) + ->setTransactions($xactions); - $add_comment_header = pht('Plea or yield'); + $add_comment_header = pht('Plea or Yield'); $draft = PhabricatorDraft::newFromUserAndKey( - $user, - $releeph_request->getPHID()); + $viewer, + $pull->getPHID()); - $title = hsprintf("RQ%d: %s", - $releeph_request->getID(), - $releeph_request->getSummaryForDisplay()); + $title = hsprintf( + "%s %s", + $pull->getMonogram(), + $pull->getSummaryForDisplay()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) - ->setUser($user) - ->setObjectPHID($releeph_request->getPHID()) + ->setUser($viewer) + ->setObjectPHID($pull->getPHID()) ->setDraft($draft) ->setHeaderText($add_comment_header) ->setAction($this->getApplicationURI( - '/request/comment/'.$releeph_request->getID().'/')) - ->setSubmitButtonName('Comment'); - - $crumbs = $this->buildApplicationCrumbs() - ->addTextCrumb($releeph_project->getName(), $releeph_project->getURI()) - ->addTextCrumb( - $releeph_branch->getDisplayNameWithDetail(), - $releeph_branch->getURI()) - ->addTextCrumb( - 'RQ'.$releeph_request->getID(), - '/RQ'.$releeph_request->getID()); + '/request/comment/'.$pull->getID().'/')) + ->setSubmitButtonName(pht('Comment')); + + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addTextCrumb($pull->getMonogram(), '/'.$pull->getMonogram()); return $this->buildStandardPageResponse( array( $crumbs, - array( - $rq_view, - $timeline, - $add_comment_form, - ) + $rq_view, + $timeline, + $add_comment_form, ), array( 'title' => $title diff --git a/src/applications/releeph/query/ReleephRequestQuery.php b/src/applications/releeph/query/ReleephRequestQuery.php --- a/src/applications/releeph/query/ReleephRequestQuery.php +++ b/src/applications/releeph/query/ReleephRequestQuery.php @@ -118,6 +118,21 @@ } } + $branch_ids = array_unique(mpull($requests, 'getBranchID')); + $branches = id(new ReleephBranchQuery()) + ->withIDs($branch_ids) + ->setViewer($this->getViewer()) + ->execute(); + $branches = mpull($branches, null, 'getID'); + foreach ($requests as $key => $request) { + $branch = idx($branches, $request->getBranchID()); + if (!$branch) { + unset($requests[$key]); + continue; + } + $request->attachBranch($branch); + } + return $requests; } diff --git a/src/applications/releeph/storage/ReleephBranch.php b/src/applications/releeph/storage/ReleephBranch.php --- a/src/applications/releeph/storage/ReleephBranch.php +++ b/src/applications/releeph/storage/ReleephBranch.php @@ -181,19 +181,21 @@ public function getCapabilities() { - return $this->getProject()->getCapabilities(); + return $this->getProduct()->getCapabilities(); } public function getPolicy($capability) { - return $this->getProject()->getPolicy($capability); + return $this->getProduct()->getPolicy($capability); } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { - return $this->getProject()->hasAutomaticCapability($capability, $viewer); + return $this->getProduct()->hasAutomaticCapability($capability, $viewer); } public function describeAutomaticCapability($capability) { - return null; + return pht( + 'Release branches have the same policies as the product they are a '. + 'part of.'); } diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -22,7 +22,9 @@ // Pre-populated handles that we'll bulk load in ReleephBranch private $handles = self::ATTACHABLE; + private $customFields = self::ATTACHABLE; + private $branch = self::ATTACHABLE; @@ -89,6 +91,19 @@ return $this->calculateStatus(); } + public function getMonogram() { + return 'Y'.$this->getID(); + } + + public function getBranch() { + return $this->assertAttached($this->branch); + } + + public function attachBranch(ReleephBranch $branch) { + $this->branch = $branch; + return $this; + } + private function calculateStatus() { if ($this->shouldBeInBranch()) { if ($this->getInBranch()) { @@ -305,15 +320,17 @@ } public function getPolicy($capability) { - return PhabricatorPolicies::POLICY_USER; + return $this->getBranch()->getPolicy($capability); } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { - return false; + return $this->getBranch()->hasAutomaticCapability($capability, $viewer); } public function describeAutomaticCapability($capability) { - return null; + return pht( + 'Pull requests have the same policies as the branches they are '. + 'requested against.'); } diff --git a/src/applications/releeph/view/request/header/ReleephRequestHeaderListView.php b/src/applications/releeph/view/request/header/ReleephRequestHeaderListView.php --- a/src/applications/releeph/view/request/header/ReleephRequestHeaderListView.php +++ b/src/applications/releeph/view/request/header/ReleephRequestHeaderListView.php @@ -3,7 +3,6 @@ final class ReleephRequestHeaderListView extends AphrontView { - private $originType; private $releephProject; private $releephBranch; private $releephRequests; @@ -12,11 +11,6 @@ private $errors = array(); - public function setOriginType($origin) { - $this->originType = $origin; - return $this; - } - public function setReleephProject(ReleephProject $rp) { $this->releephProject = $rp; return $this; @@ -113,7 +107,6 @@ $views[] = id(new ReleephRequestHeaderView()) ->setUser($this->user) ->setAphrontRequest($this->aphrontRequest) - ->setOriginType($this->originType) ->setReleephProject($this->releephProject) ->setReleephBranch($this->releephBranch) ->setReleephRequest($releeph_request) diff --git a/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php b/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php --- a/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php +++ b/src/applications/releeph/view/request/header/ReleephRequestHeaderView.php @@ -8,7 +8,6 @@ private $releephRequest; private $releephBranch; private $releephProject; - private $originType; private $fieldGroups; public function setAphrontRequest(AphrontRequest $request) { @@ -31,21 +30,11 @@ return $this; } - public function setOriginType($origin) { - // For the Edit controller - $this->originType = $origin; - return $this; - } - public function setReleephFieldGroups(array $field_groups) { $this->fieldGroups = $field_groups; return $this; } - protected function getOrigin() { - return $this->originType; - } - public function render() { require_celerity_resource('releeph-core'); $all_properties_table = $this->renderFields(); @@ -262,8 +251,7 @@ $right_buttons[] = phutil_tag( 'a', array( - 'href' => '/releeph/request/edit/'.$this->releephRequest->getID(). - '?origin='.$this->originType, + 'href' => '/releeph/request/edit/'.$this->releephRequest->getID().'/', 'class' => 'small blue button', ), 'Edit'); diff --git a/webroot/rsrc/css/application/releeph/releeph-intents.css b/webroot/rsrc/css/application/releeph/releeph-intents.css --- a/webroot/rsrc/css/application/releeph/releeph-intents.css +++ b/webroot/rsrc/css/application/releeph/releeph-intents.css @@ -17,11 +17,11 @@ } .releeph-intents .arrow.want { - background-image: url('/rsrc/custom/image/icon/tango/go-next.png'); + /* TODO: Icon. */ } .releeph-intents .arrow.pass { - background-image: url('/rsrc/custom/image/icon/tango/go-previous-gray.png'); + /* TODO: Icon. */ } .releeph-intents a { diff --git a/webroot/rsrc/css/application/releeph/releeph-preview-branch.css b/webroot/rsrc/css/application/releeph/releeph-preview-branch.css --- a/webroot/rsrc/css/application/releeph/releeph-preview-branch.css +++ b/webroot/rsrc/css/application/releeph/releeph-preview-branch.css @@ -11,10 +11,11 @@ padding-left: 22px; background-repeat: no-repeat; background-size: 16px auto; - background-image: url(/rsrc/custom/image/releeph/releeph_warning.png); float: left; position: absolute; top: 2.5em; + + /* TODO: This had a background that's still at Facebook? */ } .releeph-preview-branch .name { diff --git a/webroot/rsrc/css/application/releeph/releeph-status.css b/webroot/rsrc/css/application/releeph/releeph-status.css --- a/webroot/rsrc/css/application/releeph/releeph-status.css +++ b/webroot/rsrc/css/application/releeph/releeph-status.css @@ -22,5 +22,6 @@ padding-left: 22px; background-repeat: no-repeat; background-size: 16px auto; - background-image: url(/rsrc/custom/image/releeph/releeph_warning.png); + + /* TODO: This had a background that's still at Facebook? */ }