3 final class DifferentialChangesetDetailView
extends AphrontView
{
6 private $buttons = array();
10 private $vsChangesetID;
12 private $renderingRef;
16 private $changesetResponse;
19 public function setAutoload($autoload) {
20 $this->autoload
= $autoload;
24 public function getAutoload() {
25 return $this->autoload
;
28 public function setRenderingRef($rendering_ref) {
29 $this->renderingRef
= $rendering_ref;
33 public function getRenderingRef() {
34 return $this->renderingRef
;
37 public function setChangesetResponse(PhabricatorChangesetResponse
$response) {
38 $this->changesetResponse
= $response;
42 public function getChangesetResponse() {
43 return $this->changesetResponse
;
46 public function setRenderURI($render_uri) {
47 $this->renderURI
= $render_uri;
51 public function getRenderURI() {
52 return $this->renderURI
;
55 public function setChangeset($changeset) {
56 $this->changeset
= $changeset;
60 public function addButton($button) {
61 $this->buttons
[] = $button;
65 public function setEditable($editable) {
66 $this->editable
= $editable;
70 public function setSymbolIndex($symbol_index) {
71 $this->symbolIndex
= $symbol_index;
75 public function setBranch($branch) {
76 $this->branch
= $branch;
80 public function getBranch() {
84 public function getID() {
86 $this->id
= celerity_generate_unique_node_id();
91 public function setID($id) {
96 public function setVsChangesetID($vs_changeset_id) {
97 $this->vsChangesetID
= $vs_changeset_id;
101 public function getVsChangesetID() {
102 return $this->vsChangesetID
;
105 public function render() {
106 $viewer = $this->getViewer();
108 $this->requireResource('differential-changeset-view-css');
109 $this->requireResource('syntax-highlighting-css');
111 Javelin
::initBehavior('phabricator-oncopy', array());
113 $changeset = $this->changeset
;
114 $class = 'differential-changeset';
115 if (!$this->editable
) {
116 $class .= ' differential-changeset-immutable';
120 if ($this->buttons
) {
121 $buttons = phutil_tag(
124 'class' => 'differential-changeset-buttons',
129 $id = $this->getID();
131 if ($this->symbolIndex
) {
132 Javelin
::initBehavior(
133 'repository-crossreference',
136 ) +
$this->symbolIndex
);
139 $display_filename = $changeset->getDisplayFilename();
140 $display_icon = FileTypeIcon
::getFileIcon($display_filename);
141 $icon = id(new PHUIIconView())
142 ->setIcon($display_icon);
144 $changeset_id = $this->changeset
->getID();
146 $vs_id = $this->getVsChangesetID();
148 // Showing a changeset normally.
149 $left_id = $changeset_id;
150 $right_id = $changeset_id;
151 } else if ($vs_id == -1) {
152 // Showing a synthetic "deleted" changeset for a file which was
153 // removed between changes.
154 $left_id = $changeset_id;
157 // Showing a diff-of-diffs.
159 $right_id = $changeset_id;
162 // In the persistent banner, emphasize the current filename.
163 $path_part = dirname($display_filename);
164 $file_part = basename($display_filename);
165 $display_parts = array();
166 if (strlen($path_part)) {
167 $path_part = $path_part.'/';
168 $display_parts[] = phutil_tag(
171 'class' => 'diff-banner-path',
175 $display_parts[] = phutil_tag(
178 'class' => 'diff-banner-file',
182 $response = $this->getChangesetResponse();
185 $changeset_markup = $response->getRenderedChangeset();
186 $changeset_state = $response->getChangesetState();
189 $changeset_markup = null;
190 $changeset_state = null;
193 $path_parts = trim($display_filename, '/');
194 $path_parts = explode('/', $path_parts);
196 $show_path_uri = null;
197 $show_directory_uri = null;
199 $repository = $this->getRepository();
201 $diff = $this->getDiff();
203 $repo_path = $changeset->getAbsoluteRepositoryPath($repository, $diff);
205 $repo_dir = dirname($repo_path);
206 if ($repo_dir === $repo_path) {
210 $show_path_uri = $repository->getDiffusionBrowseURIForPath(
213 idx($changeset->getMetadata(), 'line:first'),
216 if ($repo_dir !== null) {
217 $repo_dir = rtrim($repo_dir, '/').'/';
219 $show_directory_uri = $repository->getDiffusionBrowseURIForPath(
228 if ($show_path_uri) {
229 $show_path_uri = phutil_string_cast($show_path_uri);
232 if ($show_directory_uri) {
233 $show_directory_uri = phutil_string_cast($show_directory_uri);
239 'sigil' => 'differential-changeset',
242 'right' => $right_id,
243 'renderURI' => $this->getRenderURI(),
244 'ref' => $this->getRenderingRef(),
245 'autoload' => $this->getAutoload(),
246 'displayPath' => hsprintf('%s', $display_parts),
247 'icon' => $display_icon,
248 'pathParts' => $path_parts,
249 'symbolPath' => $display_filename,
251 'pathIconIcon' => $changeset->getPathIconIcon(),
252 'pathIconColor' => $changeset->getPathIconColor(),
253 'isLowImportance' => $changeset->getIsLowImportanceChangeset(),
254 'isOwned' => $changeset->getIsOwnedChangeset(),
256 'editorURITemplate' => $this->getEditorURITemplate(),
257 'editorConfigureURI' => $this->getEditorConfigureURI(),
259 'loaded' => $is_loaded,
260 'changesetState' => $changeset_state,
262 'showPathURI' => $show_path_uri,
263 'showDirectoryURI' => $show_directory_uri,
269 id(new PhabricatorAnchorView())
270 ->setAnchorName($changeset->getAnchorName())
271 ->setNavigationMarker(true)
277 'class' => 'differential-file-icon-header',
278 'sigil' => 'changeset-header',
285 'class' => 'differential-changeset-path-name',
286 'sigil' => 'changeset-header-path-name',
293 'class' => 'changeset-view-content',
294 'sigil' => 'changeset-view-content',
298 $this->renderChildren(),
303 public function setRepository(PhabricatorRepository
$repository) {
304 $this->repository
= $repository;
308 public function getRepository() {
309 return $this->repository
;
312 public function getChangeset() {
313 return $this->changeset
;
316 public function setDiff(DifferentialDiff
$diff) {
321 public function getDiff() {
325 private function getEditorURITemplate() {
326 $repository = $this->getRepository();
331 $viewer = $this->getViewer();
333 $link_engine = PhabricatorEditorURIEngine
::newForViewer($viewer);
338 $link_engine->setRepository($repository);
340 $changeset = $this->getChangeset();
341 $diff = $this->getDiff();
343 $path = $changeset->getAbsoluteRepositoryPath($repository, $diff);
344 $path = ltrim($path, '/');
346 return $link_engine->getURITokensForPath($path);
349 private function getEditorConfigureURI() {
350 $viewer = $this->getViewer();
352 if (!$viewer->isLoggedIn()) {
356 return '/settings/panel/editor/';