2011-01-24 13:18:41 -08:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 11:18:11 -07:00
|
|
|
final class DifferentialChangesetDetailView extends AphrontView {
|
2011-01-24 13:18:41 -08:00
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
private $changeset;
|
|
|
|
private $buttons = array();
|
2012-04-10 15:00:09 -07:00
|
|
|
private $editable;
|
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 $symbolIndex;
|
2012-01-05 20:29:16 -08:00
|
|
|
private $id;
|
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
|
|
|
private $vsChangesetID;
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
private $renderURI;
|
|
|
|
private $renderingRef;
|
|
|
|
private $autoload;
|
2020-04-17 09:25:53 -07:00
|
|
|
private $repository;
|
|
|
|
private $diff;
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
private $changesetResponse;
|
2020-04-23 07:30:21 -07:00
|
|
|
private $branch;
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
|
|
|
|
public function setAutoload($autoload) {
|
|
|
|
$this->autoload = $autoload;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAutoload() {
|
|
|
|
return $this->autoload;
|
|
|
|
}
|
|
|
|
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
public function setRenderingRef($rendering_ref) {
|
|
|
|
$this->renderingRef = $rendering_ref;
|
Use ChangesetListView on Differential standalone view
Summary:
Fixes T4452. Ref T2009. There's a hierarchy of changeset rendering power: only low-level calls, use of ChangesetDetailView, then use of ChangesetListView (a list of DetailViews).
Prior to work here, the various changeset rendering controllers got their hands dirty to varying degrees, with some using only the lowest-level rendering pipeline:
- Phriction: no view (lowest level)
- Diffusion: DetailView
- Differential Changeset: DetailView
- Differential Diff: ListView
- Differential Revision: ListView
I brought Phriction up to use DetailView, but want to bring everything all the way up to use ListView. Each composition layer adds more features to diff browsing. In particular, this change enables "Highlight As", switching 1up vs 2up, adding inlines, etc., on the standalone view.
Test Plan:
- Viewed a changeset standalone. Could change highlighting, switch 1up vs 2up, add and edit inlines, etc.
- Viewed a revision; no behavioral changes.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T4452, T2009
Differential Revision: https://secure.phabricator.com/D12012
2015-03-08 04:10:11 -07:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
public function getRenderingRef() {
|
|
|
|
return $this->renderingRef;
|
Use ChangesetListView on Differential standalone view
Summary:
Fixes T4452. Ref T2009. There's a hierarchy of changeset rendering power: only low-level calls, use of ChangesetDetailView, then use of ChangesetListView (a list of DetailViews).
Prior to work here, the various changeset rendering controllers got their hands dirty to varying degrees, with some using only the lowest-level rendering pipeline:
- Phriction: no view (lowest level)
- Diffusion: DetailView
- Differential Changeset: DetailView
- Differential Diff: ListView
- Differential Revision: ListView
I brought Phriction up to use DetailView, but want to bring everything all the way up to use ListView. Each composition layer adds more features to diff browsing. In particular, this change enables "Highlight As", switching 1up vs 2up, adding inlines, etc., on the standalone view.
Test Plan:
- Viewed a changeset standalone. Could change highlighting, switch 1up vs 2up, add and edit inlines, etc.
- Viewed a revision; no behavioral changes.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T4452, T2009
Differential Revision: https://secure.phabricator.com/D12012
2015-03-08 04:10:11 -07:00
|
|
|
}
|
|
|
|
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
public function setChangesetResponse(PhabricatorChangesetResponse $response) {
|
|
|
|
$this->changesetResponse = $response;
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
public function getChangesetResponse() {
|
|
|
|
return $this->changesetResponse;
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setRenderURI($render_uri) {
|
|
|
|
$this->renderURI = $render_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRenderURI() {
|
|
|
|
return $this->renderURI;
|
|
|
|
}
|
2011-01-24 13:18:41 -08:00
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
public function setChangeset($changeset) {
|
|
|
|
$this->changeset = $changeset;
|
2011-01-24 13:18:41 -08:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
public function addButton($button) {
|
|
|
|
$this->buttons[] = $button;
|
|
|
|
return $this;
|
|
|
|
}
|
2011-01-24 13:18:41 -08:00
|
|
|
|
2012-04-10 15:00:09 -07:00
|
|
|
public function setEditable($editable) {
|
|
|
|
$this->editable = $editable;
|
2011-04-15 14:25:23 -07: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 setSymbolIndex($symbol_index) {
|
|
|
|
$this->symbolIndex = $symbol_index;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-04-23 07:30:21 -07:00
|
|
|
public function setBranch($branch) {
|
|
|
|
$this->branch = $branch;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBranch() {
|
|
|
|
return $this->branch;
|
|
|
|
}
|
|
|
|
|
2012-01-05 20:29:16 -08:00
|
|
|
public function getID() {
|
|
|
|
if (!$this->id) {
|
|
|
|
$this->id = celerity_generate_unique_node_id();
|
|
|
|
}
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
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 setVsChangesetID($vs_changeset_id) {
|
|
|
|
$this->vsChangesetID = $vs_changeset_id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVsChangesetID() {
|
|
|
|
return $this->vsChangesetID;
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
public function render() {
|
2020-04-23 07:30:21 -07:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
2014-01-02 11:59:35 -08:00
|
|
|
$this->requireResource('differential-changeset-view-css');
|
|
|
|
$this->requireResource('syntax-highlighting-css');
|
2011-01-24 13:18:41 -08:00
|
|
|
|
Kind-of-terrible (?) oncopy handler
Summary: Works in Safari, Firefox, Chrome.
Test Plan: Copied some text, threw up a little in my mouth.
Reviewers: aran, tuomaspelkonen, tomo, rstout, btrahan
Reviewed By: aran
CC: aran, epriestley, ddfisher
Maniphest Tasks: T145, T995
Differential Revision: https://secure.phabricator.com/D244
2012-03-15 19:04:59 -07:00
|
|
|
Javelin::initBehavior('phabricator-oncopy', array());
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
$changeset = $this->changeset;
|
|
|
|
$class = 'differential-changeset';
|
2012-04-10 15:00:09 -07:00
|
|
|
if (!$this->editable) {
|
2011-01-25 11:57:47 -08:00
|
|
|
$class .= ' differential-changeset-immutable';
|
2011-01-24 13:18:41 -08:00
|
|
|
}
|
|
|
|
|
2011-05-06 12:58:53 -07:00
|
|
|
$buttons = null;
|
|
|
|
if ($this->buttons) {
|
2013-01-30 10:58:21 -08:00
|
|
|
$buttons = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-changeset-buttons',
|
|
|
|
),
|
|
|
|
$this->buttons);
|
2011-05-06 12:58:53 -07:00
|
|
|
}
|
|
|
|
|
2012-01-05 20:29:16 -08:00
|
|
|
$id = $this->getID();
|
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
|
|
|
|
|
|
|
if ($this->symbolIndex) {
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'repository-crossreference',
|
|
|
|
array(
|
|
|
|
'container' => $id,
|
|
|
|
) + $this->symbolIndex);
|
|
|
|
}
|
|
|
|
|
2011-01-25 11:57:47 -08:00
|
|
|
$display_filename = $changeset->getDisplayFilename();
|
2016-11-27 14:00:03 -08:00
|
|
|
$display_icon = FileTypeIcon::getFileIcon($display_filename);
|
2013-10-15 07:34:48 -07:00
|
|
|
$icon = id(new PHUIIconView())
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon($display_icon);
|
2012-02-23 12:26:14 -08:00
|
|
|
|
2017-05-17 08:25:39 -07:00
|
|
|
$changeset_id = $this->changeset->getID();
|
|
|
|
|
|
|
|
$vs_id = $this->getVsChangesetID();
|
|
|
|
if (!$vs_id) {
|
|
|
|
// Showing a changeset normally.
|
|
|
|
$left_id = $changeset_id;
|
|
|
|
$right_id = $changeset_id;
|
|
|
|
} else if ($vs_id == -1) {
|
|
|
|
// Showing a synthetic "deleted" changeset for a file which was
|
|
|
|
// removed between changes.
|
|
|
|
$left_id = $changeset_id;
|
|
|
|
$right_id = null;
|
|
|
|
} else {
|
|
|
|
// Showing a diff-of-diffs.
|
|
|
|
$left_id = $vs_id;
|
|
|
|
$right_id = $changeset_id;
|
|
|
|
}
|
|
|
|
|
2017-05-18 16:31:16 -07:00
|
|
|
// In the persistent banner, emphasize the current filename.
|
|
|
|
$path_part = dirname($display_filename);
|
|
|
|
$file_part = basename($display_filename);
|
|
|
|
$display_parts = array();
|
|
|
|
if (strlen($path_part)) {
|
|
|
|
$path_part = $path_part.'/';
|
|
|
|
$display_parts[] = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'diff-banner-path',
|
|
|
|
),
|
|
|
|
$path_part);
|
|
|
|
}
|
|
|
|
$display_parts[] = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'diff-banner-file',
|
|
|
|
),
|
|
|
|
$file_part);
|
|
|
|
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
$response = $this->getChangesetResponse();
|
|
|
|
if ($response) {
|
|
|
|
$is_loaded = true;
|
|
|
|
$changeset_markup = $response->getRenderedChangeset();
|
|
|
|
$changeset_state = $response->getChangesetState();
|
|
|
|
} else {
|
|
|
|
$is_loaded = false;
|
|
|
|
$changeset_markup = null;
|
|
|
|
$changeset_state = null;
|
|
|
|
}
|
|
|
|
|
2020-04-21 09:56:30 -07:00
|
|
|
$path_parts = trim($display_filename, '/');
|
|
|
|
$path_parts = explode('/', $path_parts);
|
|
|
|
|
2020-04-23 07:30:21 -07:00
|
|
|
$show_path_uri = null;
|
|
|
|
$show_directory_uri = null;
|
|
|
|
|
|
|
|
$repository = $this->getRepository();
|
|
|
|
if ($repository) {
|
|
|
|
$diff = $this->getDiff();
|
|
|
|
if ($diff) {
|
|
|
|
$repo_path = $changeset->getAbsoluteRepositoryPath($repository, $diff);
|
|
|
|
|
|
|
|
$repo_dir = dirname($repo_path);
|
|
|
|
if ($repo_dir === $repo_path) {
|
|
|
|
$repo_dir = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$show_path_uri = $repository->getDiffusionBrowseURIForPath(
|
|
|
|
$viewer,
|
|
|
|
$repo_path,
|
|
|
|
idx($changeset->getMetadata(), 'line:first'),
|
|
|
|
$this->getBranch());
|
|
|
|
|
|
|
|
if ($repo_dir !== null) {
|
|
|
|
$repo_dir = rtrim($repo_dir, '/').'/';
|
|
|
|
|
|
|
|
$show_directory_uri = $repository->getDiffusionBrowseURIForPath(
|
|
|
|
$viewer,
|
|
|
|
$repo_dir,
|
|
|
|
null,
|
|
|
|
$this->getBranch());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($show_path_uri) {
|
|
|
|
$show_path_uri = phutil_string_cast($show_path_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($show_directory_uri) {
|
|
|
|
$show_directory_uri = phutil_string_cast($show_directory_uri);
|
|
|
|
}
|
|
|
|
|
2013-01-30 10:58:21 -08:00
|
|
|
return javelin_tag(
|
2011-01-25 11:57:47 -08:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'sigil' => 'differential-changeset',
|
2011-02-01 16:42:36 -08:00
|
|
|
'meta' => array(
|
2017-05-17 08:25:39 -07:00
|
|
|
'left' => $left_id,
|
|
|
|
'right' => $right_id,
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
'renderURI' => $this->getRenderURI(),
|
|
|
|
'ref' => $this->getRenderingRef(),
|
|
|
|
'autoload' => $this->getAutoload(),
|
2017-05-18 16:31:16 -07:00
|
|
|
'displayPath' => hsprintf('%s', $display_parts),
|
|
|
|
'icon' => $display_icon,
|
2020-04-21 09:56:30 -07:00
|
|
|
'pathParts' => $path_parts,
|
2020-04-17 09:25:53 -07:00
|
|
|
|
2020-04-22 08:11:45 -07:00
|
|
|
'pathIconIcon' => $changeset->getPathIconIcon(),
|
|
|
|
'pathIconColor' => $changeset->getPathIconColor(),
|
2020-04-22 10:56:09 -07:00
|
|
|
'isLowImportance' => $changeset->getIsLowImportanceChangeset(),
|
|
|
|
'isOwned' => $changeset->getIsOwnedChangeset(),
|
2020-04-22 08:11:45 -07:00
|
|
|
|
2020-04-17 09:25:53 -07:00
|
|
|
'editorURI' => $this->getEditorURI(),
|
|
|
|
'editorConfigureURI' => $this->getEditorConfigureURI(),
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
|
|
|
|
'loaded' => $is_loaded,
|
|
|
|
'changesetState' => $changeset_state,
|
2020-04-23 07:30:21 -07:00
|
|
|
|
|
|
|
'showPathURI' => $show_path_uri,
|
|
|
|
'showDirectoryURI' => $show_directory_uri,
|
2011-02-01 16:42:36 -08:00
|
|
|
),
|
2011-01-25 11:57:47 -08:00
|
|
|
'class' => $class,
|
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
|
|
|
'id' => $id,
|
2011-01-25 11:57:47 -08:00
|
|
|
),
|
2013-03-09 13:52:41 -08:00
|
|
|
array(
|
|
|
|
id(new PhabricatorAnchorView())
|
|
|
|
->setAnchorName($changeset->getAnchorName())
|
|
|
|
->setNavigationMarker(true)
|
|
|
|
->render(),
|
|
|
|
$buttons,
|
2020-04-23 08:50:46 -07:00
|
|
|
javelin_tag(
|
|
|
|
'h1',
|
2013-10-15 07:34:48 -07:00
|
|
|
array(
|
2014-10-08 00:01:04 +11:00
|
|
|
'class' => 'differential-file-icon-header',
|
2020-04-23 08:50:46 -07:00
|
|
|
'sigil' => 'changeset-header',
|
2014-10-08 00:01:04 +11:00
|
|
|
),
|
2013-10-15 07:34:48 -07:00
|
|
|
array(
|
|
|
|
$icon,
|
2020-05-08 06:36:31 -07:00
|
|
|
javelin_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-changeset-path-name',
|
|
|
|
'sigil' => 'changeset-header-path-name',
|
|
|
|
),
|
|
|
|
$display_filename),
|
Consolidate changeset rendering logic
Summary:
Ref T5179. Currently, all the changeset rendering logic is in the "populate" behavior, and a lot of it comes in via configuration and is hard to get at.
Instead, surface an object which can control it, and which other behaviors can access more easily.
In particular, this allows us to add a "Load/Reload" item to the view options menu, which would previously have been very challenging.
Load/Reload isn't useful on its own, but is a step away from "Show whitespace as...", "Highlight as...", "Show tabtops as...", "View Unified", "View Side-By-Side", etc.
Test Plan:
- Viewed Differential.
- Viewed Diffusion.
- Viewed large changesets, clicked "Load".
- Used "Load" and "Reload" from view options menu.
- Loaded all changes in a large diff, verified "Load" and TOC clicks take precedence over other content loads.
- Played with content stability stuff.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5179
Differential Revision: https://secure.phabricator.com/D9286
2014-05-25 07:13:22 -07:00
|
|
|
)),
|
|
|
|
javelin_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'changeset-view-content',
|
|
|
|
'sigil' => 'changeset-view-content',
|
|
|
|
),
|
Make "renderer", "engine", and "encoding" sticky across reloads in Differential and Diffusion
Summary:
Ref T13455. Update the other "view state" properties to work like "highlight" now works.
Some complexity here arises from these concerns:
- In "View Standalone", we render the changeset inline. This is useful for debugging/development, and desirable to retain.
- In all other cases, we render the changeset with AJAX.
So the client needs to be able to learn about the "state" properties of the changeset on two different flows. Prior to this change, each pathway had a fair amount of unique code.
Then, some bookkeeping issues:
- At inital rendering time, we may not know which renderer will be selected: it may be based on the client viewport dimensions.
- Prior to this change, the client didn't separate "value of the property for the changeset as rendered" and "desired value of the property".
Test Plan:
- Viewed changes in Differential, Diffusion, and in standalone mode.
- Toggled renderer, character sets, and document engine (this one isn't terribly useful). Reloaded, saw them stick.
- Started typing a comment, cancelled it, hit the undo UI.
Maniphest Tasks: T13455
Differential Revision: https://secure.phabricator.com/D21138
2020-04-17 15:39:47 -07:00
|
|
|
array(
|
|
|
|
$changeset_markup,
|
|
|
|
$this->renderChildren(),
|
|
|
|
)),
|
2013-03-09 13:52:41 -08:00
|
|
|
));
|
2011-01-24 13:18:41 -08:00
|
|
|
}
|
|
|
|
|
2020-04-17 09:25:53 -07:00
|
|
|
public function setRepository(PhabricatorRepository $repository) {
|
|
|
|
$this->repository = $repository;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRepository() {
|
|
|
|
return $this->repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getChangeset() {
|
|
|
|
return $this->changeset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDiff(DifferentialDiff $diff) {
|
|
|
|
$this->diff = $diff;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDiff() {
|
|
|
|
return $this->diff;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getEditorURI() {
|
2020-04-18 11:31:27 -07:00
|
|
|
$repository = $this->getRepository();
|
|
|
|
if (!$repository) {
|
2020-04-17 09:25:53 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-18 11:31:27 -07:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$link_engine = PhabricatorEditorURIEngine::newForViewer($viewer);
|
|
|
|
if (!$link_engine) {
|
2020-04-17 09:25:53 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-18 11:31:27 -07:00
|
|
|
$link_engine->setRepository($repository);
|
|
|
|
|
2020-04-17 09:25:53 -07:00
|
|
|
$changeset = $this->getChangeset();
|
|
|
|
$diff = $this->getDiff();
|
|
|
|
|
|
|
|
$path = $changeset->getAbsoluteRepositoryPath($repository, $diff);
|
|
|
|
$path = ltrim($path, '/');
|
|
|
|
|
|
|
|
$line = idx($changeset->getMetadata(), 'line:first', 1);
|
|
|
|
|
2020-04-18 11:31:27 -07:00
|
|
|
return $link_engine->getURIForPath($path, $line);
|
2020-04-17 09:25:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getEditorConfigureURI() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
if (!$viewer->isLoggedIn()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-21 13:02:36 -07:00
|
|
|
return '/settings/panel/editor/';
|
2020-04-17 09:25:53 -07:00
|
|
|
}
|
2015-03-08 15:27:16 -07:00
|
|
|
|
2011-01-24 13:18:41 -08:00
|
|
|
}
|