mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 06:50:55 +01:00
Slightly modernize NuanceSource
Summary: Ref T8434. Minor cleanup/modernization. I made type selection modal (like Herald, Auth, etc) so we can render the form on the next screen based on the type. {F472519} Test Plan: Created a new source, edited an existing source. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8434 Differential Revision: https://secure.phabricator.com/D13161
This commit is contained in:
parent
1f65a50f04
commit
837e6b5ca7
9 changed files with 145 additions and 113 deletions
|
@ -1138,6 +1138,7 @@ phutil_register_library_map(array(
|
||||||
'NuanceRequestorViewController' => 'applications/nuance/controller/NuanceRequestorViewController.php',
|
'NuanceRequestorViewController' => 'applications/nuance/controller/NuanceRequestorViewController.php',
|
||||||
'NuanceSchemaSpec' => 'applications/nuance/storage/NuanceSchemaSpec.php',
|
'NuanceSchemaSpec' => 'applications/nuance/storage/NuanceSchemaSpec.php',
|
||||||
'NuanceSource' => 'applications/nuance/storage/NuanceSource.php',
|
'NuanceSource' => 'applications/nuance/storage/NuanceSource.php',
|
||||||
|
'NuanceSourceCreateController' => 'applications/nuance/controller/NuanceSourceCreateController.php',
|
||||||
'NuanceSourceDefaultEditCapability' => 'applications/nuance/capability/NuanceSourceDefaultEditCapability.php',
|
'NuanceSourceDefaultEditCapability' => 'applications/nuance/capability/NuanceSourceDefaultEditCapability.php',
|
||||||
'NuanceSourceDefaultViewCapability' => 'applications/nuance/capability/NuanceSourceDefaultViewCapability.php',
|
'NuanceSourceDefaultViewCapability' => 'applications/nuance/capability/NuanceSourceDefaultViewCapability.php',
|
||||||
'NuanceSourceDefinition' => 'applications/nuance/source/NuanceSourceDefinition.php',
|
'NuanceSourceDefinition' => 'applications/nuance/source/NuanceSourceDefinition.php',
|
||||||
|
@ -4455,6 +4456,7 @@ phutil_register_library_map(array(
|
||||||
'NuanceQueue' => array(
|
'NuanceQueue' => array(
|
||||||
'NuanceDAO',
|
'NuanceDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorApplicationTransactionInterface',
|
||||||
),
|
),
|
||||||
'NuanceQueueEditController' => 'NuanceController',
|
'NuanceQueueEditController' => 'NuanceController',
|
||||||
'NuanceQueueEditor' => 'PhabricatorApplicationTransactionEditor',
|
'NuanceQueueEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
@ -4481,6 +4483,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
|
'NuanceSourceCreateController' => 'NuanceController',
|
||||||
'NuanceSourceDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
'NuanceSourceDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||||
'NuanceSourceDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
'NuanceSourceDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||||
'NuanceSourceDefinition' => 'Phobject',
|
'NuanceSourceDefinition' => 'Phobject',
|
||||||
|
|
|
@ -46,7 +46,8 @@ final class PhabricatorNuanceApplication extends PhabricatorApplication {
|
||||||
'source/' => array(
|
'source/' => array(
|
||||||
'view/(?P<id>[1-9]\d*)/' => 'NuanceSourceViewController',
|
'view/(?P<id>[1-9]\d*)/' => 'NuanceSourceViewController',
|
||||||
'edit/(?P<id>[1-9]\d*)/' => 'NuanceSourceEditController',
|
'edit/(?P<id>[1-9]\d*)/' => 'NuanceSourceEditController',
|
||||||
'new/' => 'NuanceSourceEditController',
|
'new/(?P<type>[^/]+)/' => 'NuanceSourceEditController',
|
||||||
|
'create/' => 'NuanceSourceCreateController',
|
||||||
),
|
),
|
||||||
'queue/' => array(
|
'queue/' => array(
|
||||||
'view/(?P<id>[1-9]\d*)/' => 'NuanceQueueViewController',
|
'view/(?P<id>[1-9]\d*)/' => 'NuanceQueueViewController',
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class NuanceSourceCreateController extends NuanceController {
|
||||||
|
|
||||||
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$can_edit = $this->requireApplicationCapability(
|
||||||
|
NuanceSourceManageCapability::CAPABILITY);
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$map = NuanceSourceDefinition::getAllDefinitions();
|
||||||
|
$cancel_uri = $this->getApplicationURI('source/');
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
$type = $request->getStr('type');
|
||||||
|
if (isset($map[$type])) {
|
||||||
|
$uri = $this->getApplicationURI('source/new/'.$type.'/');
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$source_types = id(new AphrontFormRadioButtonControl())
|
||||||
|
->setName('type')
|
||||||
|
->setLabel(pht('Source Type'));
|
||||||
|
|
||||||
|
foreach ($map as $type => $definition) {
|
||||||
|
$source_types->addButton(
|
||||||
|
$type,
|
||||||
|
$definition->getName(),
|
||||||
|
$definition->getSourceDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->appendChild($source_types)
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue(pht('Continue'))
|
||||||
|
->addCancelButton($cancel_uri));
|
||||||
|
|
||||||
|
$box = id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText(pht('Choose Source Type'))
|
||||||
|
->appendChild($form);
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(pht('Sources'), $cancel_uri);
|
||||||
|
$crumbs->addTextCrumb(pht('New'));
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$box,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => pht('Choose Source Type'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,35 +2,32 @@
|
||||||
|
|
||||||
final class NuanceSourceEditController extends NuanceController {
|
final class NuanceSourceEditController extends NuanceController {
|
||||||
|
|
||||||
private $sourceID;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
|
||||||
public function setSourceID($source_id) {
|
|
||||||
$this->sourceID = $source_id;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
public function getSourceID() {
|
|
||||||
return $this->sourceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
|
||||||
$this->setSourceID(idx($data, 'id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$can_edit = $this->requireApplicationCapability(
|
$can_edit = $this->requireApplicationCapability(
|
||||||
NuanceSourceManageCapability::CAPABILITY);
|
NuanceSourceManageCapability::CAPABILITY);
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$viewer = $this->getViewer();
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
$source_id = $this->getSourceID();
|
$sources_uri = $this->getApplicationURI('source/');
|
||||||
|
|
||||||
|
$source_id = $request->getURIData('id');
|
||||||
$is_new = !$source_id;
|
$is_new = !$source_id;
|
||||||
|
|
||||||
if ($is_new) {
|
if ($is_new) {
|
||||||
$source = NuanceSource::initializeNewSource($user);
|
$source = NuanceSource::initializeNewSource($viewer);
|
||||||
|
|
||||||
|
$type = $request->getURIData('type');
|
||||||
|
$map = NuanceSourceDefinition::getAllDefinitions();
|
||||||
|
|
||||||
|
if (empty($map[$type])) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$source->setType($type);
|
||||||
|
$cancel_uri = $sources_uri;
|
||||||
} else {
|
} else {
|
||||||
$source = id(new NuanceSourceQuery())
|
$source = id(new NuanceSourceQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($source_id))
|
->withIDs(array($source_id))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
|
@ -38,14 +35,14 @@ final class NuanceSourceEditController extends NuanceController {
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
))
|
))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
}
|
if (!$source) {
|
||||||
|
return new Aphront404Response();
|
||||||
if (!$source) {
|
}
|
||||||
return new Aphront404Response();
|
$cancel_uri = $source->getURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition = NuanceSourceDefinition::getDefinitionForSource($source);
|
$definition = NuanceSourceDefinition::getDefinitionForSource($source);
|
||||||
$definition->setActor($user);
|
$definition->setActor($viewer);
|
||||||
|
|
||||||
$response = $definition->buildEditLayout($request);
|
$response = $definition->buildEditLayout($request);
|
||||||
if ($response instanceof AphrontResponse) {
|
if ($response instanceof AphrontResponse) {
|
||||||
|
@ -54,6 +51,15 @@ final class NuanceSourceEditController extends NuanceController {
|
||||||
$layout = $response;
|
$layout = $response;
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(pht('Sources'), $sources_uri);
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$crumbs->addTextCrumb(pht('New'));
|
||||||
|
} else {
|
||||||
|
$crumbs->addTextCrumb($source->getName(), $cancel_uri);
|
||||||
|
$crumbs->addTextCrumb(pht('Edit'));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
$crumbs,
|
$crumbs,
|
||||||
|
|
|
@ -2,30 +2,13 @@
|
||||||
|
|
||||||
final class NuanceSourceViewController extends NuanceController {
|
final class NuanceSourceViewController extends NuanceController {
|
||||||
|
|
||||||
private $sourceID;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
public function setSourceID($source_id) {
|
|
||||||
$this->sourceID = $source_id;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
public function getSourceID() {
|
|
||||||
return $this->sourceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
|
||||||
$this->setSourceID($data['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$viewer = $request->getUser();
|
|
||||||
|
|
||||||
$source_id = $this->getSourceID();
|
|
||||||
$source = id(new NuanceSourceQuery())
|
$source = id(new NuanceSourceQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($source_id))
|
->withIDs(array($request->getURIData('id')))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
if (!$source) {
|
if (!$source) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
@ -37,10 +20,6 @@ final class NuanceSourceViewController extends NuanceController {
|
||||||
new NuanceSourceTransactionQuery());
|
new NuanceSourceTransactionQuery());
|
||||||
$timeline->setShouldTerminate(true);
|
$timeline->setShouldTerminate(true);
|
||||||
|
|
||||||
$title = pht('%s', $source->getName());
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
|
||||||
$crumbs->addTextCrumb($title);
|
|
||||||
|
|
||||||
$header = $this->buildHeaderView($source);
|
$header = $this->buildHeaderView($source);
|
||||||
$actions = $this->buildActionView($source);
|
$actions = $this->buildActionView($source);
|
||||||
$properties = $this->buildPropertyView($source, $actions);
|
$properties = $this->buildPropertyView($source, $actions);
|
||||||
|
@ -49,6 +28,12 @@ final class NuanceSourceViewController extends NuanceController {
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->addPropertyList($properties);
|
||||||
|
|
||||||
|
$title = $source->getName();
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(pht('Sources'), $this->getApplicationURI('source/'));
|
||||||
|
|
||||||
|
$crumbs->addTextCrumb($title);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
$crumbs,
|
$crumbs,
|
||||||
|
@ -58,12 +43,10 @@ final class NuanceSourceViewController extends NuanceController {
|
||||||
array(
|
array(
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildHeaderView(NuanceSource $source) {
|
||||||
private function buildHeaderView(NuanceSource $source) {
|
$viewer = $this->getViewer();
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
|
@ -74,7 +57,7 @@ final class NuanceSourceViewController extends NuanceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(NuanceSource $source) {
|
private function buildActionView(NuanceSource $source) {
|
||||||
$viewer = $this->getRequest()->getUser();
|
$viewer = $this->getViewer();
|
||||||
$id = $source->getID();
|
$id = $source->getID();
|
||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
|
|
|
@ -5,7 +5,6 @@ final class NuanceSourceQuery
|
||||||
|
|
||||||
private $ids;
|
private $ids;
|
||||||
private $phids;
|
private $phids;
|
||||||
private $creatorPHIDs;
|
|
||||||
private $types;
|
private $types;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
|
@ -18,66 +17,52 @@ final class NuanceSourceQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withCreatorPHIDs(array $phids) {
|
|
||||||
$this->CreatorPHIDs = $phids;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function withTypes($types) {
|
public function withTypes($types) {
|
||||||
$this->types = $types;
|
$this->types = $types;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
$table = new NuanceSource();
|
$table = new NuanceSource();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn = $table->establishConnection('r');
|
||||||
|
|
||||||
$data = queryfx_all(
|
$data = queryfx_all(
|
||||||
$conn_r,
|
$conn,
|
||||||
'SELECT * FROM %T %Q %Q %Q',
|
'%Q FROM %T %Q %Q %Q',
|
||||||
|
$this->buildSelectClause($conn),
|
||||||
$table->getTableName(),
|
$table->getTableName(),
|
||||||
$this->buildWhereClause($conn_r),
|
$this->buildWhereClause($conn),
|
||||||
$this->buildOrderClause($conn_r),
|
$this->buildOrderClause($conn),
|
||||||
$this->buildLimitClause($conn_r));
|
$this->buildLimitClause($conn));
|
||||||
|
|
||||||
return $table->loadAllFromArray($data);
|
return $table->loadAllFromArray($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
$where = array();
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
if ($this->types !== null) {
|
||||||
|
|
||||||
if ($this->creatorPHIDs) {
|
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'creatorPHID IN (%Ls)',
|
'type IN (%Ls)',
|
||||||
$this->creatorPHIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->types) {
|
|
||||||
$where[] = qsprintf(
|
|
||||||
$conn_r,
|
|
||||||
'type IN (%Ld)',
|
|
||||||
$this->types);
|
$this->types);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->ids) {
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'phid IN (%Ls)',
|
'phid IN (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ final class NuancePhabricatorFormSourceDefinition
|
||||||
return pht('Phabricator Form');
|
return pht('Phabricator Form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSourceDescription() {
|
||||||
|
return pht('Create a web form that submits into a Nuance queue.');
|
||||||
|
}
|
||||||
|
|
||||||
public function getSourceTypeConstant() {
|
public function getSourceTypeConstant() {
|
||||||
return 'phabricator-form';
|
return 'phabricator-form';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
$this->actor = $actor;
|
$this->actor = $actor;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActor() {
|
public function getActor() {
|
||||||
return $this->actor;
|
return $this->actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireActor() {
|
public function requireActor() {
|
||||||
$actor = $this->getActor();
|
$actor = $this->getActor();
|
||||||
if (!$actor) {
|
if (!$actor) {
|
||||||
|
@ -25,9 +27,11 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
$this->sourceObject = $source;
|
$this->sourceObject = $source;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSourceObject() {
|
public function getSourceObject() {
|
||||||
return $this->sourceObject;
|
return $this->sourceObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireSourceObject() {
|
public function requireSourceObject() {
|
||||||
$source = $this->getSourceObject();
|
$source = $this->getSourceObject();
|
||||||
if (!$source) {
|
if (!$source) {
|
||||||
|
@ -36,19 +40,6 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSelectOptions() {
|
|
||||||
$definitions = self::getAllDefinitions();
|
|
||||||
|
|
||||||
$options = array();
|
|
||||||
foreach ($definitions as $definition) {
|
|
||||||
$key = $definition->getSourceTypeConstant();
|
|
||||||
$name = $definition->getName();
|
|
||||||
$options[$key] = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives a @{class:NuanceSourceDefinition} object for a given
|
* Gives a @{class:NuanceSourceDefinition} object for a given
|
||||||
* @{class:NuanceSource}. Note you still need to @{method:setActor}
|
* @{class:NuanceSource}. Note you still need to @{method:setActor}
|
||||||
|
@ -67,6 +58,8 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
static $definitions;
|
static $definitions;
|
||||||
|
|
||||||
if ($definitions === null) {
|
if ($definitions === null) {
|
||||||
|
$definitions = array();
|
||||||
|
|
||||||
$objects = id(new PhutilSymbolLoader())
|
$objects = id(new PhutilSymbolLoader())
|
||||||
->setAncestorClass(__CLASS__)
|
->setAncestorClass(__CLASS__)
|
||||||
->loadObjects();
|
->loadObjects();
|
||||||
|
@ -82,9 +75,10 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
$conflict,
|
$conflict,
|
||||||
$name));
|
$name));
|
||||||
}
|
}
|
||||||
|
$definitions[$key] = $definition;
|
||||||
}
|
}
|
||||||
$definitions = $objects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $definitions;
|
return $definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +87,12 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
*/
|
*/
|
||||||
abstract public function getName();
|
abstract public function getName();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human readable description of this source, a sentence or two long.
|
||||||
|
*/
|
||||||
|
abstract public function getSourceDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should be a any VARCHAR(32).
|
* This should be a any VARCHAR(32).
|
||||||
*
|
*
|
||||||
|
@ -193,13 +193,7 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
->setLabel(pht('Name'))
|
->setLabel(pht('Name'))
|
||||||
->setName('name')
|
->setName('name')
|
||||||
->setError($e_name)
|
->setError($e_name)
|
||||||
->setValue($source->getName()))
|
->setValue($source->getName()));
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormSelectControl())
|
|
||||||
->setLabel(pht('Type'))
|
|
||||||
->setName('type')
|
|
||||||
->setOptions(self::getSelectOptions())
|
|
||||||
->setValue($source->getType()));
|
|
||||||
|
|
||||||
$form = $this->augmentEditForm($form, $ex);
|
$form = $this->augmentEditForm($form, $ex);
|
||||||
|
|
||||||
|
|
|
@ -57,13 +57,9 @@ final class NuanceSource extends NuanceDAO
|
||||||
$edit_policy = $app->getPolicy(
|
$edit_policy = $app->getPolicy(
|
||||||
NuanceSourceDefaultEditCapability::CAPABILITY);
|
NuanceSourceDefaultEditCapability::CAPABILITY);
|
||||||
|
|
||||||
$definitions = NuanceSourceDefinition::getAllDefinitions();
|
|
||||||
$lucky_definition = head($definitions);
|
|
||||||
|
|
||||||
return id(new NuanceSource())
|
return id(new NuanceSource())
|
||||||
->setViewPolicy($view_policy)
|
->setViewPolicy($view_policy)
|
||||||
->setEditPolicy($edit_policy)
|
->setEditPolicy($edit_policy);
|
||||||
->setType($lucky_definition->getSourceTypeConstant());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +86,9 @@ final class NuanceSource extends NuanceDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
|
Loading…
Reference in a new issue