Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14907157
D20951.id49928.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D20951.id49928.diff
View Options
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
@@ -1528,6 +1528,7 @@
'HeraldApplicationActionGroup' => 'applications/herald/action/HeraldApplicationActionGroup.php',
'HeraldApplyTranscript' => 'applications/herald/storage/transcript/HeraldApplyTranscript.php',
'HeraldBasicFieldGroup' => 'applications/herald/field/HeraldBasicFieldGroup.php',
+ 'HeraldBoolFieldValue' => 'applications/herald/value/HeraldBoolFieldValue.php',
'HeraldBuildableState' => 'applications/herald/state/HeraldBuildableState.php',
'HeraldCallWebhookAction' => 'applications/herald/action/HeraldCallWebhookAction.php',
'HeraldCommentAction' => 'applications/herald/action/HeraldCommentAction.php',
@@ -7633,6 +7634,7 @@
'HeraldApplicationActionGroup' => 'HeraldActionGroup',
'HeraldApplyTranscript' => 'Phobject',
'HeraldBasicFieldGroup' => 'HeraldFieldGroup',
+ 'HeraldBoolFieldValue' => 'HeraldFieldValue',
'HeraldBuildableState' => 'HeraldState',
'HeraldCallWebhookAction' => 'HeraldAction',
'HeraldCommentAction' => 'HeraldAction',
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -1071,6 +1071,26 @@
$condition->getValue());
}
+ public function renderFieldTranscriptValue(
+ PhabricatorUser $viewer,
+ $field_type,
+ $field_value) {
+
+ $field = $this->getFieldImplementation($field_type);
+ if ($field) {
+ return $field->renderTranscriptValue(
+ $viewer,
+ $field_value);
+ }
+
+ return phutil_tag(
+ 'em',
+ array(),
+ pht(
+ 'Unable to render value for unknown field type ("%s").',
+ $field_type));
+ }
+
/* -( Applying Effects )--------------------------------------------------- */
diff --git a/src/applications/herald/controller/HeraldTranscriptController.php b/src/applications/herald/controller/HeraldTranscriptController.php
--- a/src/applications/herald/controller/HeraldTranscriptController.php
+++ b/src/applications/herald/controller/HeraldTranscriptController.php
@@ -447,8 +447,9 @@
}
private function buildObjectTranscriptPanel(HeraldTranscript $xscript) {
-
+ $viewer = $this->getViewer();
$adapter = $this->getAdapter();
+
$field_names = $adapter->getFieldNameMap();
$object_xscript = $xscript->getObjectTranscript();
@@ -487,29 +488,21 @@
}
if ($object_xscript) {
- foreach ($object_xscript->getFields() as $field => $value) {
- if (isset($field_names[$field])) {
- $field_name = pht('Field: %s', $field_names[$field]);
+ foreach ($object_xscript->getFields() as $field_type => $value) {
+ if (isset($field_names[$field_type])) {
+ $field_name = pht('Field: %s', $field_names[$field_type]);
} else {
- $field_name = pht('Unknown Field ("%s")', $field_name);
- }
-
- if (!is_scalar($value) && !is_null($value)) {
- $value = implode("\n", $value);
+ $field_name = pht('Unknown Field ("%s")', $field_type);
}
- if (strlen($value) > 256) {
- $value = phutil_tag(
- 'textarea',
- array(
- 'class' => 'herald-field-value-transcript',
- ),
- $value);
- }
+ $field_value = $adapter->renderFieldTranscriptValue(
+ $viewer,
+ $field_type,
+ $value);
$rows[] = array(
$field_name,
- $value,
+ $field_value,
);
}
}
diff --git a/src/applications/herald/field/HeraldAlwaysField.php b/src/applications/herald/field/HeraldAlwaysField.php
--- a/src/applications/herald/field/HeraldAlwaysField.php
+++ b/src/applications/herald/field/HeraldAlwaysField.php
@@ -23,7 +23,7 @@
}
public function getHeraldFieldValueType($condition) {
- return new HeraldEmptyFieldValue();
+ return new HeraldBoolFieldValue();
}
public function supportsObject($object) {
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -105,11 +105,16 @@
}
public function getHeraldFieldValueType($condition) {
+
+ // NOTE: The condition type may be "null" to indicate that the caller
+ // wants a generic field value type. This is used when rendering field
+ // values in the object transcript.
+
$standard_type = $this->getHeraldFieldStandardType();
switch ($standard_type) {
case self::STANDARD_BOOL:
case self::STANDARD_PHID_BOOL:
- return new HeraldEmptyFieldValue();
+ return new HeraldBoolFieldValue();
case self::STANDARD_TEXT:
case self::STANDARD_TEXT_LIST:
case self::STANDARD_TEXT_MAP:
@@ -176,6 +181,14 @@
return $value_type->renderEditorValue($value);
}
+ public function renderTranscriptValue(
+ PhabricatorUser $viewer,
+ $field_value) {
+ $value_type = $this->getHeraldFieldValueType($condition_type = null);
+ $value_type->setViewer($viewer);
+ return $value_type->renderTranscriptValue($field_value);
+ }
+
public function getPHIDsAffectedByCondition(HeraldCondition $condition) {
try {
$standard_type = $this->getHeraldFieldStandardType();
diff --git a/src/applications/herald/value/HeraldBoolFieldValue.php b/src/applications/herald/value/HeraldBoolFieldValue.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/value/HeraldBoolFieldValue.php
@@ -0,0 +1,30 @@
+<?php
+
+final class HeraldBoolFieldValue
+ extends HeraldFieldValue {
+
+ public function getFieldValueKey() {
+ return 'bool';
+ }
+
+ public function getControlType() {
+ return self::CONTROL_NONE;
+ }
+
+ public function renderFieldValue($value) {
+ return null;
+ }
+
+ public function renderEditorValue($value) {
+ return null;
+ }
+
+ public function renderTranscriptValue($value) {
+ if ($value) {
+ return pht('true');
+ } else {
+ return pht('false');
+ }
+ }
+
+}
diff --git a/src/applications/herald/value/HeraldFieldValue.php b/src/applications/herald/value/HeraldFieldValue.php
--- a/src/applications/herald/value/HeraldFieldValue.php
+++ b/src/applications/herald/value/HeraldFieldValue.php
@@ -36,4 +36,8 @@
return array();
}
+ public function renderTranscriptValue($value) {
+ return $this->renderFieldValue($value);
+ }
+
}
diff --git a/src/applications/herald/value/HeraldTextFieldValue.php b/src/applications/herald/value/HeraldTextFieldValue.php
--- a/src/applications/herald/value/HeraldTextFieldValue.php
+++ b/src/applications/herald/value/HeraldTextFieldValue.php
@@ -19,4 +19,25 @@
return $value;
}
+ public function renderTranscriptValue($value) {
+ if (is_array($value)) {
+ $value = implode('', $value);
+ }
+
+ if (!strlen($value)) {
+ return phutil_tag('em', array(), pht('None'));
+ }
+
+ if (strlen($value) > 256) {
+ $value = phutil_tag(
+ 'textarea',
+ array(
+ 'class' => 'herald-field-value-transcript',
+ ),
+ $value);
+ }
+
+ return $value;
+ }
+
}
diff --git a/src/applications/herald/value/HeraldTokenizerFieldValue.php b/src/applications/herald/value/HeraldTokenizerFieldValue.php
--- a/src/applications/herald/value/HeraldTokenizerFieldValue.php
+++ b/src/applications/herald/value/HeraldTokenizerFieldValue.php
@@ -64,27 +64,46 @@
}
public function renderFieldValue($value) {
+ return $this->renderValueAsList($value, $for_transcript = false);
+ }
+
+ public function renderEditorValue($value) {
+ $viewer = $this->getViewer();
+ $value = (array)$value;
+
+ $datasource = $this->getDatasource()
+ ->setViewer($viewer);
+
+ return $datasource->getWireTokens($value);
+ }
+
+ public function renderTranscriptValue($value) {
+ return $this->renderValueAsList($value, $for_transcript = true);
+ }
+
+ private function renderValueAsList($value, $for_transcript) {
$viewer = $this->getViewer();
$value = (array)$value;
+ if (!$value) {
+ return phutil_tag('em', array(), pht('None'));
+ }
+
if ($this->valueMap !== null) {
foreach ($value as $k => $v) {
$value[$k] = idx($this->valueMap, $v, $v);
}
+
return implode(', ', $value);
}
- return $viewer->renderHandleList((array)$value)->setAsInline(true);
- }
+ $list = $viewer->renderHandleList($value);
- public function renderEditorValue($value) {
- $viewer = $this->getViewer();
- $value = (array)$value;
-
- $datasource = $this->getDatasource()
- ->setViewer($viewer);
+ if (!$for_transcript) {
+ $list->setAsInline(true);
+ }
- return $datasource->getWireTokens($value);
+ return $list;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 11, 3:09 AM (3 h, 39 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7116168
Default Alt Text
D20951.id49928.diff (8 KB)
Attached To
Mode
D20951: In Herald transcripts, render some field values in a more readable way
Attached
Detach File
Event Timeline
Log In to Comment