From c0c5b9bb645bfc17ddd3258ba1fe3b658c729038 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 29 Feb 2012 23:16:45 -0800 Subject: [PATCH] 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 --- src/__celerity_resource_map__.php | 68 +++++++++---------- .../DifferentialRevisionViewController.php | 5 ++ .../DifferentialDiffTableOfContentsView.php | 41 +++++++++++ .../differential/table-of-contents.css | 4 ++ 4 files changed, 84 insertions(+), 34 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 3fdfe50f76..3ce61ccbc9 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -250,7 +250,7 @@ celerity_register_resource_map(array( ), 'differential-table-of-contents-css' => array( - 'uri' => '/res/d173445b/rsrc/css/application/differential/table-of-contents.css', + 'uri' => '/res/e4c089fe/rsrc/css/application/differential/table-of-contents.css', 'type' => 'css', 'requires' => array( @@ -1914,6 +1914,27 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/080edee4/typeahead.pkg.js', 'type' => 'js', ), + '09c86840' => + array( + 'name' => 'differential.pkg.css', + 'symbols' => + array( + 0 => 'differential-core-view-css', + 1 => 'differential-changeset-view-css', + 2 => 'differential-revision-detail-css', + 3 => 'differential-revision-history-css', + 4 => 'differential-table-of-contents-css', + 5 => 'differential-revision-comment-css', + 6 => 'differential-revision-add-comment-css', + 7 => 'differential-revision-comment-list-css', + 8 => 'phabricator-object-selector-css', + 9 => 'aphront-headsup-action-list-view-css', + 10 => 'phabricator-content-source-view-css', + 11 => 'differential-local-commits-view-css', + ), + 'uri' => '/res/pkg/09c86840/differential.pkg.css', + 'type' => 'css', + ), '29e2c5f1' => array( 'name' => 'core.pkg.css', @@ -1938,27 +1959,6 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/29e2c5f1/core.pkg.css', 'type' => 'css', ), - '2dc5fb48' => - array( - 'name' => 'differential.pkg.css', - 'symbols' => - array( - 0 => 'differential-core-view-css', - 1 => 'differential-changeset-view-css', - 2 => 'differential-revision-detail-css', - 3 => 'differential-revision-history-css', - 4 => 'differential-table-of-contents-css', - 5 => 'differential-revision-comment-css', - 6 => 'differential-revision-add-comment-css', - 7 => 'differential-revision-comment-list-css', - 8 => 'phabricator-object-selector-css', - 9 => 'aphront-headsup-action-list-view-css', - 10 => 'phabricator-content-source-view-css', - 11 => 'differential-local-commits-view-css', - ), - 'uri' => '/res/pkg/2dc5fb48/differential.pkg.css', - 'type' => 'css', - ), '46547a92' => array( 'name' => 'core.pkg.js', @@ -2012,23 +2012,23 @@ celerity_register_resource_map(array( 'aphront-crumbs-view-css' => '29e2c5f1', 'aphront-dialog-view-css' => '29e2c5f1', 'aphront-form-view-css' => '29e2c5f1', - 'aphront-headsup-action-list-view-css' => '2dc5fb48', + 'aphront-headsup-action-list-view-css' => '09c86840', 'aphront-list-filter-view-css' => '29e2c5f1', 'aphront-panel-view-css' => '29e2c5f1', 'aphront-side-nav-view-css' => '29e2c5f1', 'aphront-table-view-css' => '29e2c5f1', 'aphront-tokenizer-control-css' => '29e2c5f1', 'aphront-typeahead-control-css' => '29e2c5f1', - 'differential-changeset-view-css' => '2dc5fb48', - 'differential-core-view-css' => '2dc5fb48', + 'differential-changeset-view-css' => '09c86840', + 'differential-core-view-css' => '09c86840', 'differential-inline-comment-editor' => '0222c68c', - 'differential-local-commits-view-css' => '2dc5fb48', - 'differential-revision-add-comment-css' => '2dc5fb48', - 'differential-revision-comment-css' => '2dc5fb48', - 'differential-revision-comment-list-css' => '2dc5fb48', - 'differential-revision-detail-css' => '2dc5fb48', - 'differential-revision-history-css' => '2dc5fb48', - 'differential-table-of-contents-css' => '2dc5fb48', + 'differential-local-commits-view-css' => '09c86840', + 'differential-revision-add-comment-css' => '09c86840', + 'differential-revision-comment-css' => '09c86840', + 'differential-revision-comment-list-css' => '09c86840', + 'differential-revision-detail-css' => '09c86840', + 'differential-revision-history-css' => '09c86840', + 'differential-table-of-contents-css' => '09c86840', 'diffusion-commit-view-css' => '61f9d480', 'javelin-behavior' => '4fbae2af', 'javelin-behavior-aphront-basic-tokenizer' => '080edee4', @@ -2066,14 +2066,14 @@ celerity_register_resource_map(array( 'javelin-util' => '4fbae2af', 'javelin-vector' => '4fbae2af', 'javelin-workflow' => '46547a92', - 'phabricator-content-source-view-css' => '2dc5fb48', + 'phabricator-content-source-view-css' => '09c86840', 'phabricator-core-buttons-css' => '29e2c5f1', 'phabricator-core-css' => '29e2c5f1', 'phabricator-directory-css' => '29e2c5f1', 'phabricator-drag-and-drop-file-upload' => '0222c68c', 'phabricator-keyboard-shortcut' => '46547a92', 'phabricator-keyboard-shortcut-manager' => '46547a92', - 'phabricator-object-selector-css' => '2dc5fb48', + 'phabricator-object-selector-css' => '09c86840', 'phabricator-remarkup-css' => '29e2c5f1', 'phabricator-shaped-request' => '0222c68c', 'phabricator-standard-page-view' => '29e2c5f1', diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 328278153e..2b40f8dc24 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -262,6 +262,11 @@ class DifferentialRevisionViewController extends DifferentialController { $toc_view = new DifferentialDiffTableOfContentsView(); $toc_view->setChangesets($changesets); + if ($repository) { + $toc_view->setRepository($repository); + } + $toc_view->setDiff($target); + $toc_view->setUser($user); $toc_view->setStandaloneViewLink(empty($visible_changesets)); $toc_view->setVsMap($vs_map); $toc_view->setRevisionID($revision->getID()); diff --git a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php index ce1180c3dd..54519fc0a0 100644 --- a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php +++ b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php @@ -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 { ''.$meta.''. ''; } + 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 '
'. + $editor_link. '

Table of Contents

'. ''. implode("\n", $rows). diff --git a/webroot/rsrc/css/application/differential/table-of-contents.css b/webroot/rsrc/css/application/differential/table-of-contents.css index 06d459e015..72b72cbdd5 100644 --- a/webroot/rsrc/css/application/differential/table-of-contents.css +++ b/webroot/rsrc/css/application/differential/table-of-contents.css @@ -24,6 +24,10 @@ color: #444444; } +.differential-toc-edit-all { + float: right; +} + .diff-star-none { color: #666666; }