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

Phriction - move delete to modern editor + transactions

Summary:
Ref T4029. Much like D10756 this does the bare minimum to get things in there. I have a sticky with "TODOs" about moving the error-checking business logic into the editor in both cases.

Up next - move actions...

Test Plan: deleted a document and it worked! verified proper feed story.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: shadowhand, Korvin, epriestley

Maniphest Tasks: T4029

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

+57 -12
+13 -3
src/applications/phriction/controller/PhrictionDeleteController.php
··· 15 15 $document = id(new PhrictionDocumentQuery()) 16 16 ->setViewer($user) 17 17 ->withIDs(array($this->id)) 18 + ->needContent(true) 18 19 ->requireCapabilities( 19 20 array( 20 21 PhabricatorPolicyCapability::CAN_EDIT, ··· 32 33 PhrictionDocumentStatus::STATUS_STUB => true, // How could they? 33 34 ); 34 35 if (isset($disallowed_states[$document->getStatus()])) { 35 - $e_text = pht('An already moved or deleted document can not be deleted'); 36 + $e_text = pht( 37 + 'An already moved or deleted document can not be deleted.'); 36 38 } 37 39 38 40 $document_uri = PhrictionDocument::getSlugURI($document->getSlug()); 39 41 40 42 if (!$e_text && $request->isFormPost()) { 41 - $editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug())) 43 + $xactions = array(); 44 + $xactions[] = id(new PhrictionTransaction()) 45 + ->setTransactionType(PhrictionTransaction::TYPE_DELETE) 46 + ->setNewValue(true); 47 + 48 + $editor = id(new PhrictionTransactionEditor()) 42 49 ->setActor($user) 43 - ->delete(); 50 + ->setContentSourceFromRequest($request) 51 + ->setContinueOnNoEffect(true) 52 + ->applyTransactions($document, $xactions); 53 + 44 54 return id(new AphrontRedirectResponse())->setURI($document_uri); 45 55 } 46 56
+19 -8
src/applications/phriction/editor/PhrictionTransactionEditor.php
··· 48 48 $types[] = PhabricatorTransactions::TYPE_COMMENT; 49 49 $types[] = PhrictionTransaction::TYPE_TITLE; 50 50 $types[] = PhrictionTransaction::TYPE_CONTENT; 51 + $types[] = PhrictionTransaction::TYPE_DELETE; 51 52 52 53 /* TODO 53 54 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; ··· 72 73 return null; 73 74 } 74 75 return $this->getOldContent()->getContent(); 76 + case PhrictionTransaction::TYPE_DELETE: 77 + return null; 75 78 } 76 79 } 77 80 ··· 82 85 switch ($xaction->getTransactionType()) { 83 86 case PhrictionTransaction::TYPE_TITLE: 84 87 case PhrictionTransaction::TYPE_CONTENT: 88 + case PhrictionTransaction::TYPE_DELETE: 85 89 return $xaction->getNewValue(); 86 90 } 87 91 } ··· 94 98 switch ($xaction->getTransactionType()) { 95 99 case PhrictionTransaction::TYPE_TITLE: 96 100 case PhrictionTransaction::TYPE_CONTENT: 101 + case PhrictionTransaction::TYPE_DELETE: 97 102 return true; 98 103 } 99 104 } ··· 131 136 case PhrictionTransaction::TYPE_CONTENT: 132 137 $this->getNewContent()->setContent($xaction->getNewValue()); 133 138 break; 139 + case PhrictionTransaction::TYPE_DELETE: 140 + $this->getNewContent()->setContent(''); 141 + $this->getNewContent()->setChangeType( 142 + PhrictionChangeType::CHANGE_DELETE); 143 + break; 134 144 default: 135 145 break; 136 146 } ··· 145 155 switch ($xaction->getTransactionType()) { 146 156 case PhrictionTransaction::TYPE_TITLE: 147 157 case PhrictionTransaction::TYPE_CONTENT: 158 + case PhrictionTransaction::TYPE_DELETE: 148 159 $save_content = true; 149 160 break; 150 161 default: ··· 213 224 pht("A document's title changes."), 214 225 PhrictionTransaction::MAILTAG_CONTENT => 215 226 pht("A document's content changes."), 227 + PhrictionTransaction::MAILTAG_DELETE => 228 + pht('A document is deleted.'), 216 229 ); 217 230 } 218 231 ··· 279 292 private function buildNewContentTemplate( 280 293 PhrictionDocument $document) { 281 294 282 - $new_content = new PhrictionContent(); 283 - $new_content->setSlug($document->getSlug()); 284 - $new_content->setAuthorPHID($this->getActor()->getPHID()); 285 - $new_content->setChangeType(PhrictionChangeType::CHANGE_EDIT); 286 - 287 - $new_content->setTitle($this->getOldContent()->getTitle()); 288 - $new_content->setContent($this->getOldContent()->getContent()); 289 - 295 + $new_content = id(new PhrictionContent()) 296 + ->setSlug($document->getSlug()) 297 + ->setAuthorPHID($this->getActor()->getPHID()) 298 + ->setChangeType(PhrictionChangeType::CHANGE_EDIT) 299 + ->setTitle($this->getOldContent()->getTitle()) 300 + ->setContent($this->getOldContent()->getContent()); 290 301 if (strlen($this->getDescription())) { 291 302 $new_content->setDescription($this->getDescription()); 292 303 }
+25 -1
src/applications/phriction/storage/PhrictionTransaction.php
··· 5 5 6 6 const TYPE_TITLE = 'title'; 7 7 const TYPE_CONTENT = 'content'; 8 + const TYPE_DELETE = 'delete'; 8 9 9 10 const MAILTAG_TITLE = 'phriction-title'; 10 11 const MAILTAG_CONTENT = 'phriction-content'; 12 + const MAILTAG_DELETE = 'phriction-delete'; 11 13 12 14 public function getApplicationName() { 13 15 return 'phriction'; ··· 53 55 return 1.4; 54 56 case self::TYPE_CONTENT: 55 57 return 1.3; 58 + case self::TYPE_DELETE: 59 + return 1.5; 56 60 } 57 61 58 62 return parent::getActionStrength(); ··· 72 76 73 77 case self::TYPE_CONTENT: 74 78 return pht('Edited'); 79 + 80 + case self::TYPE_DELETE: 81 + return pht('Deleted'); 75 82 76 83 } 77 84 ··· 86 93 case self::TYPE_TITLE: 87 94 case self::TYPE_CONTENT: 88 95 return 'fa-pencil'; 96 + case self::TYPE_DELETE: 97 + return 'fa-times'; 89 98 } 90 99 91 100 return parent::getIcon(); 92 101 } 93 - 94 102 95 103 96 104 public function getTitle() { ··· 117 125 '%s edited the document content.', 118 126 $this->renderHandleLink($author_phid)); 119 127 128 + case self::TYPE_DELETE: 129 + return pht( 130 + '%s deleted this document.', 131 + $this->renderHandleLink($author_phid)); 132 + 133 + 120 134 } 121 135 122 136 return parent::getTitle(); ··· 151 165 $this->renderHandleLink($author_phid), 152 166 $this->renderHandleLink($object_phid)); 153 167 168 + case self::TYPE_DELETE: 169 + return pht( 170 + '%s deleted %s.', 171 + $this->renderHandleLink($author_phid), 172 + $this->renderHandleLink($object_phid)); 173 + 154 174 } 155 175 return parent::getTitleForFeed($story); 156 176 } ··· 179 199 case self::TYPE_CONTENT: 180 200 $tags[] = self::MAILTAG_CONTENT; 181 201 break; 202 + case self::TYPE_DELETE: 203 + $tags[] = self::MAILTAG_DELETE; 204 + break; 205 + 182 206 } 183 207 return $tags; 184 208 }