1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-28 04:00:17 +01:00

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
This commit is contained in:
epriestley 2018-05-07 14:09:15 -07:00
parent fddb506e98
commit 304c6a4597
5 changed files with 89 additions and 4 deletions

View file

@ -2525,6 +2525,7 @@ phutil_register_library_map(array(
'PhabricatorChatLogDAO' => 'applications/chatlog/storage/PhabricatorChatLogDAO.php',
'PhabricatorChatLogEvent' => 'applications/chatlog/storage/PhabricatorChatLogEvent.php',
'PhabricatorChatLogQuery' => 'applications/chatlog/query/PhabricatorChatLogQuery.php',
'PhabricatorCheckboxesEditField' => 'applications/transactions/editfield/PhabricatorCheckboxesEditField.php',
'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php',
'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php',
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
@ -8140,6 +8141,7 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface',
),
'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCheckboxesEditField' => 'PhabricatorEditField',
'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorClassConfigType' => 'PhabricatorTextConfigType',
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',

View file

@ -162,13 +162,17 @@ EOTEXT
->setIsConduitOnly(true)
->setValue($object->getStatus())
->setOptions($object->getStatusNameMap()),
id(new PhabricatorStringListEditField())
id(new PhabricatorCheckboxesEditField())
->setKey('ignored')
->setLabel(pht('Ignored Attributes'))
->setDescription(pht('Ignore paths with any of these attributes.'))
->setTransactionType(
PhabricatorOwnersPackageIgnoredTransaction::TRANSACTIONTYPE)
->setValue(array_keys($object->getIgnoredPathAttributes())),
->setValue(array_keys($object->getIgnoredPathAttributes()))
->setOptions(
array(
'generated' => pht('Ignore generated files (review only).'),
)),
id(new PhabricatorConduitEditField())
->setKey('paths.set')
->setLabel(pht('Paths'))

View file

@ -0,0 +1,36 @@
<?php
final class PhabricatorCheckboxesEditField
extends PhabricatorEditField {
private $options;
protected function newControl() {
$options = $this->getOptions();
return id(new AphrontFormCheckboxControl())
->setOptions($options);
}
protected function newConduitParameterType() {
return new ConduitStringListParameterType();
}
protected function newHTTPParameterType() {
return new AphrontStringListHTTPParameterType();
}
public function setOptions(array $options) {
$this->options = $options;
return $this;
}
public function getOptions() {
if ($this->options === null) {
throw new PhutilInvalidStateException('setOptions');
}
return $this->options;
}
}

View file

@ -132,6 +132,21 @@ behavior. If you want more powerful auditing behavior, you can use Herald to
write more sophisticated rules.
Ignored Attributes
==================
You can automatically exclude certain types of files, like generated files,
with **Ignored Attributes**.
When a package is marked as ignoring files with a particular attribute, and
a file in a particular change has that attribute, the file will be ignored when
computing ownership.
(This feature is currently rough, only works for Differential revisions, and
may not always compute the correct set of owning packages in some complex
cases where it interacts with dominion rules.)
Files in Multiple Packages
==========================

View file

@ -34,6 +34,20 @@ final class AphrontFormCheckboxControl extends AphrontFormControl {
return 'aphront-form-control-checkbox';
}
public function setOptions(array $options) {
$boxes = array();
foreach ($options as $key => $value) {
$boxes[] = array(
'value' => $key,
'label' => $value,
);
}
$this->boxes = $boxes;
return $this;
}
protected function renderInput() {
$rows = array();
foreach ($this->boxes as $box) {
@ -41,14 +55,28 @@ final class AphrontFormCheckboxControl extends AphrontFormControl {
if ($id === null) {
$id = celerity_generate_unique_node_id();
}
$name = idx($box, 'name');
if ($name === null) {
$name = $this->getName().'[]';
}
$value = $box['value'];
if (array_key_exists('checked', $box)) {
$checked = $box['checked'];
} else {
$checked = in_array($value, $this->getValue());
}
$checkbox = phutil_tag(
'input',
array(
'id' => $id,
'type' => 'checkbox',
'name' => $box['name'],
'name' => $name,
'value' => $box['value'],
'checked' => $box['checked'] ? 'checked' : null,
'checked' => $checked ? 'checked' : null,
'disabled' => $this->getDisabled() ? 'disabled' : null,
));
$label = phutil_tag(