2011-01-25 11:57:47 -08:00
|
|
|
<?php
|
|
|
|
|
2012-12-06 11:33:04 -08:00
|
|
|
final class DifferentialChangesetListView extends AphrontView {
|
2011-01-25 11:57:47 -08:00
|
|
|
|
|
|
|
private $changesets = array();
|
2012-05-01 12:09:50 -07:00
|
|
|
private $visibleChangesets = array();
|
2012-01-16 17:24:46 -08:00
|
|
|
private $references = array();
|
Add inline comments to Diffusion/Audit
Summary:
- Add inline comments to Audits, like Differential.
- Creates new storage for the comments in the Audits database.
- Creates a new PhabricatorAuditInlineComment class, similar to DifferentialInlineComment.
- Defines an Interface which Differential and Audit comments conform to.
- Makes consumers of DifferentialInlineComments consume objects which implement that interface instead.
- Adds save
NOTE: Some features are still missing! Wanted to cut this off before it got crazy:
- Inline comments aren't shown in the main comment list.
- Inline comments aren't shown in the emails.
- Inline comments aren't previewed.
I'll followup with those but this was getting pretty big.
@vrana, does the SQL change look correct?
Test Plan:
- Created, edited, deleted, replied to, reloaded and saved inline comments in Diffusion, on the left and right side of diffs.
- Created, edited, deleted, replied to, reloaded and saved inline comments in Differentila, on the left and right side of primary and diff-versus-diff diffs.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1898
2012-03-14 12:56:01 -07:00
|
|
|
private $inlineURI;
|
2011-03-30 17:36:16 -07:00
|
|
|
private $renderURI = '/differential/changeset/';
|
2011-04-27 21:16:35 -07:00
|
|
|
private $whitespace;
|
2012-03-19 19:57:41 -07:00
|
|
|
|
|
|
|
private $standaloneURI;
|
|
|
|
private $leftRawFileURI;
|
|
|
|
private $rightRawFileURI;
|
|
|
|
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-02 16:02:56 -07:00
|
|
|
private $symbolIndexes = array();
|
2012-01-05 14:41:11 -08:00
|
|
|
private $repository;
|
2012-10-31 14:07:25 -07:00
|
|
|
private $branch;
|
2012-01-05 14:41:11 -08:00
|
|
|
private $diff;
|
2012-02-22 08:03:48 -08:00
|
|
|
private $vsMap = array();
|
2011-01-25 11:57:47 -08:00
|
|
|
|
2012-12-12 21:21:56 -08:00
|
|
|
private $title;
|
2012-12-20 14:27:12 -08:00
|
|
|
|
2012-12-12 21:21:56 -08:00
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function getTitle() {
|
|
|
|
return $this->title;
|
|
|
|
}
|
|
|
|
|
2012-10-31 14:07:25 -07:00
|
|
|
public function setBranch($branch) {
|
|
|
|
$this->branch = $branch;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function getBranch() {
|
|
|
|
return $this->branch;
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
public function setChangesets($changesets) {
|
|
|
|
$this->changesets = $changesets;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-05-01 12:09:50 -07:00
|
|
|
public function setVisibleChangesets($visible_changesets) {
|
|
|
|
$this->visibleChangesets = $visible_changesets;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Add inline comments to Diffusion/Audit
Summary:
- Add inline comments to Audits, like Differential.
- Creates new storage for the comments in the Audits database.
- Creates a new PhabricatorAuditInlineComment class, similar to DifferentialInlineComment.
- Defines an Interface which Differential and Audit comments conform to.
- Makes consumers of DifferentialInlineComments consume objects which implement that interface instead.
- Adds save
NOTE: Some features are still missing! Wanted to cut this off before it got crazy:
- Inline comments aren't shown in the main comment list.
- Inline comments aren't shown in the emails.
- Inline comments aren't previewed.
I'll followup with those but this was getting pretty big.
@vrana, does the SQL change look correct?
Test Plan:
- Created, edited, deleted, replied to, reloaded and saved inline comments in Diffusion, on the left and right side of diffs.
- Created, edited, deleted, replied to, reloaded and saved inline comments in Differentila, on the left and right side of primary and diff-versus-diff diffs.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1898
2012-03-14 12:56:01 -07:00
|
|
|
public function setInlineCommentControllerURI($uri) {
|
|
|
|
$this->inlineURI = $uri;
|
2011-02-01 15:52:04 -08:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-01-05 14:41:11 -08:00
|
|
|
public function setRepository(PhabricatorRepository $repository) {
|
|
|
|
$this->repository = $repository;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDiff(DifferentialDiff $diff) {
|
|
|
|
$this->diff = $diff;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-11 21:46:29 -07:00
|
|
|
public function setRenderingReferences(array $references) {
|
|
|
|
$this->references = $references;
|
2011-02-03 15:41:58 -08:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-02 16:02:56 -07:00
|
|
|
public function setSymbolIndexes(array $indexes) {
|
|
|
|
$this->symbolIndexes = $indexes;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:36:16 -07:00
|
|
|
public function setRenderURI($render_uri) {
|
|
|
|
$this->renderURI = $render_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-04-18 13:38:54 -07:00
|
|
|
public function setWhitespace($whitespace) {
|
2011-04-27 21:16:35 -07:00
|
|
|
$this->whitespace = $whitespace;
|
2011-04-18 13:38:54 -07:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Resolve great internal confusion about left vs right inline comments
Summary:
This code was just all kinds of wrong, but got all the common cases anyone cares
about correct.
- In edit-inline-comments.js, if isOnRight() is true, use data.right, not
data.left (derp).
- Set data.left correctly, not to the same value as data.right (derp derp).
- Set "isNewFile" based on $is_new, not $on_right (derp derp derp).
Test Plan:
- Added JS debugging code to print "OLD" vs "NEW" and "LEFT" vs "RIGHT".
Clicked the left and right sides of diff-vs-base and diff-vs-diff diffs,
verified output was accurate in all cases.
- Added comments to the left-display-side of a diff-of-diffs, saved them, they
showed up where I put them.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T543
Differential Revision: https://secure.phabricator.com/D1567
2012-02-03 15:26:47 -08:00
|
|
|
public function setVsMap(array $vs_map) {
|
|
|
|
$this->vsMap = $vs_map;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVsMap() {
|
|
|
|
return $this->vsMap;
|
|
|
|
}
|
|
|
|
|
2012-03-19 19:57:41 -07:00
|
|
|
public function setStandaloneURI($uri) {
|
|
|
|
$this->standaloneURI = $uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRawFileURIs($l, $r) {
|
|
|
|
$this->leftRawFileURI = $l;
|
|
|
|
$this->rightRawFileURI = $r;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('differential-changeset-view-css');
|
|
|
|
|
|
|
|
$changesets = $this->changesets;
|
|
|
|
|
2012-06-11 15:59:26 -07:00
|
|
|
Javelin::initBehavior('differential-toggle-files', array());
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
$output = array();
|
|
|
|
$mapping = array();
|
|
|
|
foreach ($changesets as $key => $changeset) {
|
|
|
|
$file = $changeset->getFilename();
|
|
|
|
$class = 'differential-changeset';
|
Add inline comments to Diffusion/Audit
Summary:
- Add inline comments to Audits, like Differential.
- Creates new storage for the comments in the Audits database.
- Creates a new PhabricatorAuditInlineComment class, similar to DifferentialInlineComment.
- Defines an Interface which Differential and Audit comments conform to.
- Makes consumers of DifferentialInlineComments consume objects which implement that interface instead.
- Adds save
NOTE: Some features are still missing! Wanted to cut this off before it got crazy:
- Inline comments aren't shown in the main comment list.
- Inline comments aren't shown in the emails.
- Inline comments aren't previewed.
I'll followup with those but this was getting pretty big.
@vrana, does the SQL change look correct?
Test Plan:
- Created, edited, deleted, replied to, reloaded and saved inline comments in Diffusion, on the left and right side of diffs.
- Created, edited, deleted, replied to, reloaded and saved inline comments in Differentila, on the left and right side of primary and diff-versus-diff diffs.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1898
2012-03-14 12:56:01 -07:00
|
|
|
if (!$this->inlineURI) {
|
2011-01-25 11:57:47 -08:00
|
|
|
$class .= ' differential-changeset-noneditable';
|
|
|
|
}
|
|
|
|
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-11 21:46:29 -07:00
|
|
|
$ref = $this->references[$key];
|
2011-03-30 19:22:11 -07:00
|
|
|
|
2012-01-05 20:29:16 -08:00
|
|
|
$detail = new DifferentialChangesetDetailView();
|
|
|
|
|
2012-03-19 19:57:41 -07:00
|
|
|
$view_options = $this->renderViewOptionsDropdown(
|
|
|
|
$detail,
|
|
|
|
$ref,
|
|
|
|
$changeset);
|
2011-01-25 11:57:47 -08:00
|
|
|
|
|
|
|
$detail->setChangeset($changeset);
|
2012-03-19 19:57:41 -07:00
|
|
|
$detail->addButton($view_options);
|
2013-02-01 17:46:57 -08:00
|
|
|
$detail->setSymbolIndex(idx($this->symbolIndexes, $key));
|
Resolve great internal confusion about left vs right inline comments
Summary:
This code was just all kinds of wrong, but got all the common cases anyone cares
about correct.
- In edit-inline-comments.js, if isOnRight() is true, use data.right, not
data.left (derp).
- Set data.left correctly, not to the same value as data.right (derp derp).
- Set "isNewFile" based on $is_new, not $on_right (derp derp derp).
Test Plan:
- Added JS debugging code to print "OLD" vs "NEW" and "LEFT" vs "RIGHT".
Clicked the left and right sides of diff-vs-base and diff-vs-diff diffs,
verified output was accurate in all cases.
- Added comments to the left-display-side of a diff-of-diffs, saved them, they
showed up where I put them.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T543
Differential Revision: https://secure.phabricator.com/D1567
2012-02-03 15:26:47 -08:00
|
|
|
$detail->setVsChangesetID(idx($this->vsMap, $changeset->getID()));
|
2012-04-10 15:00:09 -07:00
|
|
|
$detail->setEditable(true);
|
2012-01-05 20:29:16 -08:00
|
|
|
|
2012-05-01 12:09:50 -07:00
|
|
|
$uniq_id = 'diff-'.$changeset->getAnchorName();
|
|
|
|
if (isset($this->visibleChangesets[$key])) {
|
|
|
|
$load = 'Loading...';
|
|
|
|
$mapping[$uniq_id] = $ref;
|
|
|
|
} else {
|
2013-01-25 12:57:17 -08:00
|
|
|
$load = javelin_tag(
|
2012-05-01 12:09:50 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#'.$uniq_id,
|
|
|
|
'meta' => array(
|
|
|
|
'id' => $uniq_id,
|
|
|
|
'ref' => $ref,
|
|
|
|
'kill' => true,
|
|
|
|
),
|
|
|
|
'sigil' => 'differential-load',
|
|
|
|
'mustcapture' => true,
|
|
|
|
),
|
2013-01-25 12:57:17 -08:00
|
|
|
pht('Load'));
|
2012-05-01 12:09:50 -07:00
|
|
|
}
|
2011-01-25 11:57:47 -08:00
|
|
|
$detail->appendChild(
|
2013-01-18 00:32:58 -08:00
|
|
|
phutil_tag(
|
2011-01-25 11:57:47 -08:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $uniq_id,
|
|
|
|
),
|
2013-01-18 00:32:58 -08:00
|
|
|
phutil_tag('div', array('class' => 'differential-loading'), $load)));
|
2011-01-25 11:57:47 -08:00
|
|
|
$output[] = $detail->render();
|
|
|
|
}
|
|
|
|
|
2012-03-12 20:04:12 -07:00
|
|
|
require_celerity_resource('aphront-tooltip-css');
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
Javelin::initBehavior('differential-populate', array(
|
|
|
|
'registry' => $mapping,
|
2011-04-18 13:38:54 -07:00
|
|
|
'whitespace' => $this->whitespace,
|
2011-03-30 17:36:16 -07:00
|
|
|
'uri' => $this->renderURI,
|
2011-01-25 11:57:47 -08:00
|
|
|
));
|
|
|
|
|
2011-01-31 20:38:13 -08:00
|
|
|
Javelin::initBehavior('differential-show-more', array(
|
2011-03-30 17:36:16 -07:00
|
|
|
'uri' => $this->renderURI,
|
Move "Rendering References" to the DifferentialChangesetParser level
Summary:
Separates changeset IDs from rendering. Now each changeset has a "rendering
reference" which is basically a description of what the ajax endpoint should
render. For Differential, it's in the form "id/vs". For Diffusion,
"branch/path;commit".
I believe this fixes pretty much all of the bugs related to "show more" breaking
in various obscure ways, although I never got a great repro for T153.
Test Plan:
Clicked "show more" in diffusion change and commit views and differential diff,
diff-of-diff, standalone-diff, standalone-diff-of-diff views. Verified refs and
'whitespace' were always sent correctly.
Made inline comments on diffs and diffs-of-diffs. Used "Reply".
Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 274
2011-05-11 21:46:29 -07:00
|
|
|
'whitespace' => $this->whitespace,
|
2011-01-31 20:38:13 -08:00
|
|
|
));
|
2011-01-25 11:57:47 -08:00
|
|
|
|
2011-05-11 12:25:29 -07:00
|
|
|
Javelin::initBehavior('differential-comment-jump', array());
|
|
|
|
|
Add inline comments to Diffusion/Audit
Summary:
- Add inline comments to Audits, like Differential.
- Creates new storage for the comments in the Audits database.
- Creates a new PhabricatorAuditInlineComment class, similar to DifferentialInlineComment.
- Defines an Interface which Differential and Audit comments conform to.
- Makes consumers of DifferentialInlineComments consume objects which implement that interface instead.
- Adds save
NOTE: Some features are still missing! Wanted to cut this off before it got crazy:
- Inline comments aren't shown in the main comment list.
- Inline comments aren't shown in the emails.
- Inline comments aren't previewed.
I'll followup with those but this was getting pretty big.
@vrana, does the SQL change look correct?
Test Plan:
- Created, edited, deleted, replied to, reloaded and saved inline comments in Diffusion, on the left and right side of diffs.
- Created, edited, deleted, replied to, reloaded and saved inline comments in Differentila, on the left and right side of primary and diff-versus-diff diffs.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1898
2012-03-14 12:56:01 -07:00
|
|
|
if ($this->inlineURI) {
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
$undo_templates = $this->renderUndoTemplates();
|
|
|
|
|
2011-02-01 15:52:04 -08:00
|
|
|
Javelin::initBehavior('differential-edit-inline-comments', array(
|
Add inline comments to Diffusion/Audit
Summary:
- Add inline comments to Audits, like Differential.
- Creates new storage for the comments in the Audits database.
- Creates a new PhabricatorAuditInlineComment class, similar to DifferentialInlineComment.
- Defines an Interface which Differential and Audit comments conform to.
- Makes consumers of DifferentialInlineComments consume objects which implement that interface instead.
- Adds save
NOTE: Some features are still missing! Wanted to cut this off before it got crazy:
- Inline comments aren't shown in the main comment list.
- Inline comments aren't shown in the emails.
- Inline comments aren't previewed.
I'll followup with those but this was getting pretty big.
@vrana, does the SQL change look correct?
Test Plan:
- Created, edited, deleted, replied to, reloaded and saved inline comments in Diffusion, on the left and right side of diffs.
- Created, edited, deleted, replied to, reloaded and saved inline comments in Differentila, on the left and right side of primary and diff-versus-diff diffs.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T904
Differential Revision: https://secure.phabricator.com/D1898
2012-03-14 12:56:01 -07:00
|
|
|
'uri' => $this->inlineURI,
|
|
|
|
'undo_templates' => $undo_templates,
|
|
|
|
'stage' => 'differential-review-stage',
|
2011-01-25 11:57:47 -08:00
|
|
|
));
|
|
|
|
}
|
2011-02-01 15:52:04 -08:00
|
|
|
|
2013-03-09 13:52:41 -08:00
|
|
|
return array(
|
|
|
|
id(new PhabricatorHeaderView())
|
|
|
|
->setHeader($this->getTitle())
|
|
|
|
->render(),
|
|
|
|
phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-review-stage',
|
|
|
|
'id' => 'differential-review-stage',
|
|
|
|
),
|
|
|
|
$output),
|
|
|
|
);
|
2011-01-25 11:57:47 -08:00
|
|
|
}
|
|
|
|
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
/**
|
|
|
|
* Render the "Undo" markup for the inline comment undo feature.
|
|
|
|
*/
|
|
|
|
private function renderUndoTemplates() {
|
2013-01-25 12:57:17 -08:00
|
|
|
$link = javelin_tag(
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'sigil' => 'differential-inline-comment-undo',
|
|
|
|
),
|
2013-01-25 12:57:17 -08:00
|
|
|
pht('Undo'));
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
|
2013-01-18 00:32:58 -08:00
|
|
|
$div = phutil_tag(
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-undo',
|
|
|
|
),
|
2013-01-18 00:32:58 -08:00
|
|
|
array('Changes discarded. ', $link));
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
|
|
|
|
return array(
|
2013-02-13 14:50:15 -08:00
|
|
|
'l' => hsprintf(
|
|
|
|
'<table><tr>'.
|
|
|
|
'<th></th><td>%s</td>'.
|
|
|
|
'<th></th><td colspan="3"></td>'.
|
|
|
|
'</tr></table>',
|
|
|
|
$div),
|
|
|
|
|
|
|
|
'r' => hsprintf(
|
|
|
|
'<table><tr>'.
|
|
|
|
'<th></th><td></td>'.
|
|
|
|
'<th></th><td colspan="3">%s</td>'.
|
|
|
|
'</tr></table>',
|
|
|
|
$div),
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-07 16:11:10 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-03-19 19:57:41 -07:00
|
|
|
private function renderViewOptionsDropdown(
|
|
|
|
DifferentialChangesetDetailView $detail,
|
|
|
|
$ref,
|
|
|
|
DifferentialChangeset $changeset) {
|
|
|
|
|
|
|
|
$meta = array();
|
|
|
|
|
|
|
|
$qparams = array(
|
|
|
|
'ref' => $ref,
|
|
|
|
'whitespace' => $this->whitespace,
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($this->standaloneURI) {
|
|
|
|
$uri = new PhutilURI($this->standaloneURI);
|
|
|
|
$uri->setQueryParams($uri->getQueryParams() + $qparams);
|
|
|
|
$meta['standaloneURI'] = (string)$uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
$repository = $this->repository;
|
|
|
|
if ($repository) {
|
2013-02-07 16:59:14 -08:00
|
|
|
try {
|
|
|
|
$meta['diffusionURI'] =
|
|
|
|
(string)$repository->getDiffusionBrowseURIForPath(
|
|
|
|
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
|
|
|
idx($changeset->getMetadata(), 'line:first'),
|
|
|
|
$this->getBranch());
|
|
|
|
} catch (DiffusionSetupException $e) {
|
|
|
|
// Ignore
|
|
|
|
}
|
2012-03-19 19:57:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$change = $changeset->getChangeType();
|
|
|
|
|
|
|
|
if ($this->leftRawFileURI) {
|
|
|
|
if ($change != DifferentialChangeType::TYPE_ADD) {
|
|
|
|
$uri = new PhutilURI($this->leftRawFileURI);
|
|
|
|
$uri->setQueryParams($uri->getQueryParams() + $qparams);
|
|
|
|
$meta['leftURI'] = (string)$uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->rightRawFileURI) {
|
|
|
|
if ($change != DifferentialChangeType::TYPE_DELETE &&
|
|
|
|
$change != DifferentialChangeType::TYPE_MULTICOPY) {
|
|
|
|
$uri = new PhutilURI($this->rightRawFileURI);
|
|
|
|
$uri->setQueryParams($uri->getQueryParams() + $qparams);
|
|
|
|
$meta['rightURI'] = (string)$uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = $this->user;
|
|
|
|
if ($user && $repository) {
|
|
|
|
$path = ltrim(
|
2012-04-09 23:42:12 -07:00
|
|
|
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
|
2012-03-19 19:57:41 -07:00
|
|
|
'/');
|
2012-09-21 11:57:45 -07:00
|
|
|
$line = idx($changeset->getMetadata(), 'line:first', 1);
|
2012-04-04 17:53:16 -07:00
|
|
|
$callsign = $repository->getCallsign();
|
|
|
|
$editor_link = $user->loadEditorLink($path, $line, $callsign);
|
2012-03-19 19:57:41 -07:00
|
|
|
if ($editor_link) {
|
|
|
|
$meta['editor'] = $editor_link;
|
|
|
|
} else {
|
2012-08-13 12:37:26 -07:00
|
|
|
$meta['editorConfigure'] = '/settings/panel/display/';
|
2012-03-19 19:57:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$meta['containerID'] = $detail->getID();
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'differential-dropdown-menus',
|
|
|
|
array());
|
|
|
|
|
2013-01-25 12:57:17 -08:00
|
|
|
return javelin_tag(
|
2012-03-19 19:57:41 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'button small grey',
|
|
|
|
'meta' => $meta,
|
|
|
|
'href' => idx($meta, 'detailURI', '#'),
|
|
|
|
'target' => '_blank',
|
|
|
|
'sigil' => 'differential-view-options',
|
|
|
|
),
|
2013-01-25 12:57:17 -08:00
|
|
|
pht("View Options \xE2\x96\xBC"));
|
2012-03-19 19:57:41 -07:00
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
}
|