From ff88eb588eb4c256aa4d45412caf80e27457b474 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 22 Apr 2020 08:11:45 -0700 Subject: [PATCH] Show change information in file icons in the filetree Summary: Ref T13516. Restores "deleted"/"added" information to the tree icons. Test Plan: {F7375145} Maniphest Tasks: T13516 Differential Revision: https://secure.phabricator.com/D21156 --- resources/celerity/map.php | 36 ++++---- .../CelerityDefaultPostprocessor.php | 3 + .../CelerityRedGreenPostprocessor.php | 3 + .../storage/DifferentialChangeset.php | 92 +++++++++++-------- .../view/DifferentialChangesetDetailView.php | 3 + webroot/rsrc/css/font/phui-font-icon-base.css | 10 ++ .../rsrc/js/application/diff/DiffChangeset.js | 9 +- 7 files changed, 101 insertions(+), 55 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 2402b08169..9bae6afb53 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,10 +9,10 @@ return array( 'names' => array( 'conpherence.pkg.css' => '3c8a0668', 'conpherence.pkg.js' => '020aebcf', - 'core.pkg.css' => '4d5d0922', + 'core.pkg.css' => 'dd5f04a3', 'core.pkg.js' => '544bc792', 'differential.pkg.css' => 'cb99cd21', - 'differential.pkg.js' => 'b3589d05', + 'differential.pkg.js' => 'b1ef535d', 'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.js' => 'a98c0bf7', 'maniphest.pkg.css' => '35995d6d', @@ -119,7 +119,7 @@ return array( 'rsrc/css/diviner/diviner-shared.css' => '4bd263b0', 'rsrc/css/font/font-awesome.css' => '3883938a', 'rsrc/css/font/font-lato.css' => '23631304', - 'rsrc/css/font/phui-font-icon-base.css' => 'd7994e06', + 'rsrc/css/font/phui-font-icon-base.css' => '303c9b87', 'rsrc/css/layout/phabricator-source-code-view.css' => '03d7ac28', 'rsrc/css/phui/button/phui-button-bar.css' => 'a4aa75c4', 'rsrc/css/phui/button/phui-button-simple.css' => '1ff278aa', @@ -378,7 +378,7 @@ return array( 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be', 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', - 'rsrc/js/application/diff/DiffChangeset.js' => '2a3101b1', + 'rsrc/js/application/diff/DiffChangeset.js' => 'd089ffb1', 'rsrc/js/application/diff/DiffChangesetList.js' => '57035863', 'rsrc/js/application/diff/DiffInline.js' => '16e97ebc', 'rsrc/js/application/diff/DiffPathView.js' => '5f70ad12', @@ -775,7 +775,7 @@ return array( 'phabricator-darklog' => '3b869402', 'phabricator-darkmessage' => '26cd4b73', 'phabricator-dashboard-css' => '5a205b9d', - 'phabricator-diff-changeset' => '2a3101b1', + 'phabricator-diff-changeset' => 'd089ffb1', 'phabricator-diff-changeset-list' => '57035863', 'phabricator-diff-inline' => '16e97ebc', 'phabricator-diff-path-view' => '5f70ad12', @@ -842,7 +842,7 @@ return array( 'phui-document-view-css' => '52b748a5', 'phui-document-view-pro-css' => 'b9613a10', 'phui-feed-story-css' => 'a0c05029', - 'phui-font-icon-base-css' => 'd7994e06', + 'phui-font-icon-base-css' => '303c9b87', 'phui-fontkit-css' => '1ec937e5', 'phui-form-css' => '1f177cb7', 'phui-form-view-css' => '01b796c0', @@ -1155,18 +1155,6 @@ return array( 'javelin-stratcom', 'javelin-behavior', ), - '2a3101b1' => array( - 'javelin-dom', - 'javelin-util', - 'javelin-stratcom', - 'javelin-install', - 'javelin-workflow', - 'javelin-router', - 'javelin-behavior-device', - 'javelin-vector', - 'phabricator-diff-inline', - 'phabricator-diff-path-view', - ), '2a8b62d9' => array( 'multirow-row-manager', 'javelin-install', @@ -2093,6 +2081,18 @@ return array( 'javelin-dom', 'javelin-stratcom', ), + 'd089ffb1' => array( + 'javelin-dom', + 'javelin-util', + 'javelin-stratcom', + 'javelin-install', + 'javelin-workflow', + 'javelin-router', + 'javelin-behavior-device', + 'javelin-vector', + 'phabricator-diff-inline', + 'phabricator-diff-path-view', + ), 'd12d214f' => array( 'javelin-install', 'javelin-dom', diff --git a/src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php b/src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php index 8cbea36d07..5430eb49cc 100644 --- a/src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php +++ b/src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php @@ -240,6 +240,9 @@ final class CelerityDefaultPostprocessor 'document.border' => '#dedee1', + 'delete-color' => '#c0392b', + 'create-color' => '#139543', + ); } diff --git a/src/applications/celerity/postprocessor/CelerityRedGreenPostprocessor.php b/src/applications/celerity/postprocessor/CelerityRedGreenPostprocessor.php index fc2f9d8e9a..cded57b7ea 100644 --- a/src/applications/celerity/postprocessor/CelerityRedGreenPostprocessor.php +++ b/src/applications/celerity/postprocessor/CelerityRedGreenPostprocessor.php @@ -17,6 +17,9 @@ final class CelerityRedGreenPostprocessor 'new-bright' => 'rgba(152, 207, 235, .35)', 'old-background' => 'rgba(250, 212, 175, .3)', 'old-bright' => 'rgba(250, 212, 175, .55)', + + 'delete-color' => '#e67e22', + 'create-color' => '#2980b9', ); } diff --git a/src/applications/differential/storage/DifferentialChangeset.php b/src/applications/differential/storage/DifferentialChangeset.php index 03400d7a16..3b2f6331e0 100644 --- a/src/applications/differential/storage/DifferentialChangeset.php +++ b/src/applications/differential/storage/DifferentialChangeset.php @@ -259,48 +259,68 @@ final class DifferentialChangeset } 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'); + $icon = $this->getPathIconIcon(); + $color = $this->getPathIconColor(); return id(new PHUIIconView()) - ->setIcon($icon.' '.$color); + ->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'; + public function getPathIconIcon() { + return idx($this->getPathIconDetails(), 'icon'); + } + + public function getPathIconColor() { + return idx($this->getPathIconDetails(), 'color'); + } + + private function getPathIconDetails() { + $change_icons = array( + DifferentialChangeType::TYPE_DELETE => array( + 'icon' => 'fa-times', + 'color' => 'delete-color', + ), + DifferentialChangeType::TYPE_ADD => array( + 'icon' => 'fa-plus', + 'color' => 'create-color', + ), + DifferentialChangeType::TYPE_MOVE_AWAY => array( + 'icon' => 'fa-circle-o', + 'color' => 'grey', + ), + DifferentialChangeType::TYPE_MULTICOPY => array( + 'icon' => 'fa-circle-o', + 'color' => 'grey', + ), + DifferentialChangeType::TYPE_MOVE_HERE => array( + 'icon' => 'fa-plus-circle', + 'color' => 'create-color', + ), + DifferentialChangeType::TYPE_COPY_HERE => array( + 'icon' => 'fa-plus-circle', + 'color' => 'create-color', + ), + ); + + $change_type = $this->getChangeType(); + if (isset($change_icons[$change_type])) { + return $change_icons[$change_type]; } - return null; + if ($this->isGeneratedChangeset()) { + return array( + 'icon' => 'fa-cogs', + 'color' => 'grey', + ); + } + + $file_type = $this->getFileType(); + $icon = DifferentialChangeType::getIconForFileType($file_type); + + return array( + 'icon' => $icon, + 'color' => 'bluetext', + ); } public function setChangesetMetadata($key, $value) { diff --git a/src/applications/differential/view/DifferentialChangesetDetailView.php b/src/applications/differential/view/DifferentialChangesetDetailView.php index 807e878ad3..b75134f66e 100644 --- a/src/applications/differential/view/DifferentialChangesetDetailView.php +++ b/src/applications/differential/view/DifferentialChangesetDetailView.php @@ -195,6 +195,9 @@ final class DifferentialChangesetDetailView extends AphrontView { 'icon' => $display_icon, 'pathParts' => $path_parts, + 'pathIconIcon' => $changeset->getPathIconIcon(), + 'pathIconColor' => $changeset->getPathIconColor(), + 'editorURI' => $this->getEditorURI(), 'editorConfigureURI' => $this->getEditorConfigureURI(), diff --git a/webroot/rsrc/css/font/phui-font-icon-base.css b/webroot/rsrc/css/font/phui-font-icon-base.css index 60c323d69d..986e4b5e5e 100644 --- a/webroot/rsrc/css/font/phui-font-icon-base.css +++ b/webroot/rsrc/css/font/phui-font-icon-base.css @@ -116,6 +116,11 @@ .phui-icon-view.red { color: {$red}; } + +.phui-icon-view.delete-color { + color: {$delete-color}; +} + .phui-icon-view.orange { color: {$orange}; } @@ -125,6 +130,11 @@ .phui-icon-view.green { color: {$green} } + +.phui-icon-view.create-color { + color: {$create-color}; +} + .phui-icon-view.blue { color: {$blue}; } diff --git a/webroot/rsrc/js/application/diff/DiffChangeset.js b/webroot/rsrc/js/application/diff/DiffChangeset.js index 9ea469e3d9..0d99f65411 100644 --- a/webroot/rsrc/js/application/diff/DiffChangeset.js +++ b/webroot/rsrc/js/application/diff/DiffChangeset.js @@ -35,6 +35,9 @@ JX.install('DiffChangeset', { this._editorURI = data.editorURI; this._editorConfigureURI = data.editorConfigureURI; + this._pathIconIcon = data.pathIconIcon; + this._pathIconColor = data.pathIconColor; + this._inlines = []; if (data.changesetState) { @@ -72,6 +75,9 @@ JX.install('DiffChangeset', { _editorConfigureURI: null, _pathView: null, + _pathIconIcon: null, + _pathIconColor: null, + getEditorURI: function() { return this._editorURI; }, @@ -897,7 +903,8 @@ JX.install('DiffChangeset', { .setPath(this._pathParts); view.getIcon() - .setIcon(this.getIcon()); + .setIcon(this._pathIconIcon) + .setColor(this._pathIconColor); this._pathView = view; }