1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-20 11:41:08 +01:00

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
This commit is contained in:
epriestley 2013-10-22 13:49:37 -07:00
parent 9b89e137cf
commit fd27538e89
8 changed files with 205 additions and 0 deletions

View file

@ -1526,6 +1526,7 @@ phutil_register_library_map(array(
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php', 'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
'PhabricatorProjectEditor' => 'applications/project/editor/PhabricatorProjectEditor.php', 'PhabricatorProjectEditor' => 'applications/project/editor/PhabricatorProjectEditor.php',
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php', 'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php', 'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
@ -1541,6 +1542,7 @@ phutil_register_library_map(array(
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php', 'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php', 'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php', 'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php', 'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php', 'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
@ -3752,6 +3754,7 @@ phutil_register_library_map(array(
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO', 'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
'PhabricatorProjectEditor' => 'PhabricatorEditor', 'PhabricatorProjectEditor' => 'PhabricatorEditor',
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase', 'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
'PhabricatorProjectListController' => 'PhabricatorProjectListController' =>
array( array(
0 => 'PhabricatorProjectController', 0 => 'PhabricatorProjectController',
@ -3770,6 +3773,7 @@ phutil_register_library_map(array(
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator', 'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorProjectTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController', 'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRedirectController' => 'PhabricatorController', 'PhabricatorRedirectController' => 'PhabricatorController',

View file

@ -48,6 +48,7 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController', 'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/' 'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
=> 'PhabricatorProjectUpdateController', => 'PhabricatorProjectUpdateController',
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
), ),
); );
} }

View file

@ -0,0 +1,60 @@
<?php
final class PhabricatorProjectHistoryController
extends PhabricatorProjectController {
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$id = $this->id;
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$xactions = id(new PhabricatorProjectTransactionQuery())
->setViewer($viewer)
->withObjectPHIDs(array($project->getPHID()))
->execute();
$timeline = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($project->getPHID())
->setTransactions($xactions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($project->getName())
->setHref($this->getApplicationURI("view/{$id}/")));
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('History')));
return $this->buildApplicationPage(
array(
$crumbs,
$timeline,
),
array(
'title' => $project->getName(),
'device' => true,
));
}
}

View file

@ -256,6 +256,12 @@ final class PhabricatorProjectProfileController
} }
$view->addAction($action); $view->addAction($action);
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('View History'))
->setHref($this->getApplicationURI("history/{$id}/"))
->setIcon('transcript'));
return $view; return $view;
} }

View file

@ -0,0 +1,10 @@
<?php
final class PhabricatorProjectTransactionQuery
extends PhabricatorApplicationTransactionQuery {
public function getTemplateApplicationTransaction() {
return new PhabricatorProjectTransaction();
}
}

View file

@ -15,4 +15,91 @@ final class PhabricatorProjectTransaction
return PhabricatorProjectPHIDTypeProject::TYPECONST; return PhabricatorProjectPHIDTypeProject::TYPECONST;
} }
public function getRequiredHandlePHIDs() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$req_phids = array();
switch ($this->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_MEMBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
$req_phids = array_merge($add, $rem);
break;
}
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$author_handle = $this->renderHandleLink($this->getAuthorPHID());
switch ($this->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_NAME:
if ($old === null) {
return pht(
'%s created this project.',
$author_handle);
} else {
return pht(
'%s renamed this project from "%s" to "%s".',
$author_handle,
$old,
$new);
}
case PhabricatorProjectTransaction::TYPE_STATUS:
if ($old == 0) {
return pht(
'%s closed this project.',
$author_handle);
} else {
return pht(
'%s reopened this project.',
$author_handle);
}
case PhabricatorProjectTransaction::TYPE_MEMBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ($add && $rem) {
return pht(
'%s changed project member(s), added %d: %s; removed %d: %s',
$author_handle,
count($add),
$this->renderHandleList($add),
count($rem),
$this->renderHandleList($rem));
} else if ($add) {
if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) {
return pht(
'%s joined this project.',
$author_handle);
} else {
return pht(
'%s added %d project member(s): %s',
$author_handle,
count($add),
$this->renderHandleList($add));
}
} else if ($rem) {
if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) {
return pht(
'%s left this project.',
$author_handle);
} else {
return pht(
'%s removed %d project member(s): %s',
$author_handle,
count($rem),
$this->renderHandleList($rem));
}
}
}
return parent::getTitle();
}
} }

View file

@ -148,6 +148,7 @@ abstract class PhabricatorApplicationTransaction
break; break;
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) { if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
$phids[] = array($old); $phids[] = array($old);
} }
@ -226,6 +227,7 @@ abstract class PhabricatorApplicationTransaction
return 'message'; return 'message';
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return 'lock'; return 'lock';
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
return 'link'; return 'link';
@ -242,6 +244,7 @@ abstract class PhabricatorApplicationTransaction
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
if ($this->getOldValue() === null) { if ($this->getOldValue() === null) {
return true; return true;
} else { } else {
@ -270,6 +273,10 @@ abstract class PhabricatorApplicationTransaction
return pht( return pht(
'This %s already has that edit policy.', 'This %s already has that edit policy.',
$this->getApplicationObjectTypeName()); $this->getApplicationObjectTypeName());
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht(
'This %s already has that join policy.',
$this->getApplicationObjectTypeName());
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht( return pht(
'All users are already subscribed to this %s.', 'All users are already subscribed to this %s.',
@ -306,6 +313,13 @@ abstract class PhabricatorApplicationTransaction
$this->getApplicationObjectTypeName(), $this->getApplicationObjectTypeName(),
$this->renderPolicyName($old), $this->renderPolicyName($old),
$this->renderPolicyName($new)); $this->renderPolicyName($new));
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht(
'%s changed the join policy of this %s from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->getApplicationObjectTypeName(),
$this->renderPolicyName($old),
$this->renderPolicyName($new));
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
$add = array_diff($new, $old); $add = array_diff($new, $old);
$rem = array_diff($old, $new); $rem = array_diff($old, $new);
@ -420,6 +434,11 @@ abstract class PhabricatorApplicationTransaction
'%s changed the edit policy for %s.', '%s changed the edit policy for %s.',
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid)); $this->renderHandleLink($object_phid));
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht(
'%s changed the join policy for %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht( return pht(
'%s updated subscribers of %s.', '%s updated subscribers of %s.',
@ -487,6 +506,7 @@ abstract class PhabricatorApplicationTransaction
return pht('Commented On'); return pht('Commented On');
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht('Changed Policy'); return pht('Changed Policy');
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht('Changed Subscribers'); return pht('Changed Subscribers');

View file

@ -793,6 +793,23 @@ abstract class PhabricatorBaseEnglishTranslation
'%s edited commit(s), added %d: %s; removed %d: %s.' => '%s edited commit(s), added %d: %s; removed %d: %s.' =>
'%s edited commits, added %3$s; removed %5$s.', '%s edited commits, added %3$s; removed %5$s.',
'%s changed project member(s), added %d: %s; removed %d: %s' =>
'%s changed project members, added %3$s; removed %5$s',
'%s added %d project member(s): %s' => array(
array(
'%s added a member: %3$s',
'%s added members: %3$s',
),
),
'%s removed %d project member(s): %s' => array(
array(
'%s removed a member: %3$s',
'%s removed members: %3$s',
),
),
); );
} }