1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Add a preference for always using unified diffs

Summary: Ref T2009. These aren't good enough to actually use so I won't land this yet, but it makes testing changes a lot easier.

Test Plan:
  - Swapped setting.
  - Loaded revisions.
  - Saw setting respected.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2009

Differential Revision: https://secure.phabricator.com/D11972
This commit is contained in:
epriestley 2015-03-05 14:01:15 -08:00
parent c82066408d
commit 33d7034276
7 changed files with 56 additions and 24 deletions

View file

@ -360,7 +360,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '82439934',
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
'rsrc/js/application/differential/ChangesetViewManager.js' => '5eb5b98c',
'rsrc/js/application/differential/ChangesetViewManager.js' => 'c024db3d',
'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'f2441746',
'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => 'e10f8e18',
'rsrc/js/application/differential/behavior-comment-jump.js' => '4fdb476d',
@ -510,7 +510,7 @@ return array(
'aphront-two-column-view-css' => '16ab3ad2',
'aphront-typeahead-control-css' => '0e403212',
'auth-css' => '1e655982',
'changeset-view-manager' => '5eb5b98c',
'changeset-view-manager' => 'c024db3d',
'config-options-css' => '7fedf08b',
'config-welcome-css' => '6abd79be',
'conpherence-durable-column-view' => '3b836442',
@ -1180,16 +1180,6 @@ return array(
'javelin-dom',
'javelin-vector',
),
'5eb5b98c' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
'javelin-workflow',
'javelin-router',
'javelin-behavior-device',
'javelin-vector',
),
'5fefb143' => array(
'javelin-behavior',
'javelin-dom',
@ -1714,6 +1704,16 @@ return array(
'javelin-util',
'phabricator-shaped-request',
),
'c024db3d' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
'javelin-workflow',
'javelin-router',
'javelin-behavior-device',
'javelin-vector',
),
'c1700f6f' => array(
'javelin-install',
'javelin-util',

View file

@ -240,10 +240,11 @@ final class DifferentialChangesetViewController extends DifferentialController {
// undergoing like six kinds of refactoring anyway.
$output = phutil_safe_html($output);
$detail = new DifferentialChangesetDetailView();
$detail->setChangeset($changeset);
$detail->appendChild($output);
$detail->setVsChangesetID($left_source);
$detail = id(new DifferentialChangesetDetailView())
->setUser($this->getViewer())
->setChangeset($changeset)
->appendChild($output)
->setVsChangesetID($left_source);
$panel = new DifferentialPrimaryPaneView();
$panel->appendChild(

View file

@ -188,6 +188,19 @@ final class DifferentialChangesetDetailView extends AphrontView {
$icon = id(new PHUIIconView())
->setIconFont($display_icon);
$renderer = null;
// If the viewer prefers unified diffs, always set the renderer to unified.
// Otherwise, we leave it unspecified and the client will choose a
// renderer based on the screen size.
$viewer = $this->getUser();
$prefs = $viewer->loadPreferences();
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
if ($prefs->getPreference($pref_unified) == 'unified') {
$renderer = '1up';
}
return javelin_tag(
'div',
array(
@ -200,7 +213,7 @@ final class DifferentialChangesetDetailView extends AphrontView {
'renderURI' => $this->getRenderURI(),
'whitespace' => $this->getWhitespace(),
'highlight' => null,
'renderer' => null,
'renderer' => $renderer,
'ref' => $this->getRenderingRef(),
'autoload' => $this->getAutoload(),
),

View file

@ -130,7 +130,7 @@ final class DifferentialChangesetListView extends AphrontView {
'Configure Editor' => pht('Configure Editor'),
'Load Changes' => pht('Load Changes'),
'View Side-by-Side' => pht('View Side-by-Side'),
'View Unified' => pht('View Unified (Barely Works!)'),
'View Unified' => pht('View Unified'),
'Change Text Encoding...' => pht('Change Text Encoding...'),
'Highlight As...' => pht('Highlight As...'),
),
@ -148,7 +148,8 @@ final class DifferentialChangesetListView extends AphrontView {
$ref = $this->references[$key];
$detail = new DifferentialChangesetDetailView();
$detail = id(new DifferentialChangesetDetailView())
->setUser($this->getUser());
$uniq_id = 'diff-'.$changeset->getAnchorName();
$detail->setID($uniq_id);

View file

@ -19,6 +19,7 @@ final class PhabricatorDiffPreferencesSettingsPanel
$user = $request->getUser();
$preferences = $user->loadPreferences();
$pref_unified = PhabricatorUserPreferences::PREFERENCE_DIFF_UNIFIED;
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
if ($request->isFormPost()) {
@ -32,6 +33,9 @@ final class PhabricatorDiffPreferencesSettingsPanel
$preferences->setPreference($pref_filetree, $filetree);
$unified = $request->getStr($pref_unified);
$preferences->setPreference($pref_unified, $unified);
$preferences->save();
return id(new AphrontRedirectResponse())
->setURI($this->getPanelURI('?saved=true'));
@ -39,6 +43,23 @@ final class PhabricatorDiffPreferencesSettingsPanel
$form = id(new AphrontFormView())
->setUser($user)
->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'),
)))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Show Filetree'))

View file

@ -28,6 +28,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_APP_TILES = 'app-tiles';
const PREFERENCE_APP_PINNED = 'app-pinned';
const PREFERENCE_DIFF_UNIFIED = 'diff-unified';
const PREFERENCE_DIFF_FILETREE = 'diff-filetree';
const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications';

View file

@ -172,17 +172,12 @@ JX.install('ChangesetViewManager', {
return this._renderer;
}
// TODO: This is a big pile of TODOs.
// NOTE: If you load the page at one device resolution and then resize to
// a different one we don't re-render the diffs, because it's a
// complicated mess and you could lose inline comments, cursor positions,
// etc.
var renderer = (JX.Device.getDevice() == 'desktop') ? '2up' : '1up';
// TODO: Once 1up works better, figure out when to show it.
renderer = '2up';
return renderer;
},