2011-03-07 17:25:47 -08:00
|
|
|
<?php
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
final class DiffusionBrowseController extends DiffusionController {
|
|
|
|
|
|
|
|
|
|
private $lintCommit;
|
|
|
|
|
private $lintMessages;
|
2017-08-21 13:07:38 -07:00
|
|
|
private $corpusButtons = array();
|
2013-09-19 11:57:33 -07:00
|
|
|
|
2013-09-23 12:53:41 -07:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
|
$response = $this->loadDiffusionContext();
|
|
|
|
|
if ($response) {
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
|
|
// Figure out if we're browsing a directory, a file, or a search result
|
|
|
|
|
// list.
|
|
|
|
|
|
|
|
|
|
$grep = $request->getStr('grep');
|
2017-08-14 16:29:27 -07:00
|
|
|
if (strlen($grep)) {
|
2016-01-05 05:18:59 -08:00
|
|
|
return $this->browseSearch();
|
|
|
|
|
}
|
|
|
|
|
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
|
->readFromRequest($request);
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$results = DiffusionBrowseResultSet::newFromConduit(
|
|
|
|
|
$this->callConduitWithDiffusionRequest(
|
|
|
|
|
'diffusion.browsequery',
|
|
|
|
|
array(
|
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
'offset' => $pager->getOffset(),
|
|
|
|
|
'limit' => $pager->getPageSize() + 1,
|
2016-01-05 05:18:59 -08:00
|
|
|
)));
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$reason = $results->getReasonForEmptyResultSet();
|
|
|
|
|
$is_file = ($reason == DiffusionBrowseResultSet::REASON_IS_FILE);
|
|
|
|
|
|
|
|
|
|
if ($is_file) {
|
2017-02-17 10:10:15 +00:00
|
|
|
return $this->browseFile();
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
2018-04-05 10:21:48 -07:00
|
|
|
|
|
|
|
|
$paths = $results->getPaths();
|
|
|
|
|
$paths = $pager->sliceResults($paths);
|
|
|
|
|
$results->setPaths($paths);
|
|
|
|
|
|
|
|
|
|
return $this->browseDirectory($results, $pager);
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function browseSearch() {
|
2016-03-17 12:01:22 -07:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$header = $this->buildHeaderView($drequest);
|
2017-08-15 14:14:08 -07:00
|
|
|
$path = nonempty(basename($drequest->getPath()), '/');
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$search_results = $this->renderSearchResults();
|
2017-08-15 14:14:08 -07:00
|
|
|
$search_form = $this->renderSearchForm($path);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2017-08-14 16:29:27 -07:00
|
|
|
$search_form = phutil_tag(
|
|
|
|
|
'div',
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'diffusion-mobile-search-form',
|
|
|
|
|
),
|
|
|
|
|
$search_form);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
|
array(
|
|
|
|
|
'branch' => true,
|
|
|
|
|
'path' => true,
|
|
|
|
|
'view' => 'browse',
|
|
|
|
|
));
|
2016-03-17 12:01:22 -07:00
|
|
|
$crumbs->setBorder(true);
|
|
|
|
|
|
2017-08-16 12:07:14 -07:00
|
|
|
$tabs = $this->buildTabsView('code');
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
|
->setHeader($header)
|
2017-08-16 12:07:14 -07:00
|
|
|
->setTabs($tabs)
|
2016-12-05 18:09:51 -08:00
|
|
|
->setFooter(
|
|
|
|
|
array(
|
2016-03-17 12:01:22 -07:00
|
|
|
$search_form,
|
|
|
|
|
$search_results,
|
|
|
|
|
));
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
|
->setTitle(
|
|
|
|
|
array(
|
|
|
|
|
nonempty(basename($drequest->getPath()), '/'),
|
|
|
|
|
$drequest->getRepository()->getDisplayName(),
|
|
|
|
|
))
|
|
|
|
|
->setCrumbs($crumbs)
|
2016-03-17 12:01:22 -07:00
|
|
|
->appendChild($view);
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function browseFile() {
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
|
|
$before = $request->getStr('before');
|
|
|
|
|
if ($before) {
|
|
|
|
|
return $this->buildBeforeResponse($before);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
$params = array(
|
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
|
);
|
|
|
|
|
|
2018-04-05 07:31:47 -07:00
|
|
|
$view = $request->getStr('view');
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$byte_limit = null;
|
|
|
|
|
if ($view !== 'raw') {
|
|
|
|
|
$byte_limit = PhabricatorFileStorageEngine::getChunkThreshold();
|
|
|
|
|
$time_limit = 10;
|
|
|
|
|
|
|
|
|
|
$params += array(
|
|
|
|
|
'timeout' => $time_limit,
|
|
|
|
|
'byteLimit' => $byte_limit,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 03:50:16 -08:00
|
|
|
$response = $this->callConduitWithDiffusionRequest(
|
|
|
|
|
'diffusion.filecontentquery',
|
|
|
|
|
$params);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-01-07 03:50:16 -08:00
|
|
|
$hit_byte_limit = $response['tooHuge'];
|
|
|
|
|
$hit_time_limit = $response['tooSlow'];
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-01-07 03:50:16 -08:00
|
|
|
$file_phid = $response['filePHID'];
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$show_editor = false;
|
2016-01-07 03:50:16 -08:00
|
|
|
if ($hit_byte_limit) {
|
2016-01-05 05:18:59 -08:00
|
|
|
$corpus = $this->buildErrorCorpus(
|
|
|
|
|
pht(
|
|
|
|
|
'This file is larger than %s byte(s), and too large to display '.
|
|
|
|
|
'in the web UI.',
|
2016-01-07 03:50:16 -08:00
|
|
|
phutil_format_bytes($byte_limit)));
|
|
|
|
|
} else if ($hit_time_limit) {
|
|
|
|
|
$corpus = $this->buildErrorCorpus(
|
|
|
|
|
pht(
|
|
|
|
|
'This file took too long to load from the repository (more than '.
|
|
|
|
|
'%s second(s)).',
|
|
|
|
|
new PhutilNumber($time_limit)));
|
|
|
|
|
} else {
|
|
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->withPHIDs(array($file_phid))
|
|
|
|
|
->executeOne();
|
|
|
|
|
if (!$file) {
|
|
|
|
|
throw new Exception(pht('Failed to load content file!'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($view === 'raw') {
|
|
|
|
|
return $file->getRedirectResponse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = $file->loadFileData();
|
2016-03-18 08:13:20 -07:00
|
|
|
|
2016-11-10 00:40:09 +00:00
|
|
|
$lfs_ref = $this->getGitLFSRef($repository, $data);
|
|
|
|
|
if ($lfs_ref) {
|
2016-03-18 08:13:20 -07:00
|
|
|
if ($view == 'git-lfs') {
|
2016-11-10 00:40:09 +00:00
|
|
|
$file = $this->loadGitLFSFile($lfs_ref);
|
2016-03-18 08:13:20 -07:00
|
|
|
|
|
|
|
|
// Rename the file locally so we generate a better vanity URI for
|
|
|
|
|
// it. In storage, it just has a name like "lfs-13f9a94c0923...",
|
|
|
|
|
// since we don't get any hints about possible human-readable names
|
|
|
|
|
// at upload time.
|
|
|
|
|
$basename = basename($drequest->getPath());
|
|
|
|
|
$file->makeEphemeral();
|
|
|
|
|
$file->setName($basename);
|
|
|
|
|
|
|
|
|
|
return $file->getRedirectResponse();
|
|
|
|
|
}
|
2018-04-08 11:38:19 -07:00
|
|
|
|
|
|
|
|
$corpus = $this->buildGitLFSCorpus($lfs_ref);
|
2016-01-05 05:18:59 -08:00
|
|
|
} else {
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$show_editor = true;
|
2016-01-07 03:50:16 -08:00
|
|
|
|
2018-04-05 10:21:48 -07:00
|
|
|
$ref = id(new PhabricatorDocumentRef())
|
|
|
|
|
->setFile($file);
|
|
|
|
|
|
|
|
|
|
$engine = id(new DiffusionDocumentRenderingEngine())
|
|
|
|
|
->setRequest($request)
|
|
|
|
|
->setDiffusionRequest($drequest);
|
|
|
|
|
|
|
|
|
|
$corpus = $engine->newDocumentView($ref);
|
|
|
|
|
|
|
|
|
|
$this->corpusButtons[] = $this->renderFileButton();
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 07:31:47 -07:00
|
|
|
$bar = $this->buildButtonBar($drequest, $show_editor);
|
2016-03-17 12:01:22 -07:00
|
|
|
$header = $this->buildHeaderView($drequest);
|
|
|
|
|
$header->setHeaderIcon('fa-file-code-o');
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$follow = $request->getStr('follow');
|
2017-08-21 13:07:38 -07:00
|
|
|
$follow_notice = null;
|
2016-01-05 05:18:59 -08:00
|
|
|
if ($follow) {
|
2017-08-21 13:07:38 -07:00
|
|
|
$follow_notice = id(new PHUIInfoView())
|
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
|
|
|
|
->setTitle(pht('Unable to Continue'));
|
2016-01-05 05:18:59 -08:00
|
|
|
switch ($follow) {
|
|
|
|
|
case 'first':
|
2017-08-21 13:07:38 -07:00
|
|
|
$follow_notice->appendChild(
|
2016-01-05 05:18:59 -08:00
|
|
|
pht(
|
|
|
|
|
'Unable to continue tracing the history of this file because '.
|
|
|
|
|
'this commit is the first commit in the repository.'));
|
|
|
|
|
break;
|
|
|
|
|
case 'created':
|
2017-08-21 13:07:38 -07:00
|
|
|
$follow_notice->appendChild(
|
2016-01-05 05:18:59 -08:00
|
|
|
pht(
|
|
|
|
|
'Unable to continue tracing the history of this file because '.
|
|
|
|
|
'this commit created the file.'));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$renamed = $request->getStr('renamed');
|
2017-08-21 13:07:38 -07:00
|
|
|
$renamed_notice = null;
|
2016-01-05 05:18:59 -08:00
|
|
|
if ($renamed) {
|
2017-08-21 13:07:38 -07:00
|
|
|
$renamed_notice = id(new PHUIInfoView())
|
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
|
|
|
|
->setTitle(pht('File Renamed'))
|
|
|
|
|
->appendChild(
|
|
|
|
|
pht(
|
|
|
|
|
'File history passes through a rename from "%s" to "%s".',
|
|
|
|
|
$drequest->getPath(),
|
|
|
|
|
$renamed));
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
$open_revisions = $this->buildOpenRevisions();
|
|
|
|
|
$owners_list = $this->buildOwnersList($drequest);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
|
array(
|
|
|
|
|
'branch' => true,
|
|
|
|
|
'path' => true,
|
|
|
|
|
'view' => 'browse',
|
|
|
|
|
));
|
2016-03-17 12:01:22 -07:00
|
|
|
$crumbs->setBorder(true);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$basename = basename($this->getDiffusionRequest()->getPath());
|
2017-08-16 12:07:14 -07:00
|
|
|
$tabs = $this->buildTabsView('code');
|
2017-08-21 13:07:38 -07:00
|
|
|
$bar->setRight($this->corpusButtons);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
|
->setHeader($header)
|
2017-08-16 12:07:14 -07:00
|
|
|
->setTabs($tabs)
|
2017-08-21 13:07:38 -07:00
|
|
|
->setFooter(array(
|
|
|
|
|
$bar,
|
|
|
|
|
$follow_notice,
|
|
|
|
|
$renamed_notice,
|
|
|
|
|
$corpus,
|
|
|
|
|
$open_revisions,
|
|
|
|
|
$owners_list,
|
|
|
|
|
));
|
2016-03-17 12:01:22 -07:00
|
|
|
|
|
|
|
|
$title = array($basename, $repository->getDisplayName());
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
return $this->newPage()
|
2016-03-17 12:01:22 -07:00
|
|
|
->setTitle($title)
|
2016-01-05 05:18:59 -08:00
|
|
|
->setCrumbs($crumbs)
|
2016-03-17 12:01:22 -07:00
|
|
|
->appendChild(
|
|
|
|
|
array(
|
|
|
|
|
$view,
|
|
|
|
|
));
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
public function browseDirectory(
|
|
|
|
|
DiffusionBrowseResultSet $results,
|
|
|
|
|
PHUIPagerView $pager) {
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
|
|
$reason = $results->getReasonForEmptyResultSet();
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->buildActionButtons($drequest, true);
|
2016-03-17 12:01:22 -07:00
|
|
|
$details = $this->buildPropertyView($drequest);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$header = $this->buildHeaderView($drequest);
|
|
|
|
|
$header->setHeaderIcon('fa-folder-open');
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$empty_result = null;
|
|
|
|
|
$browse_panel = null;
|
2016-12-05 18:09:51 -08:00
|
|
|
$branch_panel = null;
|
2016-01-05 05:18:59 -08:00
|
|
|
if (!$results->isValidResults()) {
|
|
|
|
|
$empty_result = new DiffusionEmptyResultView();
|
|
|
|
|
$empty_result->setDiffusionRequest($drequest);
|
|
|
|
|
$empty_result->setDiffusionBrowseResultSet($results);
|
|
|
|
|
$empty_result->setView($request->getStr('view'));
|
|
|
|
|
} else {
|
|
|
|
|
$phids = array();
|
|
|
|
|
foreach ($results->getPaths() as $result) {
|
|
|
|
|
$data = $result->getLastCommitData();
|
|
|
|
|
if ($data) {
|
|
|
|
|
if ($data->getCommitDetail('authorPHID')) {
|
|
|
|
|
$phids[$data->getCommitDetail('authorPHID')] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$phids = array_keys($phids);
|
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$browse_table = id(new DiffusionBrowseTableView())
|
|
|
|
|
->setDiffusionRequest($drequest)
|
|
|
|
|
->setHandles($handles)
|
|
|
|
|
->setPaths($results->getPaths())
|
|
|
|
|
->setUser($request->getUser());
|
2016-01-05 05:18:59 -08:00
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$title = nonempty(basename($drequest->getPath()), '/');
|
|
|
|
|
$icon = 'fa-folder-open';
|
2017-08-21 13:07:38 -07:00
|
|
|
$browse_header = $this->buildPanelHeaderView($title, $icon);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$browse_panel = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($browse_header)
|
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
2017-04-21 11:22:06 -07:00
|
|
|
->setTable($browse_table)
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
->addClass('diffusion-mobile-view')
|
2017-04-21 11:22:06 -07:00
|
|
|
->setPager($pager);
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2016-12-05 18:09:51 -08:00
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
$is_branch = (!strlen($path) && $repository->supportsBranchComparison());
|
|
|
|
|
if ($is_branch) {
|
|
|
|
|
$branch_panel = $this->buildBranchTable();
|
|
|
|
|
}
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$open_revisions = $this->buildOpenRevisions();
|
|
|
|
|
$readme = $this->renderDirectoryReadme($results);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
|
array(
|
|
|
|
|
'branch' => true,
|
|
|
|
|
'path' => true,
|
|
|
|
|
'view' => 'browse',
|
|
|
|
|
));
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$crumbs->setBorder(true);
|
2017-08-16 12:07:14 -07:00
|
|
|
$tabs = $this->buildTabsView('code');
|
2017-08-21 13:07:38 -07:00
|
|
|
$owners_list = $this->buildOwnersList($drequest);
|
|
|
|
|
$bar = id(new PHUILeftRightView())
|
|
|
|
|
->setRight($this->corpusButtons)
|
|
|
|
|
->addClass('diffusion-action-bar');
|
2016-03-17 12:01:22 -07:00
|
|
|
|
|
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
|
->setHeader($header)
|
2017-08-16 12:07:14 -07:00
|
|
|
->setTabs($tabs)
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
->setFooter(
|
2016-12-05 18:09:51 -08:00
|
|
|
array(
|
2017-08-21 13:07:38 -07:00
|
|
|
$bar,
|
2016-12-05 18:09:51 -08:00
|
|
|
$branch_panel,
|
|
|
|
|
$empty_result,
|
|
|
|
|
$browse_panel,
|
2016-03-17 12:01:22 -07:00
|
|
|
$open_revisions,
|
2017-08-21 13:07:38 -07:00
|
|
|
$owners_list,
|
2016-03-17 12:01:22 -07:00
|
|
|
$readme,
|
2016-12-05 18:09:51 -08:00
|
|
|
));
|
2016-03-17 12:01:22 -07:00
|
|
|
|
|
|
|
|
if ($details) {
|
2016-04-06 15:20:53 -07:00
|
|
|
$view->addPropertySection(pht('Details'), $details);
|
2016-03-17 12:01:22 -07:00
|
|
|
}
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
return $this->newPage()
|
2016-03-17 12:01:22 -07:00
|
|
|
->setTitle(array(
|
2016-01-05 05:18:59 -08:00
|
|
|
nonempty(basename($drequest->getPath()), '/'),
|
|
|
|
|
$repository->getDisplayName(),
|
|
|
|
|
))
|
|
|
|
|
->setCrumbs($crumbs)
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
->appendChild(
|
|
|
|
|
array(
|
2016-03-17 12:01:22 -07:00
|
|
|
$view,
|
Improve Diffusion behavior for directories with impressive numbers of files
Summary:
Fixes T4366. Two years ago, Facebook put 16,000 files in a directory. Today, the page has nearly loaded.
Paginate large directories.
Test Plan:
- Viewed home and browse views in Git, Mercurial and Subversion.
I put an artificially small page size (5) on home:
{F1055653}
I pushed 16,000 files to a directory and paged through them. Here's the last page, which rendered in about 200ms:
{F1055655}
Our behavior is a bit better than GitHub here, which shows only the first 1,000 files, disables pagination, and can't retrieve history for the files:
{F1055656}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4366
Differential Revision: https://secure.phabricator.com/D14956
2016-01-06 03:57:57 -08:00
|
|
|
));
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function renderSearchResults() {
|
2016-01-05 05:56:35 -08:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
$results = array();
|
|
|
|
|
|
2016-01-05 05:56:35 -08:00
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
|
->readFromRequest($request);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$search_mode = null;
|
|
|
|
|
switch ($repository->getVersionControlSystem()) {
|
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
|
$results = array();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (strlen($this->getRequest()->getStr('grep'))) {
|
|
|
|
|
$search_mode = 'grep';
|
2016-01-05 05:56:35 -08:00
|
|
|
$query_string = $request->getStr('grep');
|
2016-01-05 05:18:59 -08:00
|
|
|
$results = $this->callConduitWithDiffusionRequest(
|
|
|
|
|
'diffusion.searchquery',
|
|
|
|
|
array(
|
|
|
|
|
'grep' => $query_string,
|
|
|
|
|
'commit' => $drequest->getStableCommit(),
|
|
|
|
|
'path' => $drequest->getPath(),
|
2016-01-05 05:56:35 -08:00
|
|
|
'limit' => $pager->getPageSize() + 1,
|
|
|
|
|
'offset' => $pager->getOffset(),
|
2016-01-05 05:18:59 -08:00
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$results = $pager->sliceResults($results);
|
|
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
$table = null;
|
|
|
|
|
$header = null;
|
2016-01-05 05:18:59 -08:00
|
|
|
if ($search_mode == 'grep') {
|
|
|
|
|
$table = $this->renderGrepResults($results, $query_string);
|
2017-08-14 20:50:06 -07:00
|
|
|
$title = pht(
|
2016-01-05 05:18:59 -08:00
|
|
|
'File content matching "%s" under "%s"',
|
|
|
|
|
$query_string,
|
|
|
|
|
nonempty($drequest->getPath(), '/'));
|
2017-08-14 20:50:06 -07:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
|
->setHeader($title)
|
|
|
|
|
->addClass('diffusion-search-result-header');
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
return array($header, $table, $pager);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function renderGrepResults(array $results, $pattern) {
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
require_celerity_resource('phabricator-search-results-css');
|
|
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
if (!$results) {
|
|
|
|
|
return id(new PHUIInfoView())
|
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
|
|
|
|
|
->appendChild(
|
|
|
|
|
pht(
|
|
|
|
|
'The pattern you searched for was not found in the content of any '.
|
|
|
|
|
'files.'));
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
$grouped = array();
|
|
|
|
|
foreach ($results as $file) {
|
|
|
|
|
list($path, $line, $string) = $file;
|
|
|
|
|
$grouped[$path][] = array($line, $string);
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
$view = array();
|
|
|
|
|
foreach ($grouped as $path => $matches) {
|
|
|
|
|
$view[] = id(new DiffusionPatternSearchView())
|
|
|
|
|
->setPath($path)
|
|
|
|
|
->setMatches($matches)
|
|
|
|
|
->setPattern($pattern)
|
|
|
|
|
->setDiffusionRequest($drequest)
|
|
|
|
|
->render();
|
|
|
|
|
}
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2017-08-14 20:50:06 -07:00
|
|
|
return $view;
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
private function buildButtonBar(
|
2016-01-05 05:18:59 -08:00
|
|
|
DiffusionRequest $drequest,
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$show_editor) {
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
$viewer = $this->getViewer();
|
2016-01-05 05:18:59 -08:00
|
|
|
$base_uri = $this->getRequest()->getRequestURI();
|
|
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
$line = nonempty((int)$drequest->getLine(), 1);
|
2017-08-21 13:07:38 -07:00
|
|
|
$buttons = array();
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
|
|
|
|
|
$editor_link = $user->loadEditorLink($path, $line, $repository);
|
|
|
|
|
$template = $user->loadEditorLink($path, '%l', $repository);
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
$buttons[] =
|
|
|
|
|
id(new PHUIButtonView())
|
2017-08-24 19:36:33 -07:00
|
|
|
->setTag('a')
|
2017-08-21 13:07:38 -07:00
|
|
|
->setText(pht('Last Change'))
|
|
|
|
|
->setColor(PHUIButtonView::GREY)
|
2016-01-05 05:18:59 -08:00
|
|
|
->setHref(
|
|
|
|
|
$drequest->generateURI(
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'change',
|
|
|
|
|
)))
|
2017-08-21 13:07:38 -07:00
|
|
|
->setIcon('fa-backward');
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
if ($editor_link) {
|
|
|
|
|
$buttons[] =
|
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
|
->setTag('a')
|
|
|
|
|
->setText(pht('Open File'))
|
|
|
|
|
->setHref($editor_link)
|
|
|
|
|
->setIcon('fa-pencil')
|
|
|
|
|
->setID('editor_link')
|
|
|
|
|
->setMetadata(array('link_template' => $template))
|
|
|
|
|
->setDisabled(!$editor_link)
|
|
|
|
|
->setColor(PHUIButtonView::GREY);
|
|
|
|
|
}
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
$bar = id(new PHUILeftRightView())
|
|
|
|
|
->setLeft($buttons)
|
|
|
|
|
->addClass('diffusion-action-bar full-mobile-buttons');
|
|
|
|
|
return $bar;
|
|
|
|
|
}
|
2016-01-05 05:18:59 -08:00
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
private function buildOwnersList(DiffusionRequest $drequest) {
|
|
|
|
|
$viewer = $this->getViewer();
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$have_owners = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
|
'PhabricatorOwnersApplication',
|
|
|
|
|
$viewer);
|
|
|
|
|
if (!$have_owners) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$repository = $drequest->getRepository();
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$package_query = id(new PhabricatorOwnersPackageQuery())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->withStatuses(array(PhabricatorOwnersPackage::STATUS_ACTIVE))
|
|
|
|
|
->withControl(
|
2016-03-17 12:01:22 -07:00
|
|
|
$repository->getPHID(),
|
2017-09-19 09:22:10 -07:00
|
|
|
array(
|
|
|
|
|
$drequest->getPath(),
|
|
|
|
|
));
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$package_query->execute();
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$packages = $package_query->getControllingPackagesForPath(
|
|
|
|
|
$repository->getPHID(),
|
|
|
|
|
$drequest->getPath());
|
|
|
|
|
|
|
|
|
|
$ownership = id(new PHUIObjectItemListView())
|
|
|
|
|
->setUser($viewer)
|
|
|
|
|
->setNoDataString(pht('No Owners'));
|
|
|
|
|
|
|
|
|
|
if ($packages) {
|
|
|
|
|
foreach ($packages as $package) {
|
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
|
->setObject($package)
|
|
|
|
|
->setObjectName($package->getMonogram())
|
|
|
|
|
->setHeader($package->getName())
|
|
|
|
|
->setHref($package->getURI());
|
|
|
|
|
|
|
|
|
|
$owners = $package->getOwners();
|
|
|
|
|
if ($owners) {
|
|
|
|
|
$owner_list = $viewer->renderHandleList(
|
|
|
|
|
mpull($owners, 'getUserPHID'));
|
|
|
|
|
} else {
|
|
|
|
|
$owner_list = phutil_tag('em', array(), pht('None'));
|
2016-03-17 12:01:22 -07:00
|
|
|
}
|
2017-09-19 09:22:10 -07:00
|
|
|
$item->addAttribute(pht('Owners: %s', $owner_list));
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$auto = $package->getAutoReview();
|
|
|
|
|
$autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
|
|
|
|
|
$spec = idx($autoreview_map, $auto, array());
|
|
|
|
|
$name = idx($spec, 'name', $auto);
|
|
|
|
|
$item->addIcon('fa-code', $name);
|
|
|
|
|
|
|
|
|
|
if ($package->getAuditingEnabled()) {
|
|
|
|
|
$item->addIcon('fa-check', pht('Auditing Enabled'));
|
|
|
|
|
} else {
|
|
|
|
|
$item->addIcon('fa-ban', pht('No Auditing'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($package->isArchived()) {
|
|
|
|
|
$item->setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ownership->addItem($item);
|
|
|
|
|
}
|
2016-03-17 12:01:22 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-19 09:22:10 -07:00
|
|
|
$view = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeaderText(pht('Owner Packages'))
|
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
|
->addClass('diffusion-mobile-view')
|
|
|
|
|
->setObjectList($ownership);
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
return $view;
|
2016-01-05 05:18:59 -08:00
|
|
|
}
|
|
|
|
|
|
2016-03-18 08:13:20 -07:00
|
|
|
private function renderFileButton($file_uri = null, $label = null) {
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$base_uri = $this->getRequest()->getRequestURI();
|
|
|
|
|
|
|
|
|
|
if ($file_uri) {
|
2017-08-21 13:07:38 -07:00
|
|
|
$text = pht('Download File');
|
2016-01-05 05:18:59 -08:00
|
|
|
$href = $file_uri;
|
|
|
|
|
$icon = 'fa-download';
|
|
|
|
|
} else {
|
2017-08-21 13:07:38 -07:00
|
|
|
$text = pht('Raw File');
|
2016-01-05 05:18:59 -08:00
|
|
|
$href = $base_uri->alter('view', 'raw');
|
|
|
|
|
$icon = 'fa-file-text';
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 08:13:20 -07:00
|
|
|
if ($label !== null) {
|
|
|
|
|
$text = $label;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$button = id(new PHUIButtonView())
|
|
|
|
|
->setTag('a')
|
|
|
|
|
->setText($text)
|
|
|
|
|
->setHref($href)
|
2017-08-21 13:07:38 -07:00
|
|
|
->setIcon($icon)
|
|
|
|
|
->setColor(PHUIButtonView::GREY);
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
return $button;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 08:13:20 -07:00
|
|
|
private function renderGitLFSButton() {
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
|
|
$uri = $this->getRequest()->getRequestURI();
|
|
|
|
|
$href = $uri->alter('view', 'git-lfs');
|
|
|
|
|
|
|
|
|
|
$text = pht('Download from Git LFS');
|
|
|
|
|
$icon = 'fa-download';
|
|
|
|
|
|
|
|
|
|
return id(new PHUIButtonView())
|
|
|
|
|
->setTag('a')
|
|
|
|
|
->setText($text)
|
|
|
|
|
->setHref($href)
|
2017-12-13 06:02:09 -08:00
|
|
|
->setIcon($icon)
|
|
|
|
|
->setColor(PHUIButtonView::GREY);
|
2016-03-18 08:13:20 -07:00
|
|
|
}
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
private function buildErrorCorpus($message) {
|
|
|
|
|
$text = id(new PHUIBoxView())
|
|
|
|
|
->addPadding(PHUI::PADDING_LARGE)
|
|
|
|
|
->appendChild($message);
|
|
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
2016-04-06 15:20:53 -07:00
|
|
|
->setHeader(pht('Details'));
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($header)
|
|
|
|
|
->appendChild($text);
|
|
|
|
|
|
|
|
|
|
return $box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildBeforeResponse($before) {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
|
|
|
|
|
// NOTE: We need to get the grandparent so we can capture filename changes
|
|
|
|
|
// in the parent.
|
|
|
|
|
|
|
|
|
|
$parent = $this->loadParentCommitOf($before);
|
|
|
|
|
$old_filename = null;
|
|
|
|
|
$was_created = false;
|
|
|
|
|
if ($parent) {
|
|
|
|
|
$grandparent = $this->loadParentCommitOf($parent);
|
|
|
|
|
|
|
|
|
|
if ($grandparent) {
|
|
|
|
|
$rename_query = new DiffusionRenameHistoryQuery();
|
|
|
|
|
$rename_query->setRequest($drequest);
|
|
|
|
|
$rename_query->setOldCommit($grandparent);
|
|
|
|
|
$rename_query->setViewer($request->getUser());
|
|
|
|
|
$old_filename = $rename_query->loadOldFilename();
|
|
|
|
|
$was_created = $rename_query->getWasCreated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$follow = null;
|
|
|
|
|
if ($was_created) {
|
|
|
|
|
// If the file was created in history, that means older commits won't
|
|
|
|
|
// have it. Since we know it existed at 'before', it must have been
|
|
|
|
|
// created then; jump there.
|
|
|
|
|
$target_commit = $before;
|
|
|
|
|
$follow = 'created';
|
|
|
|
|
} else if ($parent) {
|
|
|
|
|
// If we found a parent, jump to it. This is the normal case.
|
|
|
|
|
$target_commit = $parent;
|
|
|
|
|
} else {
|
|
|
|
|
// If there's no parent, this was probably created in the initial commit?
|
|
|
|
|
// And the "was_created" check will fail because we can't identify the
|
|
|
|
|
// grandparent. Keep the user at 'before'.
|
|
|
|
|
$target_commit = $before;
|
|
|
|
|
$follow = 'first';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
$renamed = null;
|
|
|
|
|
if ($old_filename !== null &&
|
|
|
|
|
$old_filename !== '/'.$path) {
|
|
|
|
|
$renamed = $path;
|
|
|
|
|
$path = $old_filename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$line = null;
|
|
|
|
|
// If there's a follow error, drop the line so the user sees the message.
|
|
|
|
|
if (!$follow) {
|
|
|
|
|
$line = $this->getBeforeLineNumber($target_commit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$before_uri = $drequest->generateURI(
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'browse',
|
|
|
|
|
'commit' => $target_commit,
|
|
|
|
|
'line' => $line,
|
|
|
|
|
'path' => $path,
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$before_uri->setQueryParams($request->getRequestURI()->getQueryParams());
|
|
|
|
|
$before_uri = $before_uri->alter('before', null);
|
|
|
|
|
$before_uri = $before_uri->alter('renamed', $renamed);
|
|
|
|
|
$before_uri = $before_uri->alter('follow', $follow);
|
|
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($before_uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getBeforeLineNumber($target_commit) {
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2016-08-26 09:37:53 -07:00
|
|
|
$viewer = $this->getViewer();
|
2016-01-05 05:18:59 -08:00
|
|
|
|
|
|
|
|
$line = $drequest->getLine();
|
|
|
|
|
if (!$line) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-26 09:37:53 -07:00
|
|
|
$diff_info = $this->callConduitWithDiffusionRequest(
|
2016-01-05 05:18:59 -08:00
|
|
|
'diffusion.rawdiffquery',
|
|
|
|
|
array(
|
|
|
|
|
'commit' => $drequest->getCommit(),
|
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
|
'againstCommit' => $target_commit,
|
|
|
|
|
));
|
2016-08-26 09:37:53 -07:00
|
|
|
|
|
|
|
|
$file_phid = $diff_info['filePHID'];
|
|
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->withPHIDs(array($file_phid))
|
|
|
|
|
->executeOne();
|
|
|
|
|
if (!$file) {
|
|
|
|
|
throw new Exception(
|
|
|
|
|
pht(
|
|
|
|
|
'Failed to load file ("%s") returned by "%s".',
|
|
|
|
|
$file_phid,
|
|
|
|
|
'diffusion.rawdiffquery.'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$raw_diff = $file->loadFileData();
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
$old_line = 0;
|
|
|
|
|
$new_line = 0;
|
|
|
|
|
|
|
|
|
|
foreach (explode("\n", $raw_diff) as $text) {
|
|
|
|
|
if ($text[0] == '-' || $text[0] == ' ') {
|
|
|
|
|
$old_line++;
|
|
|
|
|
}
|
|
|
|
|
if ($text[0] == '+' || $text[0] == ' ') {
|
|
|
|
|
$new_line++;
|
|
|
|
|
}
|
|
|
|
|
if ($new_line == $line) {
|
|
|
|
|
return $old_line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We didn't find the target line.
|
|
|
|
|
return $line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function loadParentCommitOf($commit) {
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
|
|
$before_req = DiffusionRequest::newFromDictionary(
|
|
|
|
|
array(
|
|
|
|
|
'user' => $user,
|
|
|
|
|
'repository' => $drequest->getRepository(),
|
|
|
|
|
'commit' => $commit,
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$parents = DiffusionQuery::callConduitWithDiffusionRequest(
|
|
|
|
|
$user,
|
|
|
|
|
$before_req,
|
|
|
|
|
'diffusion.commitparentsquery',
|
|
|
|
|
array(
|
|
|
|
|
'commit' => $commit,
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
return head($parents);
|
|
|
|
|
}
|
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
protected function markupText($text) {
|
2012-04-23 18:36:25 -07:00
|
|
|
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
2013-03-04 12:33:05 -08:00
|
|
|
$engine->setConfig('viewer', $this->getRequest()->getUser());
|
2013-02-13 14:50:15 -08:00
|
|
|
$text = $engine->markupText($text);
|
2012-04-23 18:36:25 -07:00
|
|
|
|
2013-01-18 00:32:58 -08:00
|
|
|
$text = phutil_tag(
|
2012-04-23 18:36:25 -07:00
|
|
|
'div',
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
|
),
|
|
|
|
|
$text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
protected function buildHeaderView(DiffusionRequest $drequest) {
|
2016-03-17 12:01:22 -07:00
|
|
|
$viewer = $this->getViewer();
|
2017-08-16 12:07:14 -07:00
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
|
|
$commit_tag = $this->renderCommitHashTag($drequest);
|
2016-03-17 12:01:22 -07:00
|
|
|
|
2017-09-29 14:48:38 -07:00
|
|
|
$path = nonempty($drequest->getPath(), '/');
|
|
|
|
|
|
2017-08-15 14:14:08 -07:00
|
|
|
$search = $this->renderSearchForm($path);
|
2013-09-19 11:57:33 -07:00
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
|
->setUser($viewer)
|
2013-09-23 12:55:23 -07:00
|
|
|
->setHeader($this->renderPathLinks($drequest, $mode = 'browse'))
|
2017-08-14 16:29:27 -07:00
|
|
|
->addActionItem($search)
|
2017-08-16 12:07:14 -07:00
|
|
|
->addTag($commit_tag)
|
2017-08-14 16:29:27 -07:00
|
|
|
->addClass('diffusion-browse-header');
|
2013-09-19 11:57:33 -07:00
|
|
|
|
2017-08-16 12:07:14 -07:00
|
|
|
if (!$repository->isSVN()) {
|
|
|
|
|
$branch_tag = $this->renderBranchTag($drequest);
|
|
|
|
|
$header->addTag($branch_tag);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-19 11:57:33 -07:00
|
|
|
return $header;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
protected function buildPanelHeaderView($title, $icon) {
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
|
->setHeader($title)
|
|
|
|
|
->setHeaderIcon($icon)
|
|
|
|
|
->addClass('diffusion-panel-header-view');
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
return $header;
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
}
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
protected function buildActionButtons(
|
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
|
$is_directory = false) {
|
|
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
$history_uri = $drequest->generateURI(array('action' => 'history'));
|
2014-05-13 13:52:48 -07:00
|
|
|
$behind_head = $drequest->getSymbolicCommit();
|
2017-07-09 06:40:51 -07:00
|
|
|
$compare = null;
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
$head_uri = $drequest->generateURI(
|
|
|
|
|
array(
|
|
|
|
|
'commit' => '',
|
|
|
|
|
'action' => 'browse',
|
|
|
|
|
));
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
if ($repository->supportsBranchComparison() && $is_directory) {
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$compare_uri = $drequest->generateURI(array('action' => 'compare'));
|
|
|
|
|
$compare = id(new PHUIButtonView())
|
|
|
|
|
->setText(pht('Compare'))
|
|
|
|
|
->setIcon('fa-code-fork')
|
|
|
|
|
->setWorkflow(true)
|
|
|
|
|
->setTag('a')
|
|
|
|
|
->setHref($compare_uri)
|
|
|
|
|
->setColor(PHUIButtonView::GREY);
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->corpusButtons[] = $compare;
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$head = null;
|
|
|
|
|
if ($behind_head) {
|
|
|
|
|
$head = id(new PHUIButtonView())
|
2017-08-21 18:47:27 -07:00
|
|
|
->setTag('a')
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
->setText(pht('Back to HEAD'))
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
->setHref($head_uri)
|
2014-05-12 10:08:32 -07:00
|
|
|
->setIcon('fa-home')
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
->setColor(PHUIButtonView::GREY);
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->corpusButtons[] = $head;
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
}
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$history = id(new PHUIButtonView())
|
|
|
|
|
->setText(pht('History'))
|
|
|
|
|
->setHref($history_uri)
|
|
|
|
|
->setTag('a')
|
|
|
|
|
->setIcon('fa-history')
|
|
|
|
|
->setColor(PHUIButtonView::GREY);
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->corpusButtons[] = $history;
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
}
|
|
|
|
|
|
2013-10-11 07:53:56 -07:00
|
|
|
protected function buildPropertyView(
|
2016-03-17 12:01:22 -07:00
|
|
|
DiffusionRequest $drequest) {
|
2013-10-11 07:53:56 -07:00
|
|
|
|
2015-08-15 13:06:10 -07:00
|
|
|
$viewer = $this->getViewer();
|
2013-10-11 07:53:56 -07:00
|
|
|
$view = id(new PHUIPropertyListView())
|
2016-03-17 12:01:22 -07:00
|
|
|
->setUser($viewer);
|
2013-09-19 11:57:33 -07:00
|
|
|
|
2014-05-13 13:52:03 -07:00
|
|
|
if ($drequest->getSymbolicType() == 'tag') {
|
2013-11-04 12:16:53 -08:00
|
|
|
$symbolic = $drequest->getSymbolicCommit();
|
|
|
|
|
$view->addProperty(pht('Tag'), $symbolic);
|
2013-09-19 11:57:33 -07:00
|
|
|
|
2013-11-04 12:16:53 -08:00
|
|
|
$tags = $this->callConduitWithDiffusionRequest(
|
|
|
|
|
'diffusion.tagsquery',
|
|
|
|
|
array(
|
|
|
|
|
'names' => array($symbolic),
|
|
|
|
|
'needMessages' => true,
|
|
|
|
|
));
|
|
|
|
|
$tags = DiffusionRepositoryTag::newFromConduit($tags);
|
|
|
|
|
|
|
|
|
|
$tags = mpull($tags, null, 'getName');
|
|
|
|
|
$tag = idx($tags, $symbolic);
|
|
|
|
|
|
|
|
|
|
if ($tag && strlen($tag->getMessage())) {
|
2015-09-19 11:29:01 -07:00
|
|
|
$view->addSectionHeader(
|
|
|
|
|
pht('Tag Content'), 'fa-tag');
|
2013-11-04 12:16:53 -08:00
|
|
|
$view->addTextContent($this->markupText($tag->getMessage()));
|
|
|
|
|
}
|
2013-09-19 11:57:33 -07:00
|
|
|
}
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
if ($view->hasAnyProperties()) {
|
|
|
|
|
return $view;
|
2015-08-15 13:06:10 -07:00
|
|
|
}
|
|
|
|
|
|
2016-03-17 12:01:22 -07:00
|
|
|
return null;
|
2013-09-19 11:57:33 -07:00
|
|
|
}
|
|
|
|
|
|
2016-01-05 05:18:59 -08:00
|
|
|
private function buildOpenRevisions() {
|
|
|
|
|
$viewer = $this->getViewer();
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
|
|
|
|
|
$path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs();
|
|
|
|
|
$path_id = idx($path_map, $path);
|
|
|
|
|
if (!$path_id) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-25 10:21:56 -07:00
|
|
|
$recent = (PhabricatorTime::getNow() - phutil_units('30 days in seconds'));
|
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
$revisions = id(new DifferentialRevisionQuery())
|
2016-01-05 05:18:59 -08:00
|
|
|
->setViewer($viewer)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
->withPath($repository->getID(), $path_id)
|
2017-08-11 09:18:47 -07:00
|
|
|
->withIsOpen(true)
|
2015-03-25 10:21:56 -07:00
|
|
|
->withUpdatedEpochBetween($recent, null)
|
2015-04-11 20:16:52 -07:00
|
|
|
->setOrder(DifferentialRevisionQuery::ORDER_MODIFIED)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
->setLimit(10)
|
2017-03-20 14:37:24 -07:00
|
|
|
->needReviewers(true)
|
2014-02-18 17:57:45 -08:00
|
|
|
->needFlags(true)
|
|
|
|
|
->needDrafts(true)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
->execute();
|
|
|
|
|
|
|
|
|
|
if (!$revisions) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-25 10:21:56 -07:00
|
|
|
$header = id(new PHUIHeaderView())
|
2017-07-09 06:40:51 -07:00
|
|
|
->setHeader(pht('Recently Open Revisions'));
|
2015-03-25 10:21:56 -07:00
|
|
|
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
$list = id(new DifferentialRevisionListView())
|
2018-04-03 11:48:20 -07:00
|
|
|
->setViewer($viewer)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
->setRevisions($revisions)
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
->setNoBox(true);
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
$view = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($header)
|
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
|
->addClass('diffusion-mobile-view')
|
|
|
|
|
->appendChild($list);
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
|
2015-02-19 08:11:17 -08:00
|
|
|
return $view;
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-19 16:01:34 -07:00
|
|
|
}
|
|
|
|
|
|
2016-03-18 08:13:20 -07:00
|
|
|
private function getGitLFSRef(PhabricatorRepository $repository, $data) {
|
|
|
|
|
if (!$repository->canUseGitLFS()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lfs_pattern = '(^version https://git-lfs\\.github\\.com/spec/v1[\r\n])';
|
|
|
|
|
if (!preg_match($lfs_pattern, $data)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$matches = null;
|
|
|
|
|
if (!preg_match('(^oid sha256:(.*)$)m', $data, $matches)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$hash = $matches[1];
|
|
|
|
|
$hash = trim($hash);
|
|
|
|
|
|
|
|
|
|
return id(new PhabricatorRepositoryGitLFSRefQuery())
|
|
|
|
|
->setViewer($this->getViewer())
|
|
|
|
|
->withRepositoryPHIDs(array($repository->getPHID()))
|
|
|
|
|
->withObjectHashes(array($hash))
|
|
|
|
|
->executeOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildGitLFSCorpus(PhabricatorRepositoryGitLFSRef $ref) {
|
|
|
|
|
// TODO: We should probably test if we can load the file PHID here and
|
|
|
|
|
// show the user an error if we can't, rather than making them click
|
|
|
|
|
// through to hit an error.
|
|
|
|
|
|
Move Diffusion Browse to a single column layout
Summary: The main change here is moving (compare, search, history) into buttons in the header bar on all browse views. This allows Directory Browsing to be full width, since there is no other curtain information. File, Image, LFS, Binary all stay in TwoColumn layouts with the same buttons in the header.
Test Plan: Test viewing a directory, file, image, binary file, readme, and fake a gitlfs.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D17766
2017-07-01 17:38:17 +02:00
|
|
|
$title = basename($this->getDiffusionRequest()->getPath());
|
|
|
|
|
$icon = 'fa-archive';
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->buildActionButtons($drequest);
|
|
|
|
|
$header = $this->buildPanelHeaderView($title, $icon);
|
2016-03-18 08:13:20 -07:00
|
|
|
|
|
|
|
|
$severity = PHUIInfoView::SEVERITY_NOTICE;
|
|
|
|
|
|
|
|
|
|
$messages = array();
|
|
|
|
|
$messages[] = pht(
|
|
|
|
|
'This %s file is stored in Git Large File Storage.',
|
|
|
|
|
phutil_format_bytes($ref->getByteSize()));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$file = $this->loadGitLFSFile($ref);
|
2017-12-13 06:02:09 -08:00
|
|
|
$this->corpusButtons[] = $this->renderGitLFSButton();
|
2016-03-18 08:13:20 -07:00
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
$severity = PHUIInfoView::SEVERITY_ERROR;
|
|
|
|
|
$messages[] = pht('The data for this file could not be loaded.');
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 13:07:38 -07:00
|
|
|
$this->corpusButtons[] = $this->renderFileButton(
|
|
|
|
|
null, pht('View Raw LFS Pointer'));
|
2016-03-18 08:13:20 -07:00
|
|
|
|
|
|
|
|
$corpus = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($header)
|
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
->addClass('diffusion-mobile-view')
|
2016-03-18 08:13:20 -07:00
|
|
|
->setCollapsed(true);
|
|
|
|
|
|
|
|
|
|
if ($messages) {
|
|
|
|
|
$corpus->setInfoView(
|
|
|
|
|
id(new PHUIInfoView())
|
|
|
|
|
->setSeverity($severity)
|
|
|
|
|
->setErrors($messages));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $corpus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function loadGitLFSFile(PhabricatorRepositoryGitLFSRef $ref) {
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->withPHIDs(array($ref->getFilePHID()))
|
|
|
|
|
->executeOne();
|
|
|
|
|
if (!$file) {
|
|
|
|
|
throw new Exception(
|
|
|
|
|
pht(
|
|
|
|
|
'Failed to load file object for Git LFS ref "%s"!',
|
|
|
|
|
$ref->getObjectHash()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $file;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 18:09:51 -08:00
|
|
|
private function buildBranchTable() {
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
|
|
|
|
$branch = $drequest->getBranch();
|
|
|
|
|
$default_branch = $repository->getDefaultBranch();
|
|
|
|
|
|
|
|
|
|
if ($branch === $default_branch) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pager = id(new PHUIPagerView())
|
|
|
|
|
->setPageSize(10);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$results = $this->callConduitWithDiffusionRequest(
|
|
|
|
|
'diffusion.historyquery',
|
|
|
|
|
array(
|
|
|
|
|
'commit' => $branch,
|
|
|
|
|
'against' => $default_branch,
|
|
|
|
|
'path' => $drequest->getPath(),
|
|
|
|
|
'offset' => $pager->getOffset(),
|
|
|
|
|
'limit' => $pager->getPageSize() + 1,
|
|
|
|
|
));
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$history = DiffusionPathChange::newFromConduit($results['pathChanges']);
|
|
|
|
|
$history = $pager->sliceResults($history);
|
|
|
|
|
|
|
|
|
|
if (!$history) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$history_table = id(new DiffusionHistoryTableView())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->setDiffusionRequest($drequest)
|
|
|
|
|
->setHistory($history);
|
|
|
|
|
|
|
|
|
|
$history_table->loadRevisions();
|
|
|
|
|
|
|
|
|
|
$history_table
|
|
|
|
|
->setParents($results['parents'])
|
|
|
|
|
->setFilterParents(true)
|
|
|
|
|
->setIsHead(true)
|
|
|
|
|
->setIsTail(!$pager->getHasMorePages());
|
|
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
|
->setHeader(pht('%s vs %s', $branch, $default_branch));
|
|
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($header)
|
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
Mobile layouts for Diffusion
Summary: Implements a new mobile view thats more fullscreen, not boxed, so more space. Fixes issues with mobile tables when scrolling overflowed content.
Test Plan: Test home, branch, tags, code, file browse, graph, compare, history, readme, open revisions, owners.
Reviewers: epriestley
Reviewed By: epriestley
Spies: Korvin
Differential Revision: https://secure.phabricator.com/D18505
2017-08-30 12:00:07 -07:00
|
|
|
->addClass('diffusion-mobile-view')
|
2016-12-05 18:09:51 -08:00
|
|
|
->setTable($history_table);
|
|
|
|
|
}
|
2016-03-18 08:13:20 -07:00
|
|
|
|
2011-03-07 17:25:47 -08:00
|
|
|
}
|