Page MenuHomePhorge

D25548.1734789457.diff
No OneTemporary

D25548.1734789457.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
@@ -1802,6 +1802,7 @@
'ManiphestEditConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestEditConduitAPIMethod.php',
'ManiphestEditEngine' => 'applications/maniphest/editor/ManiphestEditEngine.php',
'ManiphestEmailCommand' => 'applications/maniphest/command/ManiphestEmailCommand.php',
+ 'ManiphestFlagCustomField' => 'applications/maniphest/field/ManiphestFlagCustomField.php',
'ManiphestGetTaskTransactionsConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php',
'ManiphestHovercardEngineExtension' => 'applications/maniphest/engineextension/ManiphestHovercardEngineExtension.php',
'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php',
@@ -5388,6 +5389,8 @@
'PholioTransactionView' => 'applications/pholio/view/PholioTransactionView.php',
'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php',
'PhorgeCodeWarningSetupCheck' => 'applications/config/check/PhorgeCodeWarningSetupCheck.php',
+ 'PhorgeFlagFlaggedObjectCustomField' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php',
+ 'PhorgeFlagFlaggedObjectFieldStorage' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php',
'PhorgeSystemDeprecationWarningListener' => 'applications/system/events/PhorgeSystemDeprecationWarningListener.php',
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php',
@@ -8007,6 +8010,7 @@
'ManiphestEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'ManiphestEditEngine' => 'PhabricatorEditEngine',
'ManiphestEmailCommand' => 'MetaMTAEmailTransactionCommand',
+ 'ManiphestFlagCustomField' => 'ManiphestCustomField',
'ManiphestGetTaskTransactionsConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod',
@@ -12211,6 +12215,8 @@
'PholioTransactionView' => 'PhabricatorApplicationTransactionView',
'PholioUploadedImageView' => 'AphrontView',
'PhorgeCodeWarningSetupCheck' => 'PhabricatorSetupCheck',
+ 'PhorgeFlagFlaggedObjectCustomField' => 'PhabricatorCustomField',
+ 'PhorgeFlagFlaggedObjectFieldStorage' => 'Phobject',
'PhorgeSystemDeprecationWarningListener' => 'PhabricatorEventListener',
'PhortuneAccount' => array(
'PhortuneDAO',
diff --git a/src/applications/differential/customfield/DifferentialRepositoryField.php b/src/applications/differential/customfield/DifferentialRepositoryField.php
--- a/src/applications/differential/customfield/DifferentialRepositoryField.php
+++ b/src/applications/differential/customfield/DifferentialRepositoryField.php
@@ -63,4 +63,14 @@
$repository->getMonogram().' '.$repository->getName());
}
+ public function shouldAppearInListView() {
+ return true;
+ }
+
+ public function renderOnListItem(PHUIObjectItemView $view) {
+ $handle = $this->getViewer()->renderHandle($this->getValue());
+ $view->addByLine(pht('Repository: %s', $handle));
+ }
+
+
}
diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php
--- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php
+++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php
@@ -199,6 +199,10 @@
$unlanded = $this->loadUnlandedDependencies($revisions);
+ $custom_field_lists = $this->loadCustomFields(
+ $revisions,
+ PhabricatorCustomField::ROLE_LIST);
+
$views = array();
if ($bucket) {
$bucket->setViewer($viewer);
@@ -231,6 +235,7 @@
foreach ($views as $view) {
$view->setUnlandedDependencies($unlanded);
+ $view->setCustomFieldLists($custom_field_lists);
}
if (count($views) == 1) {
diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php
--- a/src/applications/differential/view/DifferentialRevisionListView.php
+++ b/src/applications/differential/view/DifferentialRevisionListView.php
@@ -11,6 +11,7 @@
private $noBox;
private $background = null;
private $unlandedDependencies = array();
+ private $customFieldLists = array();
public function setUnlandedDependencies(array $unlanded_dependencies) {
$this->unlandedDependencies = $unlanded_dependencies;
@@ -47,6 +48,29 @@
return $this;
}
+ public function getRequiredHandlePHIDs() {
+ $phids = array();
+ foreach ($this->revisions as $revision) {
+ $phids[] = array($revision->getAuthorPHID());
+
+ // TODO: Switch to getReviewerStatus(), but not all callers pass us
+ // revisions with this data loaded.
+ $phids[] = $revision->getReviewers();
+ }
+ return array_mergev($phids);
+ }
+
+ public function setHandles(array $handles) {
+ assert_instances_of($handles, 'PhabricatorObjectHandle');
+ $this->handles = $handles;
+ return $this;
+ }
+
+ public function setCustomFieldLists(array $lists) {
+ $this->customFieldLists = $lists;
+ return $this;
+ }
+
public function render() {
$viewer = $this->getViewer();
@@ -181,6 +205,12 @@
"{$icon} {$color}",
$revision->getStatusDisplayName());
+ $field_list = idx($this->customFieldLists, $revision->getPHID());
+ if ($field_list) {
+ $field_list
+ ->addFieldsToListViewItem($revision, $this->getViewer(), $item);
+ }
+
$list->addItem($item);
}
diff --git a/src/applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php b/src/applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php
@@ -0,0 +1,46 @@
+<?php
+
+final class PhorgeFlagFlaggedObjectCustomField extends PhabricatorCustomField {
+
+ private $flag;
+
+ public function getFieldKey() {
+ return 'flag:flag';
+ }
+ public function shouldAppearInPropertyView() {
+ return false;
+ }
+
+ public function shouldAppearInListView() {
+ return true;
+ }
+
+ public function renderOnListItem(PHUIObjectItemView $view) {
+ if (!$this->flag) {
+ return;
+ }
+ // I'm very open to improvements in the way a Flag is displayed
+ $icon = PhabricatorFlagColor::getIcon($this->flag->getColor());
+ $view->addIcon($icon);
+ }
+
+
+ public function shouldUseStorage() {
+ return true;
+ }
+
+ public function setValueFromStorage($value) {
+ $this->flag = $value;
+ }
+
+ // The parent function is defined to return a PhabricatorCustomFieldStorage,
+ // but that assumes a DTO with a particular form; That doesn't apply here.
+ // Maybe the function needs to be re-defined with a suitable interface.
+ // For now, PhorgeFlagFlaggedObjectFieldStorage just duck-types into the
+ // right shape.
+ public function newStorageObject() {
+ return id(new PhorgeFlagFlaggedObjectFieldStorage())
+ ->setViewer($this->getViewer());
+ }
+
+}
diff --git a/src/applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php b/src/applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php
new file mode 100644
--- /dev/null
+++ b/src/applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php
@@ -0,0 +1,36 @@
+<?php
+
+final class PhorgeFlagFlaggedObjectFieldStorage extends Phobject {
+
+ private $viewer;
+
+ public function setViewer(PhabricatorUser $viewer) {
+ $this->viewer = $viewer;
+ return $this;
+ }
+
+ public function getStorageSourceKey() {
+ return 'flags flags flags';
+ }
+
+ public function loadStorageSourceData(array $fields) {
+
+ $objects = mpull($fields, 'getObject');
+ $object_phids = mpull($objects, 'getPHID');
+ $flags = (new PhabricatorFlagQuery())
+ ->setViewer($this->viewer)
+ ->withOwnerPHIDs(array($this->viewer->getPHID()))
+ ->withObjectPHIDs($object_phids)
+ ->execute();
+ $flags = mpull($flags, null, 'getObjectPHID');
+
+ $result = array();
+ foreach ($fields as $key => $field) {
+ $target_phid = $field->getObject()->getPHID();
+ $result[$key] = idx($flags, $target_phid);
+ }
+
+ return $result;
+ }
+
+}
diff --git a/src/applications/maniphest/field/ManiphestFlagCustomField.php b/src/applications/maniphest/field/ManiphestFlagCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/field/ManiphestFlagCustomField.php
@@ -0,0 +1,18 @@
+<?php
+
+// I'm not sure this is the right use for the Proxy capability.
+// Probably should just use Traits for this.
+final class ManiphestFlagCustomField extends ManiphestCustomField {
+
+ public function __construct() {
+ $this->setProxy(new PhorgeFlagFlaggedObjectCustomField());
+ }
+
+ public function canSetProxy() {
+ return true;
+ }
+
+ public function newStorageObject() {
+ return $this->getProxy()->newStorageObject();
+ }
+}
diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
--- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -374,11 +374,17 @@
ManiphestBulkEditCapability::CAPABILITY);
}
+ $custom_field_lists = $this->loadCustomFields(
+ $tasks,
+ PhabricatorCustomField::ROLE_LIST);
+
$list = id(new ManiphestTaskResultListView())
->setUser($viewer)
->setTasks($tasks)
+ ->setHandles($handles)
->setSavedQuery($saved)
->setCanBatchEdit($can_bulk_edit)
+ ->setCustomFieldLists($custom_field_lists)
->setShowBatchControls($this->showBatchControls);
$result = new PhabricatorApplicationSearchResultView();
@@ -387,6 +393,24 @@
return $result;
}
+ protected function getRequiredHandlePHIDsForResultList(
+ array $objects,
+ PhabricatorSavedQuery $query) {
+
+ $phids = array();
+ foreach ($objects as $task) {
+ $assigned_phid = $task->getOwnerPHID();
+ if ($assigned_phid) {
+ $phids[] = $assigned_phid;
+ }
+ foreach ($task->getProjectPHIDs() as $project_phid) {
+ $phids[] = $project_phid;
+ }
+ }
+
+ return $phids;
+ }
+
protected function willUseSavedQuery(PhabricatorSavedQuery $saved) {
// The 'withUnassigned' parameter may be present in old saved queries from
diff --git a/src/applications/maniphest/view/ManiphestTaskListView.php b/src/applications/maniphest/view/ManiphestTaskListView.php
--- a/src/applications/maniphest/view/ManiphestTaskListView.php
+++ b/src/applications/maniphest/view/ManiphestTaskListView.php
@@ -4,6 +4,7 @@
private $tasks;
private $handles;
+ private $customFieldLists = array();
private $showBatchControls;
private $noDataString;
@@ -19,6 +20,11 @@
return $this;
}
+ public function setCustomFieldLists(array $lists) {
+ $this->customFieldLists = $lists;
+ return $this;
+ }
+
public function setShowBatchControls($show_batch_controls) {
$this->showBatchControls = $show_batch_controls;
return $this;
@@ -132,12 +138,21 @@
->setHref($href));
}
+
+ $field_list = idx($this->customFieldLists, $task->getPHID());
+ if ($field_list) {
+ $field_list
+ ->addFieldsToListViewItem($task, $this->getViewer(), $item);
+ }
+
$list->addItem($item);
}
return $list;
}
+ // This method should be removed, and all call-sites switch
+ // to use ManiphestSearchEngine
public static function loadTaskHandles(
PhabricatorUser $viewer,
array $tasks) {
diff --git a/src/applications/maniphest/view/ManiphestTaskResultListView.php b/src/applications/maniphest/view/ManiphestTaskResultListView.php
--- a/src/applications/maniphest/view/ManiphestTaskResultListView.php
+++ b/src/applications/maniphest/view/ManiphestTaskResultListView.php
@@ -3,6 +3,8 @@
final class ManiphestTaskResultListView extends ManiphestView {
private $tasks;
+ private $handles;
+ private $customFieldLists = array();
private $savedQuery;
private $canBatchEdit;
private $showBatchControls;
@@ -17,6 +19,16 @@
return $this;
}
+ public function setHandles(array $handles) {
+ $this->handles = $handles;
+ return $this;
+ }
+
+ public function setCustomFieldLists(array $lists) {
+ $this->customFieldLists = $lists;
+ return $this;
+ }
+
public function setCanBatchEdit($can_batch_edit) {
$this->canBatchEdit = $can_batch_edit;
return $this;
@@ -42,11 +54,10 @@
$group_parameter = nonempty($query->getParameter('group'), 'priority');
$order_parameter = nonempty($query->getParameter('order'), 'priority');
- $handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks);
$groups = $this->groupTasks(
$tasks,
$group_parameter,
- $handles);
+ $this->handles);
$result = array();
@@ -56,7 +67,8 @@
$task_list->setShowBatchControls($this->showBatchControls);
$task_list->setUser($viewer);
$task_list->setTasks($list);
- $task_list->setHandles($handles);
+ $task_list->setHandles($this->handles);
+ $task_list->setCustomFieldLists($this->customFieldLists);
$header = id(new PHUIHeaderView())
->addSigil('task-group')
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -1626,4 +1626,33 @@
return $supported;
}
+ /**
+ * Load from object and from storage, and updates Custom Fields instances
+ * that are attached to each object.
+ *
+ * @return map<phid->PhabricatorCustomFieldList> of loaded fields.
+ * @task custom
+ */
+ protected function loadCustomFields(array $objects, $role) {
+ assert_instances_of($objects, 'PhabricatorCustomFieldInterface');
+
+ $query = new PhabricatorCustomFieldStorageQuery();
+ $lists = array();
+
+ foreach ($objects as $object) {
+ $field_list = PhabricatorCustomField::getObjectFields($object, $role);
+ $field_list->readFieldsFromObject($object);
+ foreach ($field_list->getFields() as $field) {
+ // TODO move $viewer into PhabricatorCustomFieldStorageQuery
+ $field->setViewer($this->viewer);
+ }
+ $lists[$object->getPHID()] = $field_list;
+ $query->addFields($field_list->getFields());
+ }
+ // This update the field_list objects.
+ $query->execute();
+
+ return $lists;
+ }
+
}
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -384,6 +384,7 @@
*
* @param PhabricatorCustomField Field implementation.
* @return this
+ * @task proxy
*/
final public function setProxy(PhabricatorCustomField $proxy) {
if (!$this->canSetProxy()) {
@@ -400,12 +401,20 @@
* @{method:canSetProxy}.
*
* @return PhabricatorCustomField|null Proxy field, if one is set.
+ * @task proxy
*/
final public function getProxy() {
return $this->proxy;
}
-
+ /**
+ * @task proxy
+ */
+ public function __clone() {
+ if ($this->proxy) {
+ $this->proxy = clone $this->proxy;
+ }
+ }
/* -( Contextual Data )---------------------------------------------------- */
@@ -827,7 +836,7 @@
/**
- * Appearing in ApplicationTrasactions allows a field to be edited using
+ * Appearing in ApplicationTransactions allows a field to be edited using
* standard workflows.
*
* @return bool True to appear in ApplicationTransactions.
@@ -1361,7 +1370,6 @@
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
-
/* -( Global Search )------------------------------------------------------ */
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
@@ -200,6 +200,19 @@
}
}
+ public function addFieldsToListViewItem(
+ PhabricatorCustomFieldInterface $object,
+ PhabricatorUser $viewer,
+ PHUIObjectItemView $view) {
+
+ foreach ($this->fields as $field) {
+ if ($field->shouldAppearInListView()) {
+ $field->setViewer($viewer);
+ $field->renderOnListItem($view);
+ }
+ }
+ }
+
public function buildFieldTransactionsFromRequest(
PhabricatorApplicationTransaction $template,
AphrontRequest $request) {

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 13:57 (18 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1024721
Default Alt Text
D25548.1734789457.diff (17 KB)

Event Timeline