diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 526e7d788f..368c3c3c71 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -331,6 +331,7 @@ phutil_register_library_map(array( 'DifferentialAuthorField' => 'applications/differential/customfield/DifferentialAuthorField.php', 'DifferentialAuthorFieldSpecification' => 'applications/differential/field/specification/DifferentialAuthorFieldSpecification.php', 'DifferentialAuxiliaryField' => 'applications/differential/storage/DifferentialAuxiliaryField.php', + 'DifferentialBlameRevisionField' => 'applications/differential/customfield/DifferentialBlameRevisionField.php', 'DifferentialBlameRevisionFieldSpecification' => 'applications/differential/field/specification/DifferentialBlameRevisionFieldSpecification.php', 'DifferentialBranchFieldSpecification' => 'applications/differential/field/specification/DifferentialBranchFieldSpecification.php', 'DifferentialCCWelcomeMail' => 'applications/differential/mail/DifferentialCCWelcomeMail.php', @@ -404,6 +405,7 @@ phutil_register_library_map(array( 'DifferentialFreeformFieldSpecification' => 'applications/differential/field/specification/DifferentialFreeformFieldSpecification.php', 'DifferentialGetWorkingCopy' => 'applications/differential/DifferentialGetWorkingCopy.php', 'DifferentialGitSVNIDFieldSpecification' => 'applications/differential/field/specification/DifferentialGitSVNIDFieldSpecification.php', + 'DifferentialHostField' => 'applications/differential/customfield/DifferentialHostField.php', 'DifferentialHostFieldSpecification' => 'applications/differential/field/specification/DifferentialHostFieldSpecification.php', 'DifferentialHovercardEventListener' => 'applications/differential/event/DifferentialHovercardEventListener.php', 'DifferentialHunk' => 'applications/differential/storage/DifferentialHunk.php', @@ -436,6 +438,7 @@ phutil_register_library_map(array( 'DifferentialPHIDTypeRevision' => 'applications/differential/phid/DifferentialPHIDTypeRevision.php', 'DifferentialParseCacheGarbageCollector' => 'applications/differential/garbagecollector/DifferentialParseCacheGarbageCollector.php', 'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php', + 'DifferentialPathField' => 'applications/differential/customfield/DifferentialPathField.php', 'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php', 'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php', 'DifferentialProjectReviewersField' => 'applications/differential/customfield/DifferentialProjectReviewersField.php', @@ -448,6 +451,7 @@ phutil_register_library_map(array( 'DifferentialRepositoryFieldSpecification' => 'applications/differential/field/specification/DifferentialRepositoryFieldSpecification.php', 'DifferentialRepositoryLookup' => 'applications/differential/query/DifferentialRepositoryLookup.php', 'DifferentialResultsTableView' => 'applications/differential/view/DifferentialResultsTableView.php', + 'DifferentialRevertPlanField' => 'applications/differential/customfield/DifferentialRevertPlanField.php', 'DifferentialRevertPlanFieldSpecification' => 'applications/differential/field/specification/DifferentialRevertPlanFieldSpecification.php', 'DifferentialReviewRequestMail' => 'applications/differential/mail/DifferentialReviewRequestMail.php', 'DifferentialReviewedByFieldSpecification' => 'applications/differential/field/specification/DifferentialReviewedByFieldSpecification.php', @@ -475,6 +479,7 @@ phutil_register_library_map(array( 'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php', 'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php', 'DifferentialSearchIndexer' => 'applications/differential/search/DifferentialSearchIndexer.php', + 'DifferentialStoredCustomField' => 'applications/differential/customfield/DifferentialStoredCustomField.php', 'DifferentialSubscribersField' => 'applications/differential/customfield/DifferentialSubscribersField.php', 'DifferentialSummaryField' => 'applications/differential/customfield/DifferentialSummaryField.php', 'DifferentialSummaryFieldSpecification' => 'applications/differential/field/specification/DifferentialSummaryFieldSpecification.php', @@ -2891,6 +2896,7 @@ phutil_register_library_map(array( 'DifferentialAuditorsFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialAuthorField' => 'DifferentialCustomField', 'DifferentialAuthorFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialBlameRevisionField' => 'DifferentialStoredCustomField', 'DifferentialBlameRevisionFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialBranchFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialCCWelcomeMail' => 'DifferentialReviewRequestMail', @@ -2962,6 +2968,7 @@ phutil_register_library_map(array( 'DifferentialFieldValidationException' => 'Exception', 'DifferentialFreeformFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialHostField' => 'DifferentialCustomField', 'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', 'DifferentialHunk' => 'DifferentialDAO', @@ -2973,7 +2980,7 @@ phutil_register_library_map(array( 'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DifferentialInlineCommentQuery' => 'PhabricatorOffsetPagedQuery', 'DifferentialInlineCommentView' => 'AphrontView', - 'DifferentialJIRAIssuesField' => 'DifferentialCustomField', + 'DifferentialJIRAIssuesField' => 'DifferentialStoredCustomField', 'DifferentialJIRAIssuesFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialLandingActionMenuEventListener' => 'PhabricatorEventListener', 'DifferentialLandingToGitHub' => 'DifferentialLandingStrategy', @@ -2990,6 +2997,7 @@ phutil_register_library_map(array( 'DifferentialPHIDTypeRevision' => 'PhabricatorPHIDType', 'DifferentialParseCacheGarbageCollector' => 'PhabricatorGarbageCollector', 'DifferentialParseRenderTestCase' => 'PhabricatorTestCase', + 'DifferentialPathField' => 'DifferentialCustomField', 'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialPrimaryPaneView' => 'AphrontView', 'DifferentialProjectReviewersField' => 'DifferentialCustomField', @@ -3001,6 +3009,7 @@ phutil_register_library_map(array( 'DifferentialRepositoryFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialRepositoryLookup' => 'Phobject', 'DifferentialResultsTableView' => 'AphrontView', + 'DifferentialRevertPlanField' => 'DifferentialStoredCustomField', 'DifferentialRevertPlanFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialReviewRequestMail' => 'DifferentialMail', 'DifferentialReviewedByFieldSpecification' => 'DifferentialFieldSpecification', @@ -3038,6 +3047,7 @@ phutil_register_library_map(array( 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 'DifferentialRevisionViewController' => 'DifferentialController', 'DifferentialSearchIndexer' => 'PhabricatorSearchDocumentIndexer', + 'DifferentialStoredCustomField' => 'DifferentialCustomField', 'DifferentialSubscribersField' => 'DifferentialCoreCustomField', 'DifferentialSummaryField' => 'DifferentialCoreCustomField', 'DifferentialSummaryFieldSpecification' => 'DifferentialFreeformFieldSpecification', diff --git a/src/applications/differential/customfield/DifferentialBlameRevisionField.php b/src/applications/differential/customfield/DifferentialBlameRevisionField.php new file mode 100644 index 0000000000..a5f044cc64 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialBlameRevisionField.php @@ -0,0 +1,83 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + return $this->getValue(); + } + + public function shouldAppearInEditView() { + return true; + } + + public function shouldAppearInApplicationTransactions() { + return true; + } + + public function getOldValueForApplicationTransactions() { + return $this->getValue(); + } + + public function getNewValueForApplicationTransactions() { + return $this->getValue(); + } + + public function readValueFromRequest(AphrontRequest $request) { + $this->setValue($request->getStr($this->getFieldKey())); + } + + public function renderEditControl(array $handles) { + return id(new AphrontFormTextControl()) + ->setName($this->getFieldKey()) + ->setValue($this->getValue()) + ->setLabel($this->getFieldName()); + } + + public function getApplicationTransactionTitle( + PhabricatorApplicationTransaction $xaction) { + $author_phid = $xaction->getAuthorPHID(); + $old = $xaction->getOldValue(); + $new = $xaction->getNewValue(); + + return pht( + '%s updated the blame revision for this revision.', + $xaction->renderHandleLink($author_phid)); + } + + public function getApplicationTransactionTitleForFeed( + PhabricatorApplicationTransaction $xaction, + PhabricatorFeedStory $story) { + + $object_phid = $xaction->getObjectPHID(); + $author_phid = $xaction->getAuthorPHID(); + $old = $xaction->getOldValue(); + $new = $xaction->getNewValue(); + + return pht( + '%s updated the blame revision for %s.', + $xaction->renderHandleLink($author_phid), + $xaction->renderHandleLink($object_phid)); + } + +} diff --git a/src/applications/differential/customfield/DifferentialHostField.php b/src/applications/differential/customfield/DifferentialHostField.php new file mode 100644 index 0000000000..28a5e767da --- /dev/null +++ b/src/applications/differential/customfield/DifferentialHostField.php @@ -0,0 +1,35 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + $host = $this->getObject()->getActiveDiff()->getSourceMachine(); + if (!$host) { + return null; + } + + return $host; + } + +} diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php index 30ad068235..921ec38a33 100644 --- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php +++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php @@ -1,14 +1,19 @@ getValue()); + } + + public function setValueFromStorage($value) { + $this->setValue(json_decode($value, true)); + return $this; } public function getFieldName() { @@ -46,8 +51,8 @@ final class DifferentialJIRAIssuesField $provider = PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider(); $refs = array(); - if ($this->value) { - foreach ($this->value as $jira_key) { + if ($this->getValue()) { + foreach ($this->getValue() as $jira_key) { $refs[] = id(new DoorkeeperObjectRef()) ->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA) ->setApplicationDomain($provider->getProviderDomain()) @@ -66,11 +71,13 @@ final class DifferentialJIRAIssuesField } $xobjs = id(new DoorkeeperExternalObjectQuery()) - ->setViewer($this->getUser()) + ->setViewer($this->getViewer()) ->withObjectKeys(mpull($refs, 'getObjectKey')) ->execute(); return $xobjs; } + // TODO: Implement edit; this field is readonly for now. + } diff --git a/src/applications/differential/customfield/DifferentialPathField.php b/src/applications/differential/customfield/DifferentialPathField.php new file mode 100644 index 0000000000..969aa61115 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialPathField.php @@ -0,0 +1,35 @@ +getFieldName(); + } + + public function renderPropertyViewValue(array $handles) { + $path = $this->getObject()->getActiveDiff()->getSourcePath(); + if (!$path) { + return null; + } + + return $path; + } + +} diff --git a/src/applications/differential/customfield/DifferentialRevertPlanField.php b/src/applications/differential/customfield/DifferentialRevertPlanField.php new file mode 100644 index 0000000000..15b1939ba8 --- /dev/null +++ b/src/applications/differential/customfield/DifferentialRevertPlanField.php @@ -0,0 +1,125 @@ +getFieldName(); + } + + public function getStyleForPropertyView() { + return 'block'; + } + + public function getIconForPropertyView() { + return PHUIPropertyListView::ICON_TESTPLAN; + } + + public function renderPropertyViewValue(array $handles) { + if (!strlen($this->getValue())) { + return null; + } + + return PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff()) + ->setPreserveLinebreaks(true) + ->setContent($this->getValue()), + 'default', + $this->getViewer()); + } + + public function shouldAppearInGlobalSearch() { + return true; + } + + public function updateAbstractDocument( + PhabricatorSearchAbstractDocument $document) { + if (strlen($this->getValue())) { + $document->addField('rvrt', $this->getValue()); + } + } + + public function shouldAppearInEditView() { + return true; + } + + public function shouldAppearInApplicationTransactions() { + return true; + } + + public function getOldValueForApplicationTransactions() { + return $this->getValue(); + } + + public function getNewValueForApplicationTransactions() { + return $this->getValue(); + } + + public function readValueFromRequest(AphrontRequest $request) { + $this->setValue($request->getStr($this->getFieldKey())); + } + + public function renderEditControl(array $handles) { + return id(new PhabricatorRemarkupControl()) + ->setName($this->getFieldKey()) + ->setValue($this->getValue()) + ->setLabel($this->getFieldName()); + } + + public function getApplicationTransactionTitle( + PhabricatorApplicationTransaction $xaction) { + $author_phid = $xaction->getAuthorPHID(); + $old = $xaction->getOldValue(); + $new = $xaction->getNewValue(); + + return pht( + '%s updated the revert plan for this revision.', + $xaction->renderHandleLink($author_phid)); + } + + public function getApplicationTransactionTitleForFeed( + PhabricatorApplicationTransaction $xaction, + PhabricatorFeedStory $story) { + + $object_phid = $xaction->getObjectPHID(); + $author_phid = $xaction->getAuthorPHID(); + $old = $xaction->getOldValue(); + $new = $xaction->getNewValue(); + + return pht( + '%s updated the revert plan for %s.', + $xaction->renderHandleLink($author_phid), + $xaction->renderHandleLink($object_phid)); + } + + public function getApplicationTransactionHasChangeDetails( + PhabricatorApplicationTransaction $xaction) { + return true; + } + + public function getApplicationTransactionChangeDetails( + PhabricatorApplicationTransaction $xaction, + PhabricatorUser $viewer) { + return $xaction->renderTextCorpusChangeDetails( + $viewer, + $xaction->getOldValue(), + $xaction->getNewValue()); + } + +} diff --git a/src/applications/differential/customfield/DifferentialStoredCustomField.php b/src/applications/differential/customfield/DifferentialStoredCustomField.php new file mode 100644 index 0000000000..a3fb97018b --- /dev/null +++ b/src/applications/differential/customfield/DifferentialStoredCustomField.php @@ -0,0 +1,42 @@ +value = $value; + return $this; + } + + public function getValue() { + return $this->value; + } + + public function shouldUseStorage() { + return true; + } + + public function newStorageObject() { + return new DifferentialCustomFieldStorage(); + } + + protected function newStringIndexStorage() { + return new DifferentialCustomFieldStringIndex(); + } + + protected function newNumericIndexStorage() { + return new DifferentialCustomFieldNumericIndex(); + } + + public function getValueForStorage() { + return $this->value; + } + + public function setValueFromStorage($value) { + $this->value = $value; + return $this; + } + +} diff --git a/src/applications/differential/customfield/DifferentialSummaryField.php b/src/applications/differential/customfield/DifferentialSummaryField.php index 4d95a56eb3..8b7b64e1b7 100644 --- a/src/applications/differential/customfield/DifferentialSummaryField.php +++ b/src/applications/differential/customfield/DifferentialSummaryField.php @@ -89,4 +89,33 @@ final class DifferentialSummaryField } } + public function shouldAppearInPropertyView() { + return true; + } + + public function renderPropertyViewLabel() { + return $this->getFieldName(); + } + + public function getStyleForPropertyView() { + return 'block'; + } + + public function getIconForPropertyView() { + return PHUIPropertyListView::ICON_SUMMARY; + } + + public function renderPropertyViewValue(array $handles) { + if (!strlen($this->getValue())) { + return null; + } + + return PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff()) + ->setPreserveLinebreaks(true) + ->setContent($this->getValue()), + 'default', + $this->getViewer()); + } + } diff --git a/src/applications/differential/customfield/DifferentialTestPlanField.php b/src/applications/differential/customfield/DifferentialTestPlanField.php index 3c4dbdadc5..91620f0e53 100644 --- a/src/applications/differential/customfield/DifferentialTestPlanField.php +++ b/src/applications/differential/customfield/DifferentialTestPlanField.php @@ -104,4 +104,33 @@ final class DifferentialTestPlanField } } + public function shouldAppearInPropertyView() { + return true; + } + + public function renderPropertyViewLabel() { + return $this->getFieldName(); + } + + public function getStyleForPropertyView() { + return 'block'; + } + + public function getIconForPropertyView() { + return PHUIPropertyListView::ICON_TESTPLAN; + } + + public function renderPropertyViewValue(array $handles) { + if (!strlen($this->getValue())) { + return null; + } + + return PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff()) + ->setPreserveLinebreaks(true) + ->setContent($this->getValue()), + 'default', + $this->getViewer()); + } + } diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php index d49ee400e6..762a8c73b5 100644 --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -73,6 +73,11 @@ final class DifferentialRevision extends DifferentialDAO ) + parent::getConfiguration(); } + public function getMonogram() { + $id = $this->getID(); + return "D{$id}"; + } + public function setTitle($title) { $this->title = $title; if (!$this->getID()) { diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php index b103c44dd5..9048e003bb 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomField.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php @@ -278,6 +278,10 @@ abstract class PhabricatorCustomField { return true; } + public function shouldDisableByDefault() { + return false; + } + /** * Return an index string which uniquely identifies this field. @@ -1070,6 +1074,17 @@ abstract class PhabricatorCustomField { } + /** + * @task view + */ + public function getIconForPropertyView() { + if ($this->proxy) { + return $this->proxy->getIconForPropertyView(); + } + return null; + } + + /** * @task view */ diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php index 5782f1edd9..df3b6a4ea2 100644 --- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php +++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php @@ -199,9 +199,10 @@ final class PhabricatorCustomFieldList extends Phobject { $view->addProperty($label, $value); break; case 'block': + $icon = $field->getIconForPropertyView(); $view->invokeWillRenderEvent(); if ($label !== null) { - $view->addSectionHeader($label); + $view->addSectionHeader($label, $icon); } $view->addTextContent($value); break;