Add Edit All link to Differential revision
Summary: Some text editors support opening multiple files at once. I've used space as paths separator which may be compatible with some other editors (I didn't tried any other though). Note: This approach is incompatible with spaces in paths. I am fine with changing it to anything else to support such paths or more editors. Probably the cleanest solution (yet still incompatible with most editors) would be to use something like ##editor://open/?file=A&line=1&file=B&line=2## but it would require also changing the way how it's configured and I think it's not worth it. BTW, I've used a hacky bookmarklet for this feature before. Deleted or added paths may not exist in users filesystem but we don't know which so the button tries to open everything. Test Plan: Click Edit All. Delete Editor Link in settings, verify that the button is missing. View diff without revision, verify that the button is missing. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1741
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
final class DifferentialDiffTableOfContentsView extends AphrontView {
|
||||
|
||||
private $changesets = array();
|
||||
private $repository;
|
||||
private $diff;
|
||||
private $user;
|
||||
private $standaloneViewLink = null;
|
||||
private $renderURI = '/differential/changeset/';
|
||||
private $revisionID;
|
||||
@@ -29,6 +32,21 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRepository(PhabricatorRepository $repository) {
|
||||
$this->repository = $repository;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDiff(DifferentialDiff $diff) {
|
||||
$this->diff = $diff;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStandaloneViewLink($standalone_view_link) {
|
||||
$this->standaloneViewLink = $standalone_view_link;
|
||||
return $this;
|
||||
@@ -57,6 +75,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
||||
$rows = array();
|
||||
|
||||
$changesets = $this->changesets;
|
||||
$paths = array();
|
||||
foreach ($changesets as $changeset) {
|
||||
$type = $changeset->getChangeType();
|
||||
$ftype = $changeset->getFileType();
|
||||
@@ -125,10 +144,32 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
|
||||
'<td class="differential-toc-meta">'.$meta.'</td>'.
|
||||
'</tr>';
|
||||
}
|
||||
if ($this->diff && $this->repository) {
|
||||
$paths[] =
|
||||
$changeset->getAbsoluteRepositoryPath($this->diff, $this->repository);
|
||||
}
|
||||
}
|
||||
|
||||
$editor_link = null;
|
||||
if ($paths && $this->user) {
|
||||
$editor_link = $this->user->loadEditorLink(
|
||||
implode(' ', $paths),
|
||||
1, // line number
|
||||
$this->repository);
|
||||
if ($editor_link) {
|
||||
$editor_link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $editor_link,
|
||||
'class' => 'button differential-toc-edit-all',
|
||||
),
|
||||
'Open All in Editor');
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
'<div class="differential-toc differential-panel">'.
|
||||
$editor_link.
|
||||
'<h1>Table of Contents</h1>'.
|
||||
'<table>'.
|
||||
implode("\n", $rows).
|
||||
|
||||
Reference in New Issue
Block a user