mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Remove the ability to disable blame in Diffusion
Summary: Ref T13105. Given that we now load blame with AJAX, it's not clear that there's any benefit to disabling it. This would also interact oddly with the document engine. Test Plan: Viewed files in Diffusion, no longer saw blame-related options. Reviewers: mydeveloperday Reviewed By: mydeveloperday Maniphest Tasks: T13105 Differential Revision: https://secure.phabricator.com/D19300
This commit is contained in:
parent
9bb338c038
commit
7d4e25614d
1 changed files with 29 additions and 95 deletions
|
@ -111,41 +111,18 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$path = $drequest->getPath();
|
$path = $drequest->getPath();
|
||||||
|
|
||||||
$blame_key = PhabricatorDiffusionBlameSetting::SETTINGKEY;
|
|
||||||
$show_blame = $request->getBool(
|
|
||||||
'blame',
|
|
||||||
$viewer->getUserSetting($blame_key));
|
|
||||||
|
|
||||||
$view = $request->getStr('view');
|
|
||||||
if ($request->isFormPost() && $view != 'raw' && $viewer->isLoggedIn()) {
|
|
||||||
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
|
|
||||||
|
|
||||||
$editor = id(new PhabricatorUserPreferencesEditor())
|
|
||||||
->setActor($viewer)
|
|
||||||
->setContentSourceFromRequest($request)
|
|
||||||
->setContinueOnNoEffect(true)
|
|
||||||
->setContinueOnMissingFields(true);
|
|
||||||
|
|
||||||
$xactions = array();
|
|
||||||
$xactions[] = $preferences->newTransaction($blame_key, $show_blame);
|
|
||||||
$editor->applyTransactions($preferences, $xactions);
|
|
||||||
|
|
||||||
$uri = $request->getRequestURI()
|
|
||||||
->alter('blame', null);
|
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need the blame information if blame is on and this is an Ajax request.
|
// We need the blame information if blame is on and this is an Ajax request.
|
||||||
// If blame is on and this is a colorized request, we don't show blame at
|
// If blame is on and this is a colorized request, we don't show blame at
|
||||||
// first (we ajax it in afterward) so we don't need to query for it.
|
// first (we ajax it in afterward) so we don't need to query for it.
|
||||||
$needs_blame = ($show_blame && $request->isAjax());
|
$needs_blame = $request->isAjax();
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'commit' => $drequest->getCommit(),
|
'commit' => $drequest->getCommit(),
|
||||||
'path' => $drequest->getPath(),
|
'path' => $drequest->getPath(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$view = $request->getStr('view');
|
||||||
|
|
||||||
$byte_limit = null;
|
$byte_limit = null;
|
||||||
if ($view !== 'raw') {
|
if ($view !== 'raw') {
|
||||||
$byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
|
$byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
|
||||||
|
@ -225,7 +202,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
// Build the content of the file.
|
// Build the content of the file.
|
||||||
$corpus = $this->buildCorpus(
|
$corpus = $this->buildCorpus(
|
||||||
$show_blame,
|
|
||||||
$data,
|
$data,
|
||||||
$needs_blame,
|
$needs_blame,
|
||||||
$drequest,
|
$drequest,
|
||||||
|
@ -240,8 +216,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
require_celerity_resource('diffusion-source-css');
|
require_celerity_resource('diffusion-source-css');
|
||||||
|
|
||||||
// Render the page.
|
$bar = $this->buildButtonBar($drequest, $show_editor);
|
||||||
$bar = $this->buildButtonBar($drequest, $show_blame, $show_editor);
|
|
||||||
$header = $this->buildHeaderView($drequest);
|
$header = $this->buildHeaderView($drequest);
|
||||||
$header->setHeaderIcon('fa-file-code-o');
|
$header->setHeaderIcon('fa-file-code-o');
|
||||||
|
|
||||||
|
@ -540,7 +515,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildCorpus(
|
private function buildCorpus(
|
||||||
$show_blame,
|
|
||||||
$file_corpus,
|
$file_corpus,
|
||||||
$needs_blame,
|
$needs_blame,
|
||||||
DiffusionRequest $drequest,
|
DiffusionRequest $drequest,
|
||||||
|
@ -585,8 +559,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$rows = $this->buildDisplayRows(
|
$rows = $this->buildDisplayRows(
|
||||||
$lines,
|
$lines,
|
||||||
$blame_list,
|
$blame_list,
|
||||||
$blame_commits,
|
$blame_commits);
|
||||||
$show_blame);
|
|
||||||
|
|
||||||
$corpus_table = javelin_tag(
|
$corpus_table = javelin_tag(
|
||||||
'table',
|
'table',
|
||||||
|
@ -677,7 +650,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
phutil_format_bytes($highlight_limit));
|
phutil_format_bytes($highlight_limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show_blame && !$can_blame) {
|
if (!$can_blame) {
|
||||||
$messages[] = pht(
|
$messages[] = pht(
|
||||||
'This file is larger than %s, so blame is disabled.',
|
'This file is larger than %s, so blame is disabled.',
|
||||||
phutil_format_bytes($blame_limit));
|
phutil_format_bytes($blame_limit));
|
||||||
|
@ -701,7 +674,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
private function buildButtonBar(
|
private function buildButtonBar(
|
||||||
DiffusionRequest $drequest,
|
DiffusionRequest $drequest,
|
||||||
$show_blame,
|
|
||||||
$show_editor) {
|
$show_editor) {
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
@ -728,38 +700,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
)))
|
)))
|
||||||
->setIcon('fa-backward');
|
->setIcon('fa-backward');
|
||||||
|
|
||||||
if ($show_blame) {
|
|
||||||
$blame_text = pht('Disable Blame');
|
|
||||||
$blame_icon = 'fa-exclamation-circle lightgreytext';
|
|
||||||
$blame_value = 0;
|
|
||||||
} else {
|
|
||||||
$blame_text = pht('Enable Blame');
|
|
||||||
$blame_icon = 'fa-exclamation-circle';
|
|
||||||
$blame_value = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$blame = id(new PHUIButtonView())
|
|
||||||
->setText($blame_text)
|
|
||||||
->setIcon($blame_icon)
|
|
||||||
->setUser($viewer)
|
|
||||||
->setSelected(!$blame_value)
|
|
||||||
->setColor(PHUIButtonView::GREY);
|
|
||||||
|
|
||||||
if ($viewer->isLoggedIn()) {
|
|
||||||
$blame = phabricator_form(
|
|
||||||
$viewer,
|
|
||||||
array(
|
|
||||||
'action' => $base_uri->alter('blame', $blame_value),
|
|
||||||
'method' => 'POST',
|
|
||||||
'style' => 'display: inline-block;',
|
|
||||||
),
|
|
||||||
$blame);
|
|
||||||
} else {
|
|
||||||
$blame->setTag('a');
|
|
||||||
$blame->setHref($base_uri->alter('blame', $blame_value));
|
|
||||||
}
|
|
||||||
$buttons[] = $blame;
|
|
||||||
|
|
||||||
if ($editor_link) {
|
if ($editor_link) {
|
||||||
$buttons[] =
|
$buttons[] =
|
||||||
id(new PHUIButtonView())
|
id(new PHUIButtonView())
|
||||||
|
@ -931,8 +871,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
private function buildDisplayRows(
|
private function buildDisplayRows(
|
||||||
array $lines,
|
array $lines,
|
||||||
array $blame_list,
|
array $blame_list,
|
||||||
array $blame_commits,
|
array $blame_commits) {
|
||||||
$show_blame) {
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
@ -1123,7 +1062,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$rows = $this->renderInlines(
|
$rows = $this->renderInlines(
|
||||||
idx($inlines, 0, array()),
|
idx($inlines, 0, array()),
|
||||||
$show_blame,
|
|
||||||
(bool)$this->coverage,
|
(bool)$this->coverage,
|
||||||
$engine);
|
$engine);
|
||||||
|
|
||||||
|
@ -1157,7 +1095,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$skip_text = pht('Skip Past This Commit');
|
$skip_text = pht('Skip Past This Commit');
|
||||||
$skip_icon = id(new PHUIIconView())
|
$skip_icon = id(new PHUIIconView())
|
||||||
->setIcon('fa-caret-square-o-left');
|
->setIcon('fa-backward');
|
||||||
|
|
||||||
foreach ($display as $line_index => $line) {
|
foreach ($display as $line_index => $line) {
|
||||||
$row = array();
|
$row = array();
|
||||||
|
@ -1191,7 +1129,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$skip_href = $line_href.'?before='.$identifier.'&view=blame';
|
$skip_href = $line_href.'?before='.$identifier;
|
||||||
$before_link = javelin_tag(
|
$before_link = javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
@ -1206,30 +1144,28 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
$skip_icon);
|
$skip_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show_blame) {
|
$row[] = phutil_tag(
|
||||||
$row[] = phutil_tag(
|
'th',
|
||||||
'th',
|
array(
|
||||||
array(
|
'class' => 'diffusion-blame-link',
|
||||||
'class' => 'diffusion-blame-link',
|
),
|
||||||
),
|
$before_link);
|
||||||
$before_link);
|
|
||||||
|
|
||||||
$object_links = array();
|
$object_links = array();
|
||||||
$object_links[] = $author_link;
|
$object_links[] = $author_link;
|
||||||
$object_links[] = $commit_link;
|
$object_links[] = $commit_link;
|
||||||
if ($revision_link) {
|
if ($revision_link) {
|
||||||
$object_links[] = phutil_tag('span', array(), '/');
|
$object_links[] = phutil_tag('span', array(), '/');
|
||||||
$object_links[] = $revision_link;
|
$object_links[] = $revision_link;
|
||||||
}
|
|
||||||
|
|
||||||
$row[] = phutil_tag(
|
|
||||||
'th',
|
|
||||||
array(
|
|
||||||
'class' => 'diffusion-rev-link',
|
|
||||||
),
|
|
||||||
$object_links);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$row[] = phutil_tag(
|
||||||
|
'th',
|
||||||
|
array(
|
||||||
|
'class' => 'diffusion-rev-link',
|
||||||
|
),
|
||||||
|
$object_links);
|
||||||
|
|
||||||
$line_link = phutil_tag(
|
$line_link = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
@ -1305,7 +1241,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
$cur_inlines = $this->renderInlines(
|
$cur_inlines = $this->renderInlines(
|
||||||
idx($inlines, $line_number, array()),
|
idx($inlines, $line_number, array()),
|
||||||
$show_blame,
|
|
||||||
$this->coverage,
|
$this->coverage,
|
||||||
$engine);
|
$engine);
|
||||||
foreach ($cur_inlines as $cur_inline) {
|
foreach ($cur_inlines as $cur_inline) {
|
||||||
|
@ -1318,7 +1253,6 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
|
|
||||||
private function renderInlines(
|
private function renderInlines(
|
||||||
array $inlines,
|
array $inlines,
|
||||||
$show_blame,
|
|
||||||
$has_coverage,
|
$has_coverage,
|
||||||
$engine) {
|
$engine) {
|
||||||
|
|
||||||
|
@ -1333,7 +1267,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
->setInlineComment($inline)
|
->setInlineComment($inline)
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
$row = array_fill(0, ($show_blame ? 3 : 1), phutil_tag('th'));
|
$row = array_fill(0, 3, phutil_tag('th'));
|
||||||
|
|
||||||
$row[] = phutil_tag('td', array(), $inline_view);
|
$row[] = phutil_tag('td', array(), $inline_view);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue