diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ab84350f86..c7f4fd2c88 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -322,10 +322,13 @@ phutil_register_library_map(array( 'DifferentialActionMenuEventListener' => 'applications/differential/event/DifferentialActionMenuEventListener.php', 'DifferentialAddCommentView' => 'applications/differential/view/DifferentialAddCommentView.php', 'DifferentialAffectedPath' => 'applications/differential/storage/DifferentialAffectedPath.php', + 'DifferentialApplyPatchField' => 'applications/differential/customfield/DifferentialApplyPatchField.php', 'DifferentialApplyPatchFieldSpecification' => 'applications/differential/field/specification/DifferentialApplyPatchFieldSpecification.php', 'DifferentialArcanistProjectFieldSpecification' => 'applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php', + 'DifferentialAsanaRepresentationField' => 'applications/differential/customfield/DifferentialAsanaRepresentationField.php', 'DifferentialAsanaRepresentationFieldSpecification' => 'applications/differential/field/specification/DifferentialAsanaRepresentationFieldSpecification.php', 'DifferentialAuditorsFieldSpecification' => 'applications/differential/field/specification/DifferentialAuditorsFieldSpecification.php', + 'DifferentialAuthorField' => 'applications/differential/customfield/DifferentialAuthorField.php', 'DifferentialAuthorFieldSpecification' => 'applications/differential/field/specification/DifferentialAuthorFieldSpecification.php', 'DifferentialAuxiliaryField' => 'applications/differential/storage/DifferentialAuxiliaryField.php', 'DifferentialBlameRevisionFieldSpecification' => 'applications/differential/field/specification/DifferentialBlameRevisionFieldSpecification.php', @@ -355,6 +358,7 @@ phutil_register_library_map(array( 'DifferentialCommentQuery' => 'applications/differential/query/DifferentialCommentQuery.php', 'DifferentialCommentSaveController' => 'applications/differential/controller/DifferentialCommentSaveController.php', 'DifferentialCommentSaveControllerPro' => 'applications/differential/controller/DifferentialCommentSaveControllerPro.php', + 'DifferentialCommitsField' => 'applications/differential/customfield/DifferentialCommitsField.php', 'DifferentialCommitsFieldSpecification' => 'applications/differential/field/specification/DifferentialCommitsFieldSpecification.php', 'DifferentialConflictsFieldSpecification' => 'applications/differential/field/specification/DifferentialConflictsFieldSpecification.php', 'DifferentialController' => 'applications/differential/controller/DifferentialController.php', @@ -371,7 +375,9 @@ phutil_register_library_map(array( 'DifferentialDateCreatedFieldSpecification' => 'applications/differential/field/specification/DifferentialDateCreatedFieldSpecification.php', 'DifferentialDateModifiedFieldSpecification' => 'applications/differential/field/specification/DifferentialDateModifiedFieldSpecification.php', 'DifferentialDefaultFieldSelector' => 'applications/differential/field/selector/DifferentialDefaultFieldSelector.php', + 'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php', 'DifferentialDependenciesFieldSpecification' => 'applications/differential/field/specification/DifferentialDependenciesFieldSpecification.php', + 'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php', 'DifferentialDependsOnFieldSpecification' => 'applications/differential/field/specification/DifferentialDependsOnFieldSpecification.php', 'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php', 'DifferentialDiffContentMail' => 'applications/differential/mail/DifferentialDiffContentMail.php', @@ -410,6 +416,7 @@ phutil_register_library_map(array( 'DifferentialInlineCommentPreviewController' => 'applications/differential/controller/DifferentialInlineCommentPreviewController.php', 'DifferentialInlineCommentQuery' => 'applications/differential/query/DifferentialInlineCommentQuery.php', 'DifferentialInlineCommentView' => 'applications/differential/view/DifferentialInlineCommentView.php', + 'DifferentialJIRAIssuesField' => 'applications/differential/customfield/DifferentialJIRAIssuesField.php', 'DifferentialJIRAIssuesFieldSpecification' => 'applications/differential/field/specification/DifferentialJIRAIssuesFieldSpecification.php', 'DifferentialLandingActionMenuEventListener' => 'applications/differential/landing/DifferentialLandingActionMenuEventListener.php', 'DifferentialLandingStrategy' => 'applications/differential/landing/DifferentialLandingStrategy.php', @@ -422,6 +429,7 @@ phutil_register_library_map(array( 'DifferentialLocalCommitsView' => 'applications/differential/view/DifferentialLocalCommitsView.php', 'DifferentialMail' => 'applications/differential/mail/DifferentialMail.php', 'DifferentialMailPhase' => 'applications/differential/constants/DifferentialMailPhase.php', + 'DifferentialManiphestTasksField' => 'applications/differential/customfield/DifferentialManiphestTasksField.php', 'DifferentialManiphestTasksFieldSpecification' => 'applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php', 'DifferentialNewDiffMail' => 'applications/differential/mail/DifferentialNewDiffMail.php', 'DifferentialPHIDTypeDiff' => 'applications/differential/phid/DifferentialPHIDTypeDiff.php', @@ -430,6 +438,7 @@ phutil_register_library_map(array( 'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php', 'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php', 'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php', + 'DifferentialProjectReviewersField' => 'applications/differential/customfield/DifferentialProjectReviewersField.php', 'DifferentialProjectReviewersFieldSpecification' => 'applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php', 'DifferentialRawDiffRenderer' => 'applications/differential/render/DifferentialRawDiffRenderer.php', 'DifferentialReleephRequestFieldSpecification' => 'applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php', @@ -449,7 +458,6 @@ phutil_register_library_map(array( 'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php', 'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php', 'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php', - 'DifferentialRevisionDetailRenderer' => 'applications/differential/controller/DifferentialRevisionDetailRenderer.php', 'DifferentialRevisionDetailView' => 'applications/differential/view/DifferentialRevisionDetailView.php', 'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php', 'DifferentialRevisionEditControllerPro' => 'applications/differential/controller/DifferentialRevisionEditControllerPro.php', @@ -2491,7 +2499,6 @@ phutil_register_library_map(array( 'ReleephDiffChurnFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php', 'ReleephDiffMessageFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffMessageFieldSpecification.php', 'ReleephDiffSizeFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php', - 'ReleephDifferentialRevisionDetailRenderer' => 'applications/releeph/differential/ReleephDifferentialRevisionDetailRenderer.php', 'ReleephFieldParseException' => 'applications/releeph/field/exception/ReleephFieldParseException.php', 'ReleephFieldSelector' => 'applications/releeph/field/selector/ReleephFieldSelector.php', 'ReleephFieldSpecification' => 'applications/releeph/field/specification/ReleephFieldSpecification.php', @@ -2876,10 +2883,13 @@ phutil_register_library_map(array( 'DifferentialActionMenuEventListener' => 'PhabricatorEventListener', 'DifferentialAddCommentView' => 'AphrontView', 'DifferentialAffectedPath' => 'DifferentialDAO', + 'DifferentialApplyPatchField' => 'DifferentialCustomField', 'DifferentialApplyPatchFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialArcanistProjectFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialAsanaRepresentationField' => 'DifferentialCustomField', 'DifferentialAsanaRepresentationFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialAuditorsFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialAuthorField' => 'DifferentialCustomField', 'DifferentialAuthorFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialAuxiliaryField' => 'DifferentialDAO', 'DifferentialBlameRevisionFieldSpecification' => 'DifferentialFieldSpecification', @@ -2905,6 +2915,7 @@ phutil_register_library_map(array( 'DifferentialCommentQuery' => 'PhabricatorOffsetPagedQuery', 'DifferentialCommentSaveController' => 'DifferentialController', 'DifferentialCommentSaveControllerPro' => 'DifferentialController', + 'DifferentialCommitsField' => 'DifferentialCustomField', 'DifferentialCommitsFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialConflictsFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialController' => 'PhabricatorController', @@ -2921,7 +2932,9 @@ phutil_register_library_map(array( 'DifferentialDateCreatedFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialDateModifiedFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialDefaultFieldSelector' => 'DifferentialFieldSelector', + 'DifferentialDependenciesField' => 'DifferentialCustomField', 'DifferentialDependenciesFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialDependsOnField' => 'DifferentialCustomField', 'DifferentialDependsOnFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialDiff' => array( @@ -2961,6 +2974,7 @@ phutil_register_library_map(array( 'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DifferentialInlineCommentQuery' => 'PhabricatorOffsetPagedQuery', 'DifferentialInlineCommentView' => 'AphrontView', + 'DifferentialJIRAIssuesField' => 'DifferentialCustomField', 'DifferentialJIRAIssuesFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLandingActionMenuEventListener' => 'PhabricatorEventListener', 'DifferentialLandingToGitHub' => 'DifferentialLandingStrategy', @@ -2970,6 +2984,7 @@ phutil_register_library_map(array( 'DifferentialLintFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLocalCommitsView' => 'AphrontView', 'DifferentialMail' => 'PhabricatorMail', + 'DifferentialManiphestTasksField' => 'DifferentialCustomField', 'DifferentialManiphestTasksFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail', 'DifferentialPHIDTypeDiff' => 'PhabricatorPHIDType', @@ -2978,6 +2993,7 @@ phutil_register_library_map(array( 'DifferentialParseRenderTestCase' => 'PhabricatorTestCase', 'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialPrimaryPaneView' => 'AphrontView', + 'DifferentialProjectReviewersField' => 'DifferentialCustomField', 'DifferentialProjectReviewersFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialReleephRequestFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialRemarkupRule' => 'PhabricatorRemarkupRuleObject', diff --git a/src/applications/differential/customfield/DifferentialApplyPatchField.php b/src/applications/differential/customfield/DifferentialApplyPatchField.php new file mode 100644 index 0000000000..24665b7f5c --- /dev/null +++ b/src/applications/differential/customfield/DifferentialApplyPatchField.php @@ -0,0 +1,32 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + $mono = $this->getObject()->getMonogram(); + + return phutil_tag('tt', array(), "arc patch {$mono}"); + } + +} diff --git a/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php b/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php new file mode 100644 index 0000000000..7167b6cd38 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php @@ -0,0 +1,64 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + $viewer = $this->getViewer(); + $src_phid = $this->getObject()->getPHID(); + $edge_type = PhabricatorEdgeConfig::TYPE_PHOB_HAS_ASANATASK; + + $query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(array($src_phid)) + ->withEdgeTypes(array($edge_type)) + ->needEdgeData(true); + + $edges = $query->execute(); + if (!$edges) { + return null; + } + + $edge = head($edges[$src_phid][$edge_type]); + + if (!empty($edge['data']['gone'])) { + return phutil_tag( + 'em', + array(), + pht('Asana Task Deleted')); + } + + $ref = id(new DoorkeeperImportEngine()) + ->setViewer($viewer) + ->withPHIDs(array($edge['dst'])) + ->needLocalOnly(true) + ->executeOne(); + + if (!$ref) { + return null; + } + + return id(new DoorkeeperTagView()) + ->setExternalObject($ref->getExternalObject()); + } + +} diff --git a/src/applications/differential/customfield/DifferentialAuthorField.php b/src/applications/differential/customfield/DifferentialAuthorField.php new file mode 100644 index 0000000000..4496aabcae --- /dev/null +++ b/src/applications/differential/customfield/DifferentialAuthorField.php @@ -0,0 +1,34 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return array($this->getObject()->getAuthorPHID()); + } + + public function renderPropertyViewValue(array $handles) { + return $handles[$this->getObject()->getAuthorPHID()]->renderLink(); + } + +} diff --git a/src/applications/differential/customfield/DifferentialCommitsField.php b/src/applications/differential/customfield/DifferentialCommitsField.php new file mode 100644 index 0000000000..d030dcedb1 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialCommitsField.php @@ -0,0 +1,34 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return $this->getObject()->getCommitPHIDs(); + } + + public function renderPropertyViewValue(array $handles) { + return $this->renderHandleList($handles); + } + +} diff --git a/src/applications/differential/customfield/DifferentialCustomField.php b/src/applications/differential/customfield/DifferentialCustomField.php index 2066ea8683..c39dfb6837 100644 --- a/src/applications/differential/customfield/DifferentialCustomField.php +++ b/src/applications/differential/customfield/DifferentialCustomField.php @@ -3,4 +3,17 @@ abstract class DifferentialCustomField extends PhabricatorCustomField { + protected function renderHandleList(array $handles) { + if (!$handles) { + return null; + } + + $out = array(); + foreach ($handles as $handle) { + $out[] = $handle->renderLink(); + } + + return phutil_implode_html(phutil_tag('br'), $out); + } + } diff --git a/src/applications/differential/customfield/DifferentialDependenciesField.php b/src/applications/differential/customfield/DifferentialDependenciesField.php new file mode 100644 index 0000000000..575110a885 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialDependenciesField.php @@ -0,0 +1,36 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->getObject()->getPHID(), + PhabricatorEdgeConfig::TYPE_DREV_DEPENDED_ON_BY_DREV); + } + + public function renderPropertyViewValue(array $handles) { + return $this->renderHandleList($handles); + } + +} diff --git a/src/applications/differential/customfield/DifferentialDependsOnField.php b/src/applications/differential/customfield/DifferentialDependsOnField.php new file mode 100644 index 0000000000..a48095a58a --- /dev/null +++ b/src/applications/differential/customfield/DifferentialDependsOnField.php @@ -0,0 +1,36 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->getObject()->getPHID(), + PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV); + } + + public function renderPropertyViewValue(array $handles) { + return $this->renderHandleList($handles); + } + +} diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php new file mode 100644 index 0000000000..30ad068235 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php @@ -0,0 +1,76 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + $xobjs = $this->loadDoorkeeperExternalObjects(); + if (!$xobjs) { + return null; + } + + $links = array(); + foreach ($xobjs as $xobj) { + $links[] = id(new DoorkeeperTagView()) + ->setExternalObject($xobj); + } + + return phutil_implode_html(phutil_tag('br'), $links); + } + + private function buildDoorkeeperRefs() { + $provider = PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider(); + + $refs = array(); + if ($this->value) { + foreach ($this->value as $jira_key) { + $refs[] = id(new DoorkeeperObjectRef()) + ->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA) + ->setApplicationDomain($provider->getProviderDomain()) + ->setObjectType(DoorkeeperBridgeJIRA::OBJTYPE_ISSUE) + ->setObjectID($jira_key); + } + } + + return $refs; + } + + private function loadDoorkeeperExternalObjects() { + $refs = $this->buildDoorkeeperRefs(); + if (!$refs) { + return array(); + } + + $xobjs = id(new DoorkeeperExternalObjectQuery()) + ->setViewer($this->getUser()) + ->withObjectKeys(mpull($refs, 'getObjectKey')) + ->execute(); + + return $xobjs; + } + +} diff --git a/src/applications/differential/customfield/DifferentialManiphestTasksField.php b/src/applications/differential/customfield/DifferentialManiphestTasksField.php new file mode 100644 index 0000000000..e2d54b307a --- /dev/null +++ b/src/applications/differential/customfield/DifferentialManiphestTasksField.php @@ -0,0 +1,36 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->getObject()->getPHID(), + PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK); + } + + public function renderPropertyViewValue(array $handles) { + return $this->renderHandleList($handles); + } + +} diff --git a/src/applications/differential/customfield/DifferentialProjectReviewersField.php b/src/applications/differential/customfield/DifferentialProjectReviewersField.php new file mode 100644 index 0000000000..d3f6b70705 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialProjectReviewersField.php @@ -0,0 +1,55 @@ +getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return mpull($this->getProjectReviewers(), 'getReviewerPHID'); + } + + public function renderPropertyViewValue(array $handles) { + $reviewers = $this->getProjectReviewers(); + if (!$reviewers) { + return null; + } + + $view = id(new DifferentialReviewersView()) + ->setUser($this->getViewer()) + ->setReviewers($reviewers) + ->setHandles($handles); + + // TODO: Active diff stuff. + + return $view; + } + + private function getProjectReviewers() { + $reviewers = array(); + foreach ($this->getObject()->getReviewerStatus() as $reviewer) { + if (!$reviewer->isUser()) { + $reviewers[] = $reviewer; + } + } + return $reviewers; + } +} diff --git a/src/applications/differential/customfield/DifferentialRepositoryField.php b/src/applications/differential/customfield/DifferentialRepositoryField.php index a63bfac36d..b2055f5f72 100644 --- a/src/applications/differential/customfield/DifferentialRepositoryField.php +++ b/src/applications/differential/customfield/DifferentialRepositoryField.php @@ -123,4 +123,24 @@ final class DifferentialRepositoryField } } + public function shouldAppearInPropertyView() { + return true; + } + + public function renderPropertyViewLabel() { + return $this->getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + $repository_phid = $this->getObject()->getRepositoryPHID(); + if ($repository_phid) { + return array($repository_phid); + } + return array(); + } + + public function renderPropertyViewValue(array $handles) { + return $this->renderHandleList($handles); + } + } diff --git a/src/applications/differential/customfield/DifferentialReviewersField.php b/src/applications/differential/customfield/DifferentialReviewersField.php index 98fa5dcb74..9f89feec8c 100644 --- a/src/applications/differential/customfield/DifferentialReviewersField.php +++ b/src/applications/differential/customfield/DifferentialReviewersField.php @@ -81,4 +81,41 @@ final class DifferentialReviewersField ); } + public function shouldAppearInPropertyView() { + return true; + } + + public function renderPropertyViewLabel() { + return $this->getFieldName(); + } + + public function getRequiredHandlePHIDsForPropertyView() { + return mpull($this->getUserReviewers(), 'getReviewerPHID'); + } + + public function renderPropertyViewValue(array $handles) { + $reviewers = $this->getUserReviewers(); + if (!$reviewers) { + return phutil_tag('em', array(), pht('None')); + } + + $view = id(new DifferentialReviewersView()) + ->setUser($this->getViewer()) + ->setReviewers($reviewers) + ->setHandles($handles); + + // TODO: Active diff stuff. + + return $view; + } + + private function getUserReviewers() { + $reviewers = array(); + foreach ($this->getObject()->getReviewerStatus() as $reviewer) { + if ($reviewer->isUser()) { + $reviewers[] = $reviewer; + } + } + return $reviewers; + } } diff --git a/src/applications/people/customfield/PhabricatorUserBlurbField.php b/src/applications/people/customfield/PhabricatorUserBlurbField.php index 8cdb100225..8bd903e57c 100644 --- a/src/applications/people/customfield/PhabricatorUserBlurbField.php +++ b/src/applications/people/customfield/PhabricatorUserBlurbField.php @@ -61,7 +61,7 @@ final class PhabricatorUserBlurbField return null; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $blurb = $this->getObject()->loadUserProfile()->getBlurb(); if (!strlen($blurb)) { return null; diff --git a/src/applications/people/customfield/PhabricatorUserRolesField.php b/src/applications/people/customfield/PhabricatorUserRolesField.php index add52385a2..f4c667fd56 100644 --- a/src/applications/people/customfield/PhabricatorUserRolesField.php +++ b/src/applications/people/customfield/PhabricatorUserRolesField.php @@ -21,7 +21,7 @@ final class PhabricatorUserRolesField return true; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $user = $this->getObject(); $roles = array(); diff --git a/src/applications/people/customfield/PhabricatorUserSinceField.php b/src/applications/people/customfield/PhabricatorUserSinceField.php index 22a39104ef..eff207b81b 100644 --- a/src/applications/people/customfield/PhabricatorUserSinceField.php +++ b/src/applications/people/customfield/PhabricatorUserSinceField.php @@ -21,7 +21,7 @@ final class PhabricatorUserSinceField return true; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $absolute = phabricator_datetime( $this->getObject()->getDateCreated(), $this->getViewer()); diff --git a/src/applications/people/customfield/PhabricatorUserStatusField.php b/src/applications/people/customfield/PhabricatorUserStatusField.php index 1a52c267a9..0b624706e0 100644 --- a/src/applications/people/customfield/PhabricatorUserStatusField.php +++ b/src/applications/people/customfield/PhabricatorUserStatusField.php @@ -21,7 +21,7 @@ final class PhabricatorUserStatusField return true; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $user = $this->getObject(); $viewer = $this->requireViewer(); diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php index 3cd46b0690..b103c44dd5 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomField.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php @@ -1051,9 +1051,9 @@ abstract class PhabricatorCustomField { /** * @task view */ - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { if ($this->proxy) { - return $this->proxy->renderPropertyViewValue(); + return $this->proxy->renderPropertyViewValue($handles); } throw new PhabricatorCustomFieldImplementationIncompleteException($this); } @@ -1070,6 +1070,17 @@ abstract class PhabricatorCustomField { } + /** + * @task view + */ + public function getRequiredHandlePHIDsForPropertyView() { + if ($this->proxy) { + return $this->proxy->getRequiredHandlePHIDsForPropertyView(); + } + return array(); + } + + /* -( List View )---------------------------------------------------------- */ diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php index dae4bd507a..5782f1edd9 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php @@ -149,9 +149,25 @@ final class PhabricatorCustomFieldList extends Phobject { $add_header = null; - foreach ($fields as $field) { + $phids = array(); + foreach ($fields as $key => $field) { + $phids[$key] = $field->getRequiredHandlePHIDsForPropertyView(); + } + + $all_phids = array_mergev($phids); + if ($all_phids) { + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($viewer) + ->withPHIDs($all_phids) + ->execute(); + } else { + $handles = array(); + } + + foreach ($fields as $key => $field) { + $field_handles = array_select_keys($handles, $phids[$key]); $label = $field->renderPropertyViewLabel(); - $value = $field->renderPropertyViewValue(); + $value = $field->renderPropertyViewValue($field_handles); if ($value !== null) { switch ($field->getStyleForPropertyView()) { case 'header': diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php index 702632aa75..afa2db84a2 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -217,7 +217,7 @@ abstract class PhabricatorStandardCustomField return $this->getFieldConfigValue('view', true); } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { if (!strlen($this->getFieldValue())) { return null; } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php index b52d6570a3..75a1bf0b29 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php @@ -83,7 +83,7 @@ final class PhabricatorStandardCustomFieldBool (bool)$this->getFieldValue()); } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $value = $this->getFieldValue(); if ($value) { return $this->getString('view.yes', pht('Yes')); diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php index 5754885cf7..769d36e837 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php @@ -48,7 +48,7 @@ final class PhabricatorStandardCustomFieldDate $this->setFieldValue($value); } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $value = $this->getFieldValue(); if (!$value) { return null; diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php index 256f23b75a..e826917ea9 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php @@ -26,7 +26,7 @@ final class PhabricatorStandardCustomFieldHeader return 'header'; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { return $this->getFieldName(); } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php index c3b46a2e83..c03e5a3ed2 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -68,19 +68,20 @@ abstract class PhabricatorStandardCustomFieldPHIDs return array(); } - public function renderPropertyViewValue() { + public function getRequiredHandlePHIDsForProperyView() { + $value = $this->getFieldValue(); + if ($value) { + return $value; + } + return array(); + } + + public function renderPropertyViewValue(array $handles) { $value = $this->getFieldValue(); if (!$value) { return null; } - // TODO: Surface and batch this. - - $handles = id(new PhabricatorHandleQuery()) - ->setViewer($this->getViewer()) - ->withPHIDs($value) - ->execute(); - $handles = mpull($handles, 'renderLink'); $handles = phutil_implode_html(', ', $handles); return $handles; diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php index ee79aab76b..3bd3bcd85a 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php @@ -19,7 +19,7 @@ final class PhabricatorStandardCustomFieldRemarkup return 'block'; } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { $value = $this->getFieldValue(); if (!strlen($value)) { diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php index 969ab58968..ec1856aa79 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php @@ -73,7 +73,7 @@ final class PhabricatorStandardCustomFieldSelect ->setOptions($this->getOptions()); } - public function renderPropertyViewValue() { + public function renderPropertyViewValue(array $handles) { if (!strlen($this->getFieldValue())) { return null; }