1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

Add drydock.blueprint.edit Conduit method

Summary:
Ref: https://admin.phacility.com/PHI243

Since our use case primarily focuses on transaction editing, this patch implements the `drydock.blueprint.edit` api method with the understanding that:
a) this is a work in progress
b) object editing is supported, but object creation is not yet implemented

Test Plan:
* updated existing blueprints via Conduit UI
* regression tested `maniphest.edit` by creating new and updating existing tasks

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, yelirekim, jcox

Differential Revision: https://secure.phabricator.com/D18822
This commit is contained in:
Tim Hirsh 2017-12-08 11:54:42 -05:00
parent 6d3baa92f9
commit 60e5c0ec1b
4 changed files with 43 additions and 1 deletions

View file

@ -1004,6 +1004,7 @@ phutil_register_library_map(array(
'DrydockBlueprintCustomField' => 'applications/drydock/customfield/DrydockBlueprintCustomField.php',
'DrydockBlueprintDatasource' => 'applications/drydock/typeahead/DrydockBlueprintDatasource.php',
'DrydockBlueprintDisableController' => 'applications/drydock/controller/DrydockBlueprintDisableController.php',
'DrydockBlueprintEditConduitAPIMethod' => 'applications/drydock/conduit/DrydockBlueprintEditConduitAPIMethod.php',
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
'DrydockBlueprintEditEngine' => 'applications/drydock/editor/DrydockBlueprintEditEngine.php',
'DrydockBlueprintEditor' => 'applications/drydock/editor/DrydockBlueprintEditor.php',
@ -6090,6 +6091,7 @@ phutil_register_library_map(array(
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockBlueprintDisableController' => 'DrydockBlueprintController',
'DrydockBlueprintEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditEngine' => 'PhabricatorEditEngine',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',

View file

@ -0,0 +1,20 @@
<?php
final class DrydockBlueprintEditConduitAPIMethod
extends PhabricatorEditEngineAPIMethod {
public function getAPIMethodName() {
return 'drydock.blueprint.edit';
}
public function newEditEngine() {
return new DrydockBlueprintEditEngine();
}
public function getMethodSummary() {
return pht(
'WARNING: Apply transactions to edit an existing blueprint. This method '.
'can not create new blueprints.');
}
}

View file

@ -51,6 +51,17 @@ final class DrydockBlueprintEditEngine
return $blueprint;
}
protected function newEditableObjectForDocumentation() {
// In order to generate the proper list of fields/transactions for a
// blueprint, a blueprint's type needs to be known upfront, and there's
// currently no way to pre-specify the type. Hardcoding an implementation
// here prevents the fatal on the Conduit API page and allows transactions
// to be edited.
$impl = new DrydockWorkingCopyBlueprintImplementation();
$this->setBlueprintImplementation($impl);
return $this->newEditableObject();
}
protected function newObjectQuery() {
return new DrydockBlueprintQuery();
}

View file

@ -630,6 +630,15 @@ abstract class PhabricatorEditEngine
return $this->isCreate;
}
/**
* Initialize a new object for documentation creation.
*
* @return object Newly initialized object.
* @task load
*/
protected function newEditableObjectForDocumentation() {
return $this->newEditableObject();
}
/**
* Flag this workflow as a create or edit.
@ -2198,7 +2207,7 @@ abstract class PhabricatorEditEngine
return array();
}
$object = $this->newEditableObject();
$object = $this->newEditableObjectForDocumentation();
$fields = $this->buildEditFields($object);
return $this->getConduitEditTypesFromFields($fields);
}