1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Convert Guides to Modules

Summary: Splitting these up to re-use in Config as a stop gap.

Test Plan: Visit welcome, install, and quick start on guides app

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D16478
This commit is contained in:
Chad Little 2016-08-31 12:14:05 -07:00
parent 29957d196b
commit b5c9c64b0f
9 changed files with 139 additions and 132 deletions

View file

@ -2639,11 +2639,13 @@ phutil_register_library_map(array(
'PhabricatorGoogleAuthProvider' => 'applications/auth/provider/PhabricatorGoogleAuthProvider.php',
'PhabricatorGuideApplication' => 'applications/guides/application/PhabricatorGuideApplication.php',
'PhabricatorGuideController' => 'applications/guides/controller/PhabricatorGuideController.php',
'PhabricatorGuideInstallController' => 'applications/guides/controller/PhabricatorGuideInstallController.php',
'PhabricatorGuideInstallModule' => 'applications/guides/module/PhabricatorGuideInstallModule.php',
'PhabricatorGuideItemView' => 'applications/guides/view/PhabricatorGuideItemView.php',
'PhabricatorGuideListView' => 'applications/guides/view/PhabricatorGuideListView.php',
'PhabricatorGuideQuickStartController' => 'applications/guides/controller/PhabricatorGuideQuickStartController.php',
'PhabricatorGuideWelcomeController' => 'applications/guides/controller/PhabricatorGuideWelcomeController.php',
'PhabricatorGuideModule' => 'applications/guides/module/PhabricatorGuideModule.php',
'PhabricatorGuideModuleController' => 'applications/guides/controller/PhabricatorGuideModuleController.php',
'PhabricatorGuideQuickStartModule' => 'applications/guides/module/PhabricatorGuideQuickStartModule.php',
'PhabricatorGuideWelcomeModule' => 'applications/guides/module/PhabricatorGuideWelcomeModule.php',
'PhabricatorHTTPParameterTypeTableView' => 'applications/config/view/PhabricatorHTTPParameterTypeTableView.php',
'PhabricatorHandleList' => 'applications/phid/handle/pool/PhabricatorHandleList.php',
'PhabricatorHandleObjectSelectorDataView' => 'applications/phid/handle/view/PhabricatorHandleObjectSelectorDataView.php',
@ -7454,11 +7456,13 @@ phutil_register_library_map(array(
'PhabricatorGoogleAuthProvider' => 'PhabricatorOAuth2AuthProvider',
'PhabricatorGuideApplication' => 'PhabricatorApplication',
'PhabricatorGuideController' => 'PhabricatorController',
'PhabricatorGuideInstallController' => 'PhabricatorGuideController',
'PhabricatorGuideInstallModule' => 'PhabricatorGuideModule',
'PhabricatorGuideItemView' => 'Phobject',
'PhabricatorGuideListView' => 'AphrontView',
'PhabricatorGuideQuickStartController' => 'PhabricatorGuideController',
'PhabricatorGuideWelcomeController' => 'PhabricatorGuideController',
'PhabricatorGuideModule' => 'Phobject',
'PhabricatorGuideModuleController' => 'PhabricatorGuideController',
'PhabricatorGuideQuickStartModule' => 'PhabricatorGuideModule',
'PhabricatorGuideWelcomeModule' => 'PhabricatorGuideModule',
'PhabricatorHTTPParameterTypeTableView' => 'AphrontView',
'PhabricatorHandleList' => array(
'Phobject',

View file

@ -29,11 +29,8 @@ final class PhabricatorGuideApplication extends PhabricatorApplication {
public function getRoutes() {
return array(
'/guides/' => array(
'' => 'PhabricatorGuideWelcomeController',
'install/'
=> 'PhabricatorGuideInstallController',
'quickstart/'
=> 'PhabricatorGuideQuickStartController',
'' => 'PhabricatorGuideModuleController',
'(?P<module>[^/]+)/' => 'PhabricatorGuideModuleController',
),
);
}

View file

@ -7,9 +7,11 @@ abstract class PhabricatorGuideController extends PhabricatorController {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addLabel(pht('Guides'));
$nav->addFilter('/', pht('Welcome'));
$nav->addFilter('install/', pht('Installation Guide'));
$nav->addFilter('quickstart/', pht('Quick Start Guide'));
$modules = PhabricatorGuideModule::getAllModules();
foreach ($modules as $key => $module) {
$nav->addFilter($key.'/', $module->getModuleName());
}
return $nav;
}

View file

@ -0,0 +1,42 @@
<?php
final class PhabricatorGuideModuleController
extends PhabricatorGuideController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$key = $request->getURIData('module');
if (!$key) {
$key = 'welcome';
}
$all_modules = PhabricatorGuideModule::getAllModules();
$nav = $this->buildSideNavView();
$nav->selectFilter($key.'/');
$module = $all_modules[$key];
$content = $module->renderModuleStatus($request);
$title = $module->getModuleName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader($title)
->setProfileHeader(true);
$view = id(new PHUICMSView())
->setCrumbs($crumbs)
->setNavigation($nav)
->setHeader($header)
->setContent($content);
return $this->newPage()
->setTitle($title)
->addClass('phui-cms-body')
->appendChild($view);
}
}

View file

@ -1,52 +0,0 @@
<?php
final class PhabricatorGuideWelcomeController
extends PhabricatorGuideController {
public function shouldAllowPublic() {
return false;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$title = pht('Welcome to Phabricator');
$nav = $this->buildSideNavView();
$nav->selectFilter('/');
$header = id(new PHUIHeaderView())
->setHeader($title)
->setProfileHeader(true);
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Welcome'));
$content = id(new PHUIDocumentViewPro())
->appendChild($this->getGuideContent($viewer));
$view = id(new PHUICMSView())
->setCrumbs($crumbs)
->setNavigation($nav)
->setHeader($header)
->setContent($content);
return $this->newPage()
->setTitle($title)
->addClass('phui-cms-body')
->appendChild($view);
}
private function getGuideContent($viewer) {
$content = pht(
'You have successfully installed Phabricator. These next guides will '.
'take you through configuration and new user orientation. '.
'These steps are optional, and you can go through them in any order. '.
'If you want to get back to this guide later on, you can find it in '.
'the **Config** application under **Welcome Guide**.');
return new PHUIRemarkupView($viewer, $content);
}
}

View file

@ -1,43 +1,22 @@
<?php
final class PhabricatorGuideInstallController
extends PhabricatorGuideController {
final class PhabricatorGuideInstallModule extends PhabricatorGuideModule {
public function shouldAllowPublic() {
return false;
public function getModuleKey() {
return 'install';
}
public function handleRequest(AphrontRequest $request) {
public function getModuleName() {
return pht('Install Phabricator');
}
public function getModulePosition() {
return 20;
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$title = pht('Installation Guide');
$nav = $this->buildSideNavView();
$nav->selectFilter('install/');
$header = id(new PHUIHeaderView())
->setHeader($title)
->setProfileHeader(true);
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Installation'));
$content = $this->getGuideContent($viewer);
$view = id(new PHUICMSView())
->setCrumbs($crumbs)
->setNavigation($nav)
->setHeader($header)
->setContent($content);
return $this->newPage()
->setTitle($title)
->addClass('phui-cms-body')
->appendChild($view);
}
private function getGuideContent($viewer) {
$guide_items = new PhabricatorGuideListView();
$title = pht('Resolve Setup Issues');
@ -191,5 +170,7 @@ final class PhabricatorGuideInstallController
$guide_items->addItem($item);
return $guide_items;
}
}

View file

@ -0,0 +1,18 @@
<?php
abstract class PhabricatorGuideModule extends Phobject {
abstract public function getModuleKey();
abstract public function getModuleName();
abstract public function getModulePosition();
abstract public function renderModuleStatus(AphrontRequest $request);
final public static function getAllModules() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getModuleKey')
->setSortMethod('getModulePosition')
->execute();
}
}

View file

@ -1,43 +1,22 @@
<?php
final class PhabricatorGuideQuickStartController
extends PhabricatorGuideController {
final class PhabricatorGuideQuickStartModule extends PhabricatorGuideModule {
public function shouldAllowPublic() {
return false;
public function getModuleKey() {
return 'quickstart';
}
public function handleRequest(AphrontRequest $request) {
public function getModuleName() {
return pht('Quick Start');
}
public function getModulePosition() {
return 30;
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$title = pht('Quick Start Guide');
$nav = $this->buildSideNavView();
$nav->selectFilter('quickstart/');
$header = id(new PHUIHeaderView())
->setHeader($title)
->setProfileHeader(true);
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Quick Start'));
$content = $this->getGuideContent($viewer);
$view = id(new PHUICMSView())
->setCrumbs($crumbs)
->setNavigation($nav)
->setHeader($header)
->setContent($content);
return $this->newPage()
->setTitle($title)
->addClass('phui-cms-body')
->appendChild($view);
}
private function getGuideContent($viewer) {
$guide_items = new PhabricatorGuideListView();
$title = pht('Configure Applications');
@ -205,5 +184,7 @@ final class PhabricatorGuideQuickStartController
$guide_items->addItem($item);
return $guide_items;
}
}

View file

@ -0,0 +1,34 @@
<?php
final class PhabricatorGuideWelcomeModule extends PhabricatorGuideModule {
public function getModuleKey() {
return 'welcome';
}
public function getModuleName() {
return pht('Welcome');
}
public function getModulePosition() {
return 10;
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$content = pht(
'You have successfully installed Phabricator. These next guides will '.
'take you through configuration and new user orientation. '.
'These steps are optional, and you can go through them in any order. '.
'If you want to get back to this guide later on, you can find it in '.
'the **Config** application under **Welcome Guide**.');
$content = new PHUIRemarkupView($viewer, $content);
return id(new PHUIDocumentViewPro())
->appendChild($content);
}
}