mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 07:12:41 +01:00
Make Diffusion view sticky
Summary: Blame can be slow. Test Plan: Viewed a file with no preference, saw blame. Changed view, saw it. Viewed a file, saw the changed view. Viewed a file as raw document. Reviewers: Two9A, epriestley Reviewed By: epriestley CC: aran, epriestley, Korvin, btrahan Maniphest Tasks: T1278 Differential Revision: https://secure.phabricator.com/D3000
This commit is contained in:
parent
30deacdbaf
commit
0d162e15f6
2 changed files with 23 additions and 13 deletions
|
@ -31,11 +31,20 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $drequest->getPath();
|
$path = $drequest->getPath();
|
||||||
|
|
||||||
$selected = $request->getStr('view');
|
$selected = $request->getStr('view');
|
||||||
// If requested without a view, assume that blame is required (see T1278).
|
$preferences = $request->getUser()->loadPreferences();
|
||||||
if (!$selected) {
|
if (!$selected) {
|
||||||
$selected = 'blame';
|
$selected = $preferences->getPreference(
|
||||||
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_VIEW,
|
||||||
|
'highlighted');
|
||||||
|
} else if ($request->isFormPost() && $selected != 'raw') {
|
||||||
|
$preferences->setPreference(
|
||||||
|
PhabricatorUserPreferences::PREFERENCE_DIFFUSION_VIEW,
|
||||||
|
$selected);
|
||||||
|
$preferences->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$needs_blame = ($selected == 'blame' || $selected == 'plainblame');
|
$needs_blame = ($selected == 'blame' || $selected == 'plainblame');
|
||||||
|
|
||||||
$file_query = DiffusionFileContentQuery::newFromDiffusionRequest(
|
$file_query = DiffusionFileContentQuery::newFromDiffusionRequest(
|
||||||
|
@ -60,7 +69,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
require_celerity_resource('diffusion-source-css');
|
require_celerity_resource('diffusion-source-css');
|
||||||
|
|
||||||
if ($this->corpusType == 'text') {
|
if ($this->corpusType == 'text') {
|
||||||
$view_select_panel = $this->renderViewSelectPanel();
|
$view_select_panel = $this->renderViewSelectPanel($selected);
|
||||||
} else {
|
} else {
|
||||||
$view_select_panel = null;
|
$view_select_panel = null;
|
||||||
}
|
}
|
||||||
|
@ -217,17 +226,17 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
return $corpus;
|
return $corpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderViewSelectPanel() {
|
private function renderViewSelectPanel($selected) {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$select = AphrontFormSelectControl::renderSelectTag(
|
$select = AphrontFormSelectControl::renderSelectTag(
|
||||||
$request->getStr('view'),
|
$selected,
|
||||||
array(
|
array(
|
||||||
'blame' => 'View as Highlighted Text with Blame',
|
|
||||||
'highlighted' => 'View as Highlighted Text',
|
'highlighted' => 'View as Highlighted Text',
|
||||||
'plainblame' => 'View as Plain Text with Blame',
|
'blame' => 'View as Highlighted Text with Blame',
|
||||||
'plain' => 'View as Plain Text',
|
'plain' => 'View as Plain Text',
|
||||||
|
'plainblame' => 'View as Plain Text with Blame',
|
||||||
'raw' => 'View as raw document',
|
'raw' => 'View as raw document',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
@ -235,11 +244,11 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
));
|
));
|
||||||
|
|
||||||
$view_select_panel = new AphrontPanelView();
|
$view_select_panel = new AphrontPanelView();
|
||||||
$view_select_form = phutil_render_tag(
|
$view_select_form = phabricator_render_form(
|
||||||
'form',
|
$request->getUser(),
|
||||||
array(
|
array(
|
||||||
'action' => $request->getRequestURI(),
|
'action' => $request->getRequestURI()->alter('view', null),
|
||||||
'method' => 'get',
|
'method' => 'post',
|
||||||
'class' => 'diffusion-browse-type-form',
|
'class' => 'diffusion-browse-type-form',
|
||||||
),
|
),
|
||||||
$select.
|
$select.
|
||||||
|
@ -420,10 +429,9 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||||
'action' => 'browse',
|
'action' => 'browse',
|
||||||
'line' => $line['line'],
|
'line' => $line['line'],
|
||||||
'stable' => true,
|
'stable' => true,
|
||||||
|
'params' => array('view' => $selected),
|
||||||
));
|
));
|
||||||
|
|
||||||
$line_href->setQueryParams($request->getRequestURI()->getQueryParams());
|
|
||||||
|
|
||||||
$blame = array();
|
$blame = array();
|
||||||
if ($line['color']) {
|
if ($line['color']) {
|
||||||
$color = $line['color'];
|
$color = $line['color'];
|
||||||
|
|
|
@ -30,6 +30,8 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
|
||||||
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
|
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
|
||||||
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
|
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
|
||||||
|
|
||||||
|
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
|
||||||
|
|
||||||
protected $userPHID;
|
protected $userPHID;
|
||||||
protected $preferences = array();
|
protected $preferences = array();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue