From 14e3e5ccfd826fe7df2a46282e896f8bc0852553 Mon Sep 17 00:00:00 2001 From: Nick Harper Date: Thu, 26 Jul 2012 20:25:27 -0700 Subject: [PATCH] Provide user option for disabling diffusion symbol cross-references Summary: Some people don't like these, so they should be able to turn them off. Test Plan: Toggled the setting on and off; loaded a page in diffusion and differential that should have symbol cross-references, and saw that they weren't linked when I had the setting disabled. I also checked that the symbols are still linked when the setting hasn't been touched. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3069 --- .../view/DifferentialChangesetListView.php | 7 ++++++- .../DiffusionBrowseFileController.php | 5 ++++- ...rUserPreferenceSettingsPanelController.php | 18 +++++++++++++--- .../storage/PhabricatorUserPreferences.php | 21 ++++++++++--------- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php index a819390bfb..289dd23ff7 100644 --- a/src/applications/differential/view/DifferentialChangesetListView.php +++ b/src/applications/differential/view/DifferentialChangesetListView.php @@ -132,9 +132,14 @@ final class DifferentialChangesetListView extends AphrontView { $ref, $changeset); + $prefs = $this->user->loadPreferences(); + $pref_symbols = $prefs->getPreference( + PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS); $detail->setChangeset($changeset); $detail->addButton($view_options); - $detail->setSymbolIndex(idx($this->symbolIndexes, $key)); + if ($pref_symbols != 'disabled') { + $detail->setSymbolIndex(idx($this->symbolIndexes, $key)); + } $detail->setVsChangesetID(idx($this->vsMap, $changeset->getID())); $detail->setEditable(true); diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index d88bad10b5..1eea798a0b 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -231,7 +231,10 @@ final class DiffusionBrowseFileController extends DiffusionController { $lang = last(explode('.', $drequest->getPath())); - if (isset($langs[$lang])) { + $prefs = $this->getRequest()->getUser()->loadPreferences(); + $pref_symbols = $prefs->getPreference( + PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS); + if (isset($langs[$lang]) && $pref_symbols != 'disabled') { Javelin::initBehavior( 'repository-crossreference', array( diff --git a/src/applications/people/controller/settings/panels/PhabricatorUserPreferenceSettingsPanelController.php b/src/applications/people/controller/settings/panels/PhabricatorUserPreferenceSettingsPanelController.php index f650a76008..09d5c10ce6 100644 --- a/src/applications/people/controller/settings/panels/PhabricatorUserPreferenceSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/PhabricatorUserPreferenceSettingsPanelController.php @@ -25,9 +25,10 @@ final class PhabricatorUserPreferenceSettingsPanelController $user = $request->getUser(); $preferences = $user->loadPreferences(); - $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; - $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; - $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; + $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED; + $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; + $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; + $pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS; if ($request->isFormPost()) { $monospaced = $request->getStr($pref_monospaced); @@ -37,6 +38,8 @@ final class PhabricatorUserPreferenceSettingsPanelController $preferences->setPreference($pref_titles, $request->getStr($pref_titles)); $preferences->setPreference($pref_editor, $request->getStr($pref_editor)); + $preferences->setPreference($pref_symbols, + $request->getStr($pref_symbols)); $preferences->setPreference($pref_monospaced, $monospaced); $preferences->save(); @@ -101,6 +104,15 @@ EXAMPLE; '
'.
           phutil_escape_html($example_string).
           '
')) + ->appendChild( + id(new AphrontFormRadioButtonControl()) + ->setLabel('Symbol Links') + ->setName($pref_symbols) + ->setValue($preferences->getPreference($pref_symbols) ?: 'enabled') + ->addButton('enabled', 'Enabled (default)', + 'Use this setting to disable linking symbol names in Differential '. + 'and Diffusion to their definitions. This is enabled by default.') + ->addButton('disabled', 'Disabled', null)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Save Preferences')); diff --git a/src/applications/people/storage/PhabricatorUserPreferences.php b/src/applications/people/storage/PhabricatorUserPreferences.php index d569d8929a..2d4941207b 100644 --- a/src/applications/people/storage/PhabricatorUserPreferences.php +++ b/src/applications/people/storage/PhabricatorUserPreferences.php @@ -18,19 +18,20 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO { - const PREFERENCE_MONOSPACED = 'monospaced'; - const PREFERENCE_EDITOR = 'editor'; - const PREFERENCE_TITLES = 'titles'; + const PREFERENCE_MONOSPACED = 'monospaced'; + const PREFERENCE_EDITOR = 'editor'; + const PREFERENCE_TITLES = 'titles'; - const PREFERENCE_RE_PREFIX = 're-prefix'; - const PREFERENCE_NO_SELF_MAIL = 'self-mail'; - const PREFERENCE_MAILTAGS = 'mailtags'; - const PREFERENCE_VARY_SUBJECT = 'vary-subject'; + const PREFERENCE_RE_PREFIX = 're-prefix'; + const PREFERENCE_NO_SELF_MAIL = 'self-mail'; + const PREFERENCE_MAILTAGS = 'mailtags'; + const PREFERENCE_VARY_SUBJECT = 'vary-subject'; - const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump'; - const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut'; + const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump'; + const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut'; - const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view'; + const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view'; + const PREFERENCE_DIFFUSION_SYMBOLS = 'diffusion-symbols'; protected $userPHID; protected $preferences = array();