upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialChangesetFileTreeSideNavBuilder {
|
|
|
|
|
|
|
|
private $title;
|
|
|
|
private $baseURI;
|
|
|
|
private $anchorName;
|
|
|
|
|
|
|
|
public function setAnchorName($anchor_name) {
|
|
|
|
$this->anchorName = $anchor_name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getAnchorName() {
|
|
|
|
return $this->anchorName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setBaseURI(PhutilURI $base_uri) {
|
|
|
|
$this->baseURI = $base_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getBaseURI() {
|
|
|
|
return $this->baseURI;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getTitle() {
|
|
|
|
return $this->title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function build(array $changesets) {
|
|
|
|
assert_instances_of($changesets, 'DifferentialChangeset');
|
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI($this->getBaseURI());
|
|
|
|
$nav->setFlexible(true);
|
|
|
|
|
|
|
|
$anchor = $this->getAnchorName();
|
|
|
|
|
|
|
|
$tree = new PhutilFileTree();
|
|
|
|
foreach ($changesets as $changeset) {
|
|
|
|
try {
|
|
|
|
$tree->addPath($changeset->getFilename(), $changeset);
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
// TODO: See T1702. When viewing the versus diff of diffs, we may
|
|
|
|
// have files with the same filename. For example, if you have a setup
|
|
|
|
// like this in SVN:
|
|
|
|
//
|
|
|
|
// a/
|
|
|
|
// README
|
|
|
|
// b/
|
|
|
|
// README
|
|
|
|
//
|
|
|
|
// ...and you run "arc diff" once from a/, and again from b/, you'll
|
|
|
|
// get two diffs with path README. However, in the versus diff view we
|
|
|
|
// will compute their absolute repository paths and detect that they
|
|
|
|
// aren't really the same file. This is correct, but causes us to
|
|
|
|
// throw when inserting them.
|
|
|
|
//
|
|
|
|
// We should probably compute the smallest unique path for each file
|
|
|
|
// and show these as "a/README" and "b/README" when diffed against
|
|
|
|
// one another. However, we get this wrong in a lot of places (the
|
|
|
|
// other TOC shows two "README" files, and we generate the same anchor
|
|
|
|
// hash for both) so I'm just stopping the bleeding until we can get
|
|
|
|
// a proper fix in place.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-filetree-view-css');
|
|
|
|
|
|
|
|
$filetree = array();
|
|
|
|
|
|
|
|
$path = $tree;
|
|
|
|
while (($path = $path->getNextNode())) {
|
|
|
|
$data = $path->getData();
|
|
|
|
|
|
|
|
$name = $path->getName();
|
|
|
|
$style = 'padding-left: '.(2 + (3 * $path->getDepth())).'px';
|
|
|
|
|
|
|
|
$href = null;
|
|
|
|
if ($data) {
|
|
|
|
$href = '#'.$data->getAnchorName();
|
|
|
|
$title = $name;
|
|
|
|
$icon = 'phabricator-filetree-icon-file';
|
|
|
|
} else {
|
|
|
|
$name .= '/';
|
|
|
|
$title = $path->getFullPath().'/';
|
|
|
|
$icon = 'phabricator-filetree-icon-dir';
|
|
|
|
}
|
|
|
|
|
|
|
|
$icon = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-filetree-icon '.$icon,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
2013-01-18 03:43:35 +01:00
|
|
|
$name_element = phutil_tag(
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-filetree-name',
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$name);
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
|
|
|
|
$filetree[] = javelin_render_tag(
|
|
|
|
$href ? 'a' : 'span',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
'style' => $style,
|
|
|
|
'title' => $title,
|
|
|
|
'class' => 'phabricator-filetree-item',
|
|
|
|
),
|
|
|
|
$icon.$name_element);
|
|
|
|
}
|
|
|
|
$tree->destroy();
|
|
|
|
|
|
|
|
$filetree =
|
|
|
|
'<div class="phabricator-filetree">'.
|
|
|
|
implode("\n", $filetree).
|
|
|
|
'</div>';
|
2013-01-24 22:18:44 +01:00
|
|
|
$nav->addLabel(pht('Changed Files'));
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$nav->addCustomBlock($filetree);
|
|
|
|
$nav->setActive(true);
|
2013-01-14 22:40:51 +01:00
|
|
|
$nav->selectFilter(null);
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|