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

at recaptime-dev/main 199 lines 6.8 kB view raw
1<?php 2 3final class PhabricatorOwnersPackageEditEngine 4 extends PhabricatorEditEngine { 5 6 const ENGINECONST = 'owners.package'; 7 8 public function getEngineName() { 9 return pht('Owners Packages'); 10 } 11 12 public function getSummaryHeader() { 13 return pht('Configure Owners Package Forms'); 14 } 15 16 public function getSummaryText() { 17 return pht('Configure forms for creating and editing packages in Owners.'); 18 } 19 20 public function getEngineApplicationClass() { 21 return PhabricatorOwnersApplication::class; 22 } 23 24 protected function newEditableObject() { 25 return PhabricatorOwnersPackage::initializeNewPackage($this->getViewer()); 26 } 27 28 protected function newObjectQuery() { 29 return id(new PhabricatorOwnersPackageQuery()) 30 ->needPaths(true); 31 } 32 33 protected function getObjectCreateTitleText($object) { 34 return pht('Create New Package'); 35 } 36 37 protected function getObjectEditTitleText($object) { 38 return pht('Edit Package: %s', $object->getName()); 39 } 40 41 protected function getObjectEditShortText($object) { 42 return pht('Package %d', $object->getID()); 43 } 44 45 protected function getObjectCreateShortText() { 46 return pht('Create Package'); 47 } 48 49 protected function getObjectName() { 50 return pht('Package'); 51 } 52 53 protected function getObjectViewURI($object) { 54 return $object->getURI(); 55 } 56 57 protected function buildCustomEditFields($object) { 58 59 $paths_help = pht(<<<EOTEXT 60When updating the paths for a package, pass a list of dictionaries like 61this as the `value` for the transaction: 62 63```lang=json, name="Example Paths Value" 64[ 65 { 66 "repositoryPHID": "PHID-REPO-1234", 67 "path": "/path/to/directory/", 68 "excluded": false 69 }, 70 { 71 "repositoryPHID": "PHID-REPO-1234", 72 "path": "/another/example/path/", 73 "excluded": false 74 } 75] 76``` 77 78This transaction will set the paths to the list you provide, overwriting any 79previous paths. 80 81Generally, you will call `owners.search` first to get a list of current paths 82(which are provided in the same format), make changes, then update them by 83applying a transaction of this type. 84EOTEXT 85 ); 86 87 $autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap(); 88 $autoreview_map = ipull($autoreview_map, 'name'); 89 90 $dominion_map = PhabricatorOwnersPackage::getDominionOptionsMap(); 91 $dominion_map = ipull($dominion_map, 'name'); 92 93 $authority_map = PhabricatorOwnersPackage::getAuthorityOptionsMap(); 94 $authority_map = ipull($authority_map, 'name'); 95 96 return array( 97 id(new PhabricatorTextEditField()) 98 ->setKey('name') 99 ->setLabel(pht('Name')) 100 ->setDescription(pht('Name of the package.')) 101 ->setTransactionType( 102 PhabricatorOwnersPackageNameTransaction::TRANSACTIONTYPE) 103 ->setIsRequired(true) 104 ->setValue($object->getName()), 105 id(new PhabricatorDatasourceEditField()) 106 ->setKey('owners') 107 ->setLabel(pht('Owners')) 108 ->setDescription(pht('Users and projects which own the package.')) 109 ->setTransactionType( 110 PhabricatorOwnersPackageOwnersTransaction::TRANSACTIONTYPE) 111 ->setDatasource(new PhabricatorProjectOrUserDatasource()) 112 ->setIsCopyable(true) 113 ->setValue($object->getOwnerPHIDs()), 114 id(new PhabricatorSelectEditField()) 115 ->setKey('dominion') 116 ->setLabel(pht('Dominion')) 117 ->setDescription( 118 pht('Change package dominion rules.')) 119 ->setTransactionType( 120 PhabricatorOwnersPackageDominionTransaction::TRANSACTIONTYPE) 121 ->setIsCopyable(true) 122 ->setValue($object->getDominion()) 123 ->setOptions($dominion_map), 124 id(new PhabricatorSelectEditField()) 125 ->setKey('authority') 126 ->setLabel(pht('Authority')) 127 ->setDescription( 128 pht('Change package authority rules.')) 129 ->setTransactionType( 130 PhabricatorOwnersPackageAuthorityTransaction::TRANSACTIONTYPE) 131 ->setIsCopyable(true) 132 ->setValue($object->getAuthorityMode()) 133 ->setOptions($authority_map), 134 id(new PhabricatorSelectEditField()) 135 ->setKey('autoReview') 136 ->setLabel(pht('Auto Review')) 137 ->setDescription( 138 pht( 139 'Automatically trigger reviews for commits affecting files in '. 140 'this package.')) 141 ->setTransactionType( 142 PhabricatorOwnersPackageAutoreviewTransaction::TRANSACTIONTYPE) 143 ->setIsCopyable(true) 144 ->setValue($object->getAutoReview()) 145 ->setOptions($autoreview_map), 146 id(new PhabricatorSelectEditField()) 147 ->setKey('auditing') 148 ->setLabel(pht('Auditing')) 149 ->setDescription( 150 pht( 151 'Automatically trigger audits for commits affecting files in '. 152 'this package.')) 153 ->setTransactionType( 154 PhabricatorOwnersPackageAuditingTransaction::TRANSACTIONTYPE) 155 ->setIsCopyable(true) 156 ->setValue($object->getAuditingState()) 157 ->setOptions(PhabricatorOwnersAuditRule::newSelectControlMap()), 158 id(new PhabricatorRemarkupEditField()) 159 ->setKey('description') 160 ->setLabel(pht('Description')) 161 ->setDescription(pht('Human-readable description of the package.')) 162 ->setTransactionType( 163 PhabricatorOwnersPackageDescriptionTransaction::TRANSACTIONTYPE) 164 ->setValue($object->getDescription()), 165 id(new PhabricatorSelectEditField()) 166 ->setKey('status') 167 ->setLabel(pht('Status')) 168 ->setDescription(pht('Archive or enable the package.')) 169 ->setTransactionType( 170 PhabricatorOwnersPackageStatusTransaction::TRANSACTIONTYPE) 171 ->setIsFormField(false) 172 ->setValue($object->getStatus()) 173 ->setOptions($object->getStatusNameMap()), 174 id(new PhabricatorCheckboxesEditField()) 175 ->setKey('ignored') 176 ->setLabel(pht('Ignored Attributes')) 177 ->setDescription(pht('Ignore paths with any of these attributes.')) 178 ->setTransactionType( 179 PhabricatorOwnersPackageIgnoredTransaction::TRANSACTIONTYPE) 180 ->setValue(array_keys($object->getIgnoredPathAttributes())) 181 ->setOptions( 182 array( 183 'generated' => pht('Ignore generated files (review only).'), 184 )), 185 id(new PhabricatorConduitEditField()) 186 ->setKey('paths.set') 187 ->setLabel(pht('Paths')) 188 ->setIsFormField(false) 189 ->setTransactionType( 190 PhabricatorOwnersPackagePathsTransaction::TRANSACTIONTYPE) 191 ->setConduitDescription( 192 pht('Overwrite existing package paths with new paths.')) 193 ->setConduitTypeDescription( 194 pht('List of dictionaries, each describing a path.')) 195 ->setConduitDocumentation($paths_help), 196 ); 197 } 198 199}