1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Allow inline comment storage objects to generate their own runtime objects

Summary:
Ref T13513. Currently, inline storage objects ("TransactionComment") can't directly generate a runtime object ("InlineComment").

Allow this transformation to be performed in a genric way so clunky code which does it per-object-type can be removed, lifted, or simplified.

Simplify an especially gross callsite in preview code.

Test Plan: Previewed inline comments.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21226
This commit is contained in:
epriestley 2020-05-07 08:42:35 -07:00
parent 397648855f
commit 1656a2ff08
7 changed files with 41 additions and 23 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '1e667bcb', 'core.pkg.js' => '1e667bcb',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '2d70b7b9', 'differential.pkg.css' => '2d70b7b9',
'differential.pkg.js' => '22ec6f26', 'differential.pkg.js' => 'faa6e8ab',
'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7', 'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d', 'maniphest.pkg.css' => '35995d6d',
@ -433,7 +433,7 @@ return array(
'rsrc/js/application/releeph/releeph-preview-branch.js' => '75184d68', 'rsrc/js/application/releeph/releeph-preview-branch.js' => '75184d68',
'rsrc/js/application/releeph/releeph-request-state-change.js' => '9f081f05', 'rsrc/js/application/releeph/releeph-request-state-change.js' => '9f081f05',
'rsrc/js/application/releeph/releeph-request-typeahead.js' => 'aa3a100c', 'rsrc/js/application/releeph/releeph-request-typeahead.js' => 'aa3a100c',
'rsrc/js/application/repository/repository-crossreference.js' => '1c95ea63', 'rsrc/js/application/repository/repository-crossreference.js' => '6337cf26',
'rsrc/js/application/search/behavior-reorder-profile-menu-items.js' => 'e5bdb730', 'rsrc/js/application/search/behavior-reorder-profile-menu-items.js' => 'e5bdb730',
'rsrc/js/application/search/behavior-reorder-queries.js' => 'b86f297f', 'rsrc/js/application/search/behavior-reorder-queries.js' => 'b86f297f',
'rsrc/js/application/transactions/behavior-comment-actions.js' => '4dffaeb2', 'rsrc/js/application/transactions/behavior-comment-actions.js' => '4dffaeb2',
@ -685,7 +685,7 @@ return array(
'javelin-behavior-reorder-applications' => 'aa371860', 'javelin-behavior-reorder-applications' => 'aa371860',
'javelin-behavior-reorder-columns' => '8ac32fd9', 'javelin-behavior-reorder-columns' => '8ac32fd9',
'javelin-behavior-reorder-profile-menu-items' => 'e5bdb730', 'javelin-behavior-reorder-profile-menu-items' => 'e5bdb730',
'javelin-behavior-repository-crossreference' => '1c95ea63', 'javelin-behavior-repository-crossreference' => '6337cf26',
'javelin-behavior-scrollbar' => '92388bae', 'javelin-behavior-scrollbar' => '92388bae',
'javelin-behavior-search-reorder-queries' => 'b86f297f', 'javelin-behavior-search-reorder-queries' => 'b86f297f',
'javelin-behavior-select-content' => 'e8240b50', 'javelin-behavior-select-content' => 'e8240b50',
@ -1049,12 +1049,6 @@ return array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',
), ),
'1c95ea63' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-uri',
),
'1cab0e9a' => array( '1cab0e9a' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1501,6 +1495,12 @@ return array(
'60cd9241' => array( '60cd9241' => array(
'javelin-behavior', 'javelin-behavior',
), ),
'6337cf26' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-uri',
),
'65bb0011' => array( '65bb0011' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',

View file

@ -3593,6 +3593,7 @@ phutil_register_library_map(array(
'PhabricatorInfrastructureTestCase' => '__tests__/PhabricatorInfrastructureTestCase.php', 'PhabricatorInfrastructureTestCase' => '__tests__/PhabricatorInfrastructureTestCase.php',
'PhabricatorInlineComment' => 'infrastructure/diff/interface/PhabricatorInlineComment.php', 'PhabricatorInlineComment' => 'infrastructure/diff/interface/PhabricatorInlineComment.php',
'PhabricatorInlineCommentController' => 'infrastructure/diff/PhabricatorInlineCommentController.php', 'PhabricatorInlineCommentController' => 'infrastructure/diff/PhabricatorInlineCommentController.php',
'PhabricatorInlineCommentInterface' => 'applications/transactions/interface/PhabricatorInlineCommentInterface.php',
'PhabricatorInlineSummaryView' => 'infrastructure/diff/view/PhabricatorInlineSummaryView.php', 'PhabricatorInlineSummaryView' => 'infrastructure/diff/view/PhabricatorInlineSummaryView.php',
'PhabricatorInstructionsEditField' => 'applications/transactions/editfield/PhabricatorInstructionsEditField.php', 'PhabricatorInstructionsEditField' => 'applications/transactions/editfield/PhabricatorInstructionsEditField.php',
'PhabricatorIntConfigType' => 'applications/config/type/PhabricatorIntConfigType.php', 'PhabricatorIntConfigType' => 'applications/config/type/PhabricatorIntConfigType.php',
@ -6789,7 +6790,10 @@ phutil_register_library_map(array(
'DifferentialTestPlanField' => 'DifferentialCoreCustomField', 'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField', 'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField',
'DifferentialTransaction' => 'PhabricatorModularTransaction', 'DifferentialTransaction' => 'PhabricatorModularTransaction',
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment', 'DifferentialTransactionComment' => array(
'PhabricatorApplicationTransactionComment',
'PhabricatorInlineCommentInterface',
),
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'DifferentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'DifferentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'DifferentialTransactionView' => 'PhabricatorApplicationTransactionView', 'DifferentialTransactionView' => 'PhabricatorApplicationTransactionView',
@ -8599,7 +8603,10 @@ phutil_register_library_map(array(
'PhabricatorAuditStatusConstants' => 'Phobject', 'PhabricatorAuditStatusConstants' => 'Phobject',
'PhabricatorAuditSynchronizeManagementWorkflow' => 'PhabricatorAuditManagementWorkflow', 'PhabricatorAuditSynchronizeManagementWorkflow' => 'PhabricatorAuditManagementWorkflow',
'PhabricatorAuditTransaction' => 'PhabricatorModularTransaction', 'PhabricatorAuditTransaction' => 'PhabricatorModularTransaction',
'PhabricatorAuditTransactionComment' => 'PhabricatorApplicationTransactionComment', 'PhabricatorAuditTransactionComment' => array(
'PhabricatorApplicationTransactionComment',
'PhabricatorInlineCommentInterface',
),
'PhabricatorAuditTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorAuditTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorAuditTransactionView' => 'PhabricatorApplicationTransactionView', 'PhabricatorAuditTransactionView' => 'PhabricatorApplicationTransactionView',
'PhabricatorAuditUpdateOwnersManagementWorkflow' => 'PhabricatorAuditManagementWorkflow', 'PhabricatorAuditUpdateOwnersManagementWorkflow' => 'PhabricatorAuditManagementWorkflow',

View file

@ -1,7 +1,9 @@
<?php <?php
final class PhabricatorAuditTransactionComment final class PhabricatorAuditTransactionComment
extends PhabricatorApplicationTransactionComment { extends PhabricatorApplicationTransactionComment
implements
PhabricatorInlineCommentInterface {
protected $commitPHID; protected $commitPHID;
protected $pathID; protected $pathID;
@ -85,4 +87,8 @@ final class PhabricatorAuditTransactionComment
return !strlen($this->getContent()); return !strlen($this->getContent());
} }
public function newInlineCommentObject() {
return PhabricatorAuditInlineComment::newFromModernComment($this);
}
} }

View file

@ -1,7 +1,9 @@
<?php <?php
final class DifferentialTransactionComment final class DifferentialTransactionComment
extends PhabricatorApplicationTransactionComment { extends PhabricatorApplicationTransactionComment
implements
PhabricatorInlineCommentInterface {
protected $revisionPHID; protected $revisionPHID;
protected $changesetID; protected $changesetID;
@ -131,4 +133,8 @@ final class DifferentialTransactionComment
return !strlen($this->getContent()); return !strlen($this->getContent());
} }
public function newInlineCommentObject() {
return DifferentialInlineComment::newFromModernComment($this);
}
} }

View file

@ -0,0 +1,7 @@
<?php
interface PhabricatorInlineCommentInterface {
public function newInlineCommentObject();
}

View file

@ -38,15 +38,7 @@ final class PHUIDiffInlineCommentPreviewListView
$inlines = $this->getInlineComments(); $inlines = $this->getInlineComments();
foreach ($inlines as $key => $inline) { foreach ($inlines as $key => $inline) {
// TODO: This is real, real gross. $inlines[$key] = $inline->newInlineCommentObject();
if ($inline instanceof DifferentialTransactionComment) {
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
$inline);
} else {
$inlines[$key] = PhabricatorAuditInlineComment::newFromModernComment(
$inline);
}
} }
$engine = new PhabricatorMarkupEngine(); $engine = new PhabricatorMarkupEngine();

View file

@ -219,7 +219,7 @@ JX.behavior('repository-crossreference', function(config, statics) {
} }
function getPath(target) { function getPath(target) {
// This method works in Differential, when browsing a changset. // This method works in Differential, when browsing a changeset.
var changeset; var changeset;
try { try {
changeset = JX.DOM.findAbove(target, 'div', 'differential-changeset'); changeset = JX.DOM.findAbove(target, 'div', 'differential-changeset');