@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.

Add an internal service ref panel to repository "Storage" information

Summary: Ref T13611. Currently, the "writable" property on service bindings has no effect because of a trivial bug. Provide more information in the UI to make this kind of problem observable.

Test Plan:
Viewed "Storage" section of management UI, saw a more-obvious problem with ref management (a non-writable ref is listed as writable).

{F8465851}

Maniphest Tasks: T13611

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

+127
+127
src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php
··· 46 46 return array( 47 47 $this->buildStorageStatusPanel(), 48 48 $this->buildClusterStatusPanel(), 49 + $this->buildRefsStatusPanels(), 49 50 ); 50 51 } 51 52 ··· 249 250 250 251 return $this->newBox(pht('Cluster Status'), $table); 251 252 } 253 + 254 + private function buildRefsStatusPanels() { 255 + $repository = $this->getRepository(); 256 + 257 + $service_phid = $repository->getAlmanacServicePHID(); 258 + if (!$service_phid) { 259 + // If this repository isn't clustered, don't bother rendering anything. 260 + // There are enough other context clues that another empty panel isn't 261 + // useful. 262 + return; 263 + } 264 + 265 + $all_protocols = array( 266 + 'http', 267 + 'https', 268 + 'ssh', 269 + ); 270 + 271 + $readable_panel = $this->buildRefsStatusPanel( 272 + pht('Readable Service Refs'), 273 + array( 274 + 'neverProxy' => false, 275 + 'protocols' => $all_protocols, 276 + 'writable' => false, 277 + )); 278 + 279 + $writable_panel = $this->buildRefsStatusPanel( 280 + pht('Writable Service Refs'), 281 + array( 282 + 'neverProxy' => false, 283 + 'protocols' => $all_protocols, 284 + 'writable' => true, 285 + )); 286 + 287 + return array( 288 + $readable_panel, 289 + $writable_panel, 290 + ); 291 + } 292 + 293 + private function buildRefsStatusPanel( 294 + $title, 295 + $options) { 296 + 297 + $repository = $this->getRepository(); 298 + $viewer = $this->getViewer(); 299 + 300 + $caught = null; 301 + try { 302 + $refs = $repository->getAlmanacServiceRefs($viewer, $options); 303 + } catch (Exception $ex) { 304 + $caught = $ex; 305 + } catch (Throwable $ex) { 306 + $caught = $ex; 307 + } 308 + 309 + $info_view = null; 310 + if ($caught) { 311 + $refs = array(); 312 + $info_view = id(new PHUIInfoView()) 313 + ->setErrors( 314 + array( 315 + phutil_escape_html_newlines($caught->getMessage()), 316 + )); 317 + } 318 + 319 + $phids = array(); 320 + foreach ($refs as $ref) { 321 + $phids[] = $ref->getDevicePHID(); 322 + } 323 + 324 + $handles = $viewer->loadHandles($phids); 325 + 326 + $icon_writable = id(new PHUIIconView()) 327 + ->setIcon('fa-pencil', 'green'); 328 + 329 + $icon_unwritable = id(new PHUIIconView()) 330 + ->setIcon('fa-times', 'grey'); 331 + 332 + $rows = array(); 333 + foreach ($refs as $ref) { 334 + $device_phid = $ref->getDevicePHID(); 335 + $device_handle = $handles[$device_phid]; 336 + 337 + if ($ref->isWritable()) { 338 + $writable_icon = $icon_writable; 339 + $writable_text = pht('Read/Write'); 340 + } else { 341 + $writable_icon = $icon_unwritable; 342 + $writable_text = pht('Read Only'); 343 + } 344 + 345 + $rows[] = array( 346 + $device_handle->renderLink(), 347 + $ref->getURI(), 348 + $writable_icon, 349 + $writable_text, 350 + ); 351 + } 352 + 353 + $table = id(new AphrontTableView($rows)) 354 + ->setNoDataString(pht('No repository service refs available.')) 355 + ->setHeaders( 356 + array( 357 + pht('Device'), 358 + pht('Internal Service URI'), 359 + null, 360 + pht('I/O'), 361 + )) 362 + ->setColumnClasses( 363 + array( 364 + null, 365 + 'wide', 366 + 'icon', 367 + null, 368 + )); 369 + 370 + $box_view = $this->newBox($title, $table); 371 + 372 + if ($info_view) { 373 + $box_view->setInfoView($info_view); 374 + } 375 + 376 + return $box_view; 377 + } 378 + 252 379 253 380 private function isDisabledGroup(array $binding_group) { 254 381 assert_instances_of($binding_group, 'AlmanacBinding');