mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-20 03:31:10 +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:
parent
9b89e137cf
commit
fd27538e89
8 changed files with 205 additions and 0 deletions
|
@ -1526,6 +1526,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
|
||||
'PhabricatorProjectEditor' => 'applications/project/editor/PhabricatorProjectEditor.php',
|
||||
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
|
||||
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
|
||||
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
|
||||
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
|
||||
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
|
||||
|
@ -1541,6 +1542,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
|
||||
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
|
||||
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
|
||||
'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
|
||||
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
|
||||
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
|
||||
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
|
||||
|
@ -3752,6 +3754,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorProjectEditor' => 'PhabricatorEditor',
|
||||
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorProjectController',
|
||||
|
@ -3770,6 +3773,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
|
||||
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhabricatorProjectTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
|
||||
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorRedirectController' => 'PhabricatorController',
|
||||
|
|
|
@ -48,6 +48,7 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
|||
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
|
||||
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
|
||||
=> 'PhabricatorProjectUpdateController',
|
||||
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -256,6 +256,12 @@ final class PhabricatorProjectProfileController
|
|||
}
|
||||
$view->addAction($action);
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View History'))
|
||||
->setHref($this->getApplicationURI("history/{$id}/"))
|
||||
->setIcon('transcript'));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectTransactionQuery
|
||||
extends PhabricatorApplicationTransactionQuery {
|
||||
|
||||
public function getTemplateApplicationTransaction() {
|
||||
return new PhabricatorProjectTransaction();
|
||||
}
|
||||
|
||||
}
|
|
@ -15,4 +15,91 @@ final class PhabricatorProjectTransaction
|
|||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -148,6 +148,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
break;
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
|
||||
$phids[] = array($old);
|
||||
}
|
||||
|
@ -226,6 +227,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
return 'message';
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||
return 'lock';
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
return 'link';
|
||||
|
@ -242,6 +244,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
switch ($this->getTransactionType()) {
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||
if ($this->getOldValue() === null) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -270,6 +273,10 @@ abstract class PhabricatorApplicationTransaction
|
|||
return pht(
|
||||
'This %s already has that edit policy.',
|
||||
$this->getApplicationObjectTypeName());
|
||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||
return pht(
|
||||
'This %s already has that join policy.',
|
||||
$this->getApplicationObjectTypeName());
|
||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||
return pht(
|
||||
'All users are already subscribed to this %s.',
|
||||
|
@ -306,6 +313,13 @@ abstract class PhabricatorApplicationTransaction
|
|||
$this->getApplicationObjectTypeName(),
|
||||
$this->renderPolicyName($old),
|
||||
$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:
|
||||
$add = array_diff($new, $old);
|
||||
$rem = array_diff($old, $new);
|
||||
|
@ -420,6 +434,11 @@ abstract class PhabricatorApplicationTransaction
|
|||
'%s changed the edit policy for %s.',
|
||||
$this->renderHandleLink($author_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:
|
||||
return pht(
|
||||
'%s updated subscribers of %s.',
|
||||
|
@ -487,6 +506,7 @@ abstract class PhabricatorApplicationTransaction
|
|||
return pht('Commented On');
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
||||
return pht('Changed Policy');
|
||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||
return pht('Changed Subscribers');
|
||||
|
|
|
@ -793,6 +793,23 @@ abstract class PhabricatorBaseEnglishTranslation
|
|||
'%s edited commit(s), added %d: %s; removed %d: %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',
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue