diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -193,6 +193,7 @@ $corpus = $engine->newDocumentView($ref); $this->corpusButtons[] = $this->renderFileButton(); + $this->corpusButtons[] = $this->renderPermalinkButton($drequest); } } @@ -599,6 +600,39 @@ return $button; } + /** + * Render a button that points to the Permalink version of this file. + * + * @param DiffusionRequest $drequest + * @return PHUIButtonView + */ + private function renderPermalinkButton(DiffusionRequest $drequest) { + + $text = pht('Permalink'); + $icon = 'fa-link'; + + $href = (string)$drequest->generateURI( + array( + 'action' => 'browse', + 'stable' => 'true', + )); + + $selected = $drequest->getSymbolicCommit() === $drequest->getStableCommit(); + + $button = id(new PHUIButtonView()) + ->setTag('a') + ->setText($text) + ->setHref($href) + ->setIcon($icon) + ->setSelected($selected) + ->setColor(PHUIButtonView::GREY); + + // TODO: Somehow change the URL of the page without reloading the page. + // Similar dark magic is probably in the "Hide Blame" button. + + return $button; + } + private function renderGitLFSButton() { $viewer = $this->getViewer();