Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/view/DiffusionEmptyResultView.php
12242 views
1
<?php
2
3
final class DiffusionEmptyResultView extends DiffusionView {
4
5
private $browseResultSet;
6
private $view;
7
8
public function setDiffusionBrowseResultSet(DiffusionBrowseResultSet $set) {
9
$this->browseResultSet = $set;
10
return $this;
11
}
12
13
public function setView($view) {
14
$this->view = $view;
15
return $this;
16
}
17
18
public function render() {
19
$drequest = $this->getDiffusionRequest();
20
$repository = $drequest->getRepository();
21
22
$commit = $drequest->getCommit();
23
if ($commit) {
24
$commit = $repository->formatCommitName($commit);
25
} else {
26
$commit = 'HEAD';
27
}
28
29
$reason = $this->browseResultSet->getReasonForEmptyResultSet();
30
switch ($reason) {
31
case DiffusionBrowseResultSet::REASON_IS_NONEXISTENT:
32
$title = pht('Path Does Not Exist');
33
// TODO: Under git, this error message should be more specific. It
34
// may exist on some other branch.
35
$body = pht('This path does not exist anywhere.');
36
$severity = PHUIInfoView::SEVERITY_ERROR;
37
break;
38
case DiffusionBrowseResultSet::REASON_IS_EMPTY:
39
$title = pht('Empty Directory');
40
$body = pht('This path was an empty directory at %s.', $commit);
41
$severity = PHUIInfoView::SEVERITY_NOTICE;
42
break;
43
case DiffusionBrowseResultSet::REASON_IS_SUBMODULE:
44
$title = pht('Submodule');
45
// TODO: We could improve this, but it is normally difficult to
46
// reach this page for a submodule.
47
$body = pht('This path was a submodule at %s.', $commit);
48
$severity = PHUIInfoView::SEVERITY_NOTICE;
49
break;
50
case DiffusionBrowseResultSet::REASON_IS_DELETED:
51
$deleted = $this->browseResultSet->getDeletedAtCommit();
52
$existed = $this->browseResultSet->getExistedAtCommit();
53
54
$existed_text = $repository->formatCommitName($existed);
55
$existed_href = $drequest->generateURI(
56
array(
57
'action' => 'browse',
58
'path' => $drequest->getPath(),
59
'commit' => $existed,
60
'params' => array(
61
'view' => $this->view,
62
),
63
));
64
65
$existed_link = phutil_tag(
66
'a',
67
array(
68
'href' => $existed_href,
69
),
70
$existed_text);
71
72
$title = pht('Path Was Deleted');
73
$body = pht(
74
'This path does not exist at %s. It was deleted in %s and last '.
75
'existed at %s.',
76
$commit,
77
self::linkCommit($drequest->getRepository(), $deleted),
78
$existed_link);
79
$severity = PHUIInfoView::SEVERITY_WARNING;
80
break;
81
case DiffusionBrowseResultSet::REASON_IS_UNTRACKED_PARENT:
82
$subdir = $drequest->getRepository()->getDetail('svn-subpath');
83
$title = pht('Directory Not Tracked');
84
$body =
85
pht(
86
"This repository is configured to track only one subdirectory ".
87
"of the entire repository ('%s'), but you aren't looking at ".
88
"something in that subdirectory, so no information is available.",
89
$subdir);
90
$severity = PHUIInfoView::SEVERITY_WARNING;
91
break;
92
default:
93
throw new Exception(pht('Unknown failure reason: %s', $reason));
94
}
95
96
$error_view = new PHUIInfoView();
97
$error_view->setSeverity($severity);
98
$error_view->setTitle($title);
99
$error_view->appendChild(phutil_tag('p', array(), $body));
100
101
return $error_view->render();
102
}
103
104
}
105
106