@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 Owners package view UI elements

Summary: Ref T8320. Use modern/standard UI elements to render package details.

Test Plan: {F437131}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8320

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

+150 -104
+12 -12
resources/celerity/map.php
··· 7 7 */ 8 8 return array( 9 9 'names' => array( 10 - 'core.pkg.css' => '439658b5', 10 + 'core.pkg.css' => '4e7df908', 11 11 'core.pkg.js' => '328799d0', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => '30602b8c', ··· 134 134 'rsrc/css/phui/phui-document.css' => '94d5dcd8', 135 135 'rsrc/css/phui/phui-feed-story.css' => 'c9f3a0b5', 136 136 'rsrc/css/phui/phui-fontkit.css' => 'dd8ddf27', 137 - 'rsrc/css/phui/phui-form-view.css' => '79793450', 137 + 'rsrc/css/phui/phui-form-view.css' => '808329f2', 138 138 'rsrc/css/phui/phui-form.css' => 'f535f938', 139 139 'rsrc/css/phui/phui-header-view.css' => '75aaf372', 140 140 'rsrc/css/phui/phui-icon.css' => 'bc766998', ··· 443 443 'rsrc/js/core/behavior-device.js' => 'a205cf28', 444 444 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e', 445 445 'rsrc/js/core/behavior-error-log.js' => '6882e80a', 446 - 'rsrc/js/core/behavior-fancy-datepicker.js' => '5c0f680f', 446 + 'rsrc/js/core/behavior-fancy-datepicker.js' => '510b5809', 447 447 'rsrc/js/core/behavior-file-tree.js' => '88236f00', 448 448 'rsrc/js/core/behavior-form.js' => '5c54cbf3', 449 449 'rsrc/js/core/behavior-gesture.js' => '3ab51e2c', ··· 576 576 'javelin-behavior-durable-column' => '16c695bf', 577 577 'javelin-behavior-error-log' => '6882e80a', 578 578 'javelin-behavior-event-all-day' => '38dcf3c8', 579 - 'javelin-behavior-fancy-datepicker' => '5c0f680f', 579 + 'javelin-behavior-fancy-datepicker' => '510b5809', 580 580 'javelin-behavior-global-drag-and-drop' => 'c8e57404', 581 581 'javelin-behavior-herald-rule-editor' => '7ebaeed3', 582 582 'javelin-behavior-high-security-warning' => 'a464fe03', ··· 776 776 'phui-font-icon-base-css' => '3dad2ae3', 777 777 'phui-fontkit-css' => 'dd8ddf27', 778 778 'phui-form-css' => 'f535f938', 779 - 'phui-form-view-css' => '79793450', 779 + 'phui-form-view-css' => '808329f2', 780 780 'phui-header-view-css' => '75aaf372', 781 781 'phui-icon-view-css' => 'bc766998', 782 782 'phui-image-mask-css' => '5a8b09c8', ··· 1175 1175 'javelin-typeahead-source', 1176 1176 'javelin-util', 1177 1177 ), 1178 + '510b5809' => array( 1179 + 'javelin-behavior', 1180 + 'javelin-util', 1181 + 'javelin-dom', 1182 + 'javelin-stratcom', 1183 + 'javelin-vector', 1184 + ), 1178 1185 '519705ea' => array( 1179 1186 'javelin-install', 1180 1187 'javelin-dom', ··· 1241 1248 'javelin-mask', 1242 1249 'javelin-uri', 1243 1250 'javelin-routable', 1244 - ), 1245 - '5c0f680f' => array( 1246 - 'javelin-behavior', 1247 - 'javelin-util', 1248 - 'javelin-dom', 1249 - 'javelin-stratcom', 1250 - 'javelin-vector', 1251 1251 ), 1252 1252 '5c54cbf3' => array( 1253 1253 'javelin-behavior',
+138 -92
src/applications/owners/controller/PhabricatorOwnersDetailController.php
··· 19 19 } 20 20 21 21 $paths = $package->loadPaths(); 22 - $owners = $package->loadOwners(); 23 22 24 23 $repository_phids = array(); 25 24 foreach ($paths as $path) { ··· 36 35 $repositories = array(); 37 36 } 38 37 39 - $phids = array(); 40 - foreach ($owners as $owner) { 41 - $phids[$owner->getUserPHID()] = true; 42 - } 43 - $phids = array_keys($phids); 44 - 45 - $handles = $this->loadViewerHandles($phids); 38 + $actions = $this->buildPackageActionView($package); 39 + $properties = $this->buildPackagePropertyView($package); 40 + $properties->setActionList($actions); 46 41 47 - $rows = array(); 48 - 49 - $rows[] = array(pht('Name'), $package->getName()); 50 - $rows[] = array(pht('Description'), $package->getDescription()); 51 - 52 - $primary_owner = null; 53 - $primary_phid = $package->getPrimaryOwnerPHID(); 54 - if ($primary_phid && isset($handles[$primary_phid])) { 55 - $primary_owner = phutil_tag( 56 - 'strong', 57 - array(), 58 - $handles[$primary_phid]->renderLink()); 59 - } 60 - $rows[] = array(pht('Primary Owner'), $primary_owner); 61 - 62 - $owner_links = array(); 63 - foreach ($owners as $owner) { 64 - $owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); 65 - } 66 - $owner_links = phutil_implode_html(phutil_tag('br'), $owner_links); 67 - $rows[] = array(pht('Owners'), $owner_links); 42 + $header = id(new PHUIHeaderView()) 43 + ->setUser($viewer) 44 + ->setHeader($package->getName()) 45 + ->setPolicyObject($package); 68 46 69 - $rows[] = array( 70 - pht('Auditing'), 71 - $package->getAuditingEnabled() ? 72 - pht('Enabled') : 73 - pht('Disabled'), 74 - ); 75 - 76 - $path_links = array(); 77 - foreach ($paths as $path) { 78 - $repo = idx($repositories, $path->getRepositoryPHID()); 79 - if (!$repo) { 80 - continue; 81 - } 82 - $href = DiffusionRequest::generateDiffusionURI( 83 - array( 84 - 'callsign' => $repo->getCallsign(), 85 - 'branch' => $repo->getDefaultBranch(), 86 - 'path' => $path->getPath(), 87 - 'action' => 'browse', 88 - )); 89 - $repo_name = phutil_tag('strong', array(), $repo->getName()); 90 - $path_link = phutil_tag( 91 - 'a', 92 - array( 93 - 'href' => (string)$href, 94 - ), 95 - $path->getPath()); 96 - $path_links[] = hsprintf( 97 - '%s %s %s', 98 - ($path->getExcluded() ? "\xE2\x80\x93" : '+'), 99 - $repo_name, 100 - $path_link); 101 - } 102 - $path_links = phutil_implode_html(phutil_tag('br'), $path_links); 103 - $rows[] = array(pht('Paths'), $path_links); 104 - 105 - $table = new AphrontTableView($rows); 106 - $table->setColumnClasses( 107 - array( 108 - 'header', 109 - 'wide', 110 - )); 111 - 112 - $panel = new PHUIObjectBoxView(); 113 - $header = new PHUIHeaderView(); 114 - $header->setHeader( 115 - pht('Package Details for "%s"', $package->getName())); 116 - $header->addActionLink( 117 - id(new PHUIButtonView()) 118 - ->setTag('a') 119 - ->setHref('/owners/delete/'.$package->getID().'/') 120 - ->addSigil('workflow') 121 - ->setText(pht('Delete Package'))); 122 - 123 - $header->addActionLink( 124 - id(new PHUIButtonView()) 125 - ->setTag('a') 126 - ->setHref('/owners/edit/'.$package->getID().'/') 127 - ->setText(pht('Edit Package'))); 128 - 129 - $panel->setHeader($header); 130 - $panel->appendChild($table); 47 + $panel = id(new PHUIObjectBoxView()) 48 + ->setHeader($header) 49 + ->addPropertyList($properties); 131 50 132 51 $commit_views = array(); 133 52 ··· 209 128 array( 210 129 $crumbs, 211 130 $panel, 131 + $this->renderPathsTable($paths, $repositories), 212 132 $commit_panels, 213 133 ), 214 134 array( 215 - 'title' => pht('Package %s', $package->getName()), 135 + 'title' => $package->getName(), 216 136 )); 137 + } 138 + 139 + 140 + private function buildPackagePropertyView(PhabricatorOwnersPackage $package) { 141 + $viewer = $this->getViewer(); 142 + 143 + $view = id(new PHUIPropertyListView()) 144 + ->setUser($viewer); 145 + 146 + $primary_phid = $package->getPrimaryOwnerPHID(); 147 + if ($primary_phid) { 148 + $primary_owner = $viewer->renderHandle($primary_phid); 149 + } else { 150 + $primary_owner = phutil_tag('em', array(), pht('None')); 151 + } 152 + $view->addProperty(pht('Primary Owner'), $primary_owner); 153 + 154 + // TODO: needOwners() this on the Query. 155 + $owners = $package->loadOwners(); 156 + if ($owners) { 157 + $owner_list = $viewer->renderHandleList(mpull($owners, 'getUserPHID')); 158 + } else { 159 + $owner_list = phutil_tag('em', array(), pht('None')); 160 + } 161 + $view->addProperty(pht('Owners'), $owner_list); 162 + 163 + if ($package->getAuditingEnabled()) { 164 + $auditing = pht('Enabled'); 165 + } else { 166 + $auditing = pht('Disabled'); 167 + } 168 + $view->addProperty(pht('Auditing'), $auditing); 169 + 170 + $description = $package->getDescription(); 171 + if (strlen($description)) { 172 + $view->addSectionHeader(pht('Description')); 173 + $view->addTextContent( 174 + $output = PhabricatorMarkupEngine::renderOneObject( 175 + id(new PhabricatorMarkupOneOff())->setContent($description), 176 + 'default', 177 + $viewer)); 178 + } 179 + 180 + return $view; 181 + } 182 + 183 + private function buildPackageActionView(PhabricatorOwnersPackage $package) { 184 + $viewer = $this->getViewer(); 185 + 186 + // TODO: Implement this capability. 187 + $can_edit = true; 188 + 189 + $id = $package->getID(); 190 + $edit_uri = $this->getApplicationURI("/edit/{$id}/"); 191 + $delete_uri = $this->getApplicationURI("/delete/{$id}/"); 192 + 193 + $view = id(new PhabricatorActionListView()) 194 + ->setUser($viewer) 195 + ->setObject($package) 196 + ->addAction( 197 + id(new PhabricatorActionView()) 198 + ->setName(pht('Edit Package')) 199 + ->setIcon('fa-pencil') 200 + ->setDisabled(!$can_edit) 201 + ->setWorkflow(!$can_edit) 202 + ->setHref($edit_uri)) 203 + ->addAction( 204 + id(new PhabricatorActionView()) 205 + ->setName(pht('Delete Package')) 206 + ->setIcon('fa-times') 207 + ->setDisabled(!$can_edit) 208 + ->setWorkflow(true) 209 + ->setHref($delete_uri)); 210 + 211 + return $view; 212 + } 213 + 214 + private function renderPathsTable(array $paths, array $repositories) { 215 + $viewer = $this->getViewer(); 216 + 217 + $rows = array(); 218 + foreach ($paths as $path) { 219 + $repo = idx($repositories, $path->getRepositoryPHID()); 220 + if (!$repo) { 221 + continue; 222 + } 223 + $href = DiffusionRequest::generateDiffusionURI( 224 + array( 225 + 'callsign' => $repo->getCallsign(), 226 + 'branch' => $repo->getDefaultBranch(), 227 + 'path' => $path->getPath(), 228 + 'action' => 'browse', 229 + )); 230 + 231 + $path_link = phutil_tag( 232 + 'a', 233 + array( 234 + 'href' => (string)$href, 235 + ), 236 + $path->getPath()); 237 + 238 + $rows[] = array( 239 + ($path->getExcluded() ? '-' : '+'), 240 + $repo->getName(), 241 + $path_link, 242 + ); 243 + } 244 + 245 + $table = id(new AphrontTableView($rows)) 246 + ->setHeaders( 247 + array( 248 + null, 249 + pht('Repository'), 250 + pht('Path'), 251 + )) 252 + ->setColumnClasses( 253 + array( 254 + null, 255 + null, 256 + 'wide', 257 + )); 258 + 259 + return id(new PHUIObjectBoxView()) 260 + ->setHeaderText(pht('Paths')) 261 + ->appendChild($table); 262 + 217 263 } 218 264 219 265 }