diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 540f58c022..6f7600a393 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -268,6 +268,7 @@ phutil_register_library_map(array( 'DiffusionController' => 'applications/diffusion/controller/base', 'DiffusionDiffController' => 'applications/diffusion/controller/diff', 'DiffusionDiffQuery' => 'applications/diffusion/query/diff/base', + 'DiffusionEmptyResultView' => 'applications/diffusion/view/emptyresult', 'DiffusionFileContent' => 'applications/diffusion/data/filecontent', 'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/base', 'DiffusionGitBranchQuery' => 'applications/diffusion/query/branch/git', diff --git a/src/applications/diffusion/controller/browse/DiffusionBrowseController.php b/src/applications/diffusion/controller/browse/DiffusionBrowseController.php index 859f6f71b8..a9001f9ae1 100644 --- a/src/applications/diffusion/controller/browse/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/browse/DiffusionBrowseController.php @@ -1,7 +1,7 @@ getCommit(); - $callsign = $drequest->getRepository()->getCallsign(); - if ($commit) { - $commit = "r{$callsign}{$commit}"; - } else { - $commit = 'HEAD'; + if ($browse_query->getReasonForEmptyResultSet() == + DiffusionBrowseQuery::REASON_IS_FILE) { + $controller = new DiffusionBrowseFileController($this->getRequest()); + $controller->setDiffusionRequest($drequest); + return $this->delegateToController($controller); } - switch ($browse_query->getReasonForEmptyResultSet()) { - case DiffusionBrowseQuery::REASON_IS_NONEXISTENT: - $title = 'Path Does Not Exist'; - // TODO: Under git, this error message should be more specific. It - // may exist on some other branch. - $body = "This path does not exist anywhere."; - $severity = AphrontErrorView::SEVERITY_ERROR; - break; - case DiffusionBrowseQuery::REASON_IS_EMPTY: - $title = 'Empty Directory'; - $body = "This path was an empty directory at {$commit}.\n"; - $severity = AphrontErrorView::SEVERITY_NOTICE; - break; - case DiffusionBrowseQuery::REASON_IS_DELETED: - $deleted = $browse_query->getDeletedAtCommit(); - $existed = $browse_query->getExistedAtCommit(); - - $deleted = "r{$callsign}{$deleted}"; - $existed = "r{$callsign}{$existed}"; - - $title = 'Path Was Deleted'; - $body = "This path does not exist at {$commit}. It was deleted in ". - "{$deleted} and last existed at {$existed}."; - $severity = AphrontErrorView::SEVERITY_WARNING; - break; - case DiffusionBrowseQuery::REASON_IS_FILE: - $controller = new DiffusionBrowseFileController($this->getRequest()); - $controller->setDiffusionRequest($drequest); - return $this->delegateToController($controller); - break; - case DiffusionBrowseQuery::REASON_IS_UNTRACKED_PARENT: - $subdir = $drequest->getRepository()->getDetail('svn-subpath'); - $title = 'Directory Not Tracked'; - $body = - "This repository is configured to track only one subdirectory ". - "of the entire repository ('".phutil_escape_html($subdir)."'), ". - "but you aren't looking at something in that subdirectory, so no ". - "information is available."; - $severity = AphrontErrorView::SEVERITY_WARNING; - break; - default: - throw new Exception("Unknown failure reason!"); - } - - $error_view = new AphrontErrorView(); - $error_view->setSeverity($severity); - $error_view->setTitle($title); - $error_view->appendChild('

'.$body.'

'); - - $content[] = $error_view; + $empty_result = new DiffusionEmptyResultView(); + $empty_result->setDiffusionRequest($drequest); + $empty_result->setBrowseQuery($browse_query); + $content[] = $empty_result; } else { diff --git a/src/applications/diffusion/controller/browse/__init__.php b/src/applications/diffusion/controller/browse/__init__.php index 2c07414577..7d33550a58 100644 --- a/src/applications/diffusion/controller/browse/__init__.php +++ b/src/applications/diffusion/controller/browse/__init__.php @@ -10,11 +10,10 @@ phutil_require_module('phabricator', 'applications/diffusion/controller/base'); phutil_require_module('phabricator', 'applications/diffusion/controller/file'); phutil_require_module('phabricator', 'applications/diffusion/query/browse/base'); phutil_require_module('phabricator', 'applications/diffusion/view/browsetable'); +phutil_require_module('phabricator', 'applications/diffusion/view/emptyresult'); phutil_require_module('phabricator', 'applications/phid/handle/data'); -phutil_require_module('phabricator', 'view/form/error'); phutil_require_module('phabricator', 'view/layout/panel'); -phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/view/emptyresult/DiffusionEmptyResultView.php b/src/applications/diffusion/view/emptyresult/DiffusionEmptyResultView.php new file mode 100644 index 0000000000..9bd39a9b6d --- /dev/null +++ b/src/applications/diffusion/view/emptyresult/DiffusionEmptyResultView.php @@ -0,0 +1,94 @@ +browseQuery = $browse_query; + } + + public function render() { + $drequest = $this->getDiffusionRequest(); + + $commit = $drequest->getCommit(); + $callsign = $drequest->getRepository()->getCallsign(); + if ($commit) { + $commit = "r{$callsign}{$commit}"; + } else { + $commit = 'HEAD'; + } + + switch ($this->browseQuery->getReasonForEmptyResultSet()) { + case DiffusionBrowseQuery::REASON_IS_NONEXISTENT: + $title = 'Path Does Not Exist'; + // TODO: Under git, this error message should be more specific. It + // may exist on some other branch. + $body = "This path does not exist anywhere."; + $severity = AphrontErrorView::SEVERITY_ERROR; + break; + case DiffusionBrowseQuery::REASON_IS_EMPTY: + $title = 'Empty Directory'; + $body = "This path was an empty directory at {$commit}.\n"; + $severity = AphrontErrorView::SEVERITY_NOTICE; + break; + case DiffusionBrowseQuery::REASON_IS_DELETED: + $deleted = $this->browseQuery->getDeletedAtCommit(); + $existed = $this->browseQuery->getExistedAtCommit(); + + $deleted = self::linkCommit($drequest->getRepository(), $deleted); + + $browse = $this->linkBrowse( + $drequest->getPath(), + array( + 'text' => 'existed', + 'commit' => $existed, + ) + ); + + $existed = "r{$callsign}{$existed}"; + + $title = 'Path Was Deleted'; + $body = "This path does not exist at {$commit}. It was deleted in ". + "{$deleted} and last {$browse} at {$existed}."; + $severity = AphrontErrorView::SEVERITY_WARNING; + break; + case DiffusionBrowseQuery::REASON_IS_UNTRACKED_PARENT: + $subdir = $drequest->getRepository()->getDetail('svn-subpath'); + $title = 'Directory Not Tracked'; + $body = + "This repository is configured to track only one subdirectory ". + "of the entire repository ('".phutil_escape_html($subdir)."'), ". + "but you aren't looking at something in that subdirectory, so no ". + "information is available."; + $severity = AphrontErrorView::SEVERITY_WARNING; + break; + default: + throw new Exception("Unknown failure reason!"); + } + + $error_view = new AphrontErrorView(); + $error_view->setSeverity($severity); + $error_view->setTitle($title); + $error_view->appendChild('

'.$body.'

'); + + return $error_view->render(); + } + +} diff --git a/src/applications/diffusion/view/emptyresult/__init__.php b/src/applications/diffusion/view/emptyresult/__init__.php new file mode 100644 index 0000000000..9da323cf77 --- /dev/null +++ b/src/applications/diffusion/view/emptyresult/__init__.php @@ -0,0 +1,16 @@ +