1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 14:51:06 +01:00

Create overview of Conduit methods

Summary:
Also couple of small changes:

- Add method name to title.
- 404 for /conduit/method/x/.
- Remove utilities from side panel.
- Remove side panel from log.

Test Plan:
/conduit/
/conduit/method/x/
/conduit/method/user.whoami/
/conduit/log/

Reviewers: btrahan, epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2326
This commit is contained in:
vrana 2012-04-26 22:25:05 -07:00
parent 11ffed7cfc
commit d27a751339
9 changed files with 128 additions and 18 deletions

View file

@ -537,6 +537,7 @@ phutil_register_library_map(array(
'PhabricatorConduitConsoleController' => 'applications/conduit/controller/console',
'PhabricatorConduitController' => 'applications/conduit/controller/base',
'PhabricatorConduitDAO' => 'applications/conduit/storage/base',
'PhabricatorConduitListController' => 'applications/conduit/controller/list',
'PhabricatorConduitLogController' => 'applications/conduit/controller/log',
'PhabricatorConduitMethodCallLog' => 'applications/conduit/storage/methodcalllog',
'PhabricatorConduitTokenController' => 'applications/conduit/controller/token',
@ -1459,6 +1460,7 @@ phutil_register_library_map(array(
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',
'PhabricatorConduitController' => 'PhabricatorController',
'PhabricatorConduitDAO' => 'PhabricatorLiskDAO',
'PhabricatorConduitListController' => 'PhabricatorConduitController',
'PhabricatorConduitLogController' => 'PhabricatorConduitController',
'PhabricatorConduitMethodCallLog' => 'PhabricatorConduitDAO',
'PhabricatorConduitTokenController' => 'PhabricatorConduitController',

View file

@ -89,7 +89,7 @@ class AphrontDefaultApplicationConfiguration
'/p/(?P<username>\w+)/(?:(?P<page>\w+)/)?'
=> 'PhabricatorPeopleProfileController',
'/conduit/' => array(
'' => 'PhabricatorConduitConsoleController',
'' => 'PhabricatorConduitListController',
'method/(?P<method>[^/]+)/' => 'PhabricatorConduitConsoleController',
'log/' => 'PhabricatorConduitLogController',
'log/view/(?P<view>[^/]+)/' => 'PhabricatorConduitLogController',

View file

@ -45,7 +45,6 @@ abstract class PhabricatorConduitController extends PhabricatorController {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/conduit/'));
$first_filter = null;
$method_filters = $this->getMethodFilters();
foreach ($method_filters as $group => $methods) {
$nav->addLabel($group);
@ -61,16 +60,10 @@ abstract class PhabricatorConduitController extends PhabricatorController {
$nav->addFilter('method/'.$method_name,
$display_name);
if (!$first_filter) {
$first_filter = 'method/'.$method_name;
}
}
$nav->addSpacer();
}
$nav->addLabel('Utilities');
$nav->addFilter('log', 'Logs');
$nav->addFilter('token', 'Token');
$nav->selectFilter($this->getFilter(), $first_filter);
$nav->selectFilter($this->getFilter());
$nav->appendChild($view);
$body = $nav;
} else {
@ -82,7 +75,6 @@ abstract class PhabricatorConduitController extends PhabricatorController {
return $response->setContent($page->render());
}
private function getFilter() {
return $this->filter;
}
@ -111,7 +103,7 @@ abstract class PhabricatorConduitController extends PhabricatorController {
return array_values(ipull($classes, 'name'));
}
private function getMethodFilters() {
protected function getMethodFilters() {
$classes = $this->getAllMethodImplementationClasses();
$method_names = array();
foreach ($classes as $method_class) {
@ -119,7 +111,8 @@ abstract class PhabricatorConduitController extends PhabricatorController {
$method_class);
$group_name = head(explode('.', $method_name));
$status = newv($method_class, array())->getMethodStatus();
$method_object = newv($method_class, array());
$status = $method_object->getMethodStatus();
$key = sprintf(
'%02d %s %s',
@ -131,6 +124,7 @@ abstract class PhabricatorConduitController extends PhabricatorController {
'full_name' => $method_name,
'group_name' => $group_name,
'status' => $status,
'description' => $method_object->getMethodDescription(),
);
}
ksort($method_names);

View file

@ -25,7 +25,7 @@ final class PhabricatorConduitConsoleController
private $method;
public function willProcessRequest(array $data) {
$this->method = idx($data, 'method');
$this->method = $data['method'];
}
public function processRequest() {
@ -34,7 +34,7 @@ final class PhabricatorConduitConsoleController
$methods = $this->getAllMethods();
if (empty($methods[$this->method])) {
$this->method = head_key($methods);
return new Aphront404Response();
}
$this->setFilter('method/'.$this->method);
@ -45,7 +45,7 @@ final class PhabricatorConduitConsoleController
$reason = $method_object->getMethodStatusDescription();
$status_view = null;
if ($status != 'stable') {
if ($status != ConduitAPIMethod::METHOD_STATUS_STABLE) {
$status_view = new AphrontErrorView();
switch ($status) {
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
@ -141,7 +141,7 @@ final class PhabricatorConduitConsoleController
$panel,
),
array(
'title' => 'Conduit Console',
'title' => 'Conduit Console - '.$this->method,
));
}

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/conduit/controller/base');
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'view/form/base');

View file

@ -0,0 +1,97 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group conduit
*/
final class PhabricatorConduitListController
extends PhabricatorConduitController {
public function processRequest() {
$method_groups = $this->getMethodFilters();
$rows = array();
foreach ($method_groups as $group => $methods) {
foreach ($methods as $info) {
switch ($info['status']) {
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
$status = 'Deprecated';
break;
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
$status = 'Unstable';
break;
default:
$status = null;
break;
}
$rows[] = array(
$group,
phutil_render_tag(
'a',
array(
'href' => '/conduit/method/'.$info['full_name'],
),
phutil_escape_html($info['full_name'])),
$info['description'],
$status,
);
$group = null;
}
}
$table = new AphrontTableView($rows);
$table->setHeaders(array(
'Group',
'Name',
'Description',
'Status',
));
$table->setColumnClasses(array(
'pri',
'pri',
'wide',
null,
));
$panel = new AphrontPanelView();
$panel->setHeader('Conduit Methods');
$panel->appendChild($table);
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
$utils = new AphrontPanelView();
$utils->setHeader('Utilities');
$utils->appendChild(
'<ul>'.
'<li><a href="/conduit/log/">Log</a> - Conduit Method Calls</li>'.
'<li><a href="/conduit/token/">Token</a> - Certificate Install</li>'.
'</ul>');
$utils->setWidth(AphrontPanelView::WIDTH_FULL);
$this->setShowSideNav(false);
return $this->buildStandardPageResponse(
array(
$panel,
$utils,
),
array(
'title' => 'Conduit Console',
));
}
}

View file

@ -0,0 +1,17 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/conduit/controller/base');
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_source('PhabricatorConduitListController.php');

View file

@ -57,7 +57,7 @@ final class PhabricatorConduitLogController
$panel->appendChild($table);
$panel->appendChild($pager);
$this->setFilter('log');
$this->setShowSideNav(false);
return $this->buildStandardPageResponse(
$panel,

View file

@ -57,7 +57,6 @@ final class PhabricatorConduitTokenController
'<p class="aphront-form-instructions">arc will then complete the '.
'install process for you.</p>');
$this->setFilter('token');
$this->setShowSideNav(false);
return $this->buildStandardPageResponse(