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

Clean up some rough Macro transaction edges

Summary: Ref T12685, cleans up various macro issues, remove subscribers, fix feed stories, etc.

Test Plan: Create a new macro, see no subscribers, edit various macros.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12685

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

+50 -21
+21 -2
src/applications/macro/editor/PhabricatorMacroEditEngine.php
··· 21 21 return 'PhabricatorMacroApplication'; 22 22 } 23 23 24 + public function isEngineConfigurable() { 25 + return false; 26 + } 27 + 24 28 protected function newEditableObject() { 25 29 $viewer = $this->getViewer(); 26 30 return PhabricatorFileImageMacro::initializeNewFileImageMacro($viewer); ··· 35 39 } 36 40 37 41 protected function getObjectEditTitleText($object) { 38 - return pht('Edit %s', $object->getName()); 42 + return pht('Edit Macro %s', $object->getName()); 39 43 } 40 44 41 45 protected function getObjectEditShortText($object) { ··· 63 67 PhabricatorMacroManageCapability::CAPABILITY); 64 68 } 65 69 70 + protected function willConfigureFields($object, array $fields) { 71 + if ($this->getIsCreate()) { 72 + $subscribers_field = idx($fields, 73 + PhabricatorSubscriptionsEditEngineExtension::FIELDKEY); 74 + if ($subscribers_field) { 75 + // By default, hide the subscribers field when creating a macro 76 + // because it makes the workflow SO HARD and wastes SO MUCH TIME. 77 + $subscribers_field->setIsHidden(true); 78 + } 79 + } 80 + return $fields; 81 + } 82 + 66 83 protected function buildCustomEditFields($object) { 67 84 68 85 return array( ··· 73 90 ->setConduitDescription(pht('Rename the macro.')) 74 91 ->setConduitTypeDescription(pht('New macro name.')) 75 92 ->setTransactionType(PhabricatorMacroNameTransaction::TRANSACTIONTYPE) 93 + ->setIsRequired(true) 76 94 ->setValue($object->getName()), 77 95 id(new PhabricatorFileEditField()) 78 96 ->setKey('filePHID') ··· 80 98 ->setDescription(pht('Image file to import.')) 81 99 ->setTransactionType(PhabricatorMacroFileTransaction::TRANSACTIONTYPE) 82 100 ->setConduitDescription(pht('File PHID to import.')) 83 - ->setConduitTypeDescription(pht('File PHID.')), 101 + ->setConduitTypeDescription(pht('File PHID.')) 102 + ->setValue($object->getFilePHID()), 84 103 ); 85 104 86 105 }
+25 -17
src/applications/macro/xaction/PhabricatorMacroFileTransaction.php
··· 49 49 50 50 public function getTitleForFeed() { 51 51 return pht( 52 - '%s changed the image for macro %s.', 52 + '%s changed the image for %s.', 53 53 $this->renderAuthor(), 54 54 $this->renderObject()); 55 55 } ··· 58 58 $errors = array(); 59 59 $viewer = $this->getActor(); 60 60 61 + $old_phid = $object->getFilePHID(); 62 + 61 63 foreach ($xactions as $xaction) { 62 64 $file_phid = $xaction->getNewValue(); 63 65 64 - if ($this->isEmptyTextTransaction($file_phid, $xactions)) { 65 - $errors[] = $this->newRequiredError( 66 - pht('Image macros must have a file.')); 66 + if (!$old_phid) { 67 + if ($this->isEmptyTextTransaction($file_phid, $xactions)) { 68 + $errors[] = $this->newRequiredError( 69 + pht('Image macros must have a file.')); 70 + return $errors; 71 + } 67 72 } 68 73 69 - $file = id(new PhabricatorFileQuery()) 70 - ->setViewer($viewer) 71 - ->withPHIDs(array($file_phid)) 72 - ->executeOne(); 74 + // Only validate if file was uploaded 75 + if ($file_phid) { 76 + $file = id(new PhabricatorFileQuery()) 77 + ->setViewer($viewer) 78 + ->withPHIDs(array($file_phid)) 79 + ->executeOne(); 73 80 74 - if (!$file) { 75 - $errors[] = $this->newInvalidError( 76 - pht('"%s" is not a valid file PHID.', 77 - $file_phid)); 78 - } else { 79 - if (!$file->isViewableInBrowser()) { 80 - $mime_type = $file->getMimeType(); 81 + if (!$file) { 81 82 $errors[] = $this->newInvalidError( 82 - pht('File mime type of "%s" is not a valid viewable image.', 83 - $mime_type)); 83 + pht('"%s" is not a valid file PHID.', 84 + $file_phid)); 85 + } else { 86 + if (!$file->isViewableImage()) { 87 + $mime_type = $file->getMimeType(); 88 + $errors[] = $this->newInvalidError( 89 + pht('File mime type of "%s" is not a valid viewable image.', 90 + $mime_type)); 91 + } 84 92 } 85 93 } 86 94
+2 -1
src/applications/macro/xaction/PhabricatorMacroNameTransaction.php
··· 23 23 24 24 public function getTitleForFeed() { 25 25 return pht( 26 - '%s renamed %s macro %s to %s.', 26 + '%s renamed %s from %s to %s.', 27 27 $this->renderAuthor(), 28 28 $this->renderObject(), 29 29 $this->renderOldValue(), ··· 37 37 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { 38 38 $errors[] = $this->newRequiredError( 39 39 pht('Macros must have a name.')); 40 + return $errors; 40 41 } 41 42 42 43 $max_length = $object->getColumnMaximumByteLength('name');
+2 -1
src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php
··· 4 4 extends PhabricatorEditEngineExtension { 5 5 6 6 const EXTENSIONKEY = 'subscriptions.subscribers'; 7 + const FIELDKEY = 'subscriberPHIDs'; 7 8 8 9 const EDITKEY_ADD = 'subscribers.add'; 9 10 const EDITKEY_SET = 'subscribers.set'; ··· 42 43 } 43 44 44 45 $subscribers_field = id(new PhabricatorSubscribersEditField()) 45 - ->setKey('subscriberPHIDs') 46 + ->setKey(self::FIELDKEY) 46 47 ->setLabel(pht('Subscribers')) 47 48 ->setEditTypeKey('subscribers') 48 49 ->setAliases(array('subscriber', 'subscribers'))