@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use EditEngine stacked comments in Diffusion

Summary: Ref T10978. Ref T8739. Fixes T10446. Converts Diffusion to modern comment/preview code, like Differential.

Test Plan: {F2342933}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10978, T10446, T8739

Differential Revision: https://secure.phabricator.com/D17183

+144 -404
+9 -17
resources/celerity/map.php
··· 13 13 'core.pkg.js' => 'a2ead3fe', 14 14 'darkconsole.pkg.js' => 'e7393ebb', 15 15 'differential.pkg.css' => '9535a7e6', 16 - 'differential.pkg.js' => '40b18f35', 16 + 'differential.pkg.js' => 'ddfeb49b', 17 17 'diffusion.pkg.css' => '91c5d3a6', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 19 'favicon.ico' => '30672e08', ··· 399 399 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 400 400 'rsrc/js/application/differential/ChangesetViewManager.js' => 'a2828756', 401 401 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => '2e3f9738', 402 - 'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => 'e10f8e18', 403 402 'rsrc/js/application/differential/behavior-comment-jump.js' => '4fdb476d', 404 403 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', 405 404 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 406 405 'rsrc/js/application/differential/behavior-dropdown-menus.js' => '9a6b9324', 407 406 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '4fbbc3e9', 408 - 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492', 407 + 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '92904457', 409 408 'rsrc/js/application/differential/behavior-populate.js' => '8694b1df', 410 409 'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb', 411 410 'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d', ··· 627 626 'javelin-behavior-detect-timezone' => '4c193c96', 628 627 'javelin-behavior-device' => 'bb1dd507', 629 628 'javelin-behavior-diff-preview-link' => '051c7832', 630 - 'javelin-behavior-differential-add-reviewers-and-ccs' => 'e10f8e18', 631 629 'javelin-behavior-differential-comment-jump' => '4fdb476d', 632 630 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', 633 631 'javelin-behavior-differential-dropdown-menus' => '9a6b9324', 634 632 'javelin-behavior-differential-edit-inline-comments' => '4fbbc3e9', 635 633 'javelin-behavior-differential-feedback-preview' => 'b064af76', 636 - 'javelin-behavior-differential-keyboard-navigation' => '2c426492', 634 + 'javelin-behavior-differential-keyboard-navigation' => '92904457', 637 635 'javelin-behavior-differential-populate' => '8694b1df', 638 636 'javelin-behavior-differential-toggle-files' => 'ca3f91eb', 639 637 'javelin-behavior-differential-user-select' => 'a8d8459d', ··· 1144 1142 'javelin-install', 1145 1143 'javelin-util', 1146 1144 ), 1147 - '2c426492' => array( 1148 - 'javelin-behavior', 1149 - 'javelin-dom', 1150 - 'javelin-stratcom', 1151 - 'phabricator-keyboard-shortcut', 1152 - ), 1153 1145 '2caa8fb8' => array( 1154 1146 'javelin-install', 1155 1147 'javelin-event', ··· 1650 1642 'javelin-behavior', 1651 1643 'javelin-dom', 1652 1644 'javelin-request', 1645 + ), 1646 + 92904457 => array( 1647 + 'javelin-behavior', 1648 + 'javelin-dom', 1649 + 'javelin-stratcom', 1650 + 'phabricator-keyboard-shortcut', 1653 1651 ), 1654 1652 '92b9ec77' => array( 1655 1653 'javelin-behavior', ··· 2086 2084 'javelin-request', 2087 2085 'javelin-util', 2088 2086 ), 2089 - 'e10f8e18' => array( 2090 - 'javelin-behavior', 2091 - 'javelin-dom', 2092 - 'phabricator-prefab', 2093 - ), 2094 2087 'e1621fd5' => array( 2095 2088 'phui-inline-comment-view-css', 2096 2089 ), ··· 2463 2456 'javelin-behavior-differential-populate', 2464 2457 'javelin-behavior-differential-diff-radios', 2465 2458 'javelin-behavior-differential-comment-jump', 2466 - 'javelin-behavior-differential-add-reviewers-and-ccs', 2467 2459 'javelin-behavior-differential-keyboard-navigation', 2468 2460 'javelin-behavior-aphront-drag-and-drop-textarea', 2469 2461 'javelin-behavior-phabricator-object-selector',
-1
resources/celerity/packages.php
··· 195 195 'javelin-behavior-differential-populate', 196 196 'javelin-behavior-differential-diff-radios', 197 197 'javelin-behavior-differential-comment-jump', 198 - 'javelin-behavior-differential-add-reviewers-and-ccs', 199 198 'javelin-behavior-differential-keyboard-navigation', 200 199 'javelin-behavior-aphront-drag-and-drop-textarea', 201 200 'javelin-behavior-phabricator-object-selector',
-4
src/__phutil_library_map__.php
··· 1867 1867 'PhabricatorAsanaSubtaskHasObjectEdgeType' => 'applications/doorkeeper/edge/PhabricatorAsanaSubtaskHasObjectEdgeType.php', 1868 1868 'PhabricatorAsanaTaskHasObjectEdgeType' => 'applications/doorkeeper/edge/PhabricatorAsanaTaskHasObjectEdgeType.php', 1869 1869 'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php', 1870 - 'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php', 1871 1870 'PhabricatorAuditApplication' => 'applications/audit/application/PhabricatorAuditApplication.php', 1872 1871 'PhabricatorAuditCommentEditor' => 'applications/audit/editor/PhabricatorAuditCommentEditor.php', 1873 1872 'PhabricatorAuditCommitStatusConstants' => 'applications/audit/constants/PhabricatorAuditCommitStatusConstants.php', ··· 1879 1878 'PhabricatorAuditMailReceiver' => 'applications/audit/mail/PhabricatorAuditMailReceiver.php', 1880 1879 'PhabricatorAuditManagementDeleteWorkflow' => 'applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php', 1881 1880 'PhabricatorAuditManagementWorkflow' => 'applications/audit/management/PhabricatorAuditManagementWorkflow.php', 1882 - 'PhabricatorAuditPreviewController' => 'applications/audit/controller/PhabricatorAuditPreviewController.php', 1883 1881 'PhabricatorAuditReplyHandler' => 'applications/audit/mail/PhabricatorAuditReplyHandler.php', 1884 1882 'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php', 1885 1883 'PhabricatorAuditTransaction' => 'applications/audit/storage/PhabricatorAuditTransaction.php', ··· 6757 6755 'PhabricatorAsanaSubtaskHasObjectEdgeType' => 'PhabricatorEdgeType', 6758 6756 'PhabricatorAsanaTaskHasObjectEdgeType' => 'PhabricatorEdgeType', 6759 6757 'PhabricatorAuditActionConstants' => 'Phobject', 6760 - 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', 6761 6758 'PhabricatorAuditApplication' => 'PhabricatorApplication', 6762 6759 'PhabricatorAuditCommentEditor' => 'PhabricatorEditor', 6763 6760 'PhabricatorAuditCommitStatusConstants' => 'Phobject', ··· 6772 6769 'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver', 6773 6770 'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow', 6774 6771 'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow', 6775 - 'PhabricatorAuditPreviewController' => 'PhabricatorAuditController', 6776 6772 'PhabricatorAuditReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 6777 6773 'PhabricatorAuditStatusConstants' => 'Phobject', 6778 6774 'PhabricatorAuditTransaction' => 'PhabricatorModularTransaction',
-2
src/applications/audit/application/PhabricatorAuditApplication.php
··· 35 35 return array( 36 36 '/audit/' => array( 37 37 '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorAuditListController', 38 - 'addcomment/' => 'PhabricatorAuditAddCommentController', 39 - 'preview/(?P<id>[1-9]\d*)/' => 'PhabricatorAuditPreviewController', 40 38 ), 41 39 ); 42 40 }
-90
src/applications/audit/controller/PhabricatorAuditAddCommentController.php
··· 1 - <?php 2 - 3 - final class PhabricatorAuditAddCommentController 4 - extends PhabricatorAuditController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - 9 - if (!$request->isFormPost()) { 10 - return new Aphront403Response(); 11 - } 12 - 13 - $commit_phid = $request->getStr('commit'); 14 - $commit = id(new DiffusionCommitQuery()) 15 - ->setViewer($viewer) 16 - ->withPHIDs(array($commit_phid)) 17 - ->needAuditRequests(true) 18 - ->executeOne(); 19 - if (!$commit) { 20 - return new Aphront404Response(); 21 - } 22 - 23 - $xactions = array(); 24 - 25 - // make sure we only add auditors or ccs if the action matches 26 - $action = $request->getStr('action'); 27 - switch ($action) { 28 - case PhabricatorAuditActionConstants::ADD_AUDITORS: 29 - $auditors = $request->getArr('auditors'); 30 - $xactions[] = id(new PhabricatorAuditTransaction()) 31 - ->setTransactionType(PhabricatorAuditActionConstants::ADD_AUDITORS) 32 - ->setNewValue(array_fuse($auditors)); 33 - break; 34 - case PhabricatorAuditActionConstants::ADD_CCS: 35 - $xactions[] = id(new PhabricatorAuditTransaction()) 36 - ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 37 - ->setNewValue( 38 - array( 39 - '+' => $request->getArr('ccs'), 40 - )); 41 - break; 42 - case PhabricatorAuditActionConstants::COMMENT: 43 - // We'll deal with this below. 44 - break; 45 - default: 46 - $xactions[] = id(new PhabricatorAuditTransaction()) 47 - ->setTransactionType(PhabricatorAuditActionConstants::ACTION) 48 - ->setNewValue($action); 49 - break; 50 - } 51 - 52 - $content = $request->getStr('content'); 53 - if (strlen($content)) { 54 - $xactions[] = id(new PhabricatorAuditTransaction()) 55 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 56 - ->attachComment( 57 - id(new PhabricatorAuditTransactionComment()) 58 - ->setCommitPHID($commit->getPHID()) 59 - ->setContent($content)); 60 - } 61 - 62 - $inlines = PhabricatorAuditInlineComment::loadDraftComments( 63 - $viewer, 64 - $commit->getPHID()); 65 - foreach ($inlines as $inline) { 66 - $xactions[] = id(new PhabricatorAuditTransaction()) 67 - ->setTransactionType(PhabricatorAuditActionConstants::INLINE) 68 - ->attachComment($inline->getTransactionComment()); 69 - } 70 - 71 - id(new PhabricatorAuditEditor()) 72 - ->setActor($viewer) 73 - ->setContentSourceFromRequest($request) 74 - ->setContinueOnMissingFields(true) 75 - ->applyTransactions($commit, $xactions); 76 - 77 - $draft = id(new PhabricatorDraft())->loadOneWhere( 78 - 'authorPHID = %s AND draftKey = %s', 79 - $viewer->getPHID(), 80 - 'diffusion-audit-'.$commit->getID()); 81 - if ($draft) { 82 - $draft->delete(); 83 - } 84 - 85 - $uri = $commit->getURI(); 86 - 87 - return id(new AphrontRedirectResponse())->setURI($uri); 88 - } 89 - 90 - }
-82
src/applications/audit/controller/PhabricatorAuditPreviewController.php
··· 1 - <?php 2 - 3 - final class PhabricatorAuditPreviewController 4 - extends PhabricatorAuditController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - $id = $request->getURIData('id'); 9 - 10 - $commit = id(new PhabricatorRepositoryCommit())->load($id); 11 - if (!$commit) { 12 - return new Aphront404Response(); 13 - } 14 - 15 - $xactions = array(); 16 - 17 - $action = $request->getStr('action'); 18 - if ($action != PhabricatorAuditActionConstants::COMMENT) { 19 - $action_xaction = id(new PhabricatorAuditTransaction()) 20 - ->setAuthorPHID($viewer->getPHID()) 21 - ->setObjectPHID($commit->getPHID()) 22 - ->setTransactionType(PhabricatorAuditActionConstants::ACTION) 23 - ->setNewValue($action); 24 - 25 - $auditors = $request->getStrList('auditors'); 26 - if ($action == PhabricatorAuditActionConstants::ADD_AUDITORS && 27 - $auditors) { 28 - $action_xaction->setTransactionType($action); 29 - $action_xaction->setNewValue(array_fuse($auditors)); 30 - } 31 - 32 - $ccs = $request->getStrList('ccs'); 33 - if ($action == PhabricatorAuditActionConstants::ADD_CCS && $ccs) { 34 - $action_xaction->setTransactionType( 35 - PhabricatorTransactions::TYPE_SUBSCRIBERS); 36 - 37 - // NOTE: This doesn't get processed before use, so just provide fake 38 - // values. 39 - $action_xaction->setOldValue(array()); 40 - $action_xaction->setNewValue($ccs); 41 - } 42 - 43 - $xactions[] = $action_xaction; 44 - } 45 - 46 - $content = $request->getStr('content'); 47 - if (strlen($content)) { 48 - $xactions[] = id(new PhabricatorAuditTransaction()) 49 - ->setAuthorPHID($viewer->getPHID()) 50 - ->setObjectPHID($commit->getPHID()) 51 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 52 - ->attachComment( 53 - id(new PhabricatorAuditTransactionComment()) 54 - ->setContent($content)); 55 - } 56 - 57 - $phids = array(); 58 - foreach ($xactions as $xaction) { 59 - $phids[] = $xaction->getRequiredHandlePHIDs(); 60 - } 61 - $phids = array_mergev($phids); 62 - $handles = $this->loadViewerHandles($phids); 63 - foreach ($xactions as $xaction) { 64 - $xaction->setHandles($handles); 65 - } 66 - 67 - $view = id(new PhabricatorAuditTransactionView()) 68 - ->setIsPreview(true) 69 - ->setUser($viewer) 70 - ->setObjectPHID($commit->getPHID()) 71 - ->setTransactions($xactions); 72 - 73 - id(new PhabricatorDraft()) 74 - ->setAuthorPHID($viewer->getPHID()) 75 - ->setDraftKey('diffusion-audit-'.$id) 76 - ->setDraft($content) 77 - ->replaceOrDelete(); 78 - 79 - return id(new AphrontAjaxResponse())->setContent(hsprintf('%s', $view)); 80 - } 81 - 82 - }
+16 -1
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 10 10 private $rawPatch; 11 11 private $auditorPHIDs = array(); 12 12 13 - private $didExpandInlineState; 13 + private $didExpandInlineState = false; 14 14 15 15 public function addAuditReason($phid, $reason) { 16 16 if (!isset($this->auditReasonMap[$phid])) { ··· 65 65 $types[] = PhabricatorAuditActionConstants::ADD_AUDITORS; 66 66 67 67 return $types; 68 + } 69 + 70 + protected function expandTransactions( 71 + PhabricatorLiskDAO $object, 72 + array $xactions) { 73 + 74 + foreach ($xactions as $xaction) { 75 + switch ($xaction->getTransactionType()) { 76 + case PhabricatorTransactions::TYPE_INLINESTATE: 77 + $this->didExpandInlineState = true; 78 + break; 79 + } 80 + } 81 + 82 + return parent::expandTransactions($object, $xactions); 68 83 } 69 84 70 85 protected function transactionHasEffect(
+6 -1
src/applications/audit/storage/PhabricatorAuditInlineComment.php
··· 68 68 69 69 public static function loadDraftComments( 70 70 PhabricatorUser $viewer, 71 - $commit_phid) { 71 + $commit_phid, 72 + $raw = false) { 72 73 73 74 $inlines = id(new DiffusionDiffInlineCommentQuery()) 74 75 ->setViewer($viewer) ··· 79 80 ->withIsDeleted(false) 80 81 ->needReplyToComments(true) 81 82 ->execute(); 83 + 84 + if ($raw) { 85 + return $inlines; 86 + } 82 87 83 88 return self::buildProxies($inlines); 84 89 }
+6 -1
src/applications/audit/view/PhabricatorAuditTransactionView.php
··· 3 3 final class PhabricatorAuditTransactionView 4 4 extends PhabricatorApplicationTransactionView { 5 5 6 - private $pathMap; 6 + private $pathMap = array(); 7 7 8 8 public function setPathMap(array $path_map) { 9 9 $this->pathMap = $path_map; ··· 55 55 $type_inline = PhabricatorAuditActionConstants::INLINE; 56 56 57 57 $group = $xaction->getTransactionGroup(); 58 + 58 59 if ($xaction->getTransactionType() == $type_inline) { 59 60 array_unshift($group, $xaction); 60 61 } else { 61 62 $out[] = parent::renderTransactionContent($xaction); 63 + } 64 + 65 + if ($this->getIsPreview()) { 66 + return $out; 62 67 } 63 68 64 69 if (!$group) {
+1 -6
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 463 463 } 464 464 465 465 Javelin::initBehavior('differential-user-select'); 466 - 467 - Javelin::initBehavior( 468 - 'differential-keyboard-navigation', 469 - array( 470 - 'haunt' => null, 471 - )); 466 + Javelin::initBehavior('differential-keyboard-navigation'); 472 467 473 468 $view = id(new PHUITwoColumnView()) 474 469 ->setHeader($header)
+10 -134
src/applications/diffusion/controller/DiffusionCommitController.php
··· 369 369 370 370 } 371 371 372 - $add_comment = $this->renderAddCommentPanel($commit, $audit_requests); 372 + $add_comment = $this->renderAddCommentPanel( 373 + $commit, 374 + $timeline); 373 375 374 376 $filetree_on = $viewer->compareUserSetting( 375 377 PhabricatorShowFiletreeSetting::SETTINGKEY, ··· 717 719 718 720 private function renderAddCommentPanel( 719 721 PhabricatorRepositoryCommit $commit, 720 - array $audit_requests) { 721 - assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest'); 722 + $timeline) { 722 723 723 724 $request = $this->getRequest(); 724 725 $viewer = $request->getUser(); 725 726 726 - if (!$viewer->isLoggedIn()) { 727 - return id(new PhabricatorApplicationTransactionCommentView()) 728 - ->setUser($viewer) 729 - ->setRequestURI($request->getRequestURI()); 730 - } 731 - 732 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 733 - 734 - $pane_id = celerity_generate_unique_node_id(); 735 - Javelin::initBehavior( 736 - 'differential-keyboard-navigation', 737 - array( 738 - 'haunt' => $pane_id, 739 - )); 740 - 741 - $draft = id(new PhabricatorDraft())->loadOneWhere( 742 - 'authorPHID = %s AND draftKey = %s', 743 - $viewer->getPHID(), 744 - 'diffusion-audit-'.$commit->getID()); 745 - if ($draft) { 746 - $draft = $draft->getDraft(); 747 - } else { 748 - $draft = null; 749 - } 750 - 751 - $actions = $this->getAuditActions($commit, $audit_requests); 752 - 753 - $mailable_source = new PhabricatorMetaMTAMailableDatasource(); 754 - $auditor_source = new DiffusionAuditorDatasource(); 755 - 756 - $form = id(new AphrontFormView()) 757 - ->setUser($viewer) 758 - ->setAction('/audit/addcomment/') 759 - ->addHiddenInput('commit', $commit->getPHID()) 760 - ->appendChild( 761 - id(new AphrontFormSelectControl()) 762 - ->setLabel(pht('Action')) 763 - ->setName('action') 764 - ->setID('audit-action') 765 - ->setOptions($actions)) 766 - ->appendControl( 767 - id(new AphrontFormTokenizerControl()) 768 - ->setLabel(pht('Add Auditors')) 769 - ->setName('auditors') 770 - ->setControlID('add-auditors') 771 - ->setControlStyle('display: none') 772 - ->setID('add-auditors-tokenizer') 773 - ->setDisableBehavior(true) 774 - ->setDatasource($auditor_source)) 775 - ->appendControl( 776 - id(new AphrontFormTokenizerControl()) 777 - ->setLabel(pht('Add CCs')) 778 - ->setName('ccs') 779 - ->setControlID('add-ccs') 780 - ->setControlStyle('display: none') 781 - ->setID('add-ccs-tokenizer') 782 - ->setDisableBehavior(true) 783 - ->setDatasource($mailable_source)) 784 - ->appendChild( 785 - id(new PhabricatorRemarkupControl()) 786 - ->setLabel(pht('Comments')) 787 - ->setName('content') 788 - ->setValue($draft) 789 - ->setID('audit-content') 790 - ->setUser($viewer)) 791 - ->appendChild( 792 - id(new AphrontFormSubmitControl()) 793 - ->setValue(pht('Submit'))); 794 - 795 - $header = new PHUIHeaderView(); 796 - $header->setHeader( 797 - $is_serious ? pht('Audit Commit') : pht('Creative Accounting')); 798 - 799 - Javelin::initBehavior( 800 - 'differential-add-reviewers-and-ccs', 801 - array( 802 - 'dynamic' => array( 803 - 'add-auditors-tokenizer' => array( 804 - 'actions' => array('add_auditors' => 1), 805 - 'src' => $auditor_source->getDatasourceURI(), 806 - 'row' => 'add-auditors', 807 - 'placeholder' => $auditor_source->getPlaceholderText(), 808 - ), 809 - 'add-ccs-tokenizer' => array( 810 - 'actions' => array('add_ccs' => 1), 811 - 'src' => $mailable_source->getDatasourceURI(), 812 - 'row' => 'add-ccs', 813 - 'placeholder' => $mailable_source->getPlaceholderText(), 814 - ), 815 - ), 816 - 'select' => 'audit-action', 817 - )); 818 - 819 - Javelin::initBehavior('differential-feedback-preview', array( 820 - 'uri' => '/audit/preview/'.$commit->getID().'/', 821 - 'preview' => 'audit-preview', 822 - 'content' => 'audit-content', 823 - 'action' => 'audit-action', 824 - 'previewTokenizers' => array( 825 - 'auditors' => 'add-auditors-tokenizer', 826 - 'ccs' => 'add-ccs-tokenizer', 827 - ), 828 - 'inline' => 'inline-comment-preview', 829 - 'inlineuri' => '/diffusion/inline/preview/'.$commit->getPHID().'/', 830 - )); 831 - 832 - $loading = phutil_tag_div( 833 - 'aphront-panel-preview-loading-text', 834 - pht('Loading preview...')); 835 - 836 - $preview_panel = phutil_tag_div( 837 - 'aphront-panel-preview aphront-panel-flush', 838 - array( 839 - phutil_tag('div', array('id' => 'audit-preview'), $loading), 840 - phutil_tag('div', array('id' => 'inline-comment-preview')), 841 - )); 727 + Javelin::initBehavior('differential-keyboard-navigation'); 842 728 843 729 // TODO: This is pretty awkward, unify the CSS between Diffusion and 844 730 // Differential better. 845 731 require_celerity_resource('differential-core-view-css'); 846 732 847 - $anchor = id(new PhabricatorAnchorView()) 848 - ->setAnchorName('comment') 849 - ->setNavigationMarker(true) 850 - ->render(); 733 + $comment_view = id(new DiffusionCommitEditEngine()) 734 + ->setViewer($viewer) 735 + ->buildEditEngineCommentView($commit); 851 736 852 - $comment_box = id(new PHUIObjectBoxView()) 853 - ->setHeader($header) 854 - ->appendChild($form); 737 + $comment_view->setTransactionTimeline($timeline); 855 738 856 - return phutil_tag( 857 - 'div', 858 - array( 859 - 'id' => $pane_id, 860 - ), 861 - phutil_tag_div( 862 - 'differential-add-comment-panel', 863 - array($anchor, $comment_box, $preview_panel))); 739 + return $comment_view; 864 740 } 865 741 866 742 /**
+87
src/applications/diffusion/editor/DiffusionCommitEditEngine.php
··· 48 48 ->needAuditRequests(true); 49 49 } 50 50 51 + protected function getEditorURI() { 52 + return $this->getApplication()->getApplicationURI('commit/edit/'); 53 + } 54 + 55 + protected function newCommentActionGroups() { 56 + return array( 57 + id(new PhabricatorEditEngineCommentActionGroup()) 58 + ->setKey(self::ACTIONGROUP_AUDIT) 59 + ->setLabel(pht('Audit Actions')), 60 + id(new PhabricatorEditEngineCommentActionGroup()) 61 + ->setKey(self::ACTIONGROUP_COMMIT) 62 + ->setLabel(pht('Commit Actions')), 63 + ); 64 + } 65 + 51 66 protected function getObjectCreateTitleText($object) { 52 67 return pht('Create Commit'); 53 68 } ··· 143 158 return $fields; 144 159 } 145 160 161 + protected function newAutomaticCommentTransactions($object) { 162 + $viewer = $this->getViewer(); 163 + $xactions = array(); 164 + 165 + $inlines = PhabricatorAuditInlineComment::loadDraftComments( 166 + $viewer, 167 + $object->getPHID(), 168 + $raw = true); 169 + $inlines = msort($inlines, 'getID'); 170 + 171 + foreach ($inlines as $inline) { 172 + $xactions[] = $object->getApplicationTransactionTemplate() 173 + ->setTransactionType(PhabricatorAuditActionConstants::INLINE) 174 + ->attachComment($inline); 175 + } 176 + 177 + $viewer_phid = $viewer->getPHID(); 178 + $viewer_is_author = ($object->getAuthorPHID() == $viewer_phid); 179 + if ($viewer_is_author) { 180 + $state_map = PhabricatorTransactions::getInlineStateMap(); 181 + 182 + $inlines = id(new DiffusionDiffInlineCommentQuery()) 183 + ->setViewer($viewer) 184 + ->withCommitPHIDs(array($object->getPHID())) 185 + ->withFixedStates(array_keys($state_map)) 186 + ->execute(); 187 + if ($inlines) { 188 + $old_value = mpull($inlines, 'getFixedState', 'getPHID'); 189 + $new_value = array(); 190 + foreach ($old_value as $key => $state) { 191 + $new_value[$key] = $state_map[$state]; 192 + } 193 + 194 + $xactions[] = $object->getApplicationTransactionTemplate() 195 + ->setTransactionType(PhabricatorTransactions::TYPE_INLINESTATE) 196 + ->setIgnoreOnNoEffect(true) 197 + ->setOldValue($old_value) 198 + ->setNewValue($new_value); 199 + } 200 + } 201 + 202 + return $xactions; 203 + } 204 + 205 + protected function newCommentPreviewContent($object, array $xactions) { 206 + $viewer = $this->getViewer(); 207 + $type_inline = PhabricatorAuditActionConstants::INLINE; 208 + 209 + $inlines = array(); 210 + foreach ($xactions as $xaction) { 211 + if ($xaction->getTransactionType() === $type_inline) { 212 + $inlines[] = $xaction->getComment(); 213 + } 214 + } 215 + 216 + $content = array(); 217 + 218 + if ($inlines) { 219 + $inline_preview = id(new PHUIDiffInlineCommentPreviewListView()) 220 + ->setViewer($viewer) 221 + ->setInlineComments($inlines); 222 + 223 + $content[] = phutil_tag( 224 + 'div', 225 + array( 226 + 'id' => 'inline-comment-preview', 227 + ), 228 + $inline_preview); 229 + } 230 + 231 + return $content; 232 + } 146 233 }
+9 -2
src/infrastructure/diff/view/PHUIDiffInlineCommentPreviewListView.php
··· 38 38 39 39 $inlines = $this->getInlineComments(); 40 40 foreach ($inlines as $key => $inline) { 41 - $inlines[$key] = DifferentialInlineComment::newFromModernComment( 42 - $inline); 41 + // TODO: This is real, real gross. 42 + 43 + if ($inline instanceof DifferentialTransactionComment) { 44 + $inlines[$key] = DifferentialInlineComment::newFromModernComment( 45 + $inline); 46 + } else { 47 + $inlines[$key] = PhabricatorAuditInlineComment::newFromModernComment( 48 + $inline); 49 + } 43 50 } 44 51 45 52 $engine = new PhabricatorMarkupEngine();
-47
webroot/rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js
··· 1 - /** 2 - * @provides javelin-behavior-differential-add-reviewers-and-ccs 3 - * @requires javelin-behavior 4 - * javelin-dom 5 - * phabricator-prefab 6 - */ 7 - 8 - JX.behavior('differential-add-reviewers-and-ccs', function(config) { 9 - 10 - var dynamic = {}; 11 - for (var k in config.dynamic) { 12 - var props = config.dynamic[k]; 13 - props.id = k; 14 - 15 - var tokenizer = JX.Prefab.buildTokenizer(props).tokenizer; 16 - tokenizer.start(); 17 - 18 - dynamic[k] = { 19 - row : JX.$(props.row), 20 - tokenizer : tokenizer, 21 - actions : props.actions, 22 - labels: props.labels 23 - }; 24 - } 25 - 26 - JX.DOM.listen( 27 - JX.$(config.select), 28 - 'change', 29 - null, 30 - function() { 31 - var v = JX.$(config.select).value; 32 - for (var k in dynamic) { 33 - if (dynamic[k].actions[v]) { 34 - JX.DOM.show(dynamic[k].row); 35 - if (dynamic[k].labels) { 36 - var label_node = JX.DOM.find(dynamic[k].row, 'label'); 37 - if (label_node) { 38 - JX.DOM.setContent(label_node, dynamic[k].labels[v]); 39 - } 40 - } 41 - dynamic[k].tokenizer.refresh(); 42 - } else { 43 - JX.DOM.hide(dynamic[k].row); 44 - } 45 - } 46 - }); 47 - });
-16
webroot/rsrc/js/application/differential/behavior-keyboard-nav.js
··· 173 173 refreshFocus(); 174 174 }); 175 175 176 - var haunt_mode = 0; 177 - function haunt() { 178 - haunt_mode = (haunt_mode + 1) % 3; 179 - 180 - var el = JX.$(config.haunt); 181 - for (var ii = 1; ii <= 2; ii++) { 182 - JX.DOM.alterClass(el, 'differential-haunt-mode-'+ii, (haunt_mode == ii)); 183 - } 184 - } 185 - 186 176 new JX.KeyboardShortcut('j', 'Jump to next change.') 187 177 .setHandler(function(manager) { 188 178 jump(manager, 1); ··· 270 260 inline_op(selection_begin, 'edit'); 271 261 }) 272 262 .register(); 273 - 274 - if (config.haunt) { 275 - new JX.KeyboardShortcut('z', 'Cycle comment panel haunting modes.') 276 - .setHandler(haunt) 277 - .register(); 278 - } 279 263 280 264 });