Page MenuHomePhabricator

D14515.id35112.diff
No OneTemporary

D14515.id35112.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1843,6 +1843,8 @@
'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',
@@ -5888,6 +5890,8 @@
'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
--- a/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php
+++ b/src/applications/transactions/controller/PhabricatorEditEngineConfigurationLockController.php
@@ -90,11 +90,19 @@
$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
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -214,6 +214,22 @@
}
}
+ $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
--- /dev/null
+++ b/src/applications/transactions/editfield/PhabricatorCommentEditField.php
@@ -0,0 +1,25 @@
+<?php
+
+final class PhabricatorCommentEditField
+ extends PhabricatorEditField {
+
+ protected function newControl() {
+ return new PhabricatorRemarkupControl();
+ }
+
+ protected function newEditType() {
+ return new PhabricatorCommentEditType();
+ }
+
+ public function generateTransaction(
+ PhabricatorApplicationTransaction $xaction) {
+
+ $spec = array(
+ 'value' => $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
--- a/src/applications/transactions/editfield/PhabricatorEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorEditField.php
@@ -357,6 +357,11 @@
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 @@
}
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
--- a/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorInstructionsEditField.php
@@ -7,4 +7,8 @@
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
--- /dev/null
+++ b/src/applications/transactions/edittype/PhabricatorCommentEditType.php
@@ -0,0 +1,31 @@
+<?php
+
+final class PhabricatorCommentEditType extends PhabricatorEditType {
+
+ public function getValueType() {
+ return id(new AphrontStringHTTPParameterType())->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
--- a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
+++ b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
@@ -106,13 +106,19 @@
$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
--- a/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php
+++ b/src/applications/transactions/view/PhabricatorApplicationEditHTTPParameterHelpView.php
@@ -42,6 +42,7 @@
$type = $field->getHTTPParameterType();
if ($type === null) {
unset($fields[$key]);
+ continue;
}
$types[$type->getTypeName()] = $type;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 28, 2:28 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719339
Default Alt Text
D14515.id35112.diff (8 KB)

Event Timeline