mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Modernize UIExamples
Summary: - Get rid of an AphrontSideNavView callsite. - Modernize and simplify the application implementation. - Doesn't work perfectly on tablet/phone but that's because not all the UI examples work there yet. Test Plan: Looked at /applications/ and /uiexample/. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D3431
This commit is contained in:
parent
1b7f04914c
commit
303ad93996
11 changed files with 102 additions and 93 deletions
|
@ -140,6 +140,7 @@ $app_map = array(
|
||||||
'feed' => array(3, 11),
|
'feed' => array(3, 11),
|
||||||
'paste' => array(9, 2),
|
'paste' => array(9, 2),
|
||||||
'audit' => array(8, 19),
|
'audit' => array(8, 19),
|
||||||
|
'uiexample' => array(7, 28),
|
||||||
);
|
);
|
||||||
|
|
||||||
$xadj = -1;
|
$xadj = -1;
|
||||||
|
|
|
@ -65,8 +65,8 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'/rsrc/image/autosprite.png' =>
|
'/rsrc/image/autosprite.png' =>
|
||||||
array(
|
array(
|
||||||
'hash' => 'bd70ca6308d6f80a87a10068a04867f8',
|
'hash' => '0b78a23fb4cec90e3a35ba1b9ce20f0c',
|
||||||
'uri' => '/res/bd70ca63/rsrc/image/autosprite.png',
|
'uri' => '/res/0b78a23f/rsrc/image/autosprite.png',
|
||||||
'disk' => '/rsrc/image/autosprite.png',
|
'disk' => '/rsrc/image/autosprite.png',
|
||||||
'type' => 'png',
|
'type' => 'png',
|
||||||
),
|
),
|
||||||
|
@ -671,7 +671,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'autosprite-css' =>
|
'autosprite-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/114f6e40/rsrc/css/autosprite.css',
|
'uri' => '/res/cb9c82fd/rsrc/css/autosprite.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -570,6 +570,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationProject' => 'applications/project/application/PhabricatorApplicationProject.php',
|
'PhabricatorApplicationProject' => 'applications/project/application/PhabricatorApplicationProject.php',
|
||||||
'PhabricatorApplicationSettings' => 'applications/settings/application/PhabricatorApplicationSettings.php',
|
'PhabricatorApplicationSettings' => 'applications/settings/application/PhabricatorApplicationSettings.php',
|
||||||
'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php',
|
'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php',
|
||||||
|
'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php',
|
||||||
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
|
'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php',
|
||||||
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
|
'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php',
|
||||||
'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php',
|
'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php',
|
||||||
|
@ -1076,7 +1077,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php',
|
'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php',
|
||||||
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
|
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
|
||||||
'PhabricatorUIExample' => 'applications/uiexample/examples/PhabricatorUIExample.php',
|
'PhabricatorUIExample' => 'applications/uiexample/examples/PhabricatorUIExample.php',
|
||||||
'PhabricatorUIExampleController' => 'applications/uiexample/controller/PhabricatorUIExampleController.php',
|
|
||||||
'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php',
|
'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php',
|
||||||
'PhabricatorUIListFilterExample' => 'applications/uiexample/examples/PhabricatorUIListFilterExample.php',
|
'PhabricatorUIListFilterExample' => 'applications/uiexample/examples/PhabricatorUIListFilterExample.php',
|
||||||
'PhabricatorUINotificationExample' => 'applications/uiexample/examples/PhabricatorUINotificationExample.php',
|
'PhabricatorUINotificationExample' => 'applications/uiexample/examples/PhabricatorUINotificationExample.php',
|
||||||
|
@ -1710,6 +1710,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationProject' => 'PhabricatorApplication',
|
'PhabricatorApplicationProject' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationSettings' => 'PhabricatorApplication',
|
'PhabricatorApplicationSettings' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationStatusView' => 'AphrontView',
|
'PhabricatorApplicationStatusView' => 'AphrontView',
|
||||||
|
'PhabricatorApplicationUIExamples' => 'PhabricatorApplication',
|
||||||
'PhabricatorApplicationsListController' => 'PhabricatorController',
|
'PhabricatorApplicationsListController' => 'PhabricatorController',
|
||||||
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
|
||||||
'PhabricatorAuditComment' => 'PhabricatorAuditDAO',
|
'PhabricatorAuditComment' => 'PhabricatorAuditDAO',
|
||||||
|
@ -2155,8 +2156,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorTrivialTestCase' => 'PhabricatorTestCase',
|
'PhabricatorTrivialTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
|
'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
|
||||||
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
|
'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController',
|
||||||
'PhabricatorUIExampleController' => 'PhabricatorController',
|
'PhabricatorUIExampleRenderController' => 'PhabricatorController',
|
||||||
'PhabricatorUIExampleRenderController' => 'PhabricatorUIExampleController',
|
|
||||||
'PhabricatorUIListFilterExample' => 'PhabricatorUIExample',
|
'PhabricatorUIListFilterExample' => 'PhabricatorUIExample',
|
||||||
'PhabricatorUINotificationExample' => 'PhabricatorUIExample',
|
'PhabricatorUINotificationExample' => 'PhabricatorUIExample',
|
||||||
'PhabricatorUIPagerExample' => 'PhabricatorUIExample',
|
'PhabricatorUIPagerExample' => 'PhabricatorUIExample',
|
||||||
|
|
|
@ -166,11 +166,6 @@ class AphrontDefaultApplicationConfiguration
|
||||||
=> 'HeraldTranscriptController',
|
=> 'HeraldTranscriptController',
|
||||||
),
|
),
|
||||||
|
|
||||||
'/uiexample/' => array(
|
|
||||||
'' => 'PhabricatorUIExampleRenderController',
|
|
||||||
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
|
|
||||||
),
|
|
||||||
|
|
||||||
'/owners/' => array(
|
'/owners/' => array(
|
||||||
'' => 'PhabricatorOwnersListController',
|
'' => 'PhabricatorOwnersListController',
|
||||||
'view/(?P<view>[^/]+)/' => 'PhabricatorOwnersListController',
|
'view/(?P<view>[^/]+)/' => 'PhabricatorOwnersListController',
|
||||||
|
|
|
@ -138,21 +138,26 @@ abstract class PhabricatorApplication {
|
||||||
|
|
||||||
|
|
||||||
public static function getAllInstalledApplications() {
|
public static function getAllInstalledApplications() {
|
||||||
$classes = id(new PhutilSymbolLoader())
|
static $applications;
|
||||||
->setAncestorClass(__CLASS__)
|
|
||||||
->setConcreteOnly(true)
|
|
||||||
->selectAndLoadSymbols();
|
|
||||||
|
|
||||||
$apps = array();
|
if (empty($applications)) {
|
||||||
foreach ($classes as $class) {
|
$classes = id(new PhutilSymbolLoader())
|
||||||
$app = newv($class['name'], array());
|
->setAncestorClass(__CLASS__)
|
||||||
if (!$app->isEnabled()) {
|
->setConcreteOnly(true)
|
||||||
continue;
|
->selectAndLoadSymbols();
|
||||||
|
|
||||||
|
$apps = array();
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
$app = newv($class['name'], array());
|
||||||
|
if (!$app->isEnabled()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$apps[] = $app;
|
||||||
}
|
}
|
||||||
$apps[] = $app;
|
$applications = $apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $apps;
|
return $applications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class PhabricatorApplicationUIExamples extends PhabricatorApplication {
|
||||||
|
|
||||||
|
public function getBaseURI() {
|
||||||
|
return '/uiexample/';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getShortDescription() {
|
||||||
|
return 'Developer UI Examples';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAutospriteName() {
|
||||||
|
return 'uiexample';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleGlyph() {
|
||||||
|
return "\xE2\x8F\x9A";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoutes() {
|
||||||
|
return array(
|
||||||
|
'/uiexample/' => array(
|
||||||
|
'' => 'PhabricatorUIExampleRenderController',
|
||||||
|
'view/(?P<class>[^/]+)/' => 'PhabricatorUIExampleRenderController',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2011 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
abstract class PhabricatorUIExampleController extends PhabricatorController {
|
|
||||||
|
|
||||||
public function buildStandardPageResponse($view, array $data) {
|
|
||||||
$page = $this->buildStandardPageView();
|
|
||||||
|
|
||||||
$page->setApplicationName('UI Examples');
|
|
||||||
$page->setBaseURI('/uiexample/');
|
|
||||||
$page->setTitle(idx($data, 'title'));
|
|
||||||
$page->setGlyph("\xE2\x8F\x9A");
|
|
||||||
$page->appendChild($view);
|
|
||||||
|
|
||||||
$response = new AphrontWebpageResponse();
|
|
||||||
return $response->setContent($page->render());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -16,8 +16,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class PhabricatorUIExampleRenderController
|
final class PhabricatorUIExampleRenderController extends PhabricatorController {
|
||||||
extends PhabricatorUIExampleController {
|
|
||||||
|
|
||||||
private $class;
|
private $class;
|
||||||
|
|
||||||
|
@ -29,44 +28,31 @@ final class PhabricatorUIExampleRenderController
|
||||||
|
|
||||||
$classes = id(new PhutilSymbolLoader())
|
$classes = id(new PhutilSymbolLoader())
|
||||||
->setAncestorClass('PhabricatorUIExample')
|
->setAncestorClass('PhabricatorUIExample')
|
||||||
|
->setConcreteOnly(true)
|
||||||
->selectAndLoadSymbols();
|
->selectAndLoadSymbols();
|
||||||
$classes = ipull($classes, 'name', 'name');
|
$classes = ipull($classes, 'name', 'name');
|
||||||
|
|
||||||
$selected = null;
|
|
||||||
foreach ($classes as $class => $ignored) {
|
foreach ($classes as $class => $ignored) {
|
||||||
$classes[$class] = newv($class, array());
|
$classes[$class] = newv($class, array());
|
||||||
if ($this->class == $classes[$class]->getName()) {
|
|
||||||
$selected = $class;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$selected) {
|
$classes = msort($classes, 'getName');
|
||||||
$selected = head_key($classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
$nav = new AphrontSideNavView();
|
$nav = new AphrontSideNavFilterView();
|
||||||
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
|
||||||
|
|
||||||
foreach ($classes as $class => $obj) {
|
foreach ($classes as $class => $obj) {
|
||||||
$name = $obj->getName();
|
$name = $obj->getName();
|
||||||
|
$nav->addFilter($class, $name);
|
||||||
$nav->addNavItem(
|
|
||||||
phutil_render_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => '/uiexample/view/'.$name.'/',
|
|
||||||
'class' => ($selected == $class)
|
|
||||||
? 'aphront-side-nav-selected'
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
phutil_escape_html($obj->getName())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$selected = $nav->selectFilter($this->class, head_key($classes));
|
||||||
|
|
||||||
require_celerity_resource('phabricator-ui-example-css');
|
require_celerity_resource('phabricator-ui-example-css');
|
||||||
|
|
||||||
$example = $classes[$selected];
|
$example = $classes[$selected];
|
||||||
$example->setRequest($this->getRequest());
|
$example->setRequest($this->getRequest());
|
||||||
|
|
||||||
|
|
||||||
$nav->appendChild(
|
$nav->appendChild(
|
||||||
'<div class="phabricator-ui-example-header">'.
|
'<div class="phabricator-ui-example-header">'.
|
||||||
'<h1 class="phabricator-ui-example-name">'.
|
'<h1 class="phabricator-ui-example-name">'.
|
||||||
|
@ -80,10 +66,11 @@ final class PhabricatorUIExampleRenderController
|
||||||
|
|
||||||
$nav->appendChild($example->renderExample());
|
$nav->appendChild($example->renderExample());
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
$nav,
|
||||||
array(
|
array(
|
||||||
'title' => 'UI Example',
|
'title' => 'UI Example',
|
||||||
|
'device' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class JavelinReactorExample extends PhabricatorUIExample {
|
final class JavelinReactorExample extends PhabricatorUIExample {
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
return 'Javelin Reactor Examples';
|
return 'Javelin Reactor';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription() {
|
||||||
|
|
|
@ -251,50 +251,58 @@
|
||||||
background-position: 0px -2490px;
|
background-position: 0px -2490px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-file {
|
.app-uiexample-full {
|
||||||
background-position: 0px -2521px;
|
background-position: 0px -2521px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-uiexample {
|
||||||
|
background-position: 0px -2582px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-file {
|
||||||
|
background-position: 0px -2613px;
|
||||||
|
}
|
||||||
|
|
||||||
.action-fork {
|
.action-fork {
|
||||||
background-position: 0px -2538px;
|
background-position: 0px -2630px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-edit {
|
.action-edit {
|
||||||
background-position: 0px -2555px;
|
background-position: 0px -2647px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-0 {
|
.action-flag-0 {
|
||||||
background-position: 0px -2572px;
|
background-position: 0px -2664px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-1 {
|
.action-flag-1 {
|
||||||
background-position: 0px -2589px;
|
background-position: 0px -2681px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-2 {
|
.action-flag-2 {
|
||||||
background-position: 0px -2606px;
|
background-position: 0px -2698px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-3 {
|
.action-flag-3 {
|
||||||
background-position: 0px -2623px;
|
background-position: 0px -2715px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-4 {
|
.action-flag-4 {
|
||||||
background-position: 0px -2640px;
|
background-position: 0px -2732px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-5 {
|
.action-flag-5 {
|
||||||
background-position: 0px -2657px;
|
background-position: 0px -2749px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-6 {
|
.action-flag-6 {
|
||||||
background-position: 0px -2674px;
|
background-position: 0px -2766px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-7 {
|
.action-flag-7 {
|
||||||
background-position: 0px -2691px;
|
background-position: 0px -2783px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-flag-ghost {
|
.action-flag-ghost {
|
||||||
background-position: 0px -2708px;
|
background-position: 0px -2800px;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 90 KiB |
Loading…
Reference in a new issue