1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Allow "Change Subtype" to be selected from the comment action stack

Summary:
Ref T13222. See PHI683. Currently, you can "Change subtype..." via Conduit and the bulk editor, but not via the comment action stack or edit forms.

In PHI683 an install is doing this often enough that they'd like it to become a first-class action. I've generally been cautious about pushing this action to become a first-class action (there are some inevitable rough edges and I don't want to add too much complexity if there isn't a use case for it) but since we have evidence that users would find it useful and nothing has exploded yet, I'm comfortable taking another step forward.

Currently, `EditEngine` has this sort of weird `setIsConduitOnly()` method. This actually means more like "this doesn't show up on forms". Make it better align with that. In particular, a "conduit only" field can already show up in the bulk editor, which is goofy. Change this to `setIsFormField()` and convert/simplify existing callsites.

Test Plan:
There are a lot of ways to reach EditEngine so this probably isn't entirely exhaustive, but I think I got pretty much anything which is likely to break:

- Searched for `setIsConduitOnly()` and `getIsConduitOnly()`, converted all callsites to `setIsFormField()`.
- Searched for `setIsLockable()`, `setIsReorderable()` and `setIsDefaultable()` and aligned these calls to intent where applicable.
- Created an Almanac binding.
- Edited an Almanac binding.
- Created an Almanac service.
- Edited an Almanac service.
- Edited a binding property.
- Deleted a binding property.
- Created and edited a badge.
- Awarded and revoked a badge.
- Created and edited an event.
- Made an event recurring.
- Created and edited a Conpherence thread.
- Edited and updated the diff for a revision.
- Created and edited a repository.
- Created and disabled repository URIs.
- Created and edited a blueprint.
- Created and edited tasks.
- Created a paste, edited/archived a paste.
- Created/edited/archived a package.
- Created/edited a project.
- Made comments.
- Moved tasks on workboards via comment action stack.
- Changed task subtype via comment action stack.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13222

Differential Revision: https://secure.phabricator.com/D19842
This commit is contained in:
epriestley 2018-11-26 15:44:48 -08:00
parent 1d0b99e1f8
commit 2f11001f6e
29 changed files with 85 additions and 68 deletions

View file

@ -136,7 +136,7 @@ final class AlmanacBindingEditEngine
id(new PhabricatorTextEditField())
->setKey('service')
->setLabel(pht('Service'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
AlmanacBindingServiceTransaction::TRANSACTIONTYPE)
->setDescription(pht('Service to create a binding for.'))
@ -146,7 +146,7 @@ final class AlmanacBindingEditEngine
id(new PhabricatorTextEditField())
->setKey('interface')
->setLabel(pht('Interface'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
AlmanacBindingInterfaceTransaction::TRANSACTIONTYPE)
->setDescription(pht('Interface to bind the service to.'))
@ -156,7 +156,7 @@ final class AlmanacBindingEditEngine
id(new PhabricatorBoolEditField())
->setKey('disabled')
->setLabel(pht('Disabled'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
AlmanacBindingDisableTransaction::TRANSACTIONTYPE)
->setDescription(pht('Disable or enable the binding.'))

View file

@ -150,7 +150,7 @@ final class AlmanacInterfaceEditEngine
id(new PhabricatorTextEditField())
->setKey('device')
->setLabel(pht('Device'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
AlmanacInterfaceDeviceTransaction::TRANSACTIONTYPE)
->setDescription(pht('When creating an interface, set the device.'))

View file

@ -136,7 +136,7 @@ final class AlmanacServiceEditEngine
id(new PhabricatorTextEditField())
->setKey('type')
->setLabel(pht('Type'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
AlmanacServiceTypeTransaction::TRANSACTIONTYPE)
->setDescription(pht('When creating a service, set the type.'))

View file

@ -30,14 +30,14 @@ final class AlmanacPropertiesEditEngineExtension
->setConduitDescription(
pht('Pass a map of values to set one or more properties.'))
->setConduitTypeDescription(pht('Map of property names to values.'))
->setIsConduitOnly(true),
->setIsFormField(false),
id(new AlmanacDeletePropertyEditField())
->setKey('property.delete')
->setTransactionType($object->getAlmanacPropertyDeleteTransactionType())
->setConduitDescription(
pht('Pass a list of property names to delete properties.'))
->setConduitTypeDescription(pht('List of property names.'))
->setIsConduitOnly(true),
->setIsFormField(false),
);
}

View file

@ -126,7 +126,7 @@ final class PhabricatorBadgesEditEngine
->setValue($object->getDescription()),
id(new PhabricatorUsersEditField())
->setKey('award')
->setIsConduitOnly(true)
->setIsFormField(false)
->setDescription(pht('New badge award recipients.'))
->setConduitTypeDescription(pht('New badge award recipients.'))
->setTransactionType(
@ -134,7 +134,7 @@ final class PhabricatorBadgesEditEngine
->setLabel(pht('Award Recipients')),
id(new PhabricatorUsersEditField())
->setKey('revoke')
->setIsConduitOnly(true)
->setIsFormField(false)
->setDescription(pht('Revoke badge award recipients.'))
->setConduitTypeDescription(pht('Revoke badge award recipients.'))
->setTransactionType(

View file

@ -148,7 +148,7 @@ final class PhabricatorCalendarEventEditEngine
->setDescription(pht('Cancel the event.'))
->setTransactionType(
PhabricatorCalendarEventCancelTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Cancel or restore the event.'))
->setConduitTypeDescription(pht('True to cancel the event.'))
->setValue($object->getIsCancelled()),
@ -161,7 +161,7 @@ final class PhabricatorCalendarEventEditEngine
->setDescription(pht('Host of the event.'))
->setTransactionType(
PhabricatorCalendarEventHostTransaction::TRANSACTIONTYPE)
->setIsConduitOnly($this->getIsCreate())
->setIsFormField(!$this->getIsCreate())
->setConduitDescription(pht('Change the host of the event.'))
->setConduitTypeDescription(pht('New event host.'))
->setSingleValue($object->getHostPHID()),

View file

@ -99,7 +99,7 @@ final class PhabricatorCalendarExportEditEngine
->setDescription(pht('Disable the export.'))
->setTransactionType(
PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Disable or restore the export.'))
->setConduitTypeDescription(pht('True to cancel the export.'))
->setValue($object->getIsDisabled()),

View file

@ -101,7 +101,7 @@ final class PhabricatorCalendarImportEditEngine
->setDescription(pht('Disable the import.'))
->setTransactionType(
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Disable or restore the import.'))
->setConduitTypeDescription(pht('True to cancel the import.'))
->setValue($object->getIsDisabled()),
@ -111,7 +111,7 @@ final class PhabricatorCalendarImportEditEngine
->setDescription(pht('Delete all events from this source.'))
->setTransactionType(
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Disable or restore the import.'))
->setConduitTypeDescription(pht('True to delete imported events.'))
->setValue(false),
@ -121,7 +121,7 @@ final class PhabricatorCalendarImportEditEngine
->setDescription(pht('Reload events imported from this source.'))
->setTransactionType(
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Disable or restore the import.'))
->setConduitTypeDescription(pht('True to reload the import.'))
->setValue(false),

View file

@ -76,8 +76,8 @@ final class ConpherenceEditEngine
$initial_phids = $participant_phids;
}
// Only show participants on create or conduit, not edit
$conduit_only = !$this->getIsCreate();
// Only show participants on create or conduit, not edit.
$show_participants = (bool)$this->getIsCreate();
return array(
id(new PhabricatorTextEditField())
@ -103,7 +103,7 @@ final class ConpherenceEditEngine
->setKey('participants')
->setValue($participant_phids)
->setInitialValue($initial_phids)
->setIsConduitOnly($conduit_only)
->setIsFormField($show_participants)
->setAliases(array('users', 'members', 'participants', 'userPHID'))
->setDescription(pht('Room participants.'))
->setUseEdgeTransactions(true)

View file

@ -138,7 +138,7 @@ final class DifferentialRevisionEditEngine
DifferentialRevisionUpdateTransaction::TRANSACTIONTYPE)
->setHandleParameterType(new AphrontPHIDListHTTPParameterType())
->setSingleValue($diff_phid)
->setIsConduitOnly(!$diff)
->setIsFormField((bool)$diff)
->setIsReorderable(false)
->setIsDefaultable(false)
->setIsInvisible(true)
@ -225,7 +225,7 @@ final class DifferentialRevisionEditEngine
$fields[] = id(new PhabricatorHandlesEditField())
->setKey('tasks')
->setUseEdgeTransactions(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
@ -245,7 +245,7 @@ final class DifferentialRevisionEditEngine
$fields[] = id(new PhabricatorBoolEditField())
->setKey('draft')
->setLabel(pht('Hold as Draft'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(
pht('Autosubmit Once Builds Finish'),
pht('Hold as Draft'))

View file

@ -244,7 +244,7 @@ final class DiffusionRepositoryEditEngine
->setKey('vcs')
->setLabel(pht('Version Control System'))
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_VCS)
->setIsConduitOnly(true)
->setIsFormField(false)
->setIsCopyable(true)
->setOptions(PhabricatorRepositoryType::getAllRepositoryTypes())
->setDescription(pht('Underlying repository version control system.'))
@ -300,7 +300,7 @@ final class DiffusionRepositoryEditEngine
->setKey('allowDangerousChanges')
->setLabel(pht('Allow Dangerous Changes'))
->setIsCopyable(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(
pht('Prevent Dangerous Changes'),
pht('Allow Dangerous Changes'))
@ -313,7 +313,7 @@ final class DiffusionRepositoryEditEngine
->setKey('allowEnormousChanges')
->setLabel(pht('Allow Enormous Changes'))
->setIsCopyable(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(
pht('Prevent Enormous Changes'),
pht('Allow Enormous Changes'))
@ -326,7 +326,7 @@ final class DiffusionRepositoryEditEngine
->setKey('status')
->setLabel(pht('Status'))
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_ACTIVATE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(PhabricatorRepository::getStatusNameMap())
->setDescription(pht('Active or inactive status.'))
->setConduitDescription(pht('Active or deactivate the repository.'))

View file

@ -150,7 +150,7 @@ final class DiffusionURIEditEngine
->setAliases(array('repositoryPHID'))
->setLabel(pht('Repository'))
->setIsRequired(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
PhabricatorRepositoryURITransaction::TYPE_REPOSITORY)
->setDescription(pht('The repository this URI is associated with.'))
@ -195,7 +195,7 @@ final class DiffusionURIEditEngine
->setKey('credential')
->setAliases(array('credentialPHID'))
->setLabel(pht('Credential'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
PhabricatorRepositoryURITransaction::TYPE_CREDENTIAL)
->setDescription(
@ -206,7 +206,7 @@ final class DiffusionURIEditEngine
id(new PhabricatorBoolEditField())
->setKey('disable')
->setLabel(pht('Disabled'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(PhabricatorRepositoryURITransaction::TYPE_DISABLE)
->setDescription(pht('Active status of the URI.'))
->setConduitDescription(pht('Disable or activate the URI.'))

View file

@ -153,7 +153,7 @@ final class DrydockBlueprintEditEngine
id(new PhabricatorTextEditField())
->setKey('type')
->setLabel(pht('Type'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
DrydockBlueprintTypeTransaction::TRANSACTIONTYPE)
->setDescription(pht('When creating a blueprint, set the type.'))

View file

@ -169,9 +169,7 @@ EODOCS
->setConduitDocumentation($column_documentation)
->setAliases(array('columnPHID', 'columns', 'columnPHIDs'))
->setTransactionType(PhabricatorTransactions::TYPE_COLUMNS)
->setIsReorderable(false)
->setIsDefaultable(false)
->setIsLockable(false)
->setIsFormField(false)
->setCommentActionLabel(pht('Move on Workboard'))
->setCommentActionOrder(2000)
->setColumnMap($column_map),
@ -291,7 +289,7 @@ EODOCS
->setConduitDescription(pht('Change the parents of this task.'))
->setConduitTypeDescription(pht('List of parent task PHIDs.'))
->setUseEdgeTransactions(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $parent_type)
->setValue($parent_phids);
@ -303,7 +301,7 @@ EODOCS
->setConduitDescription(pht('Change the subtasks of this task.'))
->setConduitTypeDescription(pht('List of subtask PHIDs.'))
->setUseEdgeTransactions(true)
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $subtask_type)
->setValue($parent_phids);

View file

@ -159,7 +159,7 @@ EOTEXT
->setDescription(pht('Archive or enable the package.'))
->setTransactionType(
PhabricatorOwnersPackageStatusTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setValue($object->getStatus())
->setOptions($object->getStatusNameMap()),
id(new PhabricatorCheckboxesEditField())
@ -176,7 +176,7 @@ EOTEXT
id(new PhabricatorConduitEditField())
->setKey('paths.set')
->setLabel(pht('Paths'))
->setIsConduitOnly(true)
->setIsFormField(false)
->setTransactionType(
PhabricatorOwnersPackagePathsTransaction::TRANSACTIONTYPE)
->setConduitDescription(

View file

@ -104,7 +104,7 @@ final class PhabricatorPasteEditEngine
->setLabel(pht('Status'))
->setTransactionType(
PhabricatorPasteStatusTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(PhabricatorPaste::getStatusNameMap())
->setDescription(pht('Active or archived status.'))
->setConduitDescription(pht('Active or archive the paste.'))

View file

@ -71,7 +71,7 @@ final class PhabricatorUserEditEngine
->setLabel(pht('Disabled'))
->setDescription(pht('Disable the user.'))
->setTransactionType(PhabricatorUserDisableTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setConduitDescription(pht('Disable or enable the user.'))
->setConduitTypeDescription(pht('True to disable the user.'))
->setValue($object->getIsDisabled()),

View file

@ -126,7 +126,7 @@ final class PhameBlogEditEngine
->setKey('status')
->setLabel(pht('Status'))
->setTransactionType(PhameBlogStatusTransaction::TRANSACTIONTYPE)
->setIsConduitOnly(true)
->setIsFormField(false)
->setOptions(PhameBlog::getStatusNameMap())
->setDescription(pht('Active or archived status.'))
->setConduitDescription(pht('Active or archive the blog.'))

View file

@ -287,13 +287,13 @@ final class PhabricatorProjectEditEngine
// Show this on the web UI when creating a project, but not when editing
// one. It is always available via Conduit.
$conduit_only = !$this->getIsCreate();
$show_field = (bool)$this->getIsCreate();
$members_field = id(new PhabricatorUsersEditField())
->setKey('members')
->setAliases(array('memberPHIDs'))
->setLabel(pht('Initial Members'))
->setIsConduitOnly($conduit_only)
->setIsFormField($show_field)
->setUseEdgeTransactions(true)
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(

View file

@ -30,6 +30,11 @@ final class PhabricatorEditEngineConfigurationDefaultsController
$fields = $engine->getFieldsForConfig($config);
foreach ($fields as $key => $field) {
if (!$field->getIsFormField()) {
unset($fields[$key]);
continue;
}
if (!$field->getIsDefaultable()) {
unset($fields[$key]);
continue;

View file

@ -79,6 +79,10 @@ EOTEXT
);
foreach ($fields as $field) {
if (!$field->getIsFormField()) {
continue;
}
if (!$field->getIsLockable()) {
continue;
}

View file

@ -62,6 +62,10 @@ final class PhabricatorEditEngineConfigurationReorderController
$key_order = array();
foreach ($fields as $field) {
if (!$field->getIsFormField()) {
continue;
}
if (!$field->getIsReorderable()) {
continue;
}

View file

@ -1289,6 +1289,10 @@ abstract class PhabricatorEditEngine
}
foreach ($fields as $field) {
if (!$field->getIsFormField()) {
continue;
}
$field->appendToForm($form);
}

View file

@ -44,7 +44,7 @@ abstract class PhabricatorEditField extends Phobject {
private $isDefaultable = true;
private $isLockable = true;
private $isCopyable = false;
private $isConduitOnly = false;
private $isFormField = true;
private $conduitEditTypes;
private $bulkEditTypes;
@ -139,13 +139,13 @@ abstract class PhabricatorEditField extends Phobject {
return $this->isReorderable;
}
public function setIsConduitOnly($is_conduit_only) {
$this->isConduitOnly = $is_conduit_only;
public function setIsFormField($is_form_field) {
$this->isFormField = $is_form_field;
return $this;
}
public function getIsConduitOnly() {
return $this->isConduitOnly;
public function getIsFormField() {
return $this->isFormField;
}
public function setDescription($description) {
@ -336,7 +336,7 @@ abstract class PhabricatorEditField extends Phobject {
}
protected function buildControl() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return null;
}
@ -637,7 +637,7 @@ abstract class PhabricatorEditField extends Phobject {
}
final public function getHTTPParameterType() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return null;
}
@ -840,7 +840,7 @@ abstract class PhabricatorEditField extends Phobject {
}
public function shouldGenerateTransactionsFromSubmit() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return false;
}
@ -853,7 +853,7 @@ abstract class PhabricatorEditField extends Phobject {
}
public function shouldReadValueFromRequest() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return false;
}
@ -869,7 +869,7 @@ abstract class PhabricatorEditField extends Phobject {
}
public function shouldReadValueFromSubmit() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return false;
}
@ -885,7 +885,7 @@ abstract class PhabricatorEditField extends Phobject {
}
public function shouldGenerateTransactionsFromComment() {
if ($this->getIsConduitOnly()) {
if (!$this->getCommentActionLabel()) {
return false;
}

View file

@ -57,10 +57,7 @@ final class PhabricatorCommentEditEngineExtension
->setBulkEditLabel(pht('Add comment'))
->setBulkEditGroupKey('comments')
->setAliases(array('comments'))
->setIsHidden(true)
->setIsReorderable(false)
->setIsDefaultable(false)
->setIsLockable(false)
->setIsFormField(false)
->setCanApplyWithoutEditCapability($is_interact)
->setTransactionType($comment_type)
->setConduitDescription(pht('Make comments.'))

View file

@ -36,20 +36,20 @@ final class PhabricatorSubtypeEditEngineExtension
$subtype_field = id(new PhabricatorSelectEditField())
->setKey(self::EDITKEY)
->setLabel(pht('Subtype'))
->setIsConduitOnly(true)
->setIsHidden(true)
->setIsReorderable(false)
->setIsDefaultable(false)
->setIsLockable(false)
->setIsFormField(false)
->setTransactionType($subtype_type)
->setConduitDescription(pht('Change the object subtype.'))
->setConduitTypeDescription(pht('New object subtype key.'))
->setValue($object->getEditEngineSubtype())
->setOptions($options);
// If subtypes are configured, enable changing them from the bulk editor.
// If subtypes are configured, enable changing them from the bulk editor
// and comment action stack.
if (count($map) > 1) {
$subtype_field->setBulkEditLabel(pht('Change subtype to'));
$subtype_field
->setBulkEditLabel(pht('Change subtype to'))
->setCommentActionLabel(pht('Change Subtype'))
->setCommentActionOrder(3000);
}
return array(

View file

@ -139,9 +139,14 @@ final class PhabricatorEditEngineConfiguration
$values = $this->getProperty('defaults', array());
foreach ($fields as $key => $field) {
if (!$field->getIsFormField()) {
continue;
}
if (!$field->getIsDefaultable()) {
continue;
}
if ($is_new) {
if (array_key_exists($key, $values)) {
$field->readDefaultValueFromConfiguration($values[$key]);

View file

@ -59,7 +59,7 @@ final class PhabricatorCustomFieldEditField
}
protected function buildControl() {
if ($this->getIsConduitOnly()) {
if (!$this->getIsFormField()) {
return null;
}

View file

@ -1145,10 +1145,10 @@ abstract class PhabricatorCustomField extends Phobject {
return $this->proxy->newStandardEditField();
}
if (!$this->shouldAppearInEditView()) {
$conduit_only = true;
if ($this->shouldAppearInEditView()) {
$form_field = true;
} else {
$conduit_only = false;
$form_field = false;
}
$bulk_label = $this->getBulkEditLabel();
@ -1160,7 +1160,7 @@ abstract class PhabricatorCustomField extends Phobject {
->setBulkEditLabel($bulk_label)
->setDescription($this->getFieldDescription())
->setTransactionType($this->getApplicationTransactionType())
->setIsConduitOnly($conduit_only)
->setIsFormField($form_field)
->setValue($this->getNewValueForApplicationTransactions());
}