1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Colorize filetree for adds, moves, and deletes

Summary: See PHI356. Makes it easier to pick out change types in the filetree view in Differential.

Test Plan: Created a diff with adds, copies, moves, deletions, and binary files. Viewed in Differential, had an easier time picking stuff out.

Differential Revision: https://secure.phabricator.com/D19040
This commit is contained in:
epriestley 2018-02-08 15:52:59 -08:00
parent e26a784dcf
commit 6ea1b8df9b
4 changed files with 67 additions and 6 deletions

View file

@ -12,7 +12,7 @@ return array(
'core.pkg.css' => 'ce8c2a58', 'core.pkg.css' => 'ce8c2a58',
'core.pkg.js' => '4c79d74f', 'core.pkg.js' => '4c79d74f',
'darkconsole.pkg.js' => '1f9a31bc', 'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '45951e9e', 'differential.pkg.css' => '1522c3ad',
'differential.pkg.js' => '19ee9979', 'differential.pkg.js' => '19ee9979',
'diffusion.pkg.css' => 'a2d17c7d', 'diffusion.pkg.css' => 'a2d17c7d',
'diffusion.pkg.js' => '6134c5a1', 'diffusion.pkg.js' => '6134c5a1',
@ -121,7 +121,7 @@ return array(
'rsrc/css/font/font-awesome.css' => 'e838e088', 'rsrc/css/font/font-awesome.css' => 'e838e088',
'rsrc/css/font/font-lato.css' => 'c7ccd872', 'rsrc/css/font/font-lato.css' => 'c7ccd872',
'rsrc/css/font/phui-font-icon-base.css' => '870a7360', 'rsrc/css/font/phui-font-icon-base.css' => '870a7360',
'rsrc/css/layout/phabricator-filetree-view.css' => 'fccf9f82', 'rsrc/css/layout/phabricator-filetree-view.css' => 'ea5b30a9',
'rsrc/css/layout/phabricator-source-code-view.css' => 'aea41829', 'rsrc/css/layout/phabricator-source-code-view.css' => 'aea41829',
'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494', 'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494',
'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68', 'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68',
@ -784,7 +784,7 @@ return array(
'phabricator-favicon' => '1fe2510c', 'phabricator-favicon' => '1fe2510c',
'phabricator-feed-css' => 'ecd4ec57', 'phabricator-feed-css' => 'ecd4ec57',
'phabricator-file-upload' => '680ea2c8', 'phabricator-file-upload' => '680ea2c8',
'phabricator-filetree-view-css' => 'fccf9f82', 'phabricator-filetree-view-css' => 'ea5b30a9',
'phabricator-flag-css' => 'bba8f811', 'phabricator-flag-css' => 'bba8f811',
'phabricator-keyboard-shortcut' => '1ae869f2', 'phabricator-keyboard-shortcut' => '1ae869f2',
'phabricator-keyboard-shortcut-manager' => 'c19dd9b9', 'phabricator-keyboard-shortcut-manager' => 'c19dd9b9',

View file

@ -221,6 +221,51 @@ final class DifferentialChangeset
return $this->assertAttached($this->diff); return $this->assertAttached($this->diff);
} }
public function newFileTreeIcon() {
$file_type = $this->getFileType();
$change_type = $this->getChangeType();
$change_icons = array(
DifferentialChangeType::TYPE_DELETE => 'fa-file-o',
);
if (isset($change_icons[$change_type])) {
$icon = $change_icons[$change_type];
} else {
$icon = DifferentialChangeType::getIconForFileType($file_type);
}
$change_colors = array(
DifferentialChangeType::TYPE_ADD => 'green',
DifferentialChangeType::TYPE_DELETE => 'red',
DifferentialChangeType::TYPE_MOVE_AWAY => 'orange',
DifferentialChangeType::TYPE_MOVE_HERE => 'orange',
DifferentialChangeType::TYPE_COPY_HERE => 'orange',
DifferentialChangeType::TYPE_MULTICOPY => 'orange',
);
$color = idx($change_colors, $change_type, 'bluetext');
return id(new PHUIIconView())
->setIcon($icon.' '.$color);
}
public function getFileTreeClass() {
switch ($this->getChangeType()) {
case DifferentialChangeType::TYPE_ADD:
return 'filetree-added';
case DifferentialChangeType::TYPE_DELETE:
return 'filetree-deleted';
case DifferentialChangeType::TYPE_MOVE_AWAY:
case DifferentialChangeType::TYPE_MOVE_HERE:
case DifferentialChangeType::TYPE_COPY_HERE:
case DifferentialChangeType::TYPE_MULTICOPY:
return 'filetree-movecopy';
}
return null;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -83,6 +83,9 @@ final class DifferentialChangesetFileTreeSideNavBuilder extends Phobject {
while (($path = $path->getNextNode())) { while (($path = $path->getNextNode())) {
$data = $path->getData(); $data = $path->getData();
$classes = array();
$classes[] = 'phabricator-filetree-item';
$name = $path->getName(); $name = $path->getName();
$style = 'padding-left: '.(2 + (3 * $path->getDepth())).'px'; $style = 'padding-left: '.(2 + (3 * $path->getDepth())).'px';
@ -90,8 +93,9 @@ final class DifferentialChangesetFileTreeSideNavBuilder extends Phobject {
if ($data) { if ($data) {
$href = '#'.$data->getAnchorName(); $href = '#'.$data->getAnchorName();
$title = $name; $title = $name;
$icon = id(new PHUIIconView())
->setIcon('fa-file-text-o bluetext'); $icon = $data->newFileTreeIcon();
$classes[] = $data->getFileTreeClass();
} else { } else {
$name .= '/'; $name .= '/';
$title = $path->getFullPath().'/'; $title = $path->getFullPath().'/';
@ -112,7 +116,7 @@ final class DifferentialChangesetFileTreeSideNavBuilder extends Phobject {
'href' => $href, 'href' => $href,
'style' => $style, 'style' => $style,
'title' => $title, 'title' => $title,
'class' => 'phabricator-filetree-item', 'class' => implode(' ', $classes),
), ),
array($icon, $name_element)); array($icon, $name_element));
} }

View file

@ -54,3 +54,15 @@
background-color: {$hovergrey}; background-color: {$hovergrey};
border-left: 4px solid {$sky}; border-left: 4px solid {$sky};
} }
.phabricator-filetree .filetree-added {
background: {$sh-greenbackground};
}
.phabricator-filetree .filetree-deleted {
background: {$sh-redbackground};
}
.phabricator-filetree .filetree-movecopy {
background: {$sh-orangebackground};
}