@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize Audit

Summary: Adds mobile support to Audit, converts tables to object item views. I also colored 'concerns' and 'audit required' in the list, but nothing else. We can add more if needed but I'm assuming these are the two most important cases.

Test Plan: Tested as much as I could, a little unsure of a few things since my local repo isn't super filled. Will let epriestley run through.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5962

+153 -142
+8 -8
src/applications/audit/constants/PhabricatorAuditActionConstants.php
··· 11 11 const ADD_AUDITORS = 'add_auditors'; 12 12 13 13 public static function getActionNameMap() { 14 - static $map = array( 15 - self::COMMENT => 'Comment', 16 - self::CONCERN => "Raise Concern \xE2\x9C\x98", 17 - self::ACCEPT => "Accept Commit \xE2\x9C\x94", 18 - self::RESIGN => 'Resign from Audit', 19 - self::CLOSE => 'Close Audit', 20 - self::ADD_CCS => 'Add CCs', 21 - self::ADD_AUDITORS => 'Add Auditors', 14 + $map = array( 15 + self::COMMENT => pht('Comment'), 16 + self::CONCERN => pht("Raise Concern \xE2\x9C\x98"), 17 + self::ACCEPT => pht("Accept Commit \xE2\x9C\x94"), 18 + self::RESIGN => pht('Resign from Audit'), 19 + self::CLOSE => pht('Close Audit'), 20 + self::ADD_CCS => pht('Add CCs'), 21 + self::ADD_AUDITORS => pht('Add Auditors'), 22 22 ); 23 23 24 24 return $map;
+6 -6
src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php
··· 9 9 const FULLY_AUDITED = 4; 10 10 11 11 public static function getStatusNameMap() { 12 - static $map = array( 13 - self::NONE => 'None', 14 - self::NEEDS_AUDIT => 'Audit Required', 15 - self::CONCERN_RAISED => 'Concern Raised', 16 - self::PARTIALLY_AUDITED => 'Partially Audited', 17 - self::FULLY_AUDITED => 'Audited', 12 + $map = array( 13 + self::NONE => pht('None'), 14 + self::NEEDS_AUDIT => pht('Audit Required'), 15 + self::CONCERN_RAISED => pht('Concern Raised'), 16 + self::PARTIALLY_AUDITED => pht('Partially Audited'), 17 + self::FULLY_AUDITED => pht('Audited'), 18 18 ); 19 19 20 20 return $map;
+26 -11
src/applications/audit/constants/PhabricatorAuditStatusConstants.php
··· 13 13 const CC = 'cc'; 14 14 15 15 public static function getStatusNameMap() { 16 - static $map = array( 17 - self::NONE => 'Not Applicable', 18 - self::AUDIT_NOT_REQUIRED => 'Audit Not Required', 19 - self::AUDIT_REQUIRED => 'Audit Required', 20 - self::CONCERNED => 'Concern Raised', 21 - self::ACCEPTED => 'Accepted', 22 - self::AUDIT_REQUESTED => 'Audit Requested', 23 - self::RESIGNED => 'Resigned', 24 - self::CLOSED => 'Closed', 25 - self::CC => "Was CC'd", 16 + $map = array( 17 + self::NONE => pht('Not Applicable'), 18 + self::AUDIT_NOT_REQUIRED => pht('Audit Not Required'), 19 + self::AUDIT_REQUIRED => pht('Audit Required'), 20 + self::CONCERNED => pht('Concern Raised'), 21 + self::ACCEPTED => pht('Accepted'), 22 + self::AUDIT_REQUESTED => pht('Audit Requested'), 23 + self::RESIGNED => pht('Resigned'), 24 + self::CLOSED => pht('Closed'), 25 + self::CC => pht("Was CC'd"), 26 26 ); 27 27 28 28 return $map; 29 29 } 30 30 31 31 public static function getStatusName($code) { 32 - return idx(self::getStatusNameMap(), $code, 'Unknown'); 32 + return idx(self::getStatusNameMap(), $code, pht('Unknown')); 33 + } 34 + 35 + public static function getStatusColor($code) { 36 + switch ($code) { 37 + case self::CONCERNED: 38 + $color = 'orange'; 39 + break; 40 + case self::AUDIT_REQUIRED: 41 + $color = 'red'; 42 + break; 43 + default: 44 + $color = null; 45 + break; 46 + } 47 + return $color; 33 48 } 34 49 35 50 public static function getOpenStatusConstants() {
+30
src/applications/audit/controller/PhabricatorAuditController.php
··· 2 2 3 3 abstract class PhabricatorAuditController extends PhabricatorController { 4 4 5 + public $filter; 6 + 7 + public function buildSideNavView() { 8 + 9 + $nav = new AphrontSideNavFilterView(); 10 + $nav->setBaseURI(new PhutilURI('/audit/view/')); 11 + $nav->addLabel(pht('Active')); 12 + $nav->addFilter('active', pht('Need Attention')); 13 + 14 + $nav->addLabel(pht('Audits')); 15 + $nav->addFilter('audits', pht('All')); 16 + $nav->addFilter('user', pht('By User')); 17 + $nav->addFilter('project', pht('By Project')); 18 + $nav->addFilter('package', pht('By Package')); 19 + $nav->addFilter('repository', pht('By Repository')); 20 + 21 + $nav->addLabel(pht('Commits')); 22 + $nav->addFilter('commits', pht('All')); 23 + $nav->addFilter('author', pht('By Author')); 24 + $nav->addFilter('packagecommits', pht('By Package')); 25 + 26 + $this->filter = $nav->selectFilter($this->filter, 'active'); 27 + 28 + return $nav; 29 + } 30 + 31 + public function buildApplicationMenu() { 32 + return $this->buildSideNavView()->getMenu(); 33 + } 34 + 5 35 public function buildStandardPageResponse($view, array $data) { 6 36 7 37 $page = $this->buildStandardPageView();
+5 -27
src/applications/audit/controller/PhabricatorAuditListController.php
··· 2 2 3 3 final class PhabricatorAuditListController extends PhabricatorAuditController { 4 4 5 - private $filter; 6 5 private $name; 7 6 private $filterStatus; 8 7 ··· 13 12 14 13 public function processRequest() { 15 14 $request = $this->getRequest(); 16 - 17 - $nav = $this->buildNavAndSelectFilter(); 15 + $nav = $this->buildSideNavView(); 18 16 19 17 if ($request->isFormPost()) { 20 18 // If the list filter is POST'ed, redirect to GET so the page can be ··· 75 73 $nav->appendChild($panel); 76 74 } 77 75 78 - return $this->buildStandardPageResponse( 76 + return $this->buildApplicationPage( 79 77 $nav, 80 78 array( 81 79 'title' => pht('Audits'), 80 + 'device' => true, 81 + 'dust' => true, 82 82 )); 83 83 } 84 84 85 - private function buildNavAndSelectFilter() { 86 - $nav = new AphrontSideNavFilterView(); 87 - $nav->setBaseURI(new PhutilURI('/audit/view/')); 88 - $nav->addLabel(pht('Active')); 89 - $nav->addFilter('active', pht('Need Attention')); 90 - 91 - $nav->addLabel(pht('Audits')); 92 - $nav->addFilter('audits', pht('All')); 93 - $nav->addFilter('user', pht('By User')); 94 - $nav->addFilter('project', pht('By Project')); 95 - $nav->addFilter('package', pht('By Package')); 96 - $nav->addFilter('repository', pht('By Repository')); 97 - 98 - $nav->addLabel(pht('Commits')); 99 - $nav->addFilter('commits', pht('All')); 100 - $nav->addFilter('author', pht('By Author')); 101 - $nav->addFilter('packagecommits', pht('By Package')); 102 - 103 - $this->filter = $nav->selectFilter($this->filter, 'active'); 104 - 105 - return $nav; 106 - } 107 - 108 85 private function buildListFilters(PhabricatorObjectHandle $handle = null) { 109 86 $request = $this->getRequest(); 110 87 $user = $request->getUser(); 111 88 112 89 $form = new AphrontFormView(); 113 90 $form->setUser($user); 91 + $form->setNoShading(true); 114 92 115 93 $show_status = false; 116 94 $show_user = false;
+43 -40
src/applications/audit/view/PhabricatorAuditCommitListView.php
··· 13 13 14 14 public function setCommits(array $commits) { 15 15 assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 16 - $this->commits = $commits; 16 + $this->commits = mpull($commits, null, 'getPHID'); 17 17 return $this; 18 18 } 19 19 ··· 52 52 return $handle; 53 53 } 54 54 55 + private function getCommitDescription($phid) { 56 + if ($this->commits === null) { 57 + return null; 58 + } 59 + 60 + $commit = idx($this->commits, $phid); 61 + if (!$commit) { 62 + return null; 63 + } 64 + 65 + return $commit->getCommitData()->getSummary(); 66 + } 67 + 55 68 public function render() { 56 - $rows = array(); 69 + $list = new PhabricatorObjectItemListView(); 70 + $list->setCards(true); 71 + $list->setFlush(true); 57 72 foreach ($this->commits as $commit) { 58 - $commit_name = $this->getHandle($commit->getPHID())->renderLink(); 73 + $commit_phid = $commit->getPHID(); 74 + $commit_name = $this->getHandle($commit_phid)->getName(); 75 + $commit_link = $this->getHandle($commit_phid)->getURI(); 76 + $commit_desc = $this->getCommitDescription($commit_phid); 77 + 59 78 $author_name = null; 60 79 if ($commit->getAuthorPHID()) { 61 80 $author_name = $this->getHandle($commit->getAuthorPHID())->renderLink(); ··· 66 85 $actor_phid = $audit->getActorPHID(); 67 86 $auditors[$actor_phid] = $this->getHandle($actor_phid)->renderLink(); 68 87 } 88 + $auditors = phutil_implode_html(', ', $auditors); 69 89 } 70 - $rows[] = array( 71 - $commit_name, 72 - $author_name, 73 - PhabricatorAuditCommitStatusConstants::getStatusName( 74 - $commit->getAuditStatus()), 75 - phutil_implode_html(', ', $auditors), 76 - phabricator_datetime($commit->getEpoch(), $this->user), 77 - ); 78 - } 90 + $committed = phabricator_datetime($commit->getEpoch(), $this->user); 91 + $commit_status = PhabricatorAuditCommitStatusConstants::getStatusName( 92 + $commit->getAuditStatus()); 93 + 94 + $item = id(new PhabricatorObjectItemView()) 95 + ->setObjectName($commit_name) 96 + ->setHeader($commit_desc) 97 + ->setHref($commit_link) 98 + ->addAttribute($commit_status) 99 + ->addIcon('none', $committed); 100 + 101 + if (!empty($auditors)) { 102 + $item->addAttribute(pht('Auditors: %s', $auditors)); 103 + } 79 104 80 - $table = new AphrontTableView($rows); 81 - $table->setHeaders( 82 - array( 83 - 'Commit', 84 - 'Author', 85 - 'Audit Status', 86 - 'Auditors', 87 - 'Date', 88 - )); 89 - $table->setColumnClasses( 90 - array( 91 - 'wide', 92 - '', 93 - '', 94 - '', 95 - '', 96 - )); 105 + if ($author_name) { 106 + $item->addByline(pht('Author: %s', $author_name)); 107 + } 97 108 98 - if ($this->commits && reset($this->commits)->getAudits() === null) { 99 - $table->setColumnVisibility( 100 - array( 101 - true, 102 - true, 103 - true, 104 - false, 105 - true, 106 - )); 109 + $list->addItem($item); 107 110 } 108 111 109 112 if ($this->noDataString) { 110 - $table->setNoDataString($this->noDataString); 113 + $list->setNoDataString($this->noDataString); 111 114 } 112 115 113 - return $table->render(); 116 + return $list->render(); 114 117 } 115 118 116 119 }
+24 -43
src/applications/audit/view/PhabricatorAuditListView.php
··· 110 110 public function render() { 111 111 $rowc = array(); 112 112 113 - $rows = array(); 113 + $list = new PhabricatorObjectItemListView(); 114 + $list->setCards(true); 115 + $list->setFlush(true); 114 116 foreach ($this->audits as $audit) { 115 117 $commit_phid = $audit->getCommitPHID(); 116 118 $committed = null; 117 119 118 - $commit_name = $this->getHandle($commit_phid)->renderLink(); 120 + $commit_name = $this->getHandle($commit_phid)->getName(); 121 + $commit_link = $this->getHandle($commit_phid)->getURI(); 119 122 $commit_desc = $this->getCommitDescription($commit_phid); 120 123 $commit = idx($this->commits, $commit_phid); 121 124 if ($commit && $this->user) { ··· 123 126 } 124 127 125 128 $reasons = $audit->getAuditReasons(); 126 - $reasons = phutil_implode_html(phutil_tag('br'), $reasons); 129 + $reasons = phutil_implode_html(', ', $reasons); 127 130 128 131 $status_code = $audit->getAuditStatus(); 129 - $status = PhabricatorAuditStatusConstants::getStatusName($status_code); 132 + $status_text = 133 + PhabricatorAuditStatusConstants::getStatusName($status_code); 134 + $status_color = 135 + PhabricatorAuditStatusConstants::getStatusColor($status_code); 130 136 131 137 $auditor_handle = $this->getHandle($audit->getAuditorPHID()); 132 - $rows[] = array( 133 - $commit_name, 134 - $committed, 135 - $auditor_handle->renderLink(), 136 - $status, 137 - $reasons, 138 - ); 138 + $item = id(new PhabricatorObjectItemView()) 139 + ->setObjectName($commit_name) 140 + ->setHeader($commit_desc) 141 + ->setHref($commit_link) 142 + ->setBarColor($status_color) 143 + ->addAttribute($status_text) 144 + ->addAttribute($reasons) 145 + ->addIcon('none', $committed) 146 + ->addByline(pht('Auditor: %s', $auditor_handle->renderLink())); 139 147 140 - $row_class = null; 141 148 if (array_key_exists($audit->getID(), $this->getHighlightedAudits())) { 142 - $row_class = 'highlighted'; 149 + $item->setBarColor('yellow'); 143 150 } 144 - $rowc[] = $row_class; 151 + 152 + $list->addItem($item); 145 153 } 146 154 147 - $table = new AphrontTableView($rows); 148 - $table->setHeaders( 149 - array( 150 - 'Commit', 151 - 'Committed', 152 - 'Auditor', 153 - 'Status', 154 - 'Details', 155 - )); 156 - $table->setColumnClasses( 157 - array( 158 - 'pri', 159 - '', 160 - '', 161 - '', 162 - ($this->showCommits ? '' : 'wide'), 163 - )); 164 - $table->setRowClasses($rowc); 165 - $table->setColumnVisibility( 166 - array( 167 - $this->showCommits, 168 - $this->showCommits, 169 - true, 170 - true, 171 - true, 172 - )); 173 - 174 155 if ($this->noDataString) { 175 - $table->setNoDataString($this->noDataString); 156 + $list->setNoDataString($this->noDataString); 176 157 } 177 158 178 - return $table->render(); 159 + return $list->render(); 179 160 } 180 161 181 162 }
+6 -7
src/applications/diffusion/controller/DiffusionCommitController.php
··· 359 359 $content, 360 360 array( 361 361 'title' => $commit_id, 362 + 'dust' => true, 362 363 )); 363 364 } 364 365 ··· 649 650 id(new AphrontFormSubmitControl()) 650 651 ->setValue($is_serious ? pht('Submit') : pht('Cook the Books'))); 651 652 652 - $panel = new AphrontPanelView(); 653 - $panel->setHeader( 653 + $header = new PhabricatorHeaderView(); 654 + $header->setHeader( 654 655 $is_serious ? pht('Audit Commit') : pht('Creative Accounting')); 655 - $panel->appendChild($form); 656 - $panel->addClass('aphront-panel-accent'); 657 - $panel->addClass('aphront-panel-flush'); 658 656 659 657 require_celerity_resource('phabricator-transaction-view-css'); 660 658 ··· 714 712 'id' => $pane_id, 715 713 ), 716 714 hsprintf( 717 - '<div class="differential-add-comment-panel">%s%s%s</div>', 715 + '<div class="differential-add-comment-panel">%s%s%s%s</div>', 718 716 id(new PhabricatorAnchorView()) 719 717 ->setAnchorName('comment') 720 718 ->setNavigationMarker(true) 721 719 ->render(), 722 - $panel->render(), 720 + $header, 721 + $form, 723 722 $preview_panel)); 724 723 } 725 724
+5
webroot/rsrc/css/layout/phabricator-object-item-list-view.css
··· 346 346 background: #bfdcff; 347 347 } 348 348 349 + .phabricator-object-list-flush .aphront-error-view { 350 + margin: 0; 351 + background: #fff; 352 + } 353 + 349 354 350 355 /* - Foot Icons ---------------------------------------------------------------- 351 356