Path: blob/master/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
12256 views
<?php12final class PhabricatorOwnersPackageEditEngine3extends PhabricatorEditEngine {45const ENGINECONST = 'owners.package';67public function getEngineName() {8return pht('Owners Packages');9}1011public function getSummaryHeader() {12return pht('Configure Owners Package Forms');13}1415public function getSummaryText() {16return pht('Configure forms for creating and editing packages in Owners.');17}1819public function getEngineApplicationClass() {20return 'PhabricatorOwnersApplication';21}2223protected function newEditableObject() {24return PhabricatorOwnersPackage::initializeNewPackage($this->getViewer());25}2627protected function newObjectQuery() {28return id(new PhabricatorOwnersPackageQuery())29->needPaths(true);30}3132protected function getObjectCreateTitleText($object) {33return pht('Create New Package');34}3536protected function getObjectEditTitleText($object) {37return pht('Edit Package: %s', $object->getName());38}3940protected function getObjectEditShortText($object) {41return pht('Package %d', $object->getID());42}4344protected function getObjectCreateShortText() {45return pht('Create Package');46}4748protected function getObjectName() {49return pht('Package');50}5152protected function getObjectViewURI($object) {53return $object->getURI();54}5556protected function buildCustomEditFields($object) {5758$paths_help = pht(<<<EOTEXT59When updating the paths for a package, pass a list of dictionaries like60this as the `value` for the transaction:6162```lang=json, name="Example Paths Value"63[64{65"repositoryPHID": "PHID-REPO-1234",66"path": "/path/to/directory/",67"excluded": false68},69{70"repositoryPHID": "PHID-REPO-1234",71"path": "/another/example/path/",72"excluded": false73}74]75```7677This transaction will set the paths to the list you provide, overwriting any78previous paths.7980Generally, you will call `owners.search` first to get a list of current paths81(which are provided in the same format), make changes, then update them by82applying a transaction of this type.83EOTEXT84);8586$autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();87$autoreview_map = ipull($autoreview_map, 'name');8889$dominion_map = PhabricatorOwnersPackage::getDominionOptionsMap();90$dominion_map = ipull($dominion_map, 'name');9192$authority_map = PhabricatorOwnersPackage::getAuthorityOptionsMap();93$authority_map = ipull($authority_map, 'name');9495return array(96id(new PhabricatorTextEditField())97->setKey('name')98->setLabel(pht('Name'))99->setDescription(pht('Name of the package.'))100->setTransactionType(101PhabricatorOwnersPackageNameTransaction::TRANSACTIONTYPE)102->setIsRequired(true)103->setValue($object->getName()),104id(new PhabricatorDatasourceEditField())105->setKey('owners')106->setLabel(pht('Owners'))107->setDescription(pht('Users and projects which own the package.'))108->setTransactionType(109PhabricatorOwnersPackageOwnersTransaction::TRANSACTIONTYPE)110->setDatasource(new PhabricatorProjectOrUserDatasource())111->setIsCopyable(true)112->setValue($object->getOwnerPHIDs()),113id(new PhabricatorSelectEditField())114->setKey('dominion')115->setLabel(pht('Dominion'))116->setDescription(117pht('Change package dominion rules.'))118->setTransactionType(119PhabricatorOwnersPackageDominionTransaction::TRANSACTIONTYPE)120->setIsCopyable(true)121->setValue($object->getDominion())122->setOptions($dominion_map),123id(new PhabricatorSelectEditField())124->setKey('authority')125->setLabel(pht('Authority'))126->setDescription(127pht('Change package authority rules.'))128->setTransactionType(129PhabricatorOwnersPackageAuthorityTransaction::TRANSACTIONTYPE)130->setIsCopyable(true)131->setValue($object->getAuthorityMode())132->setOptions($authority_map),133id(new PhabricatorSelectEditField())134->setKey('autoReview')135->setLabel(pht('Auto Review'))136->setDescription(137pht(138'Automatically trigger reviews for commits affecting files in '.139'this package.'))140->setTransactionType(141PhabricatorOwnersPackageAutoreviewTransaction::TRANSACTIONTYPE)142->setIsCopyable(true)143->setValue($object->getAutoReview())144->setOptions($autoreview_map),145id(new PhabricatorSelectEditField())146->setKey('auditing')147->setLabel(pht('Auditing'))148->setDescription(149pht(150'Automatically trigger audits for commits affecting files in '.151'this package.'))152->setTransactionType(153PhabricatorOwnersPackageAuditingTransaction::TRANSACTIONTYPE)154->setIsCopyable(true)155->setValue($object->getAuditingState())156->setOptions(PhabricatorOwnersAuditRule::newSelectControlMap()),157id(new PhabricatorRemarkupEditField())158->setKey('description')159->setLabel(pht('Description'))160->setDescription(pht('Human-readable description of the package.'))161->setTransactionType(162PhabricatorOwnersPackageDescriptionTransaction::TRANSACTIONTYPE)163->setValue($object->getDescription()),164id(new PhabricatorSelectEditField())165->setKey('status')166->setLabel(pht('Status'))167->setDescription(pht('Archive or enable the package.'))168->setTransactionType(169PhabricatorOwnersPackageStatusTransaction::TRANSACTIONTYPE)170->setIsFormField(false)171->setValue($object->getStatus())172->setOptions($object->getStatusNameMap()),173id(new PhabricatorCheckboxesEditField())174->setKey('ignored')175->setLabel(pht('Ignored Attributes'))176->setDescription(pht('Ignore paths with any of these attributes.'))177->setTransactionType(178PhabricatorOwnersPackageIgnoredTransaction::TRANSACTIONTYPE)179->setValue(array_keys($object->getIgnoredPathAttributes()))180->setOptions(181array(182'generated' => pht('Ignore generated files (review only).'),183)),184id(new PhabricatorConduitEditField())185->setKey('paths.set')186->setLabel(pht('Paths'))187->setIsFormField(false)188->setTransactionType(189PhabricatorOwnersPackagePathsTransaction::TRANSACTIONTYPE)190->setConduitDescription(191pht('Overwrite existing package paths with new paths.'))192->setConduitTypeDescription(193pht('List of dictionaries, each describing a path.'))194->setConduitDocumentation($paths_help),195);196}197198}199200201