Skip to content

Commit 7a24548

Browse files
author
epriestley
committedAug 21, 2013
Provide a history controller for Releeph branches
Summary: Ref T3663. Same as D6785, but for branches. No writes to this table yet. Test Plan: Clicked "View History", got a blank but non-broken page. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3663 Differential Revision: https://secure.phabricator.com/D6787
1 parent f034fd8 commit 7a24548

5 files changed

+76
-4
lines changed
 

‎src/__phutil_library_map__.php

+4
Original file line numberDiff line numberDiff line change
@@ -1942,12 +1942,14 @@
19421942
'ReleephBranchCreateController' => 'applications/releeph/controller/branch/ReleephBranchCreateController.php',
19431943
'ReleephBranchEditController' => 'applications/releeph/controller/branch/ReleephBranchEditController.php',
19441944
'ReleephBranchEditor' => 'applications/releeph/editor/ReleephBranchEditor.php',
1945+
'ReleephBranchHistoryController' => 'applications/releeph/controller/branch/ReleephBranchHistoryController.php',
19451946
'ReleephBranchNamePreviewController' => 'applications/releeph/controller/branch/ReleephBranchNamePreviewController.php',
19461947
'ReleephBranchPreviewView' => 'applications/releeph/view/branch/ReleephBranchPreviewView.php',
19471948
'ReleephBranchQuery' => 'applications/releeph/query/ReleephBranchQuery.php',
19481949
'ReleephBranchSearchEngine' => 'applications/releeph/query/ReleephBranchSearchEngine.php',
19491950
'ReleephBranchTemplate' => 'applications/releeph/view/branch/ReleephBranchTemplate.php',
19501951
'ReleephBranchTransaction' => 'applications/releeph/storage/ReleephBranchTransaction.php',
1952+
'ReleephBranchTransactionQuery' => 'applications/releeph/query/ReleephBranchTransactionQuery.php',
19511953
'ReleephBranchViewController' => 'applications/releeph/controller/branch/ReleephBranchViewController.php',
19521954
'ReleephCommitFinder' => 'applications/releeph/commitfinder/ReleephCommitFinder.php',
19531955
'ReleephCommitFinderException' => 'applications/releeph/commitfinder/ReleephCommitFinderException.php',
@@ -4122,11 +4124,13 @@
41224124
'ReleephBranchCreateController' => 'ReleephProjectController',
41234125
'ReleephBranchEditController' => 'ReleephProjectController',
41244126
'ReleephBranchEditor' => 'PhabricatorEditor',
4127+
'ReleephBranchHistoryController' => 'ReleephProjectController',
41254128
'ReleephBranchNamePreviewController' => 'ReleephController',
41264129
'ReleephBranchPreviewView' => 'AphrontFormControl',
41274130
'ReleephBranchQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
41284131
'ReleephBranchSearchEngine' => 'PhabricatorApplicationSearchEngine',
41294132
'ReleephBranchTransaction' => 'PhabricatorApplicationTransaction',
4133+
'ReleephBranchTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
41304134
'ReleephBranchViewController' =>
41314135
array(
41324136
0 => 'ReleephProjectController',

‎src/applications/releeph/application/PhabricatorApplicationReleeph.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function getRoutes() {
5151
'(?P<action>close|re-open)/(?P<branchID>[1-9]\d*)/' =>
5252
'ReleephBranchAccessController',
5353
'preview/' => 'ReleephBranchNamePreviewController',
54-
55-
// Left in, just in case the by-name stuff fails!
56-
'(?P<branchID>[^/]+)/' =>
57-
'ReleephBranchViewController',
54+
'(?P<branchID>[^/]+)/' => array(
55+
'history/' => 'ReleephBranchHistoryController',
56+
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephBranchViewController',
57+
),
5858
),
5959
'request/' => array(
6060
'(?P<requestID>[1-9]\d*)/' => 'ReleephRequestViewController',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
final class ReleephBranchHistoryController extends ReleephProjectController {
4+
5+
private $id;
6+
7+
public function willProcessRequest(array $data) {
8+
$this->id = $data['branchID'];
9+
parent::willProcessRequest($data);
10+
}
11+
12+
public function processRequest() {
13+
$request = $this->getRequest();
14+
$viewer = $request->getUser();
15+
16+
$branch = id(new ReleephBranchQuery())
17+
->setViewer($viewer)
18+
->withIDs(array($this->id))
19+
->executeOne();
20+
if (!$branch) {
21+
return new Aphront404Response();
22+
}
23+
24+
$xactions = id(new ReleephBranchTransactionQuery())
25+
->setViewer($viewer)
26+
->withObjectPHIDs(array($branch->getPHID()))
27+
->execute();
28+
29+
$timeline = id(new PhabricatorApplicationTransactionView())
30+
->setUser($viewer)
31+
->setObjectPHID($branch->getPHID())
32+
->setTransactions($xactions);
33+
34+
$crumbs = $this->buildApplicationCrumbs();
35+
$crumbs->addCrumb(
36+
id(new PhabricatorCrumbView())
37+
->setName(pht('History')));
38+
39+
return $this->buildApplicationPage(
40+
array(
41+
$crumbs,
42+
$timeline,
43+
),
44+
array(
45+
'title' => pht('Branch History'),
46+
'device' => true,
47+
));
48+
}
49+
50+
}

‎src/applications/releeph/controller/branch/ReleephBranchViewController.php

+8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ private function renderPreface() {
123123
$close_uri = $branch->getURI('close/');
124124
$reopen_uri = $branch->getURI('re-open/');
125125

126+
$id = $branch->getID();
127+
$history_uri = $this->getApplicationURI("branch/{$id}/history/");
128+
126129
$actions->addAction(
127130
id(new PhabricatorActionView())
128131
->setName(pht('Edit Branch'))
@@ -151,6 +154,11 @@ private function renderPreface() {
151154
->setWorkflow(true));
152155
}
153156

157+
$actions->addAction(
158+
id(new PhabricatorActionView())
159+
->setName(pht('View History'))
160+
->setHref($history_uri)
161+
->setIcon('transcript'));
154162

155163
$properties = id(new PhabricatorPropertyListView())
156164
->setUser($viewer)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
final class ReleephBranchTransactionQuery
4+
extends PhabricatorApplicationTransactionQuery {
5+
6+
public function getTemplateApplicationTransaction() {
7+
return new ReleephBranchTransaction();
8+
}
9+
10+
}

0 commit comments

Comments
 (0)
Failed to load comments.