Differential D21696 Diff 51659 src/applications/conduit/controller/PhabricatorConduitConsoleController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/controller/PhabricatorConduitConsoleController.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | $info_box = id(new PHUIObjectBoxView()) | ||||
->setFormErrors($errors) | ->setFormErrors($errors) | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->appendChild($properties); | ->appendChild($properties); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb($method->getAPIMethodName()); | $crumbs->addTextCrumb($method->getAPIMethodName()); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$documentation_pages = $method->getDocumentationPages($viewer); | |||||
$documentation_view = $this->newDocumentationView( | |||||
$method, | |||||
$documentation_pages); | |||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setFooter(array( | ->setFooter(array( | ||||
id(new PhabricatorAnchorView()) | |||||
->setAnchorName('overview'), | |||||
$info_box, | $info_box, | ||||
$method->getMethodDocumentation(), | |||||
id(new PhabricatorAnchorView()) | |||||
->setAnchorName('documentation'), | |||||
$documentation_view, | |||||
id(new PhabricatorAnchorView()) | |||||
->setAnchorName('call'), | |||||
$form_box, | $form_box, | ||||
id(new PhabricatorAnchorView()) | |||||
->setAnchorName('examples'), | |||||
$this->renderExampleBox($method, null), | $this->renderExampleBox($method, null), | ||||
)); | )); | ||||
$title = $method->getAPIMethodName(); | $title = $method->getAPIMethodName(); | ||||
$nav = $this->newNavigationView($method, $documentation_pages); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setNavigation($nav) | |||||
->appendChild($view); | ->appendChild($view); | ||||
} | } | ||||
private function newDocumentationView( | |||||
ConduitAPIMethod $method, | |||||
array $documentation_pages) { | |||||
assert_instances_of($documentation_pages, 'ConduitAPIDocumentationPage'); | |||||
$viewer = $this->getViewer(); | |||||
$description_properties = id(new PHUIPropertyListView()); | |||||
$description_properties->addTextContent( | |||||
new PHUIRemarkupView($viewer, $method->getMethodDescription())); | |||||
$description_box = id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Method Description')) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($description_properties); | |||||
$view = array(); | |||||
$view[] = $description_box; | |||||
foreach ($documentation_pages as $page) { | |||||
$view[] = $page->newView(); | |||||
} | |||||
return $view; | |||||
} | |||||
private function newNavigationView( | |||||
ConduitAPIMethod $method, | |||||
array $documentation_pages) { | |||||
assert_instances_of($documentation_pages, 'ConduitAPIDocumentationPage'); | |||||
$console_uri = urisprintf( | |||||
'/method/%s/', | |||||
$method->getAPIMethodName()); | |||||
$console_uri = $this->getApplicationURI($console_uri); | |||||
$console_uri = new PhutilURI($console_uri); | |||||
$nav = id(new AphrontSideNavFilterView()) | |||||
->setBaseURI($console_uri); | |||||
$nav->selectFilter(null); | |||||
$nav->newLink('overview') | |||||
->setHref('#overview') | |||||
->setName(pht('Overview')) | |||||
->setIcon('fa-list'); | |||||
$nav->newLink('documentation') | |||||
->setHref('#documentation') | |||||
->setName(pht('Documentation')) | |||||
->setIcon('fa-book'); | |||||
foreach ($documentation_pages as $page) { | |||||
$nav->newLink($page->getAnchor()) | |||||
->setHref('#'.$page->getAnchor()) | |||||
->setName($page->getName()) | |||||
->setIcon($page->getIconIcon()) | |||||
->setIndented(true); | |||||
} | |||||
$nav->newLink('call') | |||||
->setHref('#call') | |||||
->setName(pht('Call Method')) | |||||
->setIcon('fa-play'); | |||||
$nav->newLink('examples') | |||||
->setHref('#examples') | |||||
->setName(pht('Examples')) | |||||
->setIcon('fa-folder-open-o'); | |||||
return $nav; | |||||
} | |||||
private function buildMethodProperties(ConduitAPIMethod $method) { | private function buildMethodProperties(ConduitAPIMethod $method) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$view = id(new PHUIPropertyListView()); | $view = id(new PHUIPropertyListView()); | ||||
$status = $method->getMethodStatus(); | $status = $method->getMethodStatus(); | ||||
$reason = $method->getMethodStatusDescription(); | $reason = $method->getMethodStatusDescription(); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | foreach ($error_types as $error => $meaning) { | ||||
$meaning); | $meaning); | ||||
} | } | ||||
$error_description = phutil_tag('ul', array(), $error_description); | $error_description = phutil_tag('ul', array(), $error_description); | ||||
$view->addProperty( | $view->addProperty( | ||||
pht('Errors'), | pht('Errors'), | ||||
$error_description); | $error_description); | ||||
$scope = $method->getRequiredScope(); | $scope = $method->getRequiredScope(); | ||||
switch ($scope) { | switch ($scope) { | ||||
case ConduitAPIMethod::SCOPE_ALWAYS: | case ConduitAPIMethod::SCOPE_ALWAYS: | ||||
$oauth_icon = 'fa-globe green'; | $oauth_icon = 'fa-globe green'; | ||||
$oauth_description = pht( | $oauth_description = pht( | ||||
'OAuth clients may always call this method.'); | 'OAuth clients may always call this method.'); | ||||
break; | break; | ||||
case ConduitAPIMethod::SCOPE_NEVER: | case ConduitAPIMethod::SCOPE_NEVER: | ||||
Show All 13 Lines | private function buildMethodProperties(ConduitAPIMethod $method) { | ||||
$view->addProperty( | $view->addProperty( | ||||
pht('OAuth Scope'), | pht('OAuth Scope'), | ||||
array( | array( | ||||
id(new PHUIIconView())->setIcon($oauth_icon), | id(new PHUIIconView())->setIcon($oauth_icon), | ||||
' ', | ' ', | ||||
$oauth_description, | $oauth_description, | ||||
)); | )); | ||||
$view->addSectionHeader( | |||||
pht('Description'), PHUIPropertyListView::ICON_SUMMARY); | |||||
$view->addTextContent( | |||||
new PHUIRemarkupView($viewer, $method->getMethodDescription())); | |||||
return $view; | return $view; | ||||
} | } | ||||
} | } |