2013-02-05 02:00:27 +01:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 05:20:08 +01:00
|
|
|
final class PhabricatorDiffPreferencesSettingsPanel
|
2013-02-05 02:00:27 +01:00
|
|
|
extends PhabricatorSettingsPanel {
|
|
|
|
|
|
|
|
public function getPanelKey() {
|
|
|
|
return 'diff';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelName() {
|
|
|
|
return pht('Diff Preferences');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelGroup() {
|
|
|
|
return pht('Application Settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
|
|
|
$user = $request->getUser();
|
|
|
|
$preferences = $user->loadPreferences();
|
|
|
|
|
2015-03-05 23:01:15 +01:00
|
|
|
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
|
2015-05-04 21:02:42 +02:00
|
|
|
$pref_ghosts = PhabricatorUserPreferences::PREFERENCE_DIFF_GHOSTS;
|
2013-02-05 02:00:27 +01:00
|
|
|
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
2013-02-28 21:55:03 +01:00
|
|
|
$filetree = $request->getInt($pref_filetree);
|
|
|
|
|
|
|
|
if ($filetree && !$preferences->getPreference($pref_filetree)) {
|
|
|
|
$preferences->setPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
$preferences->setPreference($pref_filetree, $filetree);
|
2013-02-05 02:00:27 +01:00
|
|
|
|
2015-03-05 23:01:15 +01:00
|
|
|
$unified = $request->getStr($pref_unified);
|
|
|
|
$preferences->setPreference($pref_unified, $unified);
|
|
|
|
|
2015-05-04 21:02:42 +02:00
|
|
|
$ghosts = $request->getStr($pref_ghosts);
|
|
|
|
$preferences->setPreference($pref_ghosts, $ghosts);
|
|
|
|
|
2013-02-05 02:00:27 +01:00
|
|
|
$preferences->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($this->getPanelURI('?saved=true'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
2015-03-05 23:01:15 +01:00
|
|
|
->appendRemarkupInstructions(
|
|
|
|
pht(
|
|
|
|
'Phabricator normally shows diffs in a side-by-side layout on '.
|
|
|
|
'large screens, and automatically switches to a unified '.
|
|
|
|
'view on small screens (like mobile phones). If you prefer '.
|
|
|
|
'unified diffs even on large screens, you can select them as '.
|
|
|
|
'the default layout.'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Show Unified Diffs'))
|
|
|
|
->setName($pref_unified)
|
|
|
|
->setValue($preferences->getPreference($pref_unified))
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'default' => pht('On Small Screens'),
|
|
|
|
'unified' => pht('Always'),
|
|
|
|
)))
|
2015-05-04 21:02:42 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Show Older Inlines'))
|
|
|
|
->setName($pref_ghosts)
|
|
|
|
->setValue($preferences->getPreference($pref_ghosts))
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'default' => pht('Enabled'),
|
|
|
|
'disabled' => pht('Disabled'),
|
|
|
|
)))
|
2013-02-05 02:00:27 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Show Filetree'))
|
|
|
|
->setName($pref_filetree)
|
|
|
|
->setValue($preferences->getPreference($pref_filetree))
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
0 => pht('Disable Filetree'),
|
|
|
|
1 => pht('Enable Filetree'),
|
|
|
|
))
|
|
|
|
->setCaption(
|
2015-05-22 09:27:56 +02:00
|
|
|
pht(
|
|
|
|
'When looking at a revision or commit, enable a sidebar '.
|
|
|
|
'showing affected files. You can press %s to show or hide '.
|
|
|
|
'the sidebar.',
|
|
|
|
phutil_tag('tt', array(), 'f'))))
|
2013-02-05 02:00:27 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue(pht('Save Preferences')));
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText(pht('Diff Preferences'))
|
2014-01-10 18:17:37 +01:00
|
|
|
->setFormSaved($request->getBool('saved'))
|
2013-08-26 20:53:11 +02:00
|
|
|
->setForm($form);
|
|
|
|
|
2013-02-05 02:00:27 +01:00
|
|
|
return array(
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2013-02-05 02:00:27 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|