mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +01:00
Allow Conduit console to be browsed by logged-out users
Summary: Ref T4830. A few methods, like `conduit.ping`, are callable without authentication, so this even has some use cases. Also: - Make some Differential stuff a little more consistent. - Use slightly more modern rendering. - Deprecate the status-oriented `user` calls; these will be replaced by Calendar methods. Test Plan: Browsed console as logged out / logged in users. Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4830 Differential Revision: https://secure.phabricator.com/D8826
This commit is contained in:
parent
4143ecf015
commit
27d426e3fe
21 changed files with 100 additions and 118 deletions
|
@ -2718,26 +2718,26 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_conpherence_updatethread_Method' => 'ConduitAPI_conpherence_Method',
|
||||
'ConduitAPI_differential_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_close_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_createcomment_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_createcomment_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_createinline_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_createrawdiff_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_finishpostponedlinters_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_getrawdiff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_find_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_finishpostponedlinters_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getrawdiff_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getrevision_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_getrevisioncomments_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_query_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_querydiffs_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_querydiffs_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPI_differential_Method',
|
||||
'ConduitAPI_diffusion_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method',
|
||||
'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class PhabricatorConduitConsoleController
|
||||
extends PhabricatorConduitController {
|
||||
|
||||
private $method;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->method = $data['method'];
|
||||
}
|
||||
|
@ -26,28 +27,25 @@ final class PhabricatorConduitConsoleController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$can_call_method = false;
|
||||
|
||||
$status = $method->getMethodStatus();
|
||||
$reason = $method->getMethodStatusDescription();
|
||||
$errors = array();
|
||||
|
||||
$status_view = null;
|
||||
if ($status != ConduitAPIMethod::METHOD_STATUS_STABLE) {
|
||||
$status_view = new AphrontErrorView();
|
||||
switch ($status) {
|
||||
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
|
||||
$status_view->setTitle('Deprecated Method');
|
||||
$status_view->appendChild(
|
||||
nonempty($reason, "This method is deprecated."));
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
|
||||
$status_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
|
||||
$status_view->setTitle('Unstable Method');
|
||||
$status_view->appendChild(
|
||||
nonempty(
|
||||
$reason,
|
||||
"This method is new and unstable. Its interface is subject ".
|
||||
"to change."));
|
||||
break;
|
||||
}
|
||||
switch ($status) {
|
||||
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
|
||||
$reason = nonempty($reason, pht('This method is deprecated.'));
|
||||
$errors[] = pht('Deprecated Method: %s', $reason);
|
||||
break;
|
||||
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
|
||||
$reason = nonempty(
|
||||
$reason,
|
||||
pht(
|
||||
'This method is new and unstable. Its interface is subject '.
|
||||
'to change.'));
|
||||
$errors[] = pht('Unstable Method: %s', $reason);
|
||||
break;
|
||||
}
|
||||
|
||||
$error_types = $method->defineErrorTypes();
|
||||
|
@ -61,7 +59,8 @@ final class PhabricatorConduitConsoleController
|
|||
}
|
||||
$error_description = phutil_tag('ul', array(), $error_description);
|
||||
} else {
|
||||
$error_description = "This method does not raise any specific errors.";
|
||||
$error_description = pht(
|
||||
'This method does not raise any specific errors.');
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
|
@ -95,29 +94,38 @@ final class PhabricatorConduitConsoleController
|
|||
->setCaption($desc));
|
||||
}
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('Output Format')
|
||||
->setName('output')
|
||||
->setOptions(
|
||||
array(
|
||||
'human' => 'Human Readable',
|
||||
'json' => 'JSON',
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($this->getApplicationURI())
|
||||
->setValue('Call Method'));
|
||||
$must_login = !$viewer->isLoggedIn() &&
|
||||
$method->shouldRequireAuthentication();
|
||||
if ($must_login) {
|
||||
$errors[] = pht(
|
||||
'Login Required: This method requires authentication. You must '.
|
||||
'log in before you can make calls to it.');
|
||||
} else {
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('Output Format')
|
||||
->setName('output')
|
||||
->setOptions(
|
||||
array(
|
||||
'human' => 'Human Readable',
|
||||
'json' => 'JSON',
|
||||
)))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($this->getApplicationURI())
|
||||
->setValue(pht('Call Method')));
|
||||
}
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setUser($viewer)
|
||||
->setHeader($method->getAPIMethodName());
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($method->getAPIMethodName())
|
||||
->setHeader($header)
|
||||
->setFormErrors($errors)
|
||||
->setForm($form);
|
||||
|
||||
if ($status_view) {
|
||||
$form_box->setErrorView($status_view);
|
||||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($method->getAPIMethodName());
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class PhabricatorConduitListController
|
||||
extends PhabricatorConduitController
|
||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->queryKey = idx($data, 'queryKey');
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_createcomment_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return pht("Add a comment to a Differential revision.");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod {
|
||||
final class ConduitAPI_differential_creatediff_Method
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Create a new Differential diff.";
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_createinline_Method
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_createrawdiff_Method
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
|
||||
final class ConduitAPI_differential_find_Method
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodStatus() {
|
||||
return self::METHOD_STATUS_DEPRECATED;
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_finishpostponedlinters_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Update diff with new lint messages and mark postponed ".
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_getalldiffs_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodStatus() {
|
||||
return self::METHOD_STATUS_DEPRECATED;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class ConduitAPI_differential_getcommitmessage_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Retrieve Differential commit messages or message templates.";
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_getcommitpaths_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Query which paths should be included when committing a ".
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_getdiff_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class ConduitAPI_differential_getrawdiff_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return pht("Retrieve a raw diff");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
final class ConduitAPI_differential_parsecommitmessage_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
private $errors;
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_querydiffs_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return pht('Query differential diffs which match certain criteria.');
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_setdiffproperty_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Attach properties to Differential diffs.";
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_differential_updateunitresults_Method
|
||||
extends ConduitAPIMethod {
|
||||
extends ConduitAPI_differential_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Update arc unit results for a postponed test.";
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
abstract class ConduitAPI_user_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getApplication() {
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method {
|
||||
final class ConduitAPI_user_addstatus_Method
|
||||
extends ConduitAPI_user_Method {
|
||||
|
||||
public function getMethodStatus() {
|
||||
return self::METHOD_STATUS_UNSTABLE;
|
||||
return self::METHOD_STATUS_DEPRECATED;
|
||||
}
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Add status information to the logged-in user.";
|
||||
return pht("Add status information to the logged-in user.");
|
||||
}
|
||||
|
||||
public function getMethodStatusDescription() {
|
||||
return pht(
|
||||
'Statuses are becoming full-fledged events as part of the '.
|
||||
'Calendar application.');
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method {
|
||||
|
||||
public function getMethodStatus() {
|
||||
return self::METHOD_STATUS_UNSTABLE;
|
||||
return self::METHOD_STATUS_DEPRECATED;
|
||||
}
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Delete status information of the logged-in user.";
|
||||
return pht("Delete status information of the logged-in user.");
|
||||
}
|
||||
|
||||
public function getMethodStatusDescription() {
|
||||
return pht(
|
||||
'Statuses are becoming full-fledged events as part of the '.
|
||||
'Calendar application.');
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
|
|
Loading…
Reference in a new issue