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

Support editing statuses and paths in Owners via Conduit API

Summary: Ref T9964. Fixes T9752. Provides API access to enable/disable packages and change their paths.

Test Plan:
- Changed status via Conduit.
- Changed paths via Conduit.
- Tried to change a path use a nonsense/bogus repository PHID, got an error.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9752, T9964

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

+115 -3
+2
src/__phutil_library_map__.php
··· 1887 1887 'PhabricatorConduitConsoleController' => 'applications/conduit/controller/PhabricatorConduitConsoleController.php', 1888 1888 'PhabricatorConduitController' => 'applications/conduit/controller/PhabricatorConduitController.php', 1889 1889 'PhabricatorConduitDAO' => 'applications/conduit/storage/PhabricatorConduitDAO.php', 1890 + 'PhabricatorConduitEditField' => 'applications/transactions/editfield/PhabricatorConduitEditField.php', 1890 1891 'PhabricatorConduitListController' => 'applications/conduit/controller/PhabricatorConduitListController.php', 1891 1892 'PhabricatorConduitLogController' => 'applications/conduit/controller/PhabricatorConduitLogController.php', 1892 1893 'PhabricatorConduitLogQuery' => 'applications/conduit/query/PhabricatorConduitLogQuery.php', ··· 6004 6005 'PhabricatorConduitConsoleController' => 'PhabricatorConduitController', 6005 6006 'PhabricatorConduitController' => 'PhabricatorController', 6006 6007 'PhabricatorConduitDAO' => 'PhabricatorLiskDAO', 6008 + 'PhabricatorConduitEditField' => 'PhabricatorEditField', 6007 6009 'PhabricatorConduitListController' => 'PhabricatorConduitController', 6008 6010 'PhabricatorConduitLogController' => 'PhabricatorConduitController', 6009 6011 'PhabricatorConduitLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+16 -1
src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
··· 18 18 } 19 19 20 20 protected function newObjectQuery() { 21 - return id(new PhabricatorOwnersPackageQuery()); 21 + return id(new PhabricatorOwnersPackageQuery()) 22 + ->needPaths(true); 22 23 } 23 24 24 25 protected function getObjectCreateTitleText($object) { ··· 81 82 ->setTransactionType( 82 83 PhabricatorOwnersPackageTransaction::TYPE_DESCRIPTION) 83 84 ->setValue($object->getDescription()), 85 + id(new PhabricatorSelectEditField()) 86 + ->setKey('status') 87 + ->setLabel(pht('Status')) 88 + ->setDescription(pht('Archive or enable the package.')) 89 + ->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_STATUS) 90 + ->setIsConduitOnly(true) 91 + ->setValue($object->getStatus()) 92 + ->setOptions($object->getStatusNameMap()), 93 + id(new PhabricatorConduitEditField()) 94 + ->setKey('paths.set') 95 + ->setLabel(pht('Paths')) 96 + ->setDescription(pht('Set paths for this package.')) 97 + ->setIsConduitOnly(true) 98 + ->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_PATHS), 84 99 ); 85 100 } 86 101
+82 -1
src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php
··· 54 54 switch ($xaction->getTransactionType()) { 55 55 case PhabricatorOwnersPackageTransaction::TYPE_NAME: 56 56 case PhabricatorOwnersPackageTransaction::TYPE_DESCRIPTION: 57 - case PhabricatorOwnersPackageTransaction::TYPE_PATHS: 58 57 case PhabricatorOwnersPackageTransaction::TYPE_STATUS: 59 58 return $xaction->getNewValue(); 59 + case PhabricatorOwnersPackageTransaction::TYPE_PATHS: 60 + $new = $xaction->getNewValue(); 61 + foreach ($new as $key => $info) { 62 + $new[$key]['excluded'] = (int)idx($info, 'excluded'); 63 + } 64 + return $new; 60 65 case PhabricatorOwnersPackageTransaction::TYPE_AUDITING: 61 66 return (int)$xaction->getNewValue(); 62 67 case PhabricatorOwnersPackageTransaction::TYPE_OWNERS: ··· 196 201 197 202 $error->setIsMissingFieldError(true); 198 203 $errors[] = $error; 204 + } 205 + break; 206 + case PhabricatorOwnersPackageTransaction::TYPE_PATHS: 207 + $old = mpull($object->getPaths(), 'getRef'); 208 + foreach ($xactions as $xaction) { 209 + $new = $xaction->getNewValue(); 210 + 211 + // Check that we have a list of paths. 212 + if (!is_array($new)) { 213 + $errors[] = new PhabricatorApplicationTransactionValidationError( 214 + $type, 215 + pht('Invalid'), 216 + pht('Path specification must be a list of paths.'), 217 + $xaction); 218 + continue; 219 + } 220 + 221 + // Check that each item in the list is formatted properly. 222 + $type_exception = null; 223 + foreach ($new as $key => $value) { 224 + try { 225 + PhutilTypeSpec::checkMap( 226 + $value, 227 + array( 228 + 'repositoryPHID' => 'string', 229 + 'path' => 'string', 230 + 'excluded' => 'optional wild', 231 + )); 232 + } catch (PhutilTypeCheckException $ex) { 233 + $errors[] = new PhabricatorApplicationTransactionValidationError( 234 + $type, 235 + pht('Invalid'), 236 + pht( 237 + 'Path specification list contains invalid value '. 238 + 'in key "%s": %s.', 239 + $key, 240 + $ex->getMessage()), 241 + $xaction); 242 + $type_exception = $ex; 243 + } 244 + } 245 + 246 + if ($type_exception) { 247 + continue; 248 + } 249 + 250 + // Check that any new paths reference legitimate repositories which 251 + // the viewer has permission to see. 252 + list($rem, $add) = PhabricatorOwnersPath::getTransactionValueChanges( 253 + $old, 254 + $new); 255 + 256 + if ($add) { 257 + $repository_phids = ipull($add, 'repositoryPHID'); 258 + 259 + $repositories = id(new PhabricatorRepositoryQuery()) 260 + ->setViewer($this->getActor()) 261 + ->withPHIDs($repository_phids) 262 + ->execute(); 263 + $repositories = mpull($repositories, null, 'getPHID'); 264 + 265 + foreach ($add as $ref) { 266 + $repository_phid = $ref['repositoryPHID']; 267 + if (isset($repositories[$repository_phid])) { 268 + continue; 269 + } 270 + 271 + $errors[] = new PhabricatorApplicationTransactionValidationError( 272 + $type, 273 + pht('Invalid'), 274 + pht( 275 + 'Path specification list references repository PHID "%s", '. 276 + 'but that is not a valid, visible repository.', 277 + $repository_phid)); 278 + } 279 + } 199 280 } 200 281 break; 201 282 }
+1 -1
src/applications/owners/engineextension/PhabricatorOwnersPathsSearchEngineAttachment.php
··· 23 23 $list[] = array( 24 24 'repositoryPHID' => $path->getRepositoryPHID(), 25 25 'path' => $path->getPath(), 26 - 'isExcluded' => (bool)$path->getExcluded(), 26 + 'excluded' => (bool)$path->getExcluded(), 27 27 ); 28 28 } 29 29
+14
src/applications/transactions/editfield/PhabricatorConduitEditField.php
··· 1 + <?php 2 + 3 + final class PhabricatorConduitEditField 4 + extends PhabricatorEditField { 5 + 6 + protected function newControl() { 7 + return null; 8 + } 9 + 10 + protected function newHTTPParameterType() { 11 + return null; 12 + } 13 + 14 + }