1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Restore "Tags" and "Subscribers" edit capabilities to Maniphest bulk editor

Summary: Depends on D18867. Ref T13025. Fixes T8740. Rebuilds the tag/subscriber actions (add, remove, set) into the bulk editor.

Test Plan: Added, removed and set these values via bulk edit.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13025, T8740

Differential Revision: https://secure.phabricator.com/D18868
This commit is contained in:
epriestley 2018-01-11 10:58:10 -08:00
parent 687fada5af
commit 0cad6021b6
8 changed files with 123 additions and 4 deletions

View file

@ -226,6 +226,7 @@ phutil_register_library_map(array(
'BulkRemarkupParameterType' => 'applications/transactions/bulk/type/BulkRemarkupParameterType.php',
'BulkSelectParameterType' => 'applications/transactions/bulk/type/BulkSelectParameterType.php',
'BulkStringParameterType' => 'applications/transactions/bulk/type/BulkStringParameterType.php',
'BulkTokenizerParameterType' => 'applications/transactions/bulk/type/BulkTokenizerParameterType.php',
'CalendarTimeUtil' => 'applications/calendar/util/CalendarTimeUtil.php',
'CalendarTimeUtilTestCase' => 'applications/calendar/__tests__/CalendarTimeUtilTestCase.php',
'CelerityAPI' => 'applications/celerity/CelerityAPI.php',
@ -5249,6 +5250,7 @@ phutil_register_library_map(array(
'BulkRemarkupParameterType' => 'BulkParameterType',
'BulkSelectParameterType' => 'BulkParameterType',
'BulkStringParameterType' => 'BulkParameterType',
'BulkTokenizerParameterType' => 'BulkParameterType',
'CalendarTimeUtil' => 'Phobject',
'CalendarTimeUtilTestCase' => 'PhabricatorTestCase',
'CelerityAPI' => 'Phobject',

View file

@ -46,6 +46,8 @@ final class PhabricatorProjectsEditEngineExtension
$project_phids = array();
}
$viewer = $engine->getViewer();
$projects_field = id(new PhabricatorProjectsEditField())
->setKey('projectPHIDs')
->setLabel(pht('Tags'))
@ -58,9 +60,11 @@ final class PhabricatorProjectsEditEngineExtension
->setDescription(pht('Select project tags for the object.'))
->setTransactionType($edge_type)
->setMetadataValue('edge:type', $project_edge_type)
->setValue($project_phids);
->setValue($project_phids)
->setViewer($viewer);
$projects_field->setViewer($engine->getViewer());
$projects_datasource = id(new PhabricatorProjectDatasource())
->setViewer($viewer);
$edit_add = $projects_field->getConduitEditType(self::EDITKEY_ADD)
->setConduitDescription(pht('Add project tags.'));
@ -72,6 +76,18 @@ final class PhabricatorProjectsEditEngineExtension
$edit_rem = $projects_field->getConduitEditType(self::EDITKEY_REMOVE)
->setConduitDescription(pht('Remove project tags.'));
$projects_field->getBulkEditType(self::EDITKEY_ADD)
->setBulkEditLabel(pht('Add project tags'))
->setDatasource($projects_datasource);
$projects_field->getBulkEditType(self::EDITKEY_SET)
->setBulkEditLabel(pht('Set project tags to'))
->setDatasource($projects_datasource);
$projects_field->getBulkEditType(self::EDITKEY_REMOVE)
->setBulkEditLabel(pht('Remove project tags'))
->setDatasource($projects_datasource);
return array(
$projects_field,
);

View file

@ -42,6 +42,8 @@ final class PhabricatorSubscriptionsEditEngineExtension
$sub_phids = array();
}
$viewer = $engine->getViewer();
$subscribers_field = id(new PhabricatorSubscribersEditField())
->setKey(self::FIELDKEY)
->setLabel(pht('Subscribers'))
@ -53,9 +55,11 @@ final class PhabricatorSubscriptionsEditEngineExtension
->setCommentActionOrder(9000)
->setDescription(pht('Choose subscribers.'))
->setTransactionType($subscribers_type)
->setValue($sub_phids);
->setValue($sub_phids)
->setViewer($viewer);
$subscribers_field->setViewer($engine->getViewer());
$subscriber_datasource = id(new PhabricatorMetaMTAMailableDatasource())
->setViewer($viewer);
$edit_add = $subscribers_field->getConduitEditType(self::EDITKEY_ADD)
->setConduitDescription(pht('Add subscribers.'));
@ -67,6 +71,18 @@ final class PhabricatorSubscriptionsEditEngineExtension
$edit_rem = $subscribers_field->getConduitEditType(self::EDITKEY_REMOVE)
->setConduitDescription(pht('Remove subscribers.'));
$subscribers_field->getBulkEditType(self::EDITKEY_ADD)
->setBulkEditLabel(pht('Add subscribers'))
->setDatasource($subscriber_datasource);
$subscribers_field->getBulkEditType(self::EDITKEY_SET)
->setBulkEditLabel(pht('Set subscribers to'))
->setDatasource($subscriber_datasource);
$subscribers_field->getBulkEditType(self::EDITKEY_REMOVE)
->setBulkEditLabel(pht('Remove subscribers'))
->setDatasource($subscriber_datasource);
return array(
$subscribers_field,
);

View file

@ -82,6 +82,12 @@ final class PhabricatorEditEngineBulkJobType
$xaction->attachComment($comment);
}
if (isset($raw_xaction['metadata'])) {
foreach ($raw_xaction['metadata'] as $meta_key => $meta_value) {
$xaction->setMetadataValue($meta_key, $meta_value);
}
}
$xactions[] = $xaction;
}

View file

@ -0,0 +1,40 @@
<?php
final class BulkTokenizerParameterType
extends BulkParameterType {
private $datasource;
public function setDatasource(PhabricatorTypeaheadDatasource $datasource) {
$this->datasource = $datasource;
return $this;
}
public function getDatasource() {
return $this->datasource;
}
public function getPHUIXControlType() {
return 'tokenizer';
}
public function getPHUIXControlSpecification() {
$template = new AphrontTokenizerTemplateView();
$template_markup = $template->render();
$datasource = $this->getDatasource();
$limit = null;
return array(
'markup' => (string)hsprintf('%s', $template_markup),
'config' => array(
'src' => $datasource->getDatasourceURI(),
'browseURI' => $datasource->getBrowseURI(),
'placeholder' => $datasource->getPlaceholderText(),
'limit' => $limit,
),
'value' => null,
);
}
}

View file

@ -2498,6 +2498,8 @@ abstract class PhabricatorEditEngine
// but it's possible that this isn't the case.
$xaction['type'] = $edit_type->getTransactionType();
$xaction['metadata'] = $edit_type->getMetadata();
$xaction = $edit_type->newRawBulkTransaction($xaction);
if ($xaction === null) {
unset($xactions[$key]);

View file

@ -769,6 +769,19 @@ abstract class PhabricatorEditField extends Phobject {
return $this->bulkEditTypes;
}
final public function getBulkEditType($key) {
$edit_types = $this->getBulkEditTypes();
if (empty($edit_types[$key])) {
throw new Exception(
pht(
'This EditField does not provide a Bulk EditType with key "%s".',
$key));
}
return $edit_types[$key];
}
protected function newBulkEditTypes() {
$edit_type = $this->getEditType();

View file

@ -34,4 +34,28 @@ final class PhabricatorEdgeEditType
return array($xaction);
}
protected function newBulkParameterType() {
if (!$this->getDatasource()) {
return null;
}
return id(new BulkTokenizerParameterType())
->setDatasource($this->getDatasource());
}
public function newRawBulkTransaction(array $xaction) {
$value = idx($xaction, 'value');
if ($this->getEdgeOperation() !== null) {
$value = array_fuse($value);
$value = array(
$this->getEdgeOperation() => $value,
);
$xaction['value'] = $value;
}
return $xaction;
}
}