@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+81 -17
+4
src/__phutil_library_map__.php
··· 2319 2319 'PhabricatorDifferentialManagementWorkflow' => 'applications/differential/management/PhabricatorDifferentialManagementWorkflow.php', 2320 2320 'PhabricatorDifferentialRevisionTestDataGenerator' => 'applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php', 2321 2321 'PhabricatorDiffusionApplication' => 'applications/diffusion/application/PhabricatorDiffusionApplication.php', 2322 + 'PhabricatorDiffusionBlameSetting' => 'applications/settings/setting/PhabricatorDiffusionBlameSetting.php', 2323 + 'PhabricatorDiffusionColorSetting' => 'applications/settings/setting/PhabricatorDiffusionColorSetting.php', 2322 2324 'PhabricatorDiffusionConfigOptions' => 'applications/diffusion/config/PhabricatorDiffusionConfigOptions.php', 2323 2325 'PhabricatorDisabledUserController' => 'applications/auth/controller/PhabricatorDisabledUserController.php', 2324 2326 'PhabricatorDisplayPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php', ··· 6889 6891 'PhabricatorDifferentialManagementWorkflow' => 'PhabricatorManagementWorkflow', 6890 6892 'PhabricatorDifferentialRevisionTestDataGenerator' => 'PhabricatorTestDataGenerator', 6891 6893 'PhabricatorDiffusionApplication' => 'PhabricatorApplication', 6894 + 'PhabricatorDiffusionBlameSetting' => 'PhabricatorInternalSetting', 6895 + 'PhabricatorDiffusionColorSetting' => 'PhabricatorInternalSetting', 6892 6896 'PhabricatorDiffusionConfigOptions' => 'PhabricatorApplicationConfigOptions', 6893 6897 'PhabricatorDisabledUserController' => 'PhabricatorAuthController', 6894 6898 'PhabricatorDisplayPreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
+17 -14
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 105 105 106 106 $path = $drequest->getPath(); 107 107 108 - $preferences = $viewer->loadPreferences(); 108 + $blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY; 109 + $color_key = PhabricatorDiffusionColorSetting::SETTINGKEY; 109 110 110 111 $show_blame = $request->getBool( 111 112 'blame', 112 - $preferences->getPreference( 113 - PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME, 114 - false)); 113 + $viewer->getUserSetting($blame_key)); 114 + 115 115 $show_color = $request->getBool( 116 116 'color', 117 - $preferences->getPreference( 118 - PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR, 119 - true)); 117 + $viewer->getUserSetting($color_key)); 120 118 121 119 $view = $request->getStr('view'); 122 120 if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) { 123 - $preferences->setPreference( 124 - PhabricatorUserPreferences::PREFERENCE_DIFFUSION_BLAME, 125 - $show_blame); 126 - $preferences->setPreference( 127 - PhabricatorUserPreferences::PREFERENCE_DIFFUSION_COLOR, 128 - $show_color); 129 - $preferences->save(); 121 + $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); 122 + 123 + $editor = id(new PhabricatorUserPreferencesEditor()) 124 + ->setActor($viewer) 125 + ->setContentSourceFromRequest($request) 126 + ->setContinueOnNoEffect(true) 127 + ->setContinueOnMissingFields(true); 128 + 129 + $xactions = array(); 130 + $xactions[] = $preferences->newTransaction($blame_key, $show_blame); 131 + $xactions[] = $preferences->newTransaction($color_key, $show_color); 132 + $editor->applyTransactions($preferences, $xactions); 130 133 131 134 $uri = $request->getRequestURI() 132 135 ->alter('blame', null)
+16
src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorDiffusionBlameSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'diffusion-blame'; 7 + 8 + public function getSettingName() { 9 + return pht('Diffusion Blame'); 10 + } 11 + 12 + public function getSettingDefaultValue() { 13 + return false; 14 + } 15 + 16 + }
+16
src/applications/settings/setting/PhabricatorDiffusionColorSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorDiffusionColorSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'diffusion-color'; 7 + 8 + public function getSettingName() { 9 + return pht('Diffusion Color'); 10 + } 11 + 12 + public function getSettingDefaultValue() { 13 + return false; 14 + } 15 + 16 + }
+28 -3
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 24 24 const PREFERENCE_VARY_SUBJECT = 'vary-subject'; 25 25 const PREFERENCE_HTML_EMAILS = 'html-emails'; 26 26 27 - const PREFERENCE_DIFFUSION_BLAME = 'diffusion-blame'; 28 - const PREFERENCE_DIFFUSION_COLOR = 'diffusion-color'; 29 - 30 27 const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed'; 31 28 const PREFERENCE_NAV_WIDTH = 'nav-width'; 32 29 const PREFERENCE_APP_TILES = 'app-tiles'; ··· 172 169 return parent::save(); 173 170 } 174 171 172 + /** 173 + * Load or create a preferences object for the given user. 174 + * 175 + * @param PhabricatorUser User to load or create preferences for. 176 + */ 177 + public static function loadUserPreferences(PhabricatorUser $user) { 178 + $preferences = id(new PhabricatorUserPreferencesQuery()) 179 + ->setViewer($user) 180 + ->withUsers(array($user)) 181 + ->executeOne(); 182 + if ($preferences) { 183 + return $preferences; 184 + } 185 + 186 + return id(new self()) 187 + ->setUserPHID($user->getPHID()) 188 + ->attachUser($user); 189 + } 190 + 191 + public function newTransaction($key, $value) { 192 + $setting_property = PhabricatorUserPreferencesTransaction::PROPERTY_SETTING; 193 + $xaction_type = PhabricatorUserPreferencesTransaction::TYPE_SETTING; 194 + 195 + return id(clone $this->getApplicationTransactionTemplate()) 196 + ->setTransactionType($xaction_type) 197 + ->setMetadataValue($setting_property, $key) 198 + ->setNewValue($value); 199 + } 175 200 176 201 177 202 /* -( PhabricatorPolicyInterface )----------------------------------------- */