1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-18 18:51:12 +01:00

Separate external editor integration from callsigns

Summary: Ref T4245. Pass the whole repository in so it can do something else in a future change.

Test Plan: Loaded changesets in Diffusion.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14931
This commit is contained in:
epriestley 2016-01-02 11:56:19 -08:00
parent b1388c5ca1
commit be5b89687e
5 changed files with 15 additions and 15 deletions

View file

@ -64,7 +64,7 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
$line .= ' called at ['.$entry['file'].':'.$entry['line'].']'; $line .= ' called at ['.$entry['file'].':'.$entry['line'].']';
try { try {
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$href = $user->loadEditorLink($entry['file'], $entry['line'], ''); $href = $user->loadEditorLink($entry['file'], $entry['line'], null);
} catch (Exception $ex) { } catch (Exception $ex) {
// The database can be inaccessible. // The database can be inaccessible.
} }

View file

@ -314,8 +314,7 @@ final class DifferentialChangesetListView extends AphrontView {
$changeset->getAbsoluteRepositoryPath($repository, $this->diff), $changeset->getAbsoluteRepositoryPath($repository, $this->diff),
'/'); '/');
$line = idx($changeset->getMetadata(), 'line:first', 1); $line = idx($changeset->getMetadata(), 'line:first', 1);
$callsign = $repository->getCallsign(); $editor_link = $user->loadEditorLink($path, $line, $repository);
$editor_link = $user->loadEditorLink($path, $line, $callsign);
if ($editor_link) { if ($editor_link) {
$meta['editor'] = $editor_link; $meta['editor'] = $editor_link;
} else { } else {

View file

@ -435,9 +435,8 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
$path = $drequest->getPath(); $path = $drequest->getPath();
$line = nonempty((int)$drequest->getLine(), 1); $line = nonempty((int)$drequest->getLine(), 1);
$callsign = $repository->getCallsign(); $editor_link = $user->loadEditorLink($path, $line, $repository);
$editor_link = $user->loadEditorLink($path, $line, $callsign); $template = $user->loadEditorLink($path, '%l', $repository);
$template = $user->loadEditorLink($path, '%l', $callsign);
$icon_edit = id(new PHUIIconView()) $icon_edit = id(new PHUIIconView())
->setIconFont('fa-pencil'); ->setIconFont('fa-pencil');

View file

@ -504,7 +504,11 @@ final class PhabricatorUser
return $preferences; return $preferences;
} }
public function loadEditorLink($path, $line, $callsign) { public function loadEditorLink(
$path,
$line,
PhabricatorRepository $repository = null) {
$editor = $this->loadPreferences()->getPreference( $editor = $this->loadPreferences()->getPreference(
PhabricatorUserPreferences::PREFERENCE_EDITOR); PhabricatorUserPreferences::PREFERENCE_EDITOR);
@ -524,6 +528,12 @@ final class PhabricatorUser
return null; return null;
} }
if ($repository) {
$callsign = $repository->getCallsign();
} else {
$callsign = null;
}
$uri = strtr($editor, array( $uri = strtr($editor, array(
'%%' => '%', '%%' => '%',
'%f' => phutil_escape_uri($path), '%f' => phutil_escape_uri($path),

View file

@ -50,14 +50,6 @@ final class AphrontStackTraceView extends AphrontView {
if ($file) { if ($file) {
if (isset($callsigns[$lib])) { if (isset($callsigns[$lib])) {
$attrs = array('title' => $file); $attrs = array('title' => $file);
try {
$attrs['href'] = $user->loadEditorLink(
'/src/'.$relative,
$part['line'],
$callsigns[$lib]);
} catch (Exception $ex) {
// The database can be inaccessible.
}
if (empty($attrs['href'])) { if (empty($attrs['href'])) {
$attrs['href'] = sprintf($path, $callsigns[$lib]). $attrs['href'] = sprintf($path, $callsigns[$lib]).
str_replace(DIRECTORY_SEPARATOR, '/', $relative). str_replace(DIRECTORY_SEPARATOR, '/', $relative).