diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 1e9b07657c..c1eac5a583 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1843,6 +1843,8 @@ phutil_register_library_map(array( 'PhabricatorChatLogQuery' => 'applications/chatlog/query/PhabricatorChatLogQuery.php', 'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php', 'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php', + 'PhabricatorCommentEditField' => 'applications/transactions/editfield/PhabricatorCommentEditField.php', + 'PhabricatorCommentEditType' => 'applications/transactions/edittype/PhabricatorCommentEditType.php', 'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php', 'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php', 'PhabricatorCommitMergedCommitsField' => 'applications/repository/customfield/PhabricatorCommitMergedCommitsField.php', @@ -5890,6 +5892,8 @@ phutil_register_library_map(array( 'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine', 'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorCommentEditField' => 'PhabricatorEditField', + 'PhabricatorCommentEditType' => 'PhabricatorEditType', 'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField', 'PhabricatorCommitCustomField' => 'PhabricatorCustomField', 'PhabricatorCommitMergedCommitsField' => 'PhabricatorCommitCustomField', diff --git a/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php b/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php index ba433786fb..790eaccb47 100644 --- a/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php +++ b/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php @@ -90,11 +90,19 @@ EOTEXT $label = $key; } + if ($field->getIsHidden()) { + $value = $lock_hidden; + } else if ($field->getIsLocked()) { + $value = $lock_locked; + } else { + $value = $lock_visible; + } + $form->appendControl( id(new AphrontFormSelectControl()) ->setName('locks['.$key.']') ->setLabel($label) - ->setValue(idx($locks, $key, $lock_visible)) + ->setValue($value) ->setOptions($map)); } diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php index 685a634115..b398f226eb 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -214,6 +214,22 @@ abstract class PhabricatorEditEngine } } + $xaction = $object->getApplicationTransactionTemplate(); + $comment = $xaction->getApplicationTransactionCommentObject(); + if ($comment) { + $comment_type = PhabricatorTransactions::TYPE_COMMENT; + + $comment_field = id(new PhabricatorCommentEditField()) + ->setKey('comment') + ->setLabel(pht('Comments')) + ->setDescription(pht('Add comments.')) + ->setAliases(array('comments')) + ->setIsHidden(true) + ->setTransactionType($comment_type) + ->setValue(null); + $fields[] = $comment_field; + } + $config = $this->getEditEngineConfiguration(); $fields = $config->applyConfigurationToFields($this, $fields); diff --git a/src/applications/transactions/editfield/PhabricatorCommentEditField.php b/src/applications/transactions/editfield/PhabricatorCommentEditField.php new file mode 100644 index 0000000000..6080b9fa73 --- /dev/null +++ b/src/applications/transactions/editfield/PhabricatorCommentEditField.php @@ -0,0 +1,25 @@ + $this->getValueForTransaction(), + ); + + return head($this->getEditTransactionTypes()) + ->generateTransaction($xaction, $spec); + } + +} diff --git a/src/applications/transactions/editfield/PhabricatorEditField.php b/src/applications/transactions/editfield/PhabricatorEditField.php index 38397f945c..60b48cc2b8 100644 --- a/src/applications/transactions/editfield/PhabricatorEditField.php +++ b/src/applications/transactions/editfield/PhabricatorEditField.php @@ -357,6 +357,11 @@ abstract class PhabricatorEditField extends Phobject { return $this->editTypeKey; } + protected function newEditType() { + return id(new PhabricatorSimpleEditType()) + ->setValueType($this->getHTTPParameterType()->getTypeName()); + } + public function getEditTransactionTypes() { $transaction_type = $this->getTransactionType(); if ($transaction_type === null) { @@ -411,10 +416,9 @@ abstract class PhabricatorEditField extends Phobject { } return array( - id(new PhabricatorSimpleEditType()) + $this->newEditType() ->setEditType($type_key) ->setTransactionType($transaction_type) - ->setValueType($this->getHTTPParameterType()->getTypeName()) ->setDescription($this->getDescription()) ->setMetadata($this->metadata), ); diff --git a/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php b/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php index 9da1d49ae6..02014148ae 100644 --- a/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php +++ b/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php @@ -7,4 +7,8 @@ final class PhabricatorInstructionsEditField return $form->appendRemarkupInstructions($this->getValue()); } + protected function newHTTPParameterType() { + return null; + } + } diff --git a/src/applications/transactions/edittype/PhabricatorCommentEditType.php b/src/applications/transactions/edittype/PhabricatorCommentEditType.php new file mode 100644 index 0000000000..5e4df3942f --- /dev/null +++ b/src/applications/transactions/edittype/PhabricatorCommentEditType.php @@ -0,0 +1,31 @@ +getTypeName(); + } + + public function generateTransaction( + PhabricatorApplicationTransaction $template, + array $spec) { + + $comment = $template->getApplicationTransactionCommentObject() + ->setContent(idx($spec, 'value')); + + $template + ->setTransactionType($this->getTransactionType()) + ->attachComment($comment); + + foreach ($this->getMetadata() as $key => $value) { + $template->setMetadataValue($key, $value); + } + + return $template; + } + + public function getValueDescription() { + return pht('Comment to add, formated as remarkup.'); + } + +} diff --git a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php index afe628359b..1c48ad8abd 100644 --- a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php +++ b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php @@ -106,13 +106,19 @@ final class PhabricatorEditEngineConfiguration $key = $field->getKey(); switch (idx($locks, $key)) { case self::LOCK_LOCKED: + $field->setIsHidden(false); $field->setIsLocked(true); break; case self::LOCK_HIDDEN: $field->setIsHidden(true); + $field->setIsLocked(false); break; case self::LOCK_VISIBLE: + $field->setIsHidden(false); + $field->setIsLocked(false); + break; default: + // If we don't have an explicit value, don't make any adjustments. break; } } diff --git a/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php b/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php index f1aa36fa61..e8397e6a65 100644 --- a/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php +++ b/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php @@ -42,6 +42,7 @@ final class PhabricatorApplicationEditHTTPParameterHelpView $type = $field->getHTTPParameterType(); if ($type === null) { unset($fields[$key]); + continue; } $types[$type->getTypeName()] = $type; }