diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,7 +9,7 @@ 'names' => array( 'conpherence.pkg.css' => '0e3cf785', 'conpherence.pkg.js' => '020aebcf', - 'core.pkg.css' => '9b2e2e20', + 'core.pkg.css' => '9cb7cb3f', 'core.pkg.js' => '845355f4', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => '5c459f92', @@ -133,7 +133,7 @@ 'rsrc/css/phui/object-item/phui-oi-color.css' => 'b517bfa0', 'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => 'da15d3dc', 'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '490e2e2e', - 'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'd7723ecc', + 'rsrc/css/phui/object-item/phui-oi-list-view.css' => '4b0def39', 'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => '6a30fa46', 'rsrc/css/phui/phui-action-list.css' => '1b0085b2', 'rsrc/css/phui/phui-action-panel.css' => '6c386cbf', @@ -866,7 +866,7 @@ 'phui-oi-color-css' => 'b517bfa0', 'phui-oi-drag-ui-css' => 'da15d3dc', 'phui-oi-flush-ui-css' => '490e2e2e', - 'phui-oi-list-view-css' => 'd7723ecc', + 'phui-oi-list-view-css' => '4b0def39', 'phui-oi-simple-ui-css' => '6a30fa46', 'phui-pager-css' => 'd022c7ad', 'phui-pinboard-view-css' => '1f08f5d8', diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -222,7 +222,8 @@ $bucket = $this->getResultBucket($query); $template = id(new DiffusionCommitGraphView()) - ->setViewer($viewer); + ->setViewer($viewer) + ->setShowAuditors(true); $views = array(); if ($bucket) { diff --git a/src/applications/diffusion/view/DiffusionCommitGraphView.php b/src/applications/diffusion/view/DiffusionCommitGraphView.php --- a/src/applications/diffusion/view/DiffusionCommitGraphView.php +++ b/src/applications/diffusion/view/DiffusionCommitGraphView.php @@ -14,6 +14,8 @@ private $buildableMap; private $revisionMap; + private $showAuditors; + public function setHistory(array $history) { assert_instances_of($history, 'DiffusionPathChange'); $this->history = $history; @@ -34,6 +36,15 @@ return $this->commits; } + public function setShowAuditors($show_auditors) { + $this->showAuditors = $show_auditors; + return $this; + } + + public function getShowAuditors() { + return $this->showAuditors; + } + public function setParents(array $parents) { $this->parents = $parents; return $this; @@ -92,10 +103,36 @@ } private function newObjectItemViews() { + $viewer = $this->getViewer(); + require_celerity_resource('diffusion-css'); $show_builds = $this->shouldShowBuilds(); $show_revisions = $this->shouldShowRevisions(); + $show_auditors = $this->shouldShowAuditors(); + + $phids = array(); + + if ($show_revisions) { + $revision_map = $this->getRevisionMap(); + foreach ($revision_map as $revisions) { + foreach ($revisions as $revision) { + $phids[] = $revision->getPHID(); + } + } + } + + if ($show_auditors) { + $commits = $this->getCommitMap(); + foreach ($commits as $commit) { + $audits = $commit->getAudits(); + foreach ($audits as $auditor) { + $phids[] = $auditor->getAuditorPHID(); + } + } + } + + $handles = $viewer->loadHandles($phids); $views = array(); @@ -111,38 +148,52 @@ $short_hash = $this->getCommitObjectName($hash); $is_disabled = $this->getCommitIsDisabled($commit); - $author_view = $this->getCommitAuthorView($commit); - $item_view = id(new PHUIObjectItemView()) + ->setViewer($viewer) ->setHeader($commit_description) ->setObjectName($short_hash) ->setHref($commit_link) ->setDisabled($is_disabled); - if ($author_view !== null) { - $item_view->addAttribute($author_view); + $this->addBrowseAction($item_view, $hash); + + if ($show_builds) { + $this->addBuildAction($item_view, $hash); } - $browse_button = $this->newBrowseButton($hash); + $this->addAuditAction($item_view, $hash); - $build_view = null; - if ($show_builds) { - $build_view = $this->newBuildView($hash); + if ($show_auditors) { + $auditor_list = $item_view->newPropertyList(); + if ($commit) { + $auditors = $this->newAuditorList($commit, $handles); + $auditor_list->addProperty(pht('Auditors'), $auditors); + } } - $item_view->setSideColumn( - array( - $build_view, - $browse_button, - )); + $property_list = $item_view->newPropertyList(); - $revision_view = null; - if ($show_revisions) { - $revision_view = $this->newRevisionView($hash); + if ($commit) { + $author_view = $this->getCommitAuthorView($commit); + if ($author_view) { + $property_list->addProperty( + pht('Author'), + $this->getCommitAuthorView($commit)); + } } - if ($revision_view !== null) { - $item_view->addAttribute($revision_view); + if ($show_revisions) { + if ($commit) { + $revisions = $this->getRevisions($commit); + if ($revisions) { + $revision = head($revisions); + $handle = $handles[$revision->getPHID()]; + + $property_list->addProperty( + pht('Revision'), + $handle->renderLink()); + } + } } $views[$hash] = $item_view; @@ -172,6 +223,7 @@ $item_view = $views[$hash]; $list_view = id(new PHUIObjectItemListView()) + ->setViewer($viewer) ->setFlush(true) ->addItem($item_view); @@ -268,6 +320,10 @@ return $show_revisions; } + private function shouldShowAuditors() { + return $this->getShowAuditors(); + } + private function newHistoryItems() { $items = array(); @@ -367,24 +423,6 @@ return $commit->newCommitAuthorView($viewer); } - private function newBrowseButton($hash) { - $repository = $this->getRepository(); - - if ($repository) { - $drequest = $this->getDiffusionRequest(); - - return $this->linkBrowse( - $drequest->getPath(), - array( - 'commit' => $hash, - 'branch' => $drequest->getBranch(), - ), - $as_button = true); - } - - return null; - } - private function getCommit($hash) { $commit_map = $this->getCommitMap(); return idx($commit_map, $hash); @@ -399,18 +437,84 @@ return $this->commitMap; } - private function newBuildView($hash) { + private function addBrowseAction(PHUIObjectItemView $item, $hash) { + $repository = $this->getRepository(); + + if (!$repository) { + return; + } + + $drequest = $this->getDiffusionRequest(); + $path = $drequest->getPath(); + + $uri = $drequest->generateURI( + array( + 'action' => 'browse', + 'path' => $path, + )); + + $item->newAction() + ->setIcon('fa-folder-open-o bluegrey') + ->setName(pht('Browse Repository')) + ->setHref($uri); + } + + private function addBuildAction(PHUIObjectItemView $item, $hash) { + $is_disabled = true; + + $buildable = null; + $commit = $this->getCommit($hash); if (!$commit) { - return null; + $buildable = $this->getBuildable($commit); } - $buildable = $this->getBuildable($commit); - if (!$buildable) { - return null; + if ($buildable) { + $icon = $buildable->getStatusIcon(); + $color = $buildable->getStatusColor(); + $name = $buildable->getStatusDisplayName(); + $uri = $buildable->getURI(); + } else { + $icon = 'fa-times'; + $color = 'grey'; + $name = pht('No Builds'); + $uri = null; + } + + $item->newAction() + ->setIcon($icon.' '.$color) + ->setName($name) + ->setHref($uri) + ->setDisabled(($uri === null)); + } + + private function addAuditAction(PHUIObjectItemView $item_view, $hash) { + $commit = $this->getCommit($hash); + + if ($commit) { + $status = $commit->getAuditStatusObject(); + + $text = $status->getName(); + $color = $status->getColor(); + $icon = $status->getIcon(); + + $uri = $commit->getURI(); + + $is_disabled = $status->isNoAudit(); + } else { + $text = pht('No Audit'); + $color = 'grey'; + $icon = 'fa-times'; + $uri = null; + + $is_disabled = true; } - return $this->renderBuildable($buildable, 'button'); + $item_view->newAction() + ->setIcon($icon.' '.$color) + ->setName($text) + ->setHref($uri) + ->setDisabled($is_disabled); } private function getBuildable(PhabricatorRepositoryCommit $commit) { @@ -428,28 +532,6 @@ return $this->buildableMap; } - private function newRevisionView($hash) { - $commit = $this->getCommit($hash); - if (!$commit) { - return null; - } - - $revisions = $this->getRevisions($commit); - if (!$revisions) { - return null; - } - - $revision = head($revisions); - - return id(new PHUITagView()) - ->setName($revision->getMonogram()) - ->setType(PHUITagView::TYPE_SHADE) - ->setColor(PHUITagView::COLOR_BLUE) - ->setHref($revision->getURI()) - ->setBorder(PHUITagView::BORDER_NONE) - ->setSlimShady(true); - } - private function getRevisions(PhabricatorRepositoryCommit $commit) { $revision_map = $this->getRevisionMap(); return idx($revision_map, $commit->getPHID(), array()); @@ -510,4 +592,21 @@ return $commits; } + private function newAuditorList( + PhabricatorRepositoryCommit $commit, + $handles) { + + $auditors = $commit->getAudits(); + if (!$auditors) { + return phutil_tag('em', array(), pht('None')); + } + + $auditor_phids = mpull($auditors, 'getAuditorPHID'); + $auditor_list = $handles->newSublist($auditor_phids) + ->renderList() + ->setAsInline(true); + + return $auditor_list; + } + } diff --git a/src/view/phui/PHUIObjectItemView.php b/src/view/phui/PHUIObjectItemView.php --- a/src/view/phui/PHUIObjectItemView.php +++ b/src/view/phui/PHUIObjectItemView.php @@ -16,6 +16,7 @@ private $bylines = array(); private $grippable; private $actions = array(); + private $actionItems = array(); private $headIcons = array(); private $disabled; private $imageURI; @@ -29,6 +30,7 @@ private $coverImage; private $description; private $clickable; + private $propertyLists = array(); private $selectableName; private $selectableValue; @@ -212,6 +214,18 @@ return $this; } + public function newAction() { + $action = new PhabricatorActionView(); + $this->actionItems[] = $action; + return $action; + } + + public function newPropertyList() { + $list = new PHUIPropertyListView(); + $this->propertyLists[] = $list; + return $list; + } + /** * This method has been deprecated, use @{method:setImageIcon} instead. * @@ -598,6 +612,14 @@ ''); } + $property_lists = null; + if ($this->propertyLists) { + $property_lists[] = phutil_tag( + 'div', + array(), + $this->propertyLists); + } + $content = phutil_tag( 'div', array( @@ -606,6 +628,7 @@ array( $subhead, $attrs, + $property_lists, $this->renderChildren(), )); @@ -733,6 +756,23 @@ )); } + $column4 = null; + if ($this->actionItems) { + $action_list = id(new PhabricatorActionListView()) + ->setViewer($viewer); + + foreach ($this->actionItems as $action_item) { + $action_list->addAction($action_item); + } + + $column4 = phutil_tag( + 'div', + array( + 'class' => 'phui-oi-col2 phui-oi-action-list', + ), + $action_list); + } + $table = phutil_tag( 'div', array( @@ -745,6 +785,7 @@ $column1, $column2, $column3, + $column4, ))); $box = phutil_tag( diff --git a/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css b/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css --- a/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css +++ b/webroot/rsrc/css/phui/object-item/phui-oi-list-view.css @@ -725,3 +725,9 @@ padding: 8px 0; background: linear-gradient({$lightbluebackground}, #fff 66%, #fff); } + +.phui-oi-action-list { + background: {$lightbluebackground}; + border-left: 1px solid {$thinblueborder}; + padding: 4px; +}