Skip to content

Commit fd27538

Browse files
author
epriestley
committed
Add project history and title strings
Summary: Ref T4010. Adds a history page and restores the transaction title strings, which previously sort-of existed in the defunct feed story class. Test Plan: See screenshots. Reviewers: chad, btrahan Reviewed By: chad CC: aran Maniphest Tasks: T4010 Differential Revision: https://secure.phabricator.com/D7371
1 parent 9b89e13 commit fd27538

File tree

8 files changed

+205
-0
lines changed

8 files changed

+205
-0
lines changed

src/__phutil_library_map__.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@
15261526
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
15271527
'PhabricatorProjectEditor' => 'applications/project/editor/PhabricatorProjectEditor.php',
15281528
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
1529+
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
15291530
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
15301531
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
15311532
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
@@ -1541,6 +1542,7 @@
15411542
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
15421543
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
15431544
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
1545+
'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
15441546
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
15451547
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
15461548
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
@@ -3752,6 +3754,7 @@
37523754
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
37533755
'PhabricatorProjectEditor' => 'PhabricatorEditor',
37543756
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
3757+
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
37553758
'PhabricatorProjectListController' =>
37563759
array(
37573760
0 => 'PhabricatorProjectController',
@@ -3770,6 +3773,7 @@
37703773
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
37713774
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
37723775
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
3776+
'PhabricatorProjectTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
37733777
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
37743778
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
37753779
'PhabricatorRedirectController' => 'PhabricatorController',

src/applications/project/application/PhabricatorApplicationProject.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function getRoutes() {
4848
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
4949
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
5050
=> 'PhabricatorProjectUpdateController',
51+
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
5152
),
5253
);
5354
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
final class PhabricatorProjectHistoryController
4+
extends PhabricatorProjectController {
5+
6+
private $id;
7+
8+
public function shouldAllowPublic() {
9+
return true;
10+
}
11+
12+
public function willProcessRequest(array $data) {
13+
$this->id = $data['id'];
14+
}
15+
16+
public function processRequest() {
17+
$request = $this->getRequest();
18+
$viewer = $request->getUser();
19+
20+
$id = $this->id;
21+
22+
$project = id(new PhabricatorProjectQuery())
23+
->setViewer($viewer)
24+
->withIDs(array($id))
25+
->executeOne();
26+
if (!$project) {
27+
return new Aphront404Response();
28+
}
29+
30+
$xactions = id(new PhabricatorProjectTransactionQuery())
31+
->setViewer($viewer)
32+
->withObjectPHIDs(array($project->getPHID()))
33+
->execute();
34+
35+
$timeline = id(new PhabricatorApplicationTransactionView())
36+
->setUser($viewer)
37+
->setObjectPHID($project->getPHID())
38+
->setTransactions($xactions);
39+
40+
$crumbs = $this->buildApplicationCrumbs();
41+
$crumbs->addCrumb(
42+
id(new PhabricatorCrumbView())
43+
->setName($project->getName())
44+
->setHref($this->getApplicationURI("view/{$id}/")));
45+
$crumbs->addCrumb(
46+
id(new PhabricatorCrumbView())
47+
->setName(pht('History')));
48+
49+
return $this->buildApplicationPage(
50+
array(
51+
$crumbs,
52+
$timeline,
53+
),
54+
array(
55+
'title' => $project->getName(),
56+
'device' => true,
57+
));
58+
}
59+
60+
}

src/applications/project/controller/PhabricatorProjectProfileController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ private function buildActionListView(PhabricatorProject $project) {
256256
}
257257
$view->addAction($action);
258258

259+
$view->addAction(
260+
id(new PhabricatorActionView())
261+
->setName(pht('View History'))
262+
->setHref($this->getApplicationURI("history/{$id}/"))
263+
->setIcon('transcript'));
264+
259265
return $view;
260266
}
261267

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
final class PhabricatorProjectTransactionQuery
4+
extends PhabricatorApplicationTransactionQuery {
5+
6+
public function getTemplateApplicationTransaction() {
7+
return new PhabricatorProjectTransaction();
8+
}
9+
10+
}

src/applications/project/storage/PhabricatorProjectTransaction.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,91 @@ public function getApplicationTransactionType() {
1515
return PhabricatorProjectPHIDTypeProject::TYPECONST;
1616
}
1717

18+
public function getRequiredHandlePHIDs() {
19+
$old = $this->getOldValue();
20+
$new = $this->getNewValue();
21+
22+
$req_phids = array();
23+
switch ($this->getTransactionType()) {
24+
case PhabricatorProjectTransaction::TYPE_MEMBERS:
25+
$add = array_diff($new, $old);
26+
$rem = array_diff($old, $new);
27+
$req_phids = array_merge($add, $rem);
28+
break;
29+
}
30+
31+
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
32+
}
33+
34+
public function getTitle() {
35+
$old = $this->getOldValue();
36+
$new = $this->getNewValue();
37+
$author_handle = $this->renderHandleLink($this->getAuthorPHID());
38+
39+
switch ($this->getTransactionType()) {
40+
case PhabricatorProjectTransaction::TYPE_NAME:
41+
if ($old === null) {
42+
return pht(
43+
'%s created this project.',
44+
$author_handle);
45+
} else {
46+
return pht(
47+
'%s renamed this project from "%s" to "%s".',
48+
$author_handle,
49+
$old,
50+
$new);
51+
}
52+
case PhabricatorProjectTransaction::TYPE_STATUS:
53+
if ($old == 0) {
54+
return pht(
55+
'%s closed this project.',
56+
$author_handle);
57+
} else {
58+
return pht(
59+
'%s reopened this project.',
60+
$author_handle);
61+
}
62+
case PhabricatorProjectTransaction::TYPE_MEMBERS:
63+
$add = array_diff($new, $old);
64+
$rem = array_diff($old, $new);
65+
66+
if ($add && $rem) {
67+
return pht(
68+
'%s changed project member(s), added %d: %s; removed %d: %s',
69+
$author_handle,
70+
count($add),
71+
$this->renderHandleList($add),
72+
count($rem),
73+
$this->renderHandleList($rem));
74+
} else if ($add) {
75+
if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) {
76+
return pht(
77+
'%s joined this project.',
78+
$author_handle);
79+
} else {
80+
return pht(
81+
'%s added %d project member(s): %s',
82+
$author_handle,
83+
count($add),
84+
$this->renderHandleList($add));
85+
}
86+
} else if ($rem) {
87+
if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) {
88+
return pht(
89+
'%s left this project.',
90+
$author_handle);
91+
} else {
92+
return pht(
93+
'%s removed %d project member(s): %s',
94+
$author_handle,
95+
count($rem),
96+
$this->renderHandleList($rem));
97+
}
98+
}
99+
}
100+
101+
return parent::getTitle();
102+
}
103+
104+
18105
}

src/applications/transactions/storage/PhabricatorApplicationTransaction.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public function getRequiredHandlePHIDs() {
148148
break;
149149
case PhabricatorTransactions::TYPE_EDIT_POLICY:
150150
case PhabricatorTransactions::TYPE_VIEW_POLICY:
151+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
151152
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
152153
$phids[] = array($old);
153154
}
@@ -226,6 +227,7 @@ public function getIcon() {
226227
return 'message';
227228
case PhabricatorTransactions::TYPE_VIEW_POLICY:
228229
case PhabricatorTransactions::TYPE_EDIT_POLICY:
230+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
229231
return 'lock';
230232
case PhabricatorTransactions::TYPE_EDGE:
231233
return 'link';
@@ -242,6 +244,7 @@ public function shouldHide() {
242244
switch ($this->getTransactionType()) {
243245
case PhabricatorTransactions::TYPE_VIEW_POLICY:
244246
case PhabricatorTransactions::TYPE_EDIT_POLICY:
247+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
245248
if ($this->getOldValue() === null) {
246249
return true;
247250
} else {
@@ -270,6 +273,10 @@ public function getNoEffectDescription() {
270273
return pht(
271274
'This %s already has that edit policy.',
272275
$this->getApplicationObjectTypeName());
276+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
277+
return pht(
278+
'This %s already has that join policy.',
279+
$this->getApplicationObjectTypeName());
273280
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
274281
return pht(
275282
'All users are already subscribed to this %s.',
@@ -306,6 +313,13 @@ public function getTitle() {
306313
$this->getApplicationObjectTypeName(),
307314
$this->renderPolicyName($old),
308315
$this->renderPolicyName($new));
316+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
317+
return pht(
318+
'%s changed the join policy of this %s from "%s" to "%s".',
319+
$this->renderHandleLink($author_phid),
320+
$this->getApplicationObjectTypeName(),
321+
$this->renderPolicyName($old),
322+
$this->renderPolicyName($new));
309323
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
310324
$add = array_diff($new, $old);
311325
$rem = array_diff($old, $new);
@@ -420,6 +434,11 @@ public function getTitleForFeed(PhabricatorFeedStory $story) {
420434
'%s changed the edit policy for %s.',
421435
$this->renderHandleLink($author_phid),
422436
$this->renderHandleLink($object_phid));
437+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
438+
return pht(
439+
'%s changed the join policy for %s.',
440+
$this->renderHandleLink($author_phid),
441+
$this->renderHandleLink($object_phid));
423442
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
424443
return pht(
425444
'%s updated subscribers of %s.',
@@ -487,6 +506,7 @@ public function getActionName() {
487506
return pht('Commented On');
488507
case PhabricatorTransactions::TYPE_VIEW_POLICY:
489508
case PhabricatorTransactions::TYPE_EDIT_POLICY:
509+
case PhabricatorTransactions::TYPE_JOIN_POLICY:
490510
return pht('Changed Policy');
491511
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
492512
return pht('Changed Subscribers');

src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,23 @@ public function getTranslations() {
793793
'%s edited commit(s), added %d: %s; removed %d: %s.' =>
794794
'%s edited commits, added %3$s; removed %5$s.',
795795

796+
'%s changed project member(s), added %d: %s; removed %d: %s' =>
797+
'%s changed project members, added %3$s; removed %5$s',
798+
799+
'%s added %d project member(s): %s' => array(
800+
array(
801+
'%s added a member: %3$s',
802+
'%s added members: %3$s',
803+
),
804+
),
805+
806+
'%s removed %d project member(s): %s' => array(
807+
array(
808+
'%s removed a member: %3$s',
809+
'%s removed members: %3$s',
810+
),
811+
),
812+
796813
);
797814
}
798815

0 commit comments

Comments
 (0)