From 0b4ed94cc6ad6ff58d058f43ccce8259174fed18 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 23 Jan 2016 12:17:51 -0800 Subject: [PATCH] Fix text for Passphrase credential destruction transaction when restoring credentials Summary: Fixes T10211. This transaction can either be setting or removing the "destroyed" flag, but we show "destroyed" in both cases. Instead, if the transaction is clearing the flag, render "restored". Test Plan: {F1068142} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10211 Differential Revision: https://secure.phabricator.com/D15096 --- .../PassphraseCredentialTransaction.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/applications/passphrase/storage/PassphraseCredentialTransaction.php b/src/applications/passphrase/storage/PassphraseCredentialTransaction.php index 0615bd9e90..e0c90fcdb9 100644 --- a/src/applications/passphrase/storage/PassphraseCredentialTransaction.php +++ b/src/applications/passphrase/storage/PassphraseCredentialTransaction.php @@ -26,6 +26,7 @@ final class PassphraseCredentialTransaction public function shouldHide() { $old = $this->getOldValue(); + $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: return ($old === null); @@ -35,6 +36,12 @@ final class PassphraseCredentialTransaction return !strlen($old); case self::TYPE_LOOKEDATSECRET: return false; + case self::TYPE_DESTROY: + // Don't show "undestroy" transactions because they're a bit confusing + // and redundant with restoring a secret. + if (!$new) { + return true; + } } return parent::shouldHide(); } @@ -77,12 +84,18 @@ final class PassphraseCredentialTransaction } break; case self::TYPE_SECRET_ID: - return pht( - '%s updated the secret for this credential.', - $this->renderHandleLink($author_phid)); + if ($old === null) { + return pht( + '%s attached a new secret to this credential.', + $this->renderHandleLink($author_phid)); + } else { + return pht( + '%s updated the secret for this credential.', + $this->renderHandleLink($author_phid)); + } case self::TYPE_DESTROY: return pht( - '%s destroyed this credential.', + '%s destroyed the secret for this credential.', $this->renderHandleLink($author_phid)); case self::TYPE_LOOKEDATSECRET: return pht(