mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
This commit is contained in:
parent
e9804bb7e5
commit
39077be746
1 changed files with 127 additions and 0 deletions
|
@ -46,6 +46,7 @@ final class DiffusionRepositoryStorageManagementPanel
|
||||||
return array(
|
return array(
|
||||||
$this->buildStorageStatusPanel(),
|
$this->buildStorageStatusPanel(),
|
||||||
$this->buildClusterStatusPanel(),
|
$this->buildClusterStatusPanel(),
|
||||||
|
$this->buildRefsStatusPanels(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +251,132 @@ final class DiffusionRepositoryStorageManagementPanel
|
||||||
return $this->newBox(pht('Cluster Status'), $table);
|
return $this->newBox(pht('Cluster Status'), $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildRefsStatusPanels() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
|
$service_phid = $repository->getAlmanacServicePHID();
|
||||||
|
if (!$service_phid) {
|
||||||
|
// If this repository isn't clustered, don't bother rendering anything.
|
||||||
|
// There are enough other context clues that another empty panel isn't
|
||||||
|
// useful.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$all_protocols = array(
|
||||||
|
'http',
|
||||||
|
'https',
|
||||||
|
'ssh',
|
||||||
|
);
|
||||||
|
|
||||||
|
$readable_panel = $this->buildRefsStatusPanel(
|
||||||
|
pht('Readable Service Refs'),
|
||||||
|
array(
|
||||||
|
'neverProxy' => false,
|
||||||
|
'protocols' => $all_protocols,
|
||||||
|
'writable' => false,
|
||||||
|
));
|
||||||
|
|
||||||
|
$writable_panel = $this->buildRefsStatusPanel(
|
||||||
|
pht('Writable Service Refs'),
|
||||||
|
array(
|
||||||
|
'neverProxy' => false,
|
||||||
|
'protocols' => $all_protocols,
|
||||||
|
'writable' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$readable_panel,
|
||||||
|
$writable_panel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildRefsStatusPanel(
|
||||||
|
$title,
|
||||||
|
$options) {
|
||||||
|
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$caught = null;
|
||||||
|
try {
|
||||||
|
$refs = $repository->getAlmanacServiceRefs($viewer, $options);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
$caught = $ex;
|
||||||
|
} catch (Throwable $ex) {
|
||||||
|
$caught = $ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
$info_view = null;
|
||||||
|
if ($caught) {
|
||||||
|
$refs = array();
|
||||||
|
$info_view = id(new PHUIInfoView())
|
||||||
|
->setErrors(
|
||||||
|
array(
|
||||||
|
phutil_escape_html_newlines($caught->getMessage()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$phids = array();
|
||||||
|
foreach ($refs as $ref) {
|
||||||
|
$phids[] = $ref->getDevicePHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
$handles = $viewer->loadHandles($phids);
|
||||||
|
|
||||||
|
$icon_writable = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-pencil', 'green');
|
||||||
|
|
||||||
|
$icon_unwritable = id(new PHUIIconView())
|
||||||
|
->setIcon('fa-times', 'grey');
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($refs as $ref) {
|
||||||
|
$device_phid = $ref->getDevicePHID();
|
||||||
|
$device_handle = $handles[$device_phid];
|
||||||
|
|
||||||
|
if ($ref->isWritable()) {
|
||||||
|
$writable_icon = $icon_writable;
|
||||||
|
$writable_text = pht('Read/Write');
|
||||||
|
} else {
|
||||||
|
$writable_icon = $icon_unwritable;
|
||||||
|
$writable_text = pht('Read Only');
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows[] = array(
|
||||||
|
$device_handle->renderLink(),
|
||||||
|
$ref->getURI(),
|
||||||
|
$writable_icon,
|
||||||
|
$writable_text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = id(new AphrontTableView($rows))
|
||||||
|
->setNoDataString(pht('No repository service refs available.'))
|
||||||
|
->setHeaders(
|
||||||
|
array(
|
||||||
|
pht('Device'),
|
||||||
|
pht('Internal Service URI'),
|
||||||
|
null,
|
||||||
|
pht('I/O'),
|
||||||
|
))
|
||||||
|
->setColumnClasses(
|
||||||
|
array(
|
||||||
|
null,
|
||||||
|
'wide',
|
||||||
|
'icon',
|
||||||
|
null,
|
||||||
|
));
|
||||||
|
|
||||||
|
$box_view = $this->newBox($title, $table);
|
||||||
|
|
||||||
|
if ($info_view) {
|
||||||
|
$box_view->setInfoView($info_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $box_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function isDisabledGroup(array $binding_group) {
|
private function isDisabledGroup(array $binding_group) {
|
||||||
assert_instances_of($binding_group, 'AlmanacBinding');
|
assert_instances_of($binding_group, 'AlmanacBinding');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue