Display links to editor in Differential and Diffusion
Summary: It is possible to open a file in editor by registering a custom URI scheme (pseudo-protocol). Some editors register it by default. Having links to open the file in external editor is productivity booster although it is a little bit harder to set up. There are several other tools using file_link_format configuration directive (XDebug, Symfony) to bind to this protocol. I've added the example with editor: protocol which can be used as a proxy to actual editor (used by Nette Framework: http://wiki.nette.org/en/howto-editor-link). Test Plan: Configure Editor Link in User Preferences. Register URI scheme in OS. Open a file in Diffusion. Click on the Edit button. Open a revision in Differential. Click on the Edit button. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1422
This commit is contained in:
@@ -25,6 +25,7 @@ class DifferentialChangesetListView extends AphrontView {
|
||||
private $renderURI = '/differential/changeset/';
|
||||
private $whitespace;
|
||||
private $standaloneViews;
|
||||
private $user;
|
||||
private $symbolIndexes = array();
|
||||
private $repository;
|
||||
private $diff;
|
||||
@@ -44,6 +45,11 @@ class DifferentialChangesetListView extends AphrontView {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRevision(DifferentialRevision $revision) {
|
||||
$this->revision = $revision;
|
||||
return $this;
|
||||
@@ -133,6 +139,19 @@ class DifferentialChangesetListView extends AphrontView {
|
||||
$meta['rightURI'] = (string)$detail_uri->alter('view', 'new');
|
||||
}
|
||||
|
||||
if ($this->user) {
|
||||
$path = ltrim(
|
||||
$changeset->getAbsoluteRepositoryPath($this->diff, $repository),
|
||||
'/');
|
||||
$line = 1; // TODO: get first changed line
|
||||
$editor_link = $this->user->loadEditorLink($path, $line, $repository);
|
||||
if ($editor_link) {
|
||||
$meta['editor'] = $editor_link;
|
||||
} else {
|
||||
$meta['editorConfigure'] = '/settings/page/preferences/';
|
||||
}
|
||||
}
|
||||
|
||||
$detail_button = javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
@@ -145,7 +164,6 @@ class DifferentialChangesetListView extends AphrontView {
|
||||
"View Options \xE2\x96\xBC");
|
||||
}
|
||||
|
||||
|
||||
$detail->setChangeset($changeset);
|
||||
$detail->addButton($detail_button);
|
||||
$detail->setSymbolIndex(idx($this->symbolIndexes, $key));
|
||||
|
||||
Reference in New Issue
Block a user