Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14065169
D13006.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13006.diff
View Options
diff --git a/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
--- a/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
+++ b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
@@ -145,9 +145,7 @@
id(new PhabricatorRepositoryCommit())
->getCustomFieldBaseClass())
->setDescription(
- pht(
- "Select and reorder diffusion fields.\n\n".
- "These will primarily show up in Mail Notifications.")),
+ pht('Select and reorder Diffusion fields.')),
);
}
diff --git a/src/applications/repository/customfield/PhabricatorCommitBranchesField.php b/src/applications/repository/customfield/PhabricatorCommitBranchesField.php
--- a/src/applications/repository/customfield/PhabricatorCommitBranchesField.php
+++ b/src/applications/repository/customfield/PhabricatorCommitBranchesField.php
@@ -7,6 +7,14 @@
return 'diffusion:branches';
}
+ public function getFieldName() {
+ return pht('Branches');
+ }
+
+ public function getFieldDescription() {
+ return pht('Shows branches a commit appears on in email.');
+ }
+
public function shouldAppearInTransactionMail() {
return true;
}
diff --git a/src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php b/src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
--- a/src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
+++ b/src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
@@ -7,6 +7,14 @@
return 'diffusion:mergedcommits';
}
+ public function getFieldName() {
+ return pht('Merged Commits');
+ }
+
+ public function getFieldDescription() {
+ return pht('For merge commits, shows merged changes in email.');
+ }
+
public function shouldDisableByDefault() {
return true;
}
diff --git a/src/applications/repository/customfield/PhabricatorCommitRepositoryField.php b/src/applications/repository/customfield/PhabricatorCommitRepositoryField.php
--- a/src/applications/repository/customfield/PhabricatorCommitRepositoryField.php
+++ b/src/applications/repository/customfield/PhabricatorCommitRepositoryField.php
@@ -7,6 +7,14 @@
return 'diffusion:repository';
}
+ public function getFieldName() {
+ return pht('Repository');
+ }
+
+ public function getFieldDescription() {
+ return pht('Shows repository in email.');
+ }
+
public function shouldDisableByDefault() {
return true;
}
diff --git a/src/applications/repository/customfield/PhabricatorCommitTagsField.php b/src/applications/repository/customfield/PhabricatorCommitTagsField.php
--- a/src/applications/repository/customfield/PhabricatorCommitTagsField.php
+++ b/src/applications/repository/customfield/PhabricatorCommitTagsField.php
@@ -7,6 +7,14 @@
return 'diffusion:tags';
}
+ public function getFieldName() {
+ return pht('Tags');
+ }
+
+ public function getFieldDescription() {
+ return pht('Shows commit tags in email.');
+ }
+
public function shouldAppearInTransactionMail() {
return true;
}
diff --git a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
--- a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
+++ b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
@@ -34,20 +34,16 @@
$field_spec = PhabricatorEnv::getEnvConfig($option->getKey());
}
- // Get all of the fields (including disabled fields) by querying for them
- // with a faux spec where no fields are disabled.
- $faux_spec = $field_spec;
- foreach ($faux_spec as $key => $spec) {
- unset($faux_spec[$key]['disabled']);
- }
-
// TODO: We might need to build a real object here eventually.
$faux_object = null;
$fields = PhabricatorCustomField::buildFieldList(
$field_base_class,
- $faux_spec,
- $faux_object);
+ $field_spec,
+ $faux_object,
+ array(
+ 'withDisabled' => true,
+ ));
$list_id = celerity_generate_unique_node_id();
$input_id = celerity_generate_unique_node_id();
@@ -63,7 +59,8 @@
->addAttribute($field->getFieldDescription())
->setHeader($field->getFieldName());
- $is_disabled = !empty($field_spec[$key]['disabled']);
+ $spec = idx($field_spec, $key, array());
+ $is_disabled = idx($spec, 'disabled', $field->shouldDisableByDefault());
$disabled_item = clone $item;
$enabled_item = clone $item;
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -105,7 +105,18 @@
/**
* @task apps
*/
- public static function buildFieldList($base_class, array $spec, $object) {
+ public static function buildFieldList(
+ $base_class,
+ array $spec,
+ $object,
+ array $options = array()) {
+
+ PhutilTypeSpec::checkMap(
+ $options,
+ array(
+ 'withDisabled' => 'optional bool',
+ ));
+
$field_objects = id(new PhutilSymbolLoader())
->setAncestorClass($base_class)
->loadObjects();
@@ -135,13 +146,16 @@
$fields = array_select_keys($fields, array_keys($spec)) + $fields;
- foreach ($spec as $key => $config) {
- if (empty($fields[$key])) {
- continue;
- }
- if (!empty($config['disabled'])) {
- if ($fields[$key]->canDisableField()) {
- unset($fields[$key]);
+ if (empty($options['withDisabled'])) {
+ foreach ($fields as $key => $field) {
+ $config = idx($spec, $key, array()) + array(
+ 'disabled' => $field->shouldDisableByDefault(),
+ );
+
+ if (!empty($config['disabled'])) {
+ if ($field->canDisableField()) {
+ unset($fields[$key]);
+ }
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 20, 3:27 AM (22 h, 14 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712795
Default Alt Text
D13006.diff (6 KB)
Attached To
Mode
D13006: Improve UX for Diffusion mail fields
Attached
Detach File
Event Timeline
Log In to Comment