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

Add repository URI view pages and IO/Display edit logic

Summary:
Ref T10748.

- New View page for repository URIs.
- Make display and I/O behavior (observe, mirror, read, read/write) editable.
- Add a bunch of checks to prevent you from completely screwing up a repository by making it writable from a bunch of differnet sources.

Test Plan:
{F1249866}

{F1249867}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

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

+549 -43
+4
src/__phutil_library_map__.php
··· 790 790 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', 791 791 'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php', 792 792 'DiffusionRepositoryURIEditController' => 'applications/diffusion/controller/DiffusionRepositoryURIEditController.php', 793 + 'DiffusionRepositoryURIViewController' => 'applications/diffusion/controller/DiffusionRepositoryURIViewController.php', 793 794 'DiffusionRepositoryURIsIndexEngineExtension' => 'applications/diffusion/engineextension/DiffusionRepositoryURIsIndexEngineExtension.php', 794 795 'DiffusionRepositoryURIsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php', 795 796 'DiffusionRequest' => 'applications/diffusion/request/DiffusionRequest.php', ··· 3244 3245 'PhabricatorRepositoryURIQuery' => 'applications/repository/query/PhabricatorRepositoryURIQuery.php', 3245 3246 'PhabricatorRepositoryURITestCase' => 'applications/repository/storage/__tests__/PhabricatorRepositoryURITestCase.php', 3246 3247 'PhabricatorRepositoryURITransaction' => 'applications/repository/storage/PhabricatorRepositoryURITransaction.php', 3248 + 'PhabricatorRepositoryURITransactionQuery' => 'applications/repository/query/PhabricatorRepositoryURITransactionQuery.php', 3247 3249 'PhabricatorRepositoryVCSPassword' => 'applications/repository/storage/PhabricatorRepositoryVCSPassword.php', 3248 3250 'PhabricatorRepositoryVersion' => 'applications/repository/constants/PhabricatorRepositoryVersion.php', 3249 3251 'PhabricatorRepositoryWorkingCopyVersion' => 'applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php', ··· 5016 5018 'DiffusionRepositoryTag' => 'Phobject', 5017 5019 'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController', 5018 5020 'DiffusionRepositoryURIEditController' => 'DiffusionRepositoryEditController', 5021 + 'DiffusionRepositoryURIViewController' => 'DiffusionController', 5019 5022 'DiffusionRepositoryURIsIndexEngineExtension' => 'PhabricatorIndexEngineExtension', 5020 5023 'DiffusionRepositoryURIsManagementPanel' => 'DiffusionRepositoryManagementPanel', 5021 5024 'DiffusionRequest' => 'Phobject', ··· 7935 7938 'PhabricatorRepositoryURIQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7936 7939 'PhabricatorRepositoryURITestCase' => 'PhabricatorTestCase', 7937 7940 'PhabricatorRepositoryURITransaction' => 'PhabricatorApplicationTransaction', 7941 + 'PhabricatorRepositoryURITransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7938 7942 'PhabricatorRepositoryVCSPassword' => 'PhabricatorRepositoryDAO', 7939 7943 'PhabricatorRepositoryVersion' => 'Phobject', 7940 7944 'PhabricatorRepositoryWorkingCopyVersion' => 'PhabricatorRepositoryDAO',
+5 -2
src/applications/diffusion/application/PhabricatorDiffusionApplication.php
··· 91 91 => 'DiffusionCommitEditController', 92 92 'manage/(?:(?P<panel>[^/]+)/)?' 93 93 => 'DiffusionRepositoryManageController', 94 - $this->getEditRoutePattern('uri/edit/') 95 - => 'DiffusionRepositoryURIEditController', 94 + 'uri/' => array( 95 + 'view/(?P<id>[0-9]\d*)/' => 'DiffusionRepositoryURIViewController', 96 + $this->getEditRoutePattern('edit/') 97 + => 'DiffusionRepositoryURIEditController', 98 + ), 96 99 'edit/' => array( 97 100 '' => 'DiffusionRepositoryEditMainController', 98 101 'basic/' => 'DiffusionRepositoryEditBasicController',
+162
src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryURIViewController 4 + extends DiffusionController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $response = $this->loadDiffusionContext(); 8 + if ($response) { 9 + return $response; 10 + } 11 + 12 + $viewer = $this->getViewer(); 13 + $drequest = $this->getDiffusionRequest(); 14 + $repository = $drequest->getRepository(); 15 + $id = $request->getURIData('id'); 16 + 17 + $uri = id(new PhabricatorRepositoryURIQuery()) 18 + ->setViewer($viewer) 19 + ->withIDs(array($id)) 20 + ->withRepositories(array($repository)) 21 + ->executeOne(); 22 + if (!$uri) { 23 + return new Aphront404Response(); 24 + } 25 + 26 + $title = array( 27 + pht('URI'), 28 + $repository->getDisplayName(), 29 + ); 30 + 31 + $crumbs = $this->buildApplicationCrumbs(); 32 + $crumbs->addTextCrumb( 33 + $repository->getDisplayName(), 34 + $repository->getURI()); 35 + $crumbs->addTextCrumb( 36 + pht('Manage'), 37 + $repository->getPathURI('manage/')); 38 + 39 + $panel_label = id(new DiffusionRepositoryURIsManagementPanel()) 40 + ->getManagementPanelLabel(); 41 + $panel_uri = $repository->getPathURI('manage/uris/'); 42 + $crumbs->addTextCrumb($panel_label, $panel_uri); 43 + 44 + $crumbs->addTextCrumb(pht('URI %d', $uri->getID())); 45 + 46 + $header_text = pht( 47 + '%s: URI %d', 48 + $repository->getDisplayName(), 49 + $uri->getID()); 50 + 51 + $header = id(new PHUIHeaderView()) 52 + ->setHeader($header_text) 53 + ->setHeaderIcon('fa-pencil'); 54 + if ($uri->getIsDisabled()) { 55 + $header->setStatus('fa-ban', 'dark', pht('Disabled')); 56 + } else { 57 + $header->setStatus('fa-check', 'bluegrey', pht('Active')); 58 + } 59 + 60 + $curtain = $this->buildCurtain($uri); 61 + $details = $this->buildPropertySection($uri); 62 + 63 + $timeline = $this->buildTransactionTimeline( 64 + $uri, 65 + new PhabricatorRepositoryURITransactionQuery()); 66 + $timeline->setShouldTerminate(true); 67 + 68 + $view = id(new PHUITwoColumnView()) 69 + ->setHeader($header) 70 + ->setMainColumn( 71 + array( 72 + $details, 73 + $timeline, 74 + )) 75 + ->setCurtain($curtain); 76 + 77 + return $this->newPage() 78 + ->setTitle($title) 79 + ->setCrumbs($crumbs) 80 + ->appendChild($view); 81 + } 82 + 83 + private function buildCurtain(PhabricatorRepositoryURI $uri) { 84 + $viewer = $this->getViewer(); 85 + 86 + $can_edit = PhabricatorPolicyFilter::hasCapability( 87 + $viewer, 88 + $uri, 89 + PhabricatorPolicyCapability::CAN_EDIT); 90 + 91 + $edit_uri = $uri->getEditURI(); 92 + 93 + $curtain = $this->newCurtainView($uri); 94 + 95 + $curtain->addAction( 96 + id(new PhabricatorActionView()) 97 + ->setIcon('fa-pencil') 98 + ->setName(pht('Edit URI')) 99 + ->setHref($edit_uri) 100 + ->setWorkflow(!$can_edit) 101 + ->setDisabled(!$can_edit)); 102 + 103 + return $curtain; 104 + } 105 + 106 + private function buildPropertySection(PhabricatorRepositoryURI $uri) { 107 + $viewer = $this->getViewer(); 108 + 109 + $properties = id(new PHUIPropertyListView()) 110 + ->setUser($viewer); 111 + 112 + $properties->addProperty(pht('URI'), $uri->getDisplayURI()); 113 + $properties->addProperty(pht('Credential'), 'TODO'); 114 + 115 + 116 + $io_type = $uri->getEffectiveIOType(); 117 + $io_map = PhabricatorRepositoryURI::getIOTypeMap(); 118 + $io_spec = idx($io_map, $io_type, array()); 119 + 120 + $io_icon = idx($io_spec, 'icon'); 121 + $io_color = idx($io_spec, 'color'); 122 + $io_label = idx($io_spec, 'label', $io_type); 123 + $io_note = idx($io_spec, 'note'); 124 + 125 + $io_item = id(new PHUIStatusItemView()) 126 + ->setIcon($io_icon, $io_color) 127 + ->setTarget(phutil_tag('strong', array(), $io_label)) 128 + ->setNote($io_note); 129 + 130 + $io_view = id(new PHUIStatusListView()) 131 + ->addItem($io_item); 132 + 133 + $properties->addProperty(pht('I/O'), $io_view); 134 + 135 + 136 + $display_type = $uri->getEffectiveDisplayType(); 137 + $display_map = PhabricatorRepositoryURI::getDisplayTypeMap(); 138 + $display_spec = idx($display_map, $display_type, array()); 139 + 140 + $display_icon = idx($display_spec, 'icon'); 141 + $display_color = idx($display_spec, 'color'); 142 + $display_label = idx($display_spec, 'label', $display_type); 143 + $display_note = idx($display_spec, 'note'); 144 + 145 + $display_item = id(new PHUIStatusItemView()) 146 + ->setIcon($display_icon, $display_color) 147 + ->setTarget(phutil_tag('strong', array(), $display_label)) 148 + ->setNote($display_note); 149 + 150 + $display_view = id(new PHUIStatusListView()) 151 + ->addItem($display_item); 152 + 153 + $properties->addProperty(pht('Display'), $display_view); 154 + 155 + 156 + return id(new PHUIObjectBoxView()) 157 + ->setHeaderText(pht('Details')) 158 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 159 + ->appendChild($properties); 160 + } 161 + 162 + }
+21 -4
src/applications/diffusion/editor/DiffusionURIEditEngine.php
··· 54 54 } 55 55 56 56 protected function getObjectEditTitleText($object) { 57 - return pht('Edit Repository URI: %s', $object->getDisplayURI()); 57 + return pht('Edit Repository URI %d', $object->getID()); 58 58 } 59 59 60 60 protected function getObjectEditShortText($object) { 61 - return $object->getDisplayURI(); 61 + return pht('URI %d', $object->getID()); 62 62 } 63 63 64 64 protected function getObjectCreateShortText() { ··· 70 70 } 71 71 72 72 protected function getObjectViewURI($object) { 73 - $repository = $this->getRepository(); 74 - return $repository->getPathURI('manage/uris/'); 73 + return $object->getViewURI(); 75 74 } 76 75 77 76 protected function buildCustomEditFields($object) { ··· 87 86 ->setConduitDescription(pht('Change the repository URI.')) 88 87 ->setConduitTypeDescription(pht('New repository URI.')) 89 88 ->setValue($object->getURI()), 89 + id(new PhabricatorSelectEditField()) 90 + ->setKey('io') 91 + ->setLabel(pht('I/O Type')) 92 + ->setTransactionType(PhabricatorRepositoryURITransaction::TYPE_IO) 93 + ->setDescription(pht('URI I/O behavior.')) 94 + ->setConduitDescription(pht('Adjust I/O behavior.')) 95 + ->setConduitTypeDescription(pht('New I/O behavior.')) 96 + ->setValue($object->getIOType()) 97 + ->setOptions($object->getAvailableIOTypeOptions()), 98 + id(new PhabricatorSelectEditField()) 99 + ->setKey('display') 100 + ->setLabel(pht('Display Type')) 101 + ->setTransactionType(PhabricatorRepositoryURITransaction::TYPE_DISPLAY) 102 + ->setDescription(pht('URI display behavior.')) 103 + ->setConduitDescription(pht('Change display behavior.')) 104 + ->setConduitTypeDescription(pht('New display behavior.')) 105 + ->setValue($object->getDisplayType()) 106 + ->setOptions($object->getAvailableDisplayTypeOptions()), 90 107 ); 91 108 } 92 109
+144
src/applications/diffusion/editor/DiffusionURIEditor.php
··· 15 15 $types = parent::getTransactionTypes(); 16 16 17 17 $types[] = PhabricatorRepositoryURITransaction::TYPE_URI; 18 + $types[] = PhabricatorRepositoryURITransaction::TYPE_IO; 19 + $types[] = PhabricatorRepositoryURITransaction::TYPE_DISPLAY; 18 20 19 21 return $types; 20 22 } ··· 26 28 switch ($xaction->getTransactionType()) { 27 29 case PhabricatorRepositoryURITransaction::TYPE_URI: 28 30 return $object->getURI(); 31 + case PhabricatorRepositoryURITransaction::TYPE_IO: 32 + return $object->getIOType(); 33 + case PhabricatorRepositoryURITransaction::TYPE_DISPLAY: 34 + return $object->getDisplayType(); 29 35 } 30 36 31 37 return parent::getCustomTransactionOldValue($object, $xaction); ··· 37 43 38 44 switch ($xaction->getTransactionType()) { 39 45 case PhabricatorRepositoryURITransaction::TYPE_URI: 46 + case PhabricatorRepositoryURITransaction::TYPE_IO: 47 + case PhabricatorRepositoryURITransaction::TYPE_DISPLAY: 40 48 return $xaction->getNewValue(); 41 49 } 42 50 ··· 51 59 case PhabricatorRepositoryURITransaction::TYPE_URI: 52 60 $object->setURI($xaction->getNewValue()); 53 61 break; 62 + case PhabricatorRepositoryURITransaction::TYPE_IO: 63 + $object->setIOType($xaction->getNewValue()); 64 + break; 65 + case PhabricatorRepositoryURITransaction::TYPE_DISPLAY: 66 + $object->setDisplayType($xaction->getNewValue()); 67 + break; 54 68 } 55 69 } 56 70 ··· 60 74 61 75 switch ($xaction->getTransactionType()) { 62 76 case PhabricatorRepositoryURITransaction::TYPE_URI: 77 + case PhabricatorRepositoryURITransaction::TYPE_IO: 78 + case PhabricatorRepositoryURITransaction::TYPE_DISPLAY: 63 79 return; 64 80 } 65 81 ··· 89 105 $error->setIsMissingFieldError(true); 90 106 $errors[] = $error; 91 107 break; 108 + } 109 + break; 110 + case PhabricatorRepositoryURITransaction::TYPE_IO: 111 + $available = $object->getAvailableIOTypeOptions(); 112 + foreach ($xactions as $xaction) { 113 + $new = $xaction->getNewValue(); 114 + 115 + if (empty($available[$new])) { 116 + $errors[] = new PhabricatorApplicationTransactionValidationError( 117 + $type, 118 + pht('Invalid'), 119 + pht( 120 + 'Value "%s" is not a valid display setting for this URI. '. 121 + 'Available types for this URI are: %s.', 122 + implode(', ', array_keys($available))), 123 + $xaction); 124 + continue; 125 + } 126 + 127 + // If we are setting this URI to use "Observe", we must have no 128 + // other "Observe" URIs and must also have no "Read/Write" URIs. 129 + 130 + // If we are setting this URI to "Read/Write", we must have no 131 + // other "Observe" URIs. It's OK to have other "Read/Write" URIs. 132 + 133 + $no_observers = false; 134 + $no_readwrite = false; 135 + switch ($new) { 136 + case PhabricatorRepositoryURI::IO_OBSERVE: 137 + $no_readwrite = true; 138 + $no_observers = true; 139 + break; 140 + case PhabricatorRepositoryURI::IO_READWRITE: 141 + $no_observers = true; 142 + break; 143 + } 144 + 145 + if ($no_observers || $no_readwrite) { 146 + $repository = id(new PhabricatorRepositoryQuery()) 147 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 148 + ->withPHIDs(array($object->getRepositoryPHID())) 149 + ->needURIs(true) 150 + ->executeOne(); 151 + $uris = $repository->getURIs(); 152 + 153 + $observe_conflict = null; 154 + $readwrite_conflict = null; 155 + foreach ($uris as $uri) { 156 + // If this is the URI being edited, it can not conflict with 157 + // itself. 158 + if ($uri->getID() == $object->getID()) { 159 + continue; 160 + } 161 + 162 + $io_type = $uri->getIoType(); 163 + 164 + if ($io_type == PhabricatorRepositoryURI::IO_READWRITE) { 165 + if ($no_readwrite) { 166 + $readwite_conflict = $uri; 167 + break; 168 + } 169 + } 170 + 171 + if ($io_type == PhabricatorRepositoryURI::IO_OBSERVE) { 172 + if ($no_observers) { 173 + $observe_conflict = $uri; 174 + break; 175 + } 176 + } 177 + } 178 + 179 + if ($observe_conflict) { 180 + if ($new == PhabricatorRepositoryURI::IO_OBSERVE) { 181 + $message = pht( 182 + 'You can not set this URI to use Observe IO because '. 183 + 'another URI for this repository is already configured '. 184 + 'in Observe IO mode. A repository can not observe two '. 185 + 'different remotes simultaneously. Turn off IO for the '. 186 + 'other URI first.'); 187 + } else { 188 + $message = pht( 189 + 'You can not set this URI to use Read/Write IO because '. 190 + 'another URI for this repository is already configured '. 191 + 'in Observe IO mode. An observed repository can not be '. 192 + 'made writable. Turn off IO for the other URI first.'); 193 + } 194 + 195 + $errors[] = new PhabricatorApplicationTransactionValidationError( 196 + $type, 197 + pht('Invalid'), 198 + $message, 199 + $xaction); 200 + continue; 201 + } 202 + 203 + if ($readwrite_conflict) { 204 + $message = pht( 205 + 'You can not set this URI to use Observe IO because '. 206 + 'another URI for this repository is already configured '. 207 + 'in Read/Write IO mode. A repository can not simultaneously '. 208 + 'be writable and observe a remote. Turn off IO for the '. 209 + 'other URI first.'); 210 + 211 + $errors[] = new PhabricatorApplicationTransactionValidationError( 212 + $type, 213 + pht('Invalid'), 214 + $message, 215 + $xaction); 216 + continue; 217 + } 218 + } 219 + } 220 + 221 + break; 222 + case PhabricatorRepositoryURITransaction::TYPE_DISPLAY: 223 + $available = $object->getAvailableDisplayTypeOptions(); 224 + foreach ($xactions as $xaction) { 225 + $new = $xaction->getNewValue(); 226 + 227 + if (empty($available[$new])) { 228 + $errors[] = new PhabricatorApplicationTransactionValidationError( 229 + $type, 230 + pht('Invalid'), 231 + pht( 232 + 'Value "%s" is not a valid display setting for this URI. '. 233 + 'Available types for this URI are: %s.', 234 + implode(', ', array_keys($available)))); 235 + } 92 236 } 93 237 break; 94 238 }
+17 -35
src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
··· 26 26 $uri_name = phutil_tag( 27 27 'a', 28 28 array( 29 - 'href' => $repository->getPathURI('uri/edit/'.$uri->getID().'/'), 29 + 'href' => $uri->getViewURI(), 30 30 ), 31 31 $uri_name); 32 32 ··· 38 38 39 39 $uri_status = id(new PHUIIconView())->setIcon($status_icon); 40 40 41 - switch ($uri->getEffectiveIOType()) { 42 - case PhabricatorRepositoryURI::IO_OBSERVE: 43 - $io_icon = 'fa-download green'; 44 - $io_label = pht('Observe'); 45 - break; 46 - case PhabricatorRepositoryURI::IO_MIRROR: 47 - $io_icon = 'fa-upload green'; 48 - $io_label = pht('Mirror'); 49 - break; 50 - case PhabricatorRepositoryURI::IO_NONE: 51 - $io_icon = 'fa-times grey'; 52 - $io_label = pht('No I/O'); 53 - break; 54 - case PhabricatorRepositoryURI::IO_READ: 55 - $io_icon = 'fa-folder blue'; 56 - $io_label = pht('Read Only'); 57 - break; 58 - case PhabricatorRepositoryURI::IO_READWRITE: 59 - $io_icon = 'fa-folder-open blue'; 60 - $io_label = pht('Read/Write'); 61 - break; 62 - } 41 + $io_type = $uri->getEffectiveIOType(); 42 + $io_map = PhabricatorRepositoryURI::getIOTypeMap(); 43 + $io_spec = idx($io_map, $io_type, array()); 44 + 45 + $io_icon = idx($io_spec, 'icon'); 46 + $io_color = idx($io_spec, 'color'); 47 + $io_label = idx($io_spec, 'label', $io_type); 63 48 64 49 $uri_io = array( 65 - id(new PHUIIconView())->setIcon($io_icon), 50 + id(new PHUIIconView())->setIcon("{$io_icon} {$io_color}"), 66 51 ' ', 67 52 $io_label, 68 53 ); 69 54 70 - switch ($uri->getEffectiveDisplayType()) { 71 - case PhabricatorRepositoryURI::DISPLAY_NEVER: 72 - $display_icon = 'fa-eye-slash grey'; 73 - $display_label = pht('Hidden'); 74 - break; 75 - case PhabricatorRepositoryURI::DISPLAY_ALWAYS: 76 - $display_icon = 'fa-eye green'; 77 - $display_label = pht('Visible'); 78 - break; 79 - } 55 + $display_type = $uri->getEffectiveDisplayType(); 56 + $display_map = PhabricatorRepositoryURI::getDisplayTypeMap(); 57 + $display_spec = idx($display_map, $display_type, array()); 58 + 59 + $display_icon = idx($display_spec, 'icon'); 60 + $display_color = idx($display_spec, 'color'); 61 + $display_label = idx($display_spec, 'label', $display_type); 80 62 81 63 $uri_display = array( 82 - id(new PHUIIconView())->setIcon($display_icon), 64 + id(new PHUIIconView())->setIcon("{$display_icon} {$display_color}"), 83 65 ' ', 84 66 $display_label, 85 67 );
+10
src/applications/repository/query/PhabricatorRepositoryURITransactionQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryURITransactionQuery 4 + extends PhabricatorApplicationTransactionQuery { 5 + 6 + public function getTemplateApplicationTransaction() { 7 + return new PhabricatorRepositoryURITransaction(); 8 + } 9 + 10 + }
+147
src/applications/repository/storage/PhabricatorRepositoryURI.php
··· 94 94 $this->getBuiltinProtocol(), 95 95 $this->getBuiltinIdentifier(), 96 96 ); 97 + 97 98 return implode('.', $parts); 98 99 } 99 100 ··· 108 109 return $display; 109 110 } 110 111 112 + return $this->getDefaultDisplayType(); 113 + } 114 + 115 + public function getDefaultDisplayType() { 111 116 switch ($this->getEffectiveIOType()) { 112 117 case self::IO_MIRROR: 113 118 case self::IO_OBSERVE: ··· 156 161 157 162 return self::DISPLAY_ALWAYS; 158 163 } 164 + 165 + return self::DISPLAY_NEVER; 159 166 } 160 167 161 168 ··· 166 173 return $io; 167 174 } 168 175 176 + return $this->getDefaultIOType(); 177 + } 178 + 179 + public function getDefaultIOType() { 169 180 if ($this->isBuiltin()) { 170 181 $repository = $this->getRepository(); 171 182 $other_uris = $repository->getURIs(); ··· 305 316 default: 306 317 return null; 307 318 } 319 + } 320 + 321 + public function getViewURI() { 322 + $id = $this->getID(); 323 + return $this->getRepository()->getPathURI("uri/view/{$id}/"); 324 + } 325 + 326 + public function getEditURI() { 327 + $id = $this->getID(); 328 + return $this->getRepository()->getPathURI("uri/edit/{$id}/"); 329 + } 330 + 331 + public function getAvailableIOTypeOptions() { 332 + $options = array( 333 + self::IO_DEFAULT, 334 + self::IO_NONE, 335 + ); 336 + 337 + if ($this->isBuiltin()) { 338 + $options[] = self::IO_READ; 339 + $options[] = self::IO_WRITE; 340 + } else { 341 + $options[] = self::IO_OBSERVE; 342 + $options[] = self::IO_MIRROR; 343 + } 344 + 345 + $map = array(); 346 + $io_map = self::getIOTypeMap(); 347 + foreach ($options as $option) { 348 + $spec = idx($io_map, $option, array()); 349 + 350 + $label = idx($spec, 'label', $option); 351 + $short = idx($spec, 'short'); 352 + 353 + $name = pht('%s: %s', $label, $short); 354 + $map[$option] = $name; 355 + } 356 + 357 + return $map; 358 + } 359 + 360 + public function getAvailableDisplayTypeOptions() { 361 + $options = array( 362 + self::DISPLAY_DEFAULT, 363 + self::DISPLAY_ALWAYS, 364 + self::DISPLAY_NEVER, 365 + ); 366 + 367 + $map = array(); 368 + $display_map = self::getDisplayTypeMap(); 369 + foreach ($options as $option) { 370 + $spec = idx($display_map, $option, array()); 371 + 372 + $label = idx($spec, 'label', $option); 373 + $short = idx($spec, 'short'); 374 + 375 + $name = pht('%s: %s', $label, $short); 376 + $map[$option] = $name; 377 + } 378 + 379 + return $map; 380 + } 381 + 382 + public static function getIOTypeMap() { 383 + return array( 384 + self::IO_DEFAULT => array( 385 + 'label' => pht('Default'), 386 + 'short' => pht('Use default behavior.'), 387 + ), 388 + self::IO_OBSERVE => array( 389 + 'icon' => 'fa-download', 390 + 'color' => 'green', 391 + 'label' => pht('Observe'), 392 + 'note' => pht( 393 + 'Phabricator will observe changes to this URI and copy them.'), 394 + 'short' => pht('Copy from a remote.'), 395 + ), 396 + self::IO_MIRROR => array( 397 + 'icon' => 'fa-upload', 398 + 'color' => 'green', 399 + 'label' => pht('Mirror'), 400 + 'note' => pht( 401 + 'Phabricator will push a copy of any changes to this URI.'), 402 + 'short' => pht('Push a copy to a remote.'), 403 + ), 404 + self::IO_NONE => array( 405 + 'icon' => 'fa-times', 406 + 'color' => 'grey', 407 + 'label' => pht('No I/O'), 408 + 'note' => pht( 409 + 'Phabricator will not push or pull any changes to this URI.'), 410 + 'short' => pht('Do not perform any I/O.'), 411 + ), 412 + self::IO_READ => array( 413 + 'icon' => 'fa-folder', 414 + 'color' => 'blue', 415 + 'label' => pht('Read Only'), 416 + 'note' => pht( 417 + 'Phabricator will serve a read-only copy of the repository from '. 418 + 'this URI.'), 419 + 'short' => pht('Serve repository in read-only mode.'), 420 + ), 421 + self::IO_READWRITE => array( 422 + 'icon' => 'fa-folder-open', 423 + 'color' => 'blue', 424 + 'label' => pht('Read/Write'), 425 + 'note' => pht( 426 + 'Phabricator will serve a read/write copy of the repository from '. 427 + 'this URI.'), 428 + 'short' => pht('Serve repository in read/write mode.'), 429 + ), 430 + ); 431 + } 432 + 433 + public static function getDisplayTypeMap() { 434 + return array( 435 + self::DISPLAY_DEFAULT => array( 436 + 'label' => pht('Default'), 437 + 'short' => pht('Use default behavior.'), 438 + ), 439 + self::DISPLAY_ALWAYS => array( 440 + 'icon' => 'fa-eye', 441 + 'color' => 'green', 442 + 'label' => pht('Visible'), 443 + 'note' => pht('This URI will be shown to users as a clone URI.'), 444 + 'short' => pht('Show as a clone URI.'), 445 + ), 446 + self::DISPLAY_NEVER => array( 447 + 'icon' => 'fa-eye-slash', 448 + 'color' => 'grey', 449 + 'label' => pht('Hidden'), 450 + 'note' => pht( 451 + 'This URI will be hidden from users.'), 452 + 'short' => pht('Do not show as a clone URI.'), 453 + ), 454 + ); 308 455 } 309 456 310 457
+39 -2
src/applications/repository/storage/PhabricatorRepositoryURITransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_URI = 'diffusion.uri.uri'; 7 + const TYPE_IO = 'diffusion.uri.io'; 8 + const TYPE_DISPLAY = 'diffusion.uri.display'; 7 9 8 10 public function getApplicationName() { 9 11 return 'repository'; ··· 13 15 return PhabricatorRepositoryURIPHIDType::TYPECONST; 14 16 } 15 17 16 - public function getApplicationTransactionCommentObject() { 17 - return null; 18 + public function getTitle() { 19 + $author_phid = $this->getAuthorPHID(); 20 + 21 + $old = $this->getOldValue(); 22 + $new = $this->getNewValue(); 23 + 24 + switch ($this->getTransactionType()) { 25 + case self::TYPE_URI: 26 + return pht( 27 + '%s changed this URI from "%s" to "%s".', 28 + $this->renderHandleLink($author_phid), 29 + $old, 30 + $new); 31 + case self::TYPE_IO: 32 + $map = PhabricatorRepositoryURI::getIOTypeMap(); 33 + $old_label = idx(idx($map, $old, array()), 'label', $old); 34 + $new_label = idx(idx($map, $new, array()), 'label', $new); 35 + 36 + return pht( 37 + '%s changed the display type for this URI from "%s" to "%s".', 38 + $this->renderHandleLink($author_phid), 39 + $old_label, 40 + $new_label); 41 + case self::TYPE_DISPLAY: 42 + $map = PhabricatorRepositoryURI::getDisplayTypeMap(); 43 + $old_label = idx(idx($map, $old, array()), 'label', $old); 44 + $new_label = idx(idx($map, $new, array()), 'label', $new); 45 + 46 + return pht( 47 + '%s changed the display type for this URI from "%s" to "%s".', 48 + $this->renderHandleLink($author_phid), 49 + $old_label, 50 + $new_label); 51 + 52 + } 53 + 54 + return parent::getTitle(); 18 55 } 19 56 20 57 }