@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

Improve UI and documentation for "Ignore Attributes" in Owners slightly

Summary:
See PHI251. Ref T13137.

- Replace the perplexing text box with a checkbox that explains what it does.
- Mention this feature in the documentation.

Test Plan:
- Clicked/unclicked checkbox.
- Read documentation.
- Used an existing checkbox control in Slowvote to make sure I didn't break it.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13137

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

+89 -4
+2
src/__phutil_library_map__.php
··· 2525 2525 'PhabricatorChatLogDAO' => 'applications/chatlog/storage/PhabricatorChatLogDAO.php', 2526 2526 'PhabricatorChatLogEvent' => 'applications/chatlog/storage/PhabricatorChatLogEvent.php', 2527 2527 'PhabricatorChatLogQuery' => 'applications/chatlog/query/PhabricatorChatLogQuery.php', 2528 + 'PhabricatorCheckboxesEditField' => 'applications/transactions/editfield/PhabricatorCheckboxesEditField.php', 2528 2529 'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php', 2529 2530 'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php', 2530 2531 'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php', ··· 8140 8141 'PhabricatorPolicyInterface', 8141 8142 ), 8142 8143 'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 8144 + 'PhabricatorCheckboxesEditField' => 'PhabricatorEditField', 8143 8145 'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine', 8144 8146 'PhabricatorClassConfigType' => 'PhabricatorTextConfigType', 8145 8147 'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
+6 -2
src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
··· 162 162 ->setIsConduitOnly(true) 163 163 ->setValue($object->getStatus()) 164 164 ->setOptions($object->getStatusNameMap()), 165 - id(new PhabricatorStringListEditField()) 165 + id(new PhabricatorCheckboxesEditField()) 166 166 ->setKey('ignored') 167 167 ->setLabel(pht('Ignored Attributes')) 168 168 ->setDescription(pht('Ignore paths with any of these attributes.')) 169 169 ->setTransactionType( 170 170 PhabricatorOwnersPackageIgnoredTransaction::TRANSACTIONTYPE) 171 - ->setValue(array_keys($object->getIgnoredPathAttributes())), 171 + ->setValue(array_keys($object->getIgnoredPathAttributes())) 172 + ->setOptions( 173 + array( 174 + 'generated' => pht('Ignore generated files (review only).'), 175 + )), 172 176 id(new PhabricatorConduitEditField()) 173 177 ->setKey('paths.set') 174 178 ->setLabel(pht('Paths'))
+36
src/applications/transactions/editfield/PhabricatorCheckboxesEditField.php
··· 1 + <?php 2 + 3 + final class PhabricatorCheckboxesEditField 4 + extends PhabricatorEditField { 5 + 6 + private $options; 7 + 8 + protected function newControl() { 9 + $options = $this->getOptions(); 10 + 11 + return id(new AphrontFormCheckboxControl()) 12 + ->setOptions($options); 13 + } 14 + 15 + protected function newConduitParameterType() { 16 + return new ConduitStringListParameterType(); 17 + } 18 + 19 + protected function newHTTPParameterType() { 20 + return new AphrontStringListHTTPParameterType(); 21 + } 22 + 23 + public function setOptions(array $options) { 24 + $this->options = $options; 25 + return $this; 26 + } 27 + 28 + public function getOptions() { 29 + if ($this->options === null) { 30 + throw new PhutilInvalidStateException('setOptions'); 31 + } 32 + 33 + return $this->options; 34 + } 35 + 36 + }
+15
src/docs/user/userguide/owners.diviner
··· 132 132 write more sophisticated rules. 133 133 134 134 135 + Ignored Attributes 136 + ================== 137 + 138 + You can automatically exclude certain types of files, like generated files, 139 + with **Ignored Attributes**. 140 + 141 + When a package is marked as ignoring files with a particular attribute, and 142 + a file in a particular change has that attribute, the file will be ignored when 143 + computing ownership. 144 + 145 + (This feature is currently rough, only works for Differential revisions, and 146 + may not always compute the correct set of owning packages in some complex 147 + cases where it interacts with dominion rules.) 148 + 149 + 135 150 Files in Multiple Packages 136 151 ========================== 137 152
+30 -2
src/view/form/control/AphrontFormCheckboxControl.php
··· 34 34 return 'aphront-form-control-checkbox'; 35 35 } 36 36 37 + public function setOptions(array $options) { 38 + $boxes = array(); 39 + foreach ($options as $key => $value) { 40 + $boxes[] = array( 41 + 'value' => $key, 42 + 'label' => $value, 43 + ); 44 + } 45 + 46 + $this->boxes = $boxes; 47 + 48 + return $this; 49 + } 50 + 37 51 protected function renderInput() { 38 52 $rows = array(); 39 53 foreach ($this->boxes as $box) { ··· 41 55 if ($id === null) { 42 56 $id = celerity_generate_unique_node_id(); 43 57 } 58 + 59 + $name = idx($box, 'name'); 60 + if ($name === null) { 61 + $name = $this->getName().'[]'; 62 + } 63 + 64 + $value = $box['value']; 65 + 66 + if (array_key_exists('checked', $box)) { 67 + $checked = $box['checked']; 68 + } else { 69 + $checked = in_array($value, $this->getValue()); 70 + } 71 + 44 72 $checkbox = phutil_tag( 45 73 'input', 46 74 array( 47 75 'id' => $id, 48 76 'type' => 'checkbox', 49 - 'name' => $box['name'], 77 + 'name' => $name, 50 78 'value' => $box['value'], 51 - 'checked' => $box['checked'] ? 'checked' : null, 79 + 'checked' => $checked ? 'checked' : null, 52 80 'disabled' => $this->getDisabled() ? 'disabled' : null, 53 81 )); 54 82 $label = phutil_tag(