mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-30 00:18:21 +01:00
Allow CustomField to provide ApplicationTransaction change details
Summary: Ref T3886. Ref T418. For fields like "Summary" and "Test Plan" where changes can't be summarized in one line, allow CustomField to provide a "(Show Details)" link and render a diff. Also consolidate some of the existing copy/paste, and simplify this featuer slightly now that we've move to dialogs. Test Plan: {F115918} - Viewed "description"-style field changes in phlux, pholio, legalpad, maniphest, differential, ponder (questions), ponder (answers), and repositories. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3886, T418 Differential Revision: https://secure.phabricator.com/D8284
This commit is contained in:
parent
be262f4b0c
commit
88227d26bc
16 changed files with 140 additions and 128 deletions
|
@ -407,7 +407,7 @@ return array(
|
||||||
'rsrc/js/application/search/behavior-reorder-queries.js' => '34397f68',
|
'rsrc/js/application/search/behavior-reorder-queries.js' => '34397f68',
|
||||||
'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'a51fdb2e',
|
'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'a51fdb2e',
|
||||||
'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9084a36f',
|
'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9084a36f',
|
||||||
'rsrc/js/application/transactions/behavior-transaction-list.js' => 'bfb45968',
|
'rsrc/js/application/transactions/behavior-transaction-list.js' => '3c918aa8',
|
||||||
'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807',
|
'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807',
|
||||||
'rsrc/js/application/uiexample/ReactorButtonExample.js' => '44524435',
|
'rsrc/js/application/uiexample/ReactorButtonExample.js' => '44524435',
|
||||||
'rsrc/js/application/uiexample/ReactorCheckboxExample.js' => '7ba325ee',
|
'rsrc/js/application/uiexample/ReactorCheckboxExample.js' => '7ba325ee',
|
||||||
|
@ -598,7 +598,7 @@ return array(
|
||||||
'javelin-behavior-phabricator-show-all-transactions' => '7c273581',
|
'javelin-behavior-phabricator-show-all-transactions' => '7c273581',
|
||||||
'javelin-behavior-phabricator-tooltips' => 'e5dd1c6d',
|
'javelin-behavior-phabricator-tooltips' => 'e5dd1c6d',
|
||||||
'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f',
|
'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f',
|
||||||
'javelin-behavior-phabricator-transaction-list' => 'bfb45968',
|
'javelin-behavior-phabricator-transaction-list' => '3c918aa8',
|
||||||
'javelin-behavior-phabricator-watch-anchor' => '06e05112',
|
'javelin-behavior-phabricator-watch-anchor' => '06e05112',
|
||||||
'javelin-behavior-phame-post-preview' => '61d927ec',
|
'javelin-behavior-phame-post-preview' => '61d927ec',
|
||||||
'javelin-behavior-pholio-mock-edit' => '1e1e8bb0',
|
'javelin-behavior-pholio-mock-edit' => '1e1e8bb0',
|
||||||
|
@ -1057,6 +1057,14 @@ return array(
|
||||||
2 => 'javelin-util',
|
2 => 'javelin-util',
|
||||||
3 => 'javelin-request',
|
3 => 'javelin-request',
|
||||||
),
|
),
|
||||||
|
'3c918aa8' =>
|
||||||
|
array(
|
||||||
|
0 => 'javelin-behavior',
|
||||||
|
1 => 'javelin-stratcom',
|
||||||
|
2 => 'javelin-workflow',
|
||||||
|
3 => 'javelin-dom',
|
||||||
|
4 => 'javelin-fx',
|
||||||
|
),
|
||||||
'403a3dce' =>
|
'403a3dce' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-install',
|
0 => 'javelin-install',
|
||||||
|
@ -1592,14 +1600,6 @@ return array(
|
||||||
1 => 'javelin-dom',
|
1 => 'javelin-dom',
|
||||||
2 => 'javelin-reactor-dom',
|
2 => 'javelin-reactor-dom',
|
||||||
),
|
),
|
||||||
'bfb45968' =>
|
|
||||||
array(
|
|
||||||
0 => 'javelin-behavior',
|
|
||||||
1 => 'javelin-stratcom',
|
|
||||||
2 => 'javelin-workflow',
|
|
||||||
3 => 'javelin-dom',
|
|
||||||
4 => 'javelin-fx',
|
|
||||||
),
|
|
||||||
'c01153ea' =>
|
'c01153ea' =>
|
||||||
array(
|
array(
|
||||||
0 => 'javelin-behavior',
|
0 => 'javelin-behavior',
|
||||||
|
|
|
@ -89,12 +89,10 @@ final class PhabricatorConfigTransaction
|
||||||
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
|
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
return $this->renderTextCorpusChangeDetails(
|
||||||
->setUser($viewer)
|
$viewer,
|
||||||
->setOldText($old_text)
|
$old_text,
|
||||||
->setNewText($new_text);
|
$new_text);
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor() {
|
public function getColor() {
|
||||||
|
|
|
@ -64,6 +64,18 @@ final class DifferentialSummaryField
|
||||||
$xaction->renderHandleLink($object_phid));
|
$xaction->renderHandleLink($object_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Support hasChangeDetails() in CustomFields.
|
public function getApplicationTransactionHasChangeDetails(
|
||||||
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationTransactionChangeDetails(
|
||||||
|
PhabricatorApplicationTransaction $xaction,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
return $xaction->renderTextCorpusChangeDetails(
|
||||||
|
$viewer,
|
||||||
|
$xaction->getOldValue(),
|
||||||
|
$xaction->getNewValue());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,15 +68,10 @@ final class LegalpadTransaction extends PhabricatorApplicationTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
$this->getOldValue(),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
$this->getNewValue());
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,17 +631,10 @@ final class ManiphestTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
$this->getOldValue(),
|
||||||
require_celerity_resource('differential-changeset-view-css');
|
$this->getNewValue());
|
||||||
|
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMailTags() {
|
public function getMailTags() {
|
||||||
|
|
|
@ -91,15 +91,10 @@ final class PassphraseCredentialTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
json_encode($this->getOldValue()),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
json_encode($this->getNewValue()));
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText(json_encode($old))
|
|
||||||
->setNewText(json_encode($new));
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,10 @@ final class PhluxTransaction extends PhabricatorApplicationTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
json_encode($this->getOldValue()),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
json_encode($this->getNewValue()));
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText(json_encode($old))
|
|
||||||
->setNewText(json_encode($new));
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -283,12 +283,10 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
||||||
$new = reset($new);
|
$new = reset($new);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
return $this->renderTextCorpusChangeDetails(
|
||||||
->setUser($viewer)
|
$viewer,
|
||||||
->setOldText($old)
|
$old,
|
||||||
->setNewText($new);
|
$new);
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor() {
|
public function getColor() {
|
||||||
|
|
|
@ -95,15 +95,10 @@ final class PonderAnswerTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
$this->getOldValue(),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
$this->getNewValue());
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,15 +135,10 @@ final class PonderQuestionTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
$this->getOldValue(),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
$this->getNewValue());
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActionStrength() {
|
public function getActionStrength() {
|
||||||
|
|
|
@ -381,15 +381,10 @@ final class PhabricatorRepositoryTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails(
|
||||||
$new = $this->getNewValue();
|
$viewer,
|
||||||
|
$this->getOldValue(),
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
$this->getNewValue());
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,15 +119,7 @@ final class PhabricatorSlowvoteTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
$old = $this->getOldValue();
|
return $this->renderTextCorpusChangeDetails($viewer);
|
||||||
$new = $this->getNewValue();
|
|
||||||
|
|
||||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->setOldText($old)
|
|
||||||
->setNewText($new);
|
|
||||||
|
|
||||||
return $view->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -250,6 +250,29 @@ abstract class PhabricatorApplicationTransaction
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTransactionCustomField() {
|
||||||
|
switch ($this->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
|
$key = $this->getMetadataValue('customfield:key');
|
||||||
|
if (!$key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$field = PhabricatorCustomField::getObjectField(
|
||||||
|
$this->getObject(),
|
||||||
|
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
||||||
|
$key);
|
||||||
|
if (!$field) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$field->setViewer($this->getViewer());
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function shouldHide() {
|
public function shouldHide() {
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
|
@ -396,13 +419,8 @@ abstract class PhabricatorApplicationTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
$key = $this->getMetadataValue('customfield:key');
|
$field = $this->getTransactionCustomField();
|
||||||
$field = PhabricatorCustomField::getObjectField(
|
|
||||||
$this->getObject(),
|
|
||||||
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
|
||||||
$key);
|
|
||||||
if ($field) {
|
if ($field) {
|
||||||
$field->setViewer($this->getViewer());
|
|
||||||
return $field->getApplicationTransactionTitle($this);
|
return $field->getApplicationTransactionTitle($this);
|
||||||
} else {
|
} else {
|
||||||
return pht(
|
return pht(
|
||||||
|
@ -460,13 +478,8 @@ abstract class PhabricatorApplicationTransaction
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
$this->renderHandleLink($object_phid));
|
$this->renderHandleLink($object_phid));
|
||||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
$key = $this->getMetadataValue('customfield:key');
|
$field = $this->getTransactionCustomField();
|
||||||
$field = PhabricatorCustomField::getObjectField(
|
|
||||||
$this->getObject(),
|
|
||||||
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
|
||||||
$key);
|
|
||||||
if ($field) {
|
if ($field) {
|
||||||
$field->setViewer($this->getViewer());
|
|
||||||
return $field->getApplicationTransactionTitleForFeed($this, $story);
|
return $field->getApplicationTransactionTitleForFeed($this, $story);
|
||||||
} else {
|
} else {
|
||||||
return pht(
|
return pht(
|
||||||
|
@ -524,11 +537,43 @@ abstract class PhabricatorApplicationTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasChangeDetails() {
|
public function hasChangeDetails() {
|
||||||
|
switch ($this->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
|
$field = $this->getTransactionCustomField();
|
||||||
|
if ($field) {
|
||||||
|
return $field->getApplicationTransactionHasChangeDetails($this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||||
return null;
|
switch ($this->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||||
|
$field = $this->getTransactionCustomField();
|
||||||
|
if ($field) {
|
||||||
|
return $field->getApplicationTransactionChangeDetails($this, $viewer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderTextCorpusChangeDetails();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderTextCorpusChangeDetails(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
$old,
|
||||||
|
$new) {
|
||||||
|
|
||||||
|
require_celerity_resource('differential-changeset-view-css');
|
||||||
|
|
||||||
|
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setOldText($old)
|
||||||
|
->setNewText($new);
|
||||||
|
|
||||||
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachTransactionGroup(array $group) {
|
public function attachTransactionGroup(array $group) {
|
||||||
|
|
|
@ -175,11 +175,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => '/transactions/detail/'.$xaction->getPHID().'/',
|
'href' => '/transactions/detail/'.$xaction->getPHID().'/',
|
||||||
'sigil' => 'transaction-detail',
|
'sigil' => 'workflow',
|
||||||
'mustcapture' => true,
|
|
||||||
'meta' => array(
|
|
||||||
'anchor' => $this->anchorOffset,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
pht('(Show Details)'));
|
pht('(Show Details)'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -904,6 +904,27 @@ abstract class PhabricatorCustomField {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getApplicationTransactionHasChangeDetails(
|
||||||
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
if ($this->proxy) {
|
||||||
|
return $this->proxy->getApplicationTransactionHasChangeDetails(
|
||||||
|
$xaction);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApplicationTransactionChangeDetails(
|
||||||
|
PhabricatorApplicationTransaction $xaction,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
if ($this->proxy) {
|
||||||
|
return $this->proxy->getApplicationTransactionChangeDetails(
|
||||||
|
$xaction,
|
||||||
|
$viewer);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Edit View )---------------------------------------------------------- */
|
/* -( Edit View )---------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,19 +75,6 @@ JX.behavior('phabricator-transaction-list', function(config) {
|
||||||
e.kill();
|
e.kill();
|
||||||
});
|
});
|
||||||
|
|
||||||
JX.DOM.listen(list, 'click', 'transaction-detail', function(e) {
|
|
||||||
if (!e.isNormalClick()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JX.Workflow.newFromLink(e.getTarget())
|
|
||||||
.setData({anchor: e.getData('anchor')})
|
|
||||||
.setHandler(ontransactions)
|
|
||||||
.start();
|
|
||||||
|
|
||||||
e.kill();
|
|
||||||
});
|
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
JX.Stratcom.listen(
|
||||||
['submit', 'didSyntheticSubmit'],
|
['submit', 'didSyntheticSubmit'],
|
||||||
'transaction-append',
|
'transaction-append',
|
||||||
|
|
Loading…
Add table
Reference in a new issue