1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-01 06:59:15 +01:00

Herald 'new rule type' interface.

This commit is contained in:
epriestley 2011-03-22 14:34:38 -07:00
parent 75fcf56b67
commit e8c960910c
6 changed files with 98 additions and 40 deletions

View file

@ -193,6 +193,7 @@ phutil_register_library_map(array(
'HeraldHomeController' => 'applications/herald/controller/home',
'HeraldInvalidConditionException' => 'applications/herald/engine/engine/exception',
'HeraldInvalidFieldException' => 'applications/herald/engine/engine/exception',
'HeraldNewController' => 'applications/herald/controller/new',
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/object',
'HeraldRecursiveConditionsException' => 'applications/herald/engine/engine/exception',
'HeraldRule' => 'applications/herald/storage/rule',
@ -533,6 +534,7 @@ phutil_register_library_map(array(
'HeraldController' => 'PhabricatorController',
'HeraldDAO' => 'PhabricatorLiskDAO',
'HeraldHomeController' => 'HeraldController',
'HeraldNewController' => 'HeraldController',
'HeraldRule' => 'HeraldDAO',
'HeraldTranscript' => 'HeraldDAO',
'ManiphestController' => 'PhabricatorController',

View file

@ -220,6 +220,8 @@ class AphrontDefaultApplicationConfiguration
'/herald/' => array(
'$' => 'HeraldHomeController',
'view/(?P<view>[^/]+)/$' => 'HeraldHomeController',
'new/(?:(?P<type>[^/]+)/)?$' => 'HeraldNewController',
'rule/(?:(?<id>\d+)/)?$' => 'HeraldRuleController',
),
);

View file

@ -78,10 +78,11 @@ class HeraldHomeController extends HeraldController {
);
}
$rules_for = phutil_escape_html($map[$this->view]);
$table = new AphrontTableView($rows);
$table->setNoDataString(
"No matching subscription rules for ".
phutil_escape_html($map[$this->view]).".");
"No matching subscription rules for {$rules_for}.");
$table->setHeaders(
array(
@ -98,23 +99,16 @@ class HeraldHomeController extends HeraldController {
'action'
));
$items = array();
foreach ($map as $key => $value) {
$uri = '/herald/view/'.$key.'/';
$items[] = 'item';
/* <tools:nav-item href={$uri} selected={$key == $this->view}>
{$value}
</tools:nav-item>;
*/
}
// require_static('herald-css');
// If you're viewing as an admin, this string renders in the table header.
// $map['admin'] = 'Omniscience';
$panel = new AphrontPanelView();
$panel->setHeader("Herald Rules for {$rules_for}");
$panel->setCreateButton(
'Create New Herald Rule',
'/herald/new/'.$this->view.'/');
$panel->appendChild($table);
$sidenav = new AphrontSideNavView();
$sidenav->appendChild($panel);
foreach ($map as $key => $value) {
$sidenav->addNavItem(
phutil_render_tag(
@ -128,34 +122,11 @@ class HeraldHomeController extends HeraldController {
phutil_escape_html($value)));
}
$content = array();
$content[] = 'oh hi';
return $this->buildStandardPageResponse(
$sidenav,
array(
'title' => 'Herald',
));
/*
<herald:standard-page title="Herald"
selectednav={:herald:standard-page::NAV_RULES}>
<div style="padding: 1em;">
<tools:side-nav items={$items}>
<div class="tools-table">
<a href={"/herald/rule/?type=".$this->view}
class="button green"
style="float: right;">Create New Rule</a>
<h1>Herald Subscription Rules
for {txt2html($map[$this->view])}</h1>
{HTML($table->render())}
</div>
</tools:side-nav>
</div>
</herald:standard-page>;
*/
}
}

View file

@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/herald/config/contenttype');
phutil_require_module('phabricator', 'applications/herald/controller/base');
phutil_require_module('phabricator', 'applications/herald/storage/rule');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phutil', 'markup');

View file

@ -0,0 +1,64 @@
<?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.
*/
class HeraldNewController extends HeraldController {
private $type;
public function willProcessRequest(array $data) {
$this->type = idx($data, 'type');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$map = HeraldContentTypeConfig::getContentTypeMap();
if (empty($map[$this->type])) {
reset($map);
$this->type = key($map);
}
$form = id(new AphrontFormView())
->setUser($user)
->setAction('/herald/rule/')
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('New rule for')
->setName('type')
->setValue($this->type)
->setOptions($map))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Create Rule')
->addCancelButton('/herald/view/'.$this->type.'/'));
$panel = new AphrontPanelView();
$panel->setHeader('Create New Herald Rule');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Create Herald Rule',
));
}
}

View file

@ -0,0 +1,18 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/herald/config/contenttype');
phutil_require_module('phabricator', 'applications/herald/controller/base');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');
phutil_require_source('HeraldNewController.php');