mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-01 15:09:14 +01:00
Herald 'new rule type' interface.
This commit is contained in:
parent
75fcf56b67
commit
e8c960910c
6 changed files with 98 additions and 40 deletions
|
@ -193,6 +193,7 @@ phutil_register_library_map(array(
|
||||||
'HeraldHomeController' => 'applications/herald/controller/home',
|
'HeraldHomeController' => 'applications/herald/controller/home',
|
||||||
'HeraldInvalidConditionException' => 'applications/herald/engine/engine/exception',
|
'HeraldInvalidConditionException' => 'applications/herald/engine/engine/exception',
|
||||||
'HeraldInvalidFieldException' => 'applications/herald/engine/engine/exception',
|
'HeraldInvalidFieldException' => 'applications/herald/engine/engine/exception',
|
||||||
|
'HeraldNewController' => 'applications/herald/controller/new',
|
||||||
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/object',
|
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/object',
|
||||||
'HeraldRecursiveConditionsException' => 'applications/herald/engine/engine/exception',
|
'HeraldRecursiveConditionsException' => 'applications/herald/engine/engine/exception',
|
||||||
'HeraldRule' => 'applications/herald/storage/rule',
|
'HeraldRule' => 'applications/herald/storage/rule',
|
||||||
|
@ -533,6 +534,7 @@ phutil_register_library_map(array(
|
||||||
'HeraldController' => 'PhabricatorController',
|
'HeraldController' => 'PhabricatorController',
|
||||||
'HeraldDAO' => 'PhabricatorLiskDAO',
|
'HeraldDAO' => 'PhabricatorLiskDAO',
|
||||||
'HeraldHomeController' => 'HeraldController',
|
'HeraldHomeController' => 'HeraldController',
|
||||||
|
'HeraldNewController' => 'HeraldController',
|
||||||
'HeraldRule' => 'HeraldDAO',
|
'HeraldRule' => 'HeraldDAO',
|
||||||
'HeraldTranscript' => 'HeraldDAO',
|
'HeraldTranscript' => 'HeraldDAO',
|
||||||
'ManiphestController' => 'PhabricatorController',
|
'ManiphestController' => 'PhabricatorController',
|
||||||
|
|
|
@ -220,6 +220,8 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'/herald/' => array(
|
'/herald/' => array(
|
||||||
'$' => 'HeraldHomeController',
|
'$' => 'HeraldHomeController',
|
||||||
'view/(?P<view>[^/]+)/$' => 'HeraldHomeController',
|
'view/(?P<view>[^/]+)/$' => 'HeraldHomeController',
|
||||||
|
'new/(?:(?P<type>[^/]+)/)?$' => 'HeraldNewController',
|
||||||
|
'rule/(?:(?<id>\d+)/)?$' => 'HeraldRuleController',
|
||||||
),
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -78,10 +78,11 @@ class HeraldHomeController extends HeraldController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rules_for = phutil_escape_html($map[$this->view]);
|
||||||
|
|
||||||
$table = new AphrontTableView($rows);
|
$table = new AphrontTableView($rows);
|
||||||
$table->setNoDataString(
|
$table->setNoDataString(
|
||||||
"No matching subscription rules for ".
|
"No matching subscription rules for {$rules_for}.");
|
||||||
phutil_escape_html($map[$this->view]).".");
|
|
||||||
|
|
||||||
$table->setHeaders(
|
$table->setHeaders(
|
||||||
array(
|
array(
|
||||||
|
@ -98,23 +99,16 @@ class HeraldHomeController extends HeraldController {
|
||||||
'action'
|
'action'
|
||||||
));
|
));
|
||||||
|
|
||||||
$items = array();
|
$panel = new AphrontPanelView();
|
||||||
foreach ($map as $key => $value) {
|
$panel->setHeader("Herald Rules for {$rules_for}");
|
||||||
$uri = '/herald/view/'.$key.'/';
|
$panel->setCreateButton(
|
||||||
$items[] = 'item';
|
'Create New Herald Rule',
|
||||||
/* <tools:nav-item href={$uri} selected={$key == $this->view}>
|
'/herald/new/'.$this->view.'/');
|
||||||
{$value}
|
$panel->appendChild($table);
|
||||||
</tools:nav-item>;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// require_static('herald-css');
|
|
||||||
|
|
||||||
// If you're viewing as an admin, this string renders in the table header.
|
|
||||||
// $map['admin'] = 'Omniscience';
|
|
||||||
|
|
||||||
$sidenav = new AphrontSideNavView();
|
$sidenav = new AphrontSideNavView();
|
||||||
|
$sidenav->appendChild($panel);
|
||||||
|
|
||||||
foreach ($map as $key => $value) {
|
foreach ($map as $key => $value) {
|
||||||
$sidenav->addNavItem(
|
$sidenav->addNavItem(
|
||||||
phutil_render_tag(
|
phutil_render_tag(
|
||||||
|
@ -128,34 +122,11 @@ class HeraldHomeController extends HeraldController {
|
||||||
phutil_escape_html($value)));
|
phutil_escape_html($value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$content = array();
|
|
||||||
$content[] = 'oh hi';
|
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$sidenav,
|
$sidenav,
|
||||||
array(
|
array(
|
||||||
'title' => 'Herald',
|
'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>;
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/herald/storage/rule');
|
phutil_require_module('phabricator', 'applications/herald/storage/rule');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
phutil_require_module('phabricator', 'view/layout/sidenav');
|
phutil_require_module('phabricator', 'view/layout/sidenav');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
|
@ -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',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/applications/herald/controller/new/__init__.php
Normal file
18
src/applications/herald/controller/new/__init__.php
Normal 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');
|
Loading…
Add table
Reference in a new issue