mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
Implement PhabricatorProjectInterface on Almanac Services and Devices
Summary: Ref T5833. Allow services and devices to be tagged with projects. (These fluff apply implementations are a good example of the issue discussed in T6403.) Test Plan: {F229569} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5833 Differential Revision: https://secure.phabricator.com/D10782
This commit is contained in:
parent
fcad9435ea
commit
2b495f1f03
11 changed files with 96 additions and 2 deletions
16
resources/sql/autopatches/20141104.almanac.3.edge.sql
Normal file
16
resources/sql/autopatches/20141104.almanac.3.edge.sql
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
CREATE TABLE {$NAMESPACE}_almanac.edge (
|
||||||
|
src VARBINARY(64) NOT NULL,
|
||||||
|
type INT UNSIGNED NOT NULL,
|
||||||
|
dst VARBINARY(64) NOT NULL,
|
||||||
|
dateCreated INT UNSIGNED NOT NULL,
|
||||||
|
seq INT UNSIGNED NOT NULL,
|
||||||
|
dataID INT UNSIGNED,
|
||||||
|
PRIMARY KEY (src, type, dst),
|
||||||
|
KEY `src` (src, type, dateCreated, seq),
|
||||||
|
UNIQUE KEY `key_dst` (dst, type, src)
|
||||||
|
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
||||||
|
|
||||||
|
CREATE TABLE {$NAMESPACE}_almanac.edgedata (
|
||||||
|
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}
|
||||||
|
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -66,6 +66,7 @@ phutil_register_library_map(array(
|
||||||
'AlmanacPropertyInterface' => 'applications/almanac/property/AlmanacPropertyInterface.php',
|
'AlmanacPropertyInterface' => 'applications/almanac/property/AlmanacPropertyInterface.php',
|
||||||
'AlmanacPropertyQuery' => 'applications/almanac/query/AlmanacPropertyQuery.php',
|
'AlmanacPropertyQuery' => 'applications/almanac/query/AlmanacPropertyQuery.php',
|
||||||
'AlmanacQuery' => 'applications/almanac/query/AlmanacQuery.php',
|
'AlmanacQuery' => 'applications/almanac/query/AlmanacQuery.php',
|
||||||
|
'AlmanacSchemaSpec' => 'applications/almanac/storage/AlmanacSchemaSpec.php',
|
||||||
'AlmanacService' => 'applications/almanac/storage/AlmanacService.php',
|
'AlmanacService' => 'applications/almanac/storage/AlmanacService.php',
|
||||||
'AlmanacServiceController' => 'applications/almanac/controller/AlmanacServiceController.php',
|
'AlmanacServiceController' => 'applications/almanac/controller/AlmanacServiceController.php',
|
||||||
'AlmanacServiceEditController' => 'applications/almanac/controller/AlmanacServiceEditController.php',
|
'AlmanacServiceEditController' => 'applications/almanac/controller/AlmanacServiceEditController.php',
|
||||||
|
@ -3002,6 +3003,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorCustomFieldInterface',
|
'PhabricatorCustomFieldInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
|
'PhabricatorProjectInterface',
|
||||||
'AlmanacPropertyInterface',
|
'AlmanacPropertyInterface',
|
||||||
),
|
),
|
||||||
'AlmanacDeviceController' => 'AlmanacController',
|
'AlmanacDeviceController' => 'AlmanacController',
|
||||||
|
@ -3049,11 +3051,13 @@ phutil_register_library_map(array(
|
||||||
'AlmanacPropertyEditController' => 'AlmanacDeviceController',
|
'AlmanacPropertyEditController' => 'AlmanacDeviceController',
|
||||||
'AlmanacPropertyQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'AlmanacPropertyQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'AlmanacQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'AlmanacQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'AlmanacSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||||
'AlmanacService' => array(
|
'AlmanacService' => array(
|
||||||
'AlmanacDAO',
|
'AlmanacDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
'PhabricatorCustomFieldInterface',
|
'PhabricatorCustomFieldInterface',
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
|
'PhabricatorProjectInterface',
|
||||||
'AlmanacPropertyInterface',
|
'AlmanacPropertyInterface',
|
||||||
),
|
),
|
||||||
'AlmanacServiceController' => 'AlmanacController',
|
'AlmanacServiceController' => 'AlmanacController',
|
||||||
|
|
|
@ -44,10 +44,20 @@ final class AlmanacDeviceEditController
|
||||||
$e_name = true;
|
$e_name = true;
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$v_projects = array();
|
||||||
|
} else {
|
||||||
|
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$device->getPHID(),
|
||||||
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||||
|
$v_projects = array_reverse($v_projects);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$v_name = $request->getStr('name');
|
$v_name = $request->getStr('name');
|
||||||
$v_view = $request->getStr('viewPolicy');
|
$v_view = $request->getStr('viewPolicy');
|
||||||
$v_edit = $request->getStr('editPolicy');
|
$v_edit = $request->getStr('editPolicy');
|
||||||
|
$v_projects = $request->getArr('projects');
|
||||||
|
|
||||||
$type_name = AlmanacDeviceTransaction::TYPE_NAME;
|
$type_name = AlmanacDeviceTransaction::TYPE_NAME;
|
||||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
|
@ -67,6 +77,12 @@ final class AlmanacDeviceEditController
|
||||||
->setTransactionType($type_edit)
|
->setTransactionType($type_edit)
|
||||||
->setNewValue($v_edit);
|
->setNewValue($v_edit);
|
||||||
|
|
||||||
|
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$xactions[] = id(new AlmanacDeviceTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $proj_edge_type)
|
||||||
|
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||||
|
|
||||||
$editor = id(new AlmanacDeviceEditor())
|
$editor = id(new AlmanacDeviceEditor())
|
||||||
->setActor($viewer)
|
->setActor($viewer)
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
|
@ -91,6 +107,12 @@ final class AlmanacDeviceEditController
|
||||||
->setObject($device)
|
->setObject($device)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
if ($v_projects) {
|
||||||
|
$project_handles = $this->loadViewerHandles($v_projects);
|
||||||
|
} else {
|
||||||
|
$project_handles = array();
|
||||||
|
}
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -111,6 +133,12 @@ final class AlmanacDeviceEditController
|
||||||
->setPolicyObject($device)
|
->setPolicyObject($device)
|
||||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||||
->setPolicies($policies))
|
->setPolicies($policies))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTokenizerControl())
|
||||||
|
->setLabel(pht('Projects'))
|
||||||
|
->setName('projects')
|
||||||
|
->setValue($project_handles)
|
||||||
|
->setDatasource(new PhabricatorProjectDatasource()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton($cancel_uri)
|
->addCancelButton($cancel_uri)
|
||||||
|
|
|
@ -68,7 +68,8 @@ final class AlmanacDeviceViewController
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$properties = id(new PHUIPropertyListView())
|
$properties = id(new PHUIPropertyListView())
|
||||||
->setUser($viewer);
|
->setUser($viewer)
|
||||||
|
->setObject($device);
|
||||||
|
|
||||||
return $properties;
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,20 @@ final class AlmanacServiceEditController
|
||||||
$e_name = true;
|
$e_name = true;
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$v_projects = array();
|
||||||
|
} else {
|
||||||
|
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$service->getPHID(),
|
||||||
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||||
|
$v_projects = array_reverse($v_projects);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$v_name = $request->getStr('name');
|
$v_name = $request->getStr('name');
|
||||||
$v_view = $request->getStr('viewPolicy');
|
$v_view = $request->getStr('viewPolicy');
|
||||||
$v_edit = $request->getStr('editPolicy');
|
$v_edit = $request->getStr('editPolicy');
|
||||||
|
$v_projects = $request->getArr('projects');
|
||||||
|
|
||||||
$type_name = AlmanacServiceTransaction::TYPE_NAME;
|
$type_name = AlmanacServiceTransaction::TYPE_NAME;
|
||||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
|
@ -67,6 +77,12 @@ final class AlmanacServiceEditController
|
||||||
->setTransactionType($type_edit)
|
->setTransactionType($type_edit)
|
||||||
->setNewValue($v_edit);
|
->setNewValue($v_edit);
|
||||||
|
|
||||||
|
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$xactions[] = id(new AlmanacServiceTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $proj_edge_type)
|
||||||
|
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||||
|
|
||||||
$editor = id(new AlmanacServiceEditor())
|
$editor = id(new AlmanacServiceEditor())
|
||||||
->setActor($viewer)
|
->setActor($viewer)
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
|
@ -91,6 +107,12 @@ final class AlmanacServiceEditController
|
||||||
->setObject($service)
|
->setObject($service)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
if ($v_projects) {
|
||||||
|
$project_handles = $this->loadViewerHandles($v_projects);
|
||||||
|
} else {
|
||||||
|
$project_handles = array();
|
||||||
|
}
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -111,6 +133,12 @@ final class AlmanacServiceEditController
|
||||||
->setPolicyObject($service)
|
->setPolicyObject($service)
|
||||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||||
->setPolicies($policies))
|
->setPolicies($policies))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTokenizerControl())
|
||||||
|
->setLabel(pht('Projects'))
|
||||||
|
->setName('projects')
|
||||||
|
->setValue($project_handles)
|
||||||
|
->setDatasource(new PhabricatorProjectDatasource()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->addCancelButton($cancel_uri)
|
->addCancelButton($cancel_uri)
|
||||||
|
|
|
@ -68,7 +68,8 @@ final class AlmanacServiceViewController
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$properties = id(new PHUIPropertyListView())
|
$properties = id(new PHUIPropertyListView())
|
||||||
->setUser($viewer);
|
->setUser($viewer)
|
||||||
|
->setObject($service);
|
||||||
|
|
||||||
return $properties;
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ final class AlmanacDeviceEditor
|
||||||
case AlmanacDeviceTransaction::TYPE_INTERFACE:
|
case AlmanacDeviceTransaction::TYPE_INTERFACE:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ final class AlmanacDeviceEditor
|
||||||
case AlmanacDeviceTransaction::TYPE_NAME:
|
case AlmanacDeviceTransaction::TYPE_NAME:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
case AlmanacDeviceTransaction::TYPE_INTERFACE:
|
case AlmanacDeviceTransaction::TYPE_INTERFACE:
|
||||||
$old = $xaction->getOldValue();
|
$old = $xaction->getOldValue();
|
||||||
|
|
|
@ -54,6 +54,7 @@ final class AlmanacServiceEditor
|
||||||
return;
|
return;
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ final class AlmanacServiceEditor
|
||||||
case AlmanacServiceTransaction::TYPE_NAME:
|
case AlmanacServiceTransaction::TYPE_NAME:
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ final class AlmanacDevice
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorCustomFieldInterface,
|
PhabricatorCustomFieldInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
|
PhabricatorProjectInterface,
|
||||||
AlmanacPropertyInterface {
|
AlmanacPropertyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
10
src/applications/almanac/storage/AlmanacSchemaSpec.php
Normal file
10
src/applications/almanac/storage/AlmanacSchemaSpec.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class AlmanacSchemaSpec
|
||||||
|
extends PhabricatorConfigSchemaSpec {
|
||||||
|
|
||||||
|
public function buildSchemata() {
|
||||||
|
$this->buildEdgeSchemata(new AlmanacService());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ final class AlmanacService
|
||||||
PhabricatorPolicyInterface,
|
PhabricatorPolicyInterface,
|
||||||
PhabricatorCustomFieldInterface,
|
PhabricatorCustomFieldInterface,
|
||||||
PhabricatorApplicationTransactionInterface,
|
PhabricatorApplicationTransactionInterface,
|
||||||
|
PhabricatorProjectInterface,
|
||||||
AlmanacPropertyInterface {
|
AlmanacPropertyInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
Loading…
Reference in a new issue