[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorOwnersDetailController 4 extends PhabricatorOwnersController { 5 6 private $id; 7 private $package; 8 9 public function willProcessRequest(array $data) { 10 $this->id = $data['id']; 11 } 12 13 public function processRequest() { 14 $request = $this->getRequest(); 15 $user = $request->getUser(); 16 17 $package = id(new PhabricatorOwnersPackage())->load($this->id); 18 if (!$package) { 19 return new Aphront404Response(); 20 } 21 $this->package = $package; 22 23 $paths = $package->loadPaths(); 24 $owners = $package->loadOwners(); 25 26 $repository_phids = array(); 27 foreach ($paths as $path) { 28 $repository_phids[$path->getRepositoryPHID()] = true; 29 } 30 31 if ($repository_phids) { 32 $repositories = id(new PhabricatorRepositoryQuery()) 33 ->setViewer($user) 34 ->withPHIDs(array_keys($repository_phids)) 35 ->execute(); 36 $repositories = mpull($repositories, null, 'getPHID'); 37 } else { 38 $repositories = array(); 39 } 40 41 $phids = array(); 42 foreach ($owners as $owner) { 43 $phids[$owner->getUserPHID()] = true; 44 } 45 $phids = array_keys($phids); 46 47 $handles = $this->loadViewerHandles($phids); 48 49 $rows = array(); 50 51 $rows[] = array(pht('Name'), $package->getName()); 52 $rows[] = array(pht('Description'), $package->getDescription()); 53 54 $primary_owner = null; 55 $primary_phid = $package->getPrimaryOwnerPHID(); 56 if ($primary_phid && isset($handles[$primary_phid])) { 57 $primary_owner = phutil_tag( 58 'strong', 59 array(), 60 $handles[$primary_phid]->renderLink()); 61 } 62 $rows[] = array(pht('Primary Owner'), $primary_owner); 63 64 $owner_links = array(); 65 foreach ($owners as $owner) { 66 $owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); 67 } 68 $owner_links = phutil_implode_html(phutil_tag('br'), $owner_links); 69 $rows[] = array(pht('Owners'), $owner_links); 70 71 $rows[] = array( 72 pht('Auditing'), 73 $package->getAuditingEnabled() ? 74 pht('Enabled') : 75 pht('Disabled'), 76 ); 77 78 $path_links = array(); 79 foreach ($paths as $path) { 80 $repo = idx($repositories, $path->getRepositoryPHID()); 81 if (!$repo) { 82 continue; 83 } 84 $href = DiffusionRequest::generateDiffusionURI( 85 array( 86 'callsign' => $repo->getCallsign(), 87 'branch' => $repo->getDefaultBranch(), 88 'path' => $path->getPath(), 89 'action' => 'browse', 90 )); 91 $repo_name = phutil_tag('strong', array(), $repo->getName()); 92 $path_link = phutil_tag( 93 'a', 94 array( 95 'href' => (string) $href, 96 ), 97 $path->getPath()); 98 $path_links[] = hsprintf( 99 '%s %s %s', 100 ($path->getExcluded() ? "\xE2\x80\x93" : '+'), 101 $repo_name, 102 $path_link); 103 } 104 $path_links = phutil_implode_html(phutil_tag('br'), $path_links); 105 $rows[] = array(pht('Paths'), $path_links); 106 107 $table = new AphrontTableView($rows); 108 $table->setColumnClasses( 109 array( 110 'header', 111 'wide', 112 )); 113 114 $panel = new AphrontPanelView(); 115 $panel->setNoBackground(); 116 $panel->setHeader( 117 pht('Package Details for "%s"', $package->getName())); 118 $panel->addButton( 119 javelin_tag( 120 'a', 121 array( 122 'href' => '/owners/delete/'.$package->getID().'/', 123 'class' => 'button grey', 124 'sigil' => 'workflow', 125 ), 126 pht('Delete Package'))); 127 $panel->addButton( 128 phutil_tag( 129 'a', 130 array( 131 'href' => '/owners/edit/'.$package->getID().'/', 132 'class' => 'button', 133 ), 134 pht('Edit Package'))); 135 $panel->appendChild($table); 136 137 $key = 'package/'.$package->getID(); 138 $this->setSideNavFilter($key); 139 140 $commit_views = array(); 141 142 $commit_uri = id(new PhutilURI('/audit/')) 143 ->setQueryParams( 144 array( 145 'auditorPHIDs' => $package->getPHID(), 146 )); 147 148 $attention_commits = id(new DiffusionCommitQuery()) 149 ->setViewer($request->getUser()) 150 ->withAuditorPHIDs(array($package->getPHID())) 151 ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN) 152 ->needCommitData(true) 153 ->setLimit(10) 154 ->execute(); 155 if ($attention_commits) { 156 $view = id(new PhabricatorAuditListView()) 157 ->setUser($user) 158 ->setCommits($attention_commits); 159 160 $commit_views[] = array( 161 'view' => $view, 162 'header' => pht('Commits in this Package that Need Attention'), 163 'button' => phutil_tag( 164 'a', 165 array( 166 'href' => $commit_uri->alter('status', 'open'), 167 'class' => 'button grey', 168 ), 169 pht('View All Problem Commits')), 170 ); 171 } 172 173 $all_commits = id(new DiffusionCommitQuery()) 174 ->setViewer($request->getUser()) 175 ->withAuditorPHIDs(array($package->getPHID())) 176 ->needCommitData(true) 177 ->setLimit(100) 178 ->execute(); 179 180 $view = id(new PhabricatorAuditListView()) 181 ->setUser($user) 182 ->setCommits($all_commits) 183 ->setNoDataString(pht('No commits in this package.')); 184 185 $commit_views[] = array( 186 'view' => $view, 187 'header' => pht('Recent Commits in Package'), 188 'button' => phutil_tag( 189 'a', 190 array( 191 'href' => $commit_uri, 192 'class' => 'button grey', 193 ), 194 pht('View All Package Commits')), 195 ); 196 197 $phids = array(); 198 foreach ($commit_views as $commit_view) { 199 $phids[] = $commit_view['view']->getRequiredHandlePHIDs(); 200 } 201 $phids = array_mergev($phids); 202 $handles = $this->loadViewerHandles($phids); 203 204 $commit_panels = array(); 205 foreach ($commit_views as $commit_view) { 206 $commit_panel = new AphrontPanelView(); 207 $commit_panel->setNoBackground(); 208 $commit_panel->setHeader($commit_view['header']); 209 if (isset($commit_view['button'])) { 210 $commit_panel->addButton($commit_view['button']); 211 } 212 $commit_view['view']->setHandles($handles); 213 $commit_panel->appendChild($commit_view['view']); 214 215 $commit_panels[] = $commit_panel; 216 } 217 218 $nav = $this->buildSideNavView(); 219 $nav->appendChild($panel); 220 $nav->appendChild($commit_panels); 221 222 return $this->buildApplicationPage( 223 array( 224 $nav, 225 ), 226 array( 227 'title' => pht('Package %s', $package->getName()), 228 )); 229 } 230 231 protected function getExtraPackageViews(AphrontSideNavFilterView $view) { 232 $package = $this->package; 233 $view->addFilter('package/'.$package->getID(), pht('Details')); 234 } 235 236 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |