@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.

Improve feed stories for Maniphest and some more translations

Summary: Ref T2217. Render feed stories like "alincoln updated T123" instead of "alincoln updated this task.". Fix up some more translations.

Test Plan: Looked at feed, saw something a bit more reasonable.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

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

+297 -4
+192
src/applications/maniphest/storage/ManiphestTransaction.php
··· 394 394 return parent::getTitle(); 395 395 } 396 396 397 + public function getTitleForFeed(PhabricatorFeedStory $story) { 398 + $author_phid = $this->getAuthorPHID(); 399 + $object_phid = $this->getObjectPHID(); 400 + 401 + $old = $this->getOldValue(); 402 + $new = $this->getNewValue(); 403 + 404 + switch ($this->getTransactionType()) { 405 + case self::TYPE_TITLE: 406 + return pht( 407 + '%s renamed %s from "%s" to "%s".', 408 + $this->renderHandleLink($author_phid), 409 + $this->renderHandleLink($object_phid), 410 + $old, 411 + $new); 412 + 413 + case self::TYPE_DESCRIPTION: 414 + return pht( 415 + '%s edited the description of %s.', 416 + $this->renderHandleLink($author_phid), 417 + $this->renderHandleLink($object_phid)); 418 + 419 + case self::TYPE_STATUS: 420 + if ($new == ManiphestTaskStatus::STATUS_OPEN) { 421 + if ($old) { 422 + return pht( 423 + '%s reopened %s.', 424 + $this->renderHandleLink($author_phid), 425 + $this->renderHandleLink($object_phid)); 426 + } else { 427 + return pht( 428 + '%s created %s.', 429 + $this->renderHandleLink($author_phid), 430 + $this->renderHandleLink($object_phid)); 431 + } 432 + } else { 433 + switch ($new) { 434 + case ManiphestTaskStatus::STATUS_CLOSED_SPITE: 435 + return pht( 436 + '%s closed %s out of spite.', 437 + $this->renderHandleLink($author_phid), 438 + $this->renderHandleLink($object_phid)); 439 + case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: 440 + return pht( 441 + '%s closed %s as a duplicate.', 442 + $this->renderHandleLink($author_phid), 443 + $this->renderHandleLink($object_phid)); 444 + default: 445 + $status_name = idx( 446 + ManiphestTaskStatus::getTaskStatusMap(), 447 + $new, 448 + '???'); 449 + return pht( 450 + '%s closed %s as "%s".', 451 + $this->renderHandleLink($author_phid), 452 + $this->renderHandleLink($object_phid), 453 + $status_name); 454 + } 455 + } 456 + 457 + case self::TYPE_OWNER: 458 + if ($author_phid == $new) { 459 + return pht( 460 + '%s claimed %s.', 461 + $this->renderHandleLink($author_phid), 462 + $this->renderHandleLink($object_phid)); 463 + } else if (!$new) { 464 + return pht( 465 + '%s placed %s up for grabs.', 466 + $this->renderHandleLink($author_phid), 467 + $this->renderHandleLink($object_phid)); 468 + } else if (!$old) { 469 + return pht( 470 + '%s assigned %s to %s.', 471 + $this->renderHandleLink($author_phid), 472 + $this->renderHandleLink($object_phid), 473 + $this->renderHandleLink($new)); 474 + } else { 475 + return pht( 476 + '%s reassigned %s from %s to %s.', 477 + $this->renderHandleLink($author_phid), 478 + $this->renderHandleLink($object_phid), 479 + $this->renderHandleLink($old), 480 + $this->renderHandleLink($new)); 481 + } 482 + 483 + case self::TYPE_PROJECTS: 484 + $added = array_diff($new, $old); 485 + $removed = array_diff($old, $new); 486 + if ($added && !$removed) { 487 + return pht( 488 + '%s added %d project(s) to %s: %s', 489 + $this->renderHandleLink($author_phid), 490 + count($added), 491 + $this->renderHandleLink($object_phid), 492 + $this->renderHandleList($added)); 493 + } else if ($removed && !$added) { 494 + return pht( 495 + '%s removed %d project(s) to %s: %s', 496 + $this->renderHandleLink($author_phid), 497 + count($removed), 498 + $this->renderHandleLink($object_phid), 499 + $this->renderHandleList($removed)); 500 + } else if ($removed && $added) { 501 + return pht( 502 + '%s changed project(s) of %s, added %d: %s; removed %d: %s', 503 + $this->renderHandleLink($author_phid), 504 + $this->renderHandleLink($object_phid), 505 + count($added), 506 + $this->renderHandleList($added), 507 + count($removed), 508 + $this->renderHandleList($removed)); 509 + } 510 + 511 + case self::TYPE_PRIORITY: 512 + $old_name = ManiphestTaskPriority::getTaskPriorityName($old); 513 + $new_name = ManiphestTaskPriority::getTaskPriorityName($new); 514 + 515 + if ($old == ManiphestTaskPriority::getDefaultPriority()) { 516 + return pht( 517 + '%s triaged %s as "%s" priority.', 518 + $this->renderHandleLink($author_phid), 519 + $this->renderHandleLink($object_phid), 520 + $new_name); 521 + } else if ($old > $new) { 522 + return pht( 523 + '%s lowered the priority of %s from "%s" to "%s".', 524 + $this->renderHandleLink($author_phid), 525 + $this->renderHandleLink($object_phid), 526 + $old_name, 527 + $new_name); 528 + } else { 529 + return pht( 530 + '%s raised the priority of %s from "%s" to "%s".', 531 + $this->renderHandleLink($author_phid), 532 + $this->renderHandleLink($object_phid), 533 + $old_name, 534 + $new_name); 535 + } 536 + 537 + case self::TYPE_CCS: 538 + // TODO: Remove this when we switch to subscribers. Just reuse the 539 + // code in the parent. 540 + $clone = clone $this; 541 + $clone->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS); 542 + return $clone->getTitleForFeed($story); 543 + 544 + case self::TYPE_EDGE: 545 + // TODO: Remove this when we switch to real edges. Just reuse the 546 + // code in the parent; 547 + $clone = clone $this; 548 + $clone->setTransactionType(PhabricatorTransactions::TYPE_EDGE); 549 + return $clone->getTitleForFeed($story); 550 + 551 + case self::TYPE_ATTACH: 552 + $old = nonempty($old, array()); 553 + $new = nonempty($new, array()); 554 + $new = array_keys(idx($new, 'FILE', array())); 555 + $old = array_keys(idx($old, 'FILE', array())); 556 + 557 + $added = array_diff($new, $old); 558 + $removed = array_diff($old, $new); 559 + if ($added && !$removed) { 560 + return pht( 561 + '%s attached %d file(s) of %s: %s', 562 + $this->renderHandleLink($author_phid), 563 + $this->renderHandleLink($object_phid), 564 + count($added), 565 + $this->renderHandleList($added)); 566 + } else if ($removed && !$added) { 567 + return pht( 568 + '%s detached %d file(s) of %s: %s', 569 + $this->renderHandleLink($author_phid), 570 + $this->renderHandleLink($object_phid), 571 + count($removed), 572 + $this->renderHandleList($removed)); 573 + } else { 574 + return pht( 575 + '%s changed file(s) for %s, attached %d: %s; detached %d: %s', 576 + $this->renderHandleLink($author_phid), 577 + $this->renderHandleLink($object_phid), 578 + count($added), 579 + $this->renderHandleList($added), 580 + count($removed), 581 + $this->renderHandleList($removed)); 582 + } 583 + 584 + } 585 + 586 + return parent::getTitleForFeed($story); 587 + } 588 + 397 589 public function hasChangeDetails() { 398 590 switch ($this->getTransactionType()) { 399 591 case self::TYPE_DESCRIPTION:
+19
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 425 425 $string, 426 426 $this->renderHandleLink($author_phid), 427 427 $this->renderHandleLink($object_phid)); 428 + case PhabricatorTransactions::TYPE_CUSTOMFIELD: 429 + $key = $this->getMetadataValue('customfield:key'); 430 + $field = PhabricatorCustomField::getObjectField( 431 + // TODO: This is a giant hack, but we currently don't have a way to 432 + // get the contextual object and this pathway is only hit by 433 + // Maniphest. We should provide a way to get the actual object here. 434 + new ManiphestTask(), 435 + PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, 436 + $key); 437 + if ($field) { 438 + $field->setViewer($this->getViewer()); 439 + return $field->getApplicationTransactionTitleForFeed($this, $story); 440 + } else { 441 + return pht( 442 + '%s edited a custom field on %s.', 443 + $this->renderHandleLink($author_phid), 444 + $this->renderHandleLink($object_phid)); 445 + } 446 + 428 447 } 429 448 430 449 return $this->getTitle();
+17
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 886 886 $xaction->renderHandleLink($author_phid)); 887 887 } 888 888 889 + public function getApplicationTransactionTitleForFeed( 890 + PhabricatorApplicationTransaction $xaction, 891 + PhabricatorFeedStory $story) { 892 + if ($this->proxy) { 893 + return $this->proxy->getApplicationTransactionTitleForFeed( 894 + $xaction, 895 + $story); 896 + } 897 + 898 + $author_phid = $xaction->getAuthorPHID(); 899 + $object_phid = $xaction->getObjectPHID(); 900 + return pht( 901 + '%s updated %s.', 902 + $xaction->renderHandleLink($author_phid), 903 + $xaction->renderHandleLink($object_phid)); 904 + } 905 + 889 906 890 907 /* -( Edit View )---------------------------------------------------------- */ 891 908
+34
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
··· 333 333 } 334 334 } 335 335 336 + public function getApplicationTransactionTitleForFeed( 337 + PhabricatorApplicationTransaction $xaction, 338 + PhabricatorFeedStory $story) { 339 + 340 + $author_phid = $xaction->getAuthorPHID(); 341 + $object_phid = $xaction->getObjectPHID(); 342 + 343 + $old = $xaction->getOldValue(); 344 + $new = $xaction->getNewValue(); 345 + 346 + if (!$old) { 347 + return pht( 348 + '%s set %s to %s on %s.', 349 + $xaction->renderHandleLink($author_phid), 350 + $this->getFieldName(), 351 + $new, 352 + $xaction->renderHandleLink($object_phid)); 353 + } else if (!$new) { 354 + return pht( 355 + '%s removed %s on %s.', 356 + $xaction->renderHandleLink($author_phid), 357 + $this->getFieldName(), 358 + $xaction->renderHandleLink($object_phid)); 359 + } else { 360 + return pht( 361 + '%s changed %s from %s to %s on %s.', 362 + $xaction->renderHandleLink($author_phid), 363 + $this->getFieldName(), 364 + $old, 365 + $new, 366 + $xaction->renderHandleLink($object_phid)); 367 + } 368 + } 369 + 336 370 337 371 }
+35 -4
src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
··· 684 684 685 685 '%s added %d project(s): %s' => array( 686 686 array( 687 - '%s added a project: %2$s', 688 - '%s added projects: %2$s', 687 + '%s added a project: %3$s', 688 + '%s added projects: %3$s', 689 689 ), 690 690 ), 691 691 692 692 '%s removed %d project(s): %s' => array( 693 693 array( 694 - '%s removed a project: %2$s', 695 - '%s removed projects: %2$s', 694 + '%s removed a project: %3$s', 695 + '%s removed projects: %3$s', 696 696 ), 697 697 ), 698 698 ··· 744 744 '%s removed dependent tasks: %3$s.', 745 745 ), 746 746 ), 747 + 748 + '%s added %d revision(s): %s.' => array( 749 + array( 750 + '%s added a revision: %3$s.', 751 + '%s added revisions: %3$s.', 752 + ), 753 + ), 754 + 755 + '%s removed %d revision(s): %s.' => array( 756 + array( 757 + '%s removed a revision: %3$s.', 758 + '%s removed revisions: %3$s.', 759 + ), 760 + ), 761 + 762 + '%s added %d commit(s): %s.' => array( 763 + array( 764 + '%s added a commit: %3$s.', 765 + '%s added commits: %3$s.', 766 + ), 767 + ), 768 + 769 + '%s removed %d commit(s): %s.' => array( 770 + array( 771 + '%s removed a commit: %3$s.', 772 + '%s removed commits: %3$s.', 773 + ), 774 + ), 775 + 776 + '%s edited commit(s), added %d: %s; removed %d: %s.' => 777 + '%s edited commits, added %3$s; removed %5$s.', 747 778 748 779 ); 749 780 }