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

Improve UX for Diffusion mail fields

Summary:
- Give the fields names and descriptions.
- When new, default-disabled fields are added, disable them by default even if there's already a config.
- Be a bit less hacky about `$faux_spec`.

Test Plan: {F432383}

Reviewers: joshuaspence, fabe

Reviewed By: fabe

Subscribers: epriestley

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

+62 -21
+1 -3
src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
··· 145 145 id(new PhabricatorRepositoryCommit()) 146 146 ->getCustomFieldBaseClass()) 147 147 ->setDescription( 148 - pht( 149 - "Select and reorder diffusion fields.\n\n". 150 - "These will primarily show up in Mail Notifications.")), 148 + pht('Select and reorder Diffusion fields.')), 151 149 ); 152 150 } 153 151
+8
src/applications/repository/customfield/PhabricatorCommitBranchesField.php
··· 7 7 return 'diffusion:branches'; 8 8 } 9 9 10 + public function getFieldName() { 11 + return pht('Branches'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('Shows branches a commit appears on in email.'); 16 + } 17 + 10 18 public function shouldAppearInTransactionMail() { 11 19 return true; 12 20 }
+8
src/applications/repository/customfield/PhabricatorCommitMergedCommitsField.php
··· 7 7 return 'diffusion:mergedcommits'; 8 8 } 9 9 10 + public function getFieldName() { 11 + return pht('Merged Commits'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('For merge commits, shows merged changes in email.'); 16 + } 17 + 10 18 public function shouldDisableByDefault() { 11 19 return true; 12 20 }
+8
src/applications/repository/customfield/PhabricatorCommitRepositoryField.php
··· 7 7 return 'diffusion:repository'; 8 8 } 9 9 10 + public function getFieldName() { 11 + return pht('Repository'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('Shows repository in email.'); 16 + } 17 + 10 18 public function shouldDisableByDefault() { 11 19 return true; 12 20 }
+8
src/applications/repository/customfield/PhabricatorCommitTagsField.php
··· 7 7 return 'diffusion:tags'; 8 8 } 9 9 10 + public function getFieldName() { 11 + return pht('Tags'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('Shows commit tags in email.'); 16 + } 17 + 10 18 public function shouldAppearInTransactionMail() { 11 19 return true; 12 20 }
+7 -10
src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
··· 34 34 $field_spec = PhabricatorEnv::getEnvConfig($option->getKey()); 35 35 } 36 36 37 - // Get all of the fields (including disabled fields) by querying for them 38 - // with a faux spec where no fields are disabled. 39 - $faux_spec = $field_spec; 40 - foreach ($faux_spec as $key => $spec) { 41 - unset($faux_spec[$key]['disabled']); 42 - } 43 - 44 37 // TODO: We might need to build a real object here eventually. 45 38 $faux_object = null; 46 39 47 40 $fields = PhabricatorCustomField::buildFieldList( 48 41 $field_base_class, 49 - $faux_spec, 50 - $faux_object); 42 + $field_spec, 43 + $faux_object, 44 + array( 45 + 'withDisabled' => true, 46 + )); 51 47 52 48 $list_id = celerity_generate_unique_node_id(); 53 49 $input_id = celerity_generate_unique_node_id(); ··· 63 59 ->addAttribute($field->getFieldDescription()) 64 60 ->setHeader($field->getFieldName()); 65 61 66 - $is_disabled = !empty($field_spec[$key]['disabled']); 62 + $spec = idx($field_spec, $key, array()); 63 + $is_disabled = idx($spec, 'disabled', $field->shouldDisableByDefault()); 67 64 68 65 $disabled_item = clone $item; 69 66 $enabled_item = clone $item;
+22 -8
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 105 105 /** 106 106 * @task apps 107 107 */ 108 - public static function buildFieldList($base_class, array $spec, $object) { 108 + public static function buildFieldList( 109 + $base_class, 110 + array $spec, 111 + $object, 112 + array $options = array()) { 113 + 114 + PhutilTypeSpec::checkMap( 115 + $options, 116 + array( 117 + 'withDisabled' => 'optional bool', 118 + )); 119 + 109 120 $field_objects = id(new PhutilSymbolLoader()) 110 121 ->setAncestorClass($base_class) 111 122 ->loadObjects(); ··· 135 146 136 147 $fields = array_select_keys($fields, array_keys($spec)) + $fields; 137 148 138 - foreach ($spec as $key => $config) { 139 - if (empty($fields[$key])) { 140 - continue; 141 - } 142 - if (!empty($config['disabled'])) { 143 - if ($fields[$key]->canDisableField()) { 144 - unset($fields[$key]); 149 + if (empty($options['withDisabled'])) { 150 + foreach ($fields as $key => $field) { 151 + $config = idx($spec, $key, array()) + array( 152 + 'disabled' => $field->shouldDisableByDefault(), 153 + ); 154 + 155 + if (!empty($config['disabled'])) { 156 + if ($field->canDisableField()) { 157 + unset($fields[$key]); 158 + } 145 159 } 146 160 } 147 161 }