Convert Diffusion blame and color into standard internal settings

Summary: Ref T4103. Modernize the blame/color toggles in Diffusion. These have no separate settings UI.

Test Plan: Toggled blame and colors, reloaded pages, settings stuck.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

Differential Revision: https://secure.phabricator.com/D16026
This commit is contained in:
epriestley
2016-06-03 07:48:26 -07:00
parent 1e17fd31a4
commit 5c8ff3d37c
5 changed files with 81 additions and 17 deletions

View File

@@ -105,28 +105,31 @@ final class DiffusionBrowseController extends DiffusionController {
$path = $drequest->getPath();
$preferences = $viewer->loadPreferences();
$blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY;
$color_key = PhabricatorDiffusionColorSetting::SETTINGKEY;
$show_blame = $request->getBool(
'blame',
$preferences->getPreference(
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
false));
$viewer->getUserSetting($blame_key));
$show_color = $request->getBool(
'color',
$preferences->getPreference(
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
true));
$viewer->getUserSetting($color_key));
$view = $request->getStr('view');
if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) {
$preferences->setPreference(
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME,
$show_blame);
$preferences->setPreference(
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR,
$show_color);
$preferences->save();
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
$editor = id(new PhabricatorUserPreferencesEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true);
$xactions = array();
$xactions[] = $preferences->newTransaction($blame_key, $show_blame);
$xactions[] = $preferences->newTransaction($color_key, $show_color);
$editor->applyTransactions($preferences, $xactions);
$uri = $request->getRequestURI()
->alter('blame', null)