2014-10-17 05:01:57 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class AlmanacServiceViewController
|
|
|
|
extends AlmanacServiceController {
|
|
|
|
|
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
|
|
|
|
$name = $request->getURIData('name');
|
|
|
|
|
|
|
|
$service = id(new AlmanacServiceQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withNames(array($name))
|
2016-02-22 12:53:40 -08:00
|
|
|
->needProperties(true)
|
2014-10-17 05:01:57 -07:00
|
|
|
->executeOne();
|
|
|
|
if (!$service) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = pht('Service %s', $service->getName());
|
|
|
|
|
|
|
|
$property_list = $this->buildPropertyList($service);
|
|
|
|
$action_list = $this->buildActionList($service);
|
|
|
|
$property_list->setActionList($action_list);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setHeader($service->getName())
|
|
|
|
->setPolicyObject($service);
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->addPropertyList($property_list);
|
|
|
|
|
2016-02-23 16:23:40 -08:00
|
|
|
if ($service->isClusterService()) {
|
|
|
|
$this->addClusterMessage(
|
2014-12-18 14:31:36 -08:00
|
|
|
$box,
|
2016-02-23 16:23:40 -08:00
|
|
|
pht('This is a cluster service.'),
|
|
|
|
pht(
|
|
|
|
'This service is a cluster service. You do not have permission to '.
|
|
|
|
'edit cluster services, so you can not edit this service.'));
|
2014-12-18 14:31:36 -08:00
|
|
|
}
|
|
|
|
|
Add AlmanacBinding, to bind a service to an interface
Summary: Ref T5833. Allows you to bind a service (like `db.example.com`) to one or more interfaces (for example, to specify a pool with one read/write host and two read-only hosts). You can't configure which hosts have which properties yet, but you can add all the relevant interfaces to the service. Next diff will start supporting service, binding, and device properties like "is writable", "is active", etc., so that Almanac will be able to express operations like "change which database is writable", "disable writes", "bring a device down", etc.
Test Plan: See screenshots.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5833
Differential Revision: https://secure.phabricator.com/D10745
2014-10-27 13:39:36 -07:00
|
|
|
$bindings = $this->buildBindingList($service);
|
|
|
|
|
2014-10-17 05:01:57 -07:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb($service->getName());
|
|
|
|
|
Transactions - deploy buildTransactionTimeline against a few more applications
Summary:
Ref T4712. Thus far, it seems that most "non-standard" things can be done pretty easily in the controller. Aside from deploying, this diff had to fix a few bugs / missing implementations of stuff.
(Notably, PhabricatorAuthProviderConfig, HeraldRule, PhabricatorSlowvotePoll, and AlmanacNetwork needed to implement PhabricatorApplicationTransactionInterface, PhabricatorAuthAuthProviderPHIDType had to be added, and a rendering bug in transactions of type PhabricatorOAuth2AuthProvider had to be fixed.)
Test Plan: Almanac - looked at binding, device, network, and service view controllers and verified timeline displayed properly. Herald - looked at a rule and verified timeline. Slowvote - looked at a vote and verified timeline. Auth - looked at an auth provider (Facebook) and verified proper display of transactions within timeline.
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T4712
Differential Revision: https://secure.phabricator.com/D10921
2014-12-02 14:33:59 -08:00
|
|
|
$timeline = $this->buildTransactionTimeline(
|
|
|
|
$service,
|
|
|
|
new AlmanacServiceTransactionQuery());
|
|
|
|
$timeline->setShouldTerminate(true);
|
2014-10-17 05:01:57 -07:00
|
|
|
|
2015-11-28 14:46:19 -08:00
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$box,
|
2015-11-28 14:57:04 -08:00
|
|
|
$bindings,
|
|
|
|
$this->buildAlmanacPropertiesTable($service),
|
|
|
|
$timeline,
|
2015-11-28 14:46:19 -08:00
|
|
|
));
|
2014-10-17 05:01:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyList(AlmanacService $service) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$properties = id(new PHUIPropertyListView())
|
2014-11-05 15:30:00 -08:00
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($service);
|
2014-10-17 05:01:57 -07:00
|
|
|
|
2014-12-17 11:10:27 -08:00
|
|
|
$properties->addProperty(
|
|
|
|
pht('Service Type'),
|
Store Almanac "service types" instead of "service classes"
Summary:
Ref T10449. Currently, we store classes (like "AlmanacClusterRepositoryServiceType") in the database.
Instead, store types (like "cluster.repository").
This is a small change, but types are a little more flexible (they let us freely reanme classes), a little cleaner (fewer magic strings in the codebase), and a little better for API usage (they're more human readable).
Make this minor usability change now, before we unprototype.
Also make services searchable by type.
Also remove old Almanac API endpoints.
Test Plan:
- Ran migration, verified all data migrated properly.
- Created, edited, rebound, and changed properties of services.
- Searched for services by service type.
- Reviewed available Conduit methods.
Reviewers: chad
Reviewed By: chad
Subscribers: yelirekim
Maniphest Tasks: T10449
Differential Revision: https://secure.phabricator.com/D15346
2016-02-25 05:05:36 -08:00
|
|
|
$service->getServiceImplementation()->getServiceTypeShortName());
|
2014-12-17 11:10:27 -08:00
|
|
|
|
2014-10-17 05:01:57 -07:00
|
|
|
return $properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionList(AlmanacService $service) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$id = $service->getID();
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$service,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setIcon('fa-pencil')
|
|
|
|
->setName(pht('Edit Service'))
|
|
|
|
->setHref($this->getApplicationURI("service/edit/{$id}/"))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit));
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
Add AlmanacBinding, to bind a service to an interface
Summary: Ref T5833. Allows you to bind a service (like `db.example.com`) to one or more interfaces (for example, to specify a pool with one read/write host and two read-only hosts). You can't configure which hosts have which properties yet, but you can add all the relevant interfaces to the service. Next diff will start supporting service, binding, and device properties like "is writable", "is active", etc., so that Almanac will be able to express operations like "change which database is writable", "disable writes", "bring a device down", etc.
Test Plan: See screenshots.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5833
Differential Revision: https://secure.phabricator.com/D10745
2014-10-27 13:39:36 -07:00
|
|
|
private function buildBindingList(AlmanacService $service) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$id = $service->getID();
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$service,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$bindings = id(new AlmanacBindingQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withServicePHIDs(array($service->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$table = id(new AlmanacBindingTableView())
|
|
|
|
->setNoDataString(
|
|
|
|
pht('This service has not been bound to any device interfaces yet.'))
|
|
|
|
->setUser($viewer)
|
2016-02-25 03:52:41 -08:00
|
|
|
->setBindings($bindings)
|
|
|
|
->setHideServiceColumn(true);
|
Add AlmanacBinding, to bind a service to an interface
Summary: Ref T5833. Allows you to bind a service (like `db.example.com`) to one or more interfaces (for example, to specify a pool with one read/write host and two read-only hosts). You can't configure which hosts have which properties yet, but you can add all the relevant interfaces to the service. Next diff will start supporting service, binding, and device properties like "is writable", "is active", etc., so that Almanac will be able to express operations like "change which database is writable", "disable writes", "bring a device down", etc.
Test Plan: See screenshots.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5833
Differential Revision: https://secure.phabricator.com/D10745
2014-10-27 13:39:36 -07:00
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Service Bindings'))
|
|
|
|
->addActionLink(
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref($this->getApplicationURI("binding/edit/?serviceID={$id}"))
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setText(pht('Add Binding'))
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon('fa-plus'));
|
Add AlmanacBinding, to bind a service to an interface
Summary: Ref T5833. Allows you to bind a service (like `db.example.com`) to one or more interfaces (for example, to specify a pool with one read/write host and two read-only hosts). You can't configure which hosts have which properties yet, but you can add all the relevant interfaces to the service. Next diff will start supporting service, binding, and device properties like "is writable", "is active", etc., so that Almanac will be able to express operations like "change which database is writable", "disable writes", "bring a device down", etc.
Test Plan: See screenshots.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5833
Differential Revision: https://secure.phabricator.com/D10745
2014-10-27 13:39:36 -07:00
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
[Redesign] Add Table, Collapse support to ObjectBox
Summary: Converts most all tables to be directly set via `setTable` to an ObjectBox. I think this path is more flexible design wise, as we can change the box based on children, and not just CSS. We also already do this with PropertyList, Forms, ObjectList, and Header. `setCollapsed` is added to ObjectBox to all children objects to bleed to the edges (like diffs).
Test Plan: I did a grep of `appendChild($table)` as well as searches for `PHUIObjectBoxView`, also with manual opening of hundreds of files. I'm sure I missed 5-8 places. If you just appendChild($table) nothing breaks, it just looks a little funny.
Reviewers: epriestley, btrahan
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12955
2015-05-20 12:43:34 -07:00
|
|
|
->setTable($table);
|
Add AlmanacBinding, to bind a service to an interface
Summary: Ref T5833. Allows you to bind a service (like `db.example.com`) to one or more interfaces (for example, to specify a pool with one read/write host and two read-only hosts). You can't configure which hosts have which properties yet, but you can add all the relevant interfaces to the service. Next diff will start supporting service, binding, and device properties like "is writable", "is active", etc., so that Almanac will be able to express operations like "change which database is writable", "disable writes", "bring a device down", etc.
Test Plan: See screenshots.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5833
Differential Revision: https://secure.phabricator.com/D10745
2014-10-27 13:39:36 -07:00
|
|
|
}
|
|
|
|
|
2014-10-17 05:01:57 -07:00
|
|
|
}
|