1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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', 'PhabricatorGoogleAuthProvider' => 'applications/auth/provider/PhabricatorGoogleAuthProvider.php',
'PhabricatorGuideApplication' => 'applications/guides/application/PhabricatorGuideApplication.php', 'PhabricatorGuideApplication' => 'applications/guides/application/PhabricatorGuideApplication.php',
'PhabricatorGuideController' => 'applications/guides/controller/PhabricatorGuideController.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', 'PhabricatorGuideItemView' => 'applications/guides/view/PhabricatorGuideItemView.php',
'PhabricatorGuideListView' => 'applications/guides/view/PhabricatorGuideListView.php', 'PhabricatorGuideListView' => 'applications/guides/view/PhabricatorGuideListView.php',
'PhabricatorGuideQuickStartController' => 'applications/guides/controller/PhabricatorGuideQuickStartController.php', 'PhabricatorGuideModule' => 'applications/guides/module/PhabricatorGuideModule.php',
'PhabricatorGuideWelcomeController' => 'applications/guides/controller/PhabricatorGuideWelcomeController.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', 'PhabricatorHTTPParameterTypeTableView' => 'applications/config/view/PhabricatorHTTPParameterTypeTableView.php',
'PhabricatorHandleList' => 'applications/phid/handle/pool/PhabricatorHandleList.php', 'PhabricatorHandleList' => 'applications/phid/handle/pool/PhabricatorHandleList.php',
'PhabricatorHandleObjectSelectorDataView' => 'applications/phid/handle/view/PhabricatorHandleObjectSelectorDataView.php', 'PhabricatorHandleObjectSelectorDataView' => 'applications/phid/handle/view/PhabricatorHandleObjectSelectorDataView.php',
@ -7454,11 +7456,13 @@ phutil_register_library_map(array(
'PhabricatorGoogleAuthProvider' => 'PhabricatorOAuth2AuthProvider', 'PhabricatorGoogleAuthProvider' => 'PhabricatorOAuth2AuthProvider',
'PhabricatorGuideApplication' => 'PhabricatorApplication', 'PhabricatorGuideApplication' => 'PhabricatorApplication',
'PhabricatorGuideController' => 'PhabricatorController', 'PhabricatorGuideController' => 'PhabricatorController',
'PhabricatorGuideInstallController' => 'PhabricatorGuideController', 'PhabricatorGuideInstallModule' => 'PhabricatorGuideModule',
'PhabricatorGuideItemView' => 'Phobject', 'PhabricatorGuideItemView' => 'Phobject',
'PhabricatorGuideListView' => 'AphrontView', 'PhabricatorGuideListView' => 'AphrontView',
'PhabricatorGuideQuickStartController' => 'PhabricatorGuideController', 'PhabricatorGuideModule' => 'Phobject',
'PhabricatorGuideWelcomeController' => 'PhabricatorGuideController', 'PhabricatorGuideModuleController' => 'PhabricatorGuideController',
'PhabricatorGuideQuickStartModule' => 'PhabricatorGuideModule',
'PhabricatorGuideWelcomeModule' => 'PhabricatorGuideModule',
'PhabricatorHTTPParameterTypeTableView' => 'AphrontView', 'PhabricatorHTTPParameterTypeTableView' => 'AphrontView',
'PhabricatorHandleList' => array( 'PhabricatorHandleList' => array(
'Phobject', 'Phobject',

View file

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

View file

@ -7,9 +7,11 @@ abstract class PhabricatorGuideController extends PhabricatorController {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addLabel(pht('Guides')); $nav->addLabel(pht('Guides'));
$nav->addFilter('/', pht('Welcome'));
$nav->addFilter('install/', pht('Installation Guide')); $modules = PhabricatorGuideModule::getAllModules();
$nav->addFilter('quickstart/', pht('Quick Start Guide')); foreach ($modules as $key => $module) {
$nav->addFilter($key.'/', $module->getModuleName());
}
return $nav; 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 <?php
final class PhabricatorGuideInstallController final class PhabricatorGuideInstallModule extends PhabricatorGuideModule {
extends PhabricatorGuideController {
public function shouldAllowPublic() { public function getModuleKey() {
return false; 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(); $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(); $guide_items = new PhabricatorGuideListView();
$title = pht('Resolve Setup Issues'); $title = pht('Resolve Setup Issues');
@ -191,5 +170,7 @@ final class PhabricatorGuideInstallController
$guide_items->addItem($item); $guide_items->addItem($item);
return $guide_items; 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 <?php
final class PhabricatorGuideQuickStartController final class PhabricatorGuideQuickStartModule extends PhabricatorGuideModule {
extends PhabricatorGuideController {
public function shouldAllowPublic() { public function getModuleKey() {
return false; 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(); $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(); $guide_items = new PhabricatorGuideListView();
$title = pht('Configure Applications'); $title = pht('Configure Applications');
@ -205,5 +184,7 @@ final class PhabricatorGuideQuickStartController
$guide_items->addItem($item); $guide_items->addItem($item);
return $guide_items; 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);
}
}