1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Settings History

Summary:
Shows a timeline of all modified settings Fixes T6545
Will show all settings (no pagination, should be not so difficult to add if needed but most installs won't have hundreds of settings changes)
I'm not happy by how the PhabricatorConfigTransaction object is instructed to render the config keys but i don't see any other reasonable way.
We could always show the keys though.

Test Plan: Changed settings and called the history page

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6545

Differential Revision: https://secure.phabricator.com/D11088
This commit is contained in:
Fabian Stelzer 2015-01-01 06:51:44 -08:00 committed by epriestley
parent 1ff6972f7e
commit 86eb7c0ec4
6 changed files with 103 additions and 1 deletions

View file

@ -1479,6 +1479,7 @@ phutil_register_library_map(array(
'PhabricatorConfigEntryQuery' => 'applications/config/query/PhabricatorConfigEntryQuery.php',
'PhabricatorConfigFileSource' => 'infrastructure/env/PhabricatorConfigFileSource.php',
'PhabricatorConfigGroupController' => 'applications/config/controller/PhabricatorConfigGroupController.php',
'PhabricatorConfigHistoryController' => 'applications/config/controller/PhabricatorConfigHistoryController.php',
'PhabricatorConfigIgnoreController' => 'applications/config/controller/PhabricatorConfigIgnoreController.php',
'PhabricatorConfigIssueListController' => 'applications/config/controller/PhabricatorConfigIssueListController.php',
'PhabricatorConfigIssueViewController' => 'applications/config/controller/PhabricatorConfigIssueViewController.php',
@ -4641,6 +4642,7 @@ phutil_register_library_map(array(
'PhabricatorConfigEntryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorConfigFileSource' => 'PhabricatorConfigProxySource',
'PhabricatorConfigGroupController' => 'PhabricatorConfigController',
'PhabricatorConfigHistoryController' => 'PhabricatorConfigController',
'PhabricatorConfigIgnoreController' => 'PhabricatorConfigController',
'PhabricatorConfigIssueListController' => 'PhabricatorConfigController',
'PhabricatorConfigIssueViewController' => 'PhabricatorConfigController',

View file

@ -39,6 +39,7 @@ final class PhabricatorConfigApplication extends PhabricatorApplication {
'/config/' => array(
'' => 'PhabricatorConfigListController',
'all/' => 'PhabricatorConfigAllController',
'history/' => 'PhabricatorConfigHistoryController',
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
'welcome/' => 'PhabricatorConfigWelcomeController',

View file

@ -14,6 +14,7 @@ abstract class PhabricatorConfigController extends PhabricatorController {
$nav->addLabel(pht('Configuration'));
$nav->addFilter('/', pht('Browse Settings'));
$nav->addFilter('all/', pht('All Settings'));
$nav->addFilter('history/', pht('Settings History'));
$nav->addLabel(pht('Setup'));
$nav->addFilter('issue/', pht('Setup Issues'));
$nav->addLabel(pht('Database'));

View file

@ -0,0 +1,50 @@
<?php
final class PhabricatorConfigHistoryController
extends PhabricatorConfigController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$xactions = id(new PhabricatorConfigTransactionQuery())
->setViewer($user)
->needComments(true)
->setReversePaging(false)
->execute();
$object = new PhabricatorConfigEntry();
$xaction = $object->getApplicationTransactionTemplate();
$view = $xaction->getApplicationTransactionViewObject();
$timeline = $view
->setUser($user)
->setTransactions($xactions)
->setRenderAsFeed(true)
->setObjectPHID(PhabricatorPHIDConstants::PHID_VOID);
$timeline->setShouldTerminate(true);
$object->willRenderTimeline($timeline, $this->getRequest());
$title = pht('Settings History');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb('Config', $this->getApplicationURI());
$crumbs->addTextCrumb($title, '/config/history/');
return $this->buildApplicationPage(
array(
$crumbs,
$timeline,
),
array(
'title' => $title,
));
}
}

View file

@ -55,6 +55,44 @@ final class PhabricatorConfigTransaction
return parent::getTitle();
}
public function getTitleForFeed(PhabricatorFeedStory $story = null) {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_EDIT:
$old_del = idx($old, 'deleted');
$new_del = idx($new, 'deleted');
if ($old_del && !$new_del) {
return pht(
'%s created %s.',
$this->renderHandleLink($author_phid),
$this->getObject()->getConfigKey());
} else if (!$old_del && $new_del) {
return pht(
'%s deleted %s.',
$this->renderHandleLink($author_phid),
$this->getObject()->getConfigKey());
} else if ($old_del && $new_del) {
// This is a bug.
return pht(
'%s deleted %s (again?).',
$this->renderHandleLink($author_phid),
$this->getObject()->getConfigKey());
} else {
return pht(
'%s edited %s.',
$this->renderHandleLink($author_phid),
$this->getObject()->getConfigKey());
}
break;
}
return parent::getTitle();
}
public function getIcon() {
switch ($this->getTransactionType()) {

View file

@ -14,8 +14,14 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private $quoteTargetID;
private $quoteRef;
private $pager;
private $renderAsFeed;
private $renderData = array();
public function setRenderAsFeed($feed) {
$this->renderAsFeed = $feed;
return $this;
}
public function setQuoteRef($quote_ref) {
$this->quoteRef = $quote_ref;
return $this;
@ -390,7 +396,11 @@ class PhabricatorApplicationTransactionView extends AphrontView {
}
if (!$this->shouldSuppressTitle($xaction, $group)) {
$title = $xaction->getTitle();
if ($this->renderAsFeed) {
$title = $xaction->getTitleForFeed();
} else {
$title = $xaction->getTitle();
}
if ($xaction->hasChangeDetails()) {
if (!$this->isPreview) {
$details = $this->buildChangeDetailsLink($xaction);