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

Convert maniphest to use standard fields

Summary: Ref T3794. Drop auxiliary field, use standard field.

Test Plan: Performed migration, field seemed to survive it intact. Edited and viewed tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3794

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

+136 -50
+66
resources/sql/patches/20130919.mfieldconf.php
··· 1 + <?php 2 + 3 + echo "Migrating Maniphest custom field configuration...\n"; 4 + 5 + $old_key = 'maniphest.custom-fields'; 6 + $new_key = 'maniphest.custom-field-definitions'; 7 + 8 + if (PhabricatorEnv::getEnvConfig($new_key)) { 9 + echo "Skipping migration, new data is already set.\n"; 10 + return; 11 + } 12 + 13 + $old = PhabricatorEnv::getEnvConfigIfExists($old_key); 14 + if (!$old) { 15 + echo "Skipping migration, old data does not exist.\n"; 16 + return; 17 + } 18 + 19 + $new = array(); 20 + foreach ($old as $field_key => $spec) { 21 + $new_spec = array(); 22 + 23 + foreach ($spec as $key => $value) { 24 + switch ($key) { 25 + case 'label': 26 + $new_spec['name'] = $value; 27 + break; 28 + case 'required': 29 + case 'default': 30 + case 'caption': 31 + case 'options': 32 + $new_spec[$key] = $value; 33 + break; 34 + case 'checkbox-label': 35 + $new_spec['strings']['edit.checkbox'] = $value; 36 + break; 37 + case 'checkbox-value': 38 + $new_spec['strings']['view.yes'] = $value; 39 + break; 40 + case 'type': 41 + switch ($value) { 42 + case 'string': 43 + $value = 'text'; 44 + break; 45 + case 'user': 46 + $value = 'users'; 47 + $new_spec['limit'] = 1; 48 + break; 49 + } 50 + $new_spec['type'] = $value; 51 + break; 52 + case 'copy': 53 + $new_spec['copy'] = $value; 54 + break; 55 + } 56 + } 57 + 58 + $new[$field_key] = $new_spec; 59 + } 60 + 61 + PhabricatorConfigEntry::loadConfigEntry($new_key) 62 + ->setIsDeleted(0) 63 + ->setValue($new) 64 + ->save(); 65 + 66 + echo "Done.\n";
+6
src/__phutil_library_map__.php
··· 688 688 'ManiphestAuxiliaryFieldDefaultSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php', 689 689 'ManiphestAuxiliaryFieldSpecification' => 'applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldSpecification.php', 690 690 'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php', 691 + 'ManiphestConfiguredCustomField' => 'applications/maniphest/field/ManiphestConfiguredCustomField.php', 691 692 'ManiphestConstants' => 'applications/maniphest/constants/ManiphestConstants.php', 692 693 'ManiphestController' => 'applications/maniphest/controller/ManiphestController.php', 693 694 'ManiphestCreateMailReceiver' => 'applications/maniphest/mail/ManiphestCreateMailReceiver.php', ··· 2765 2766 1 => 'PhabricatorMarkupInterface', 2766 2767 ), 2767 2768 'ManiphestBatchEditController' => 'ManiphestController', 2769 + 'ManiphestConfiguredCustomField' => 2770 + array( 2771 + 0 => 'ManiphestCustomField', 2772 + 1 => 'PhabricatorStandardCustomFieldInterface', 2773 + ), 2768 2774 'ManiphestController' => 'PhabricatorController', 2769 2775 'ManiphestCreateMailReceiver' => 'PhabricatorMailReceiver', 2770 2776 'ManiphestCustomField' => 'PhabricatorCustomField',
+5
src/applications/config/check/PhabricatorSetupCheckExtraConfig.php
··· 150 150 pht( 151 151 'Maniphest fields are now loaded automatically. You can configure '. 152 152 'them with `maniphest.fields`.'), 153 + 'maniphest.custom-fields' => 154 + pht( 155 + 'Maniphest fields are now defined in '. 156 + '`maniphest.custom-field-definitions`. Existing definitions have '. 157 + 'been migrated.'), 153 158 ); 154 159 155 160 return $ancient_config;
+1 -26
src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php
··· 26 26 const TYPE_HEADER = 'header'; 27 27 28 28 public function createFields() { 29 - $fields = PhabricatorEnv::getEnvConfig('maniphest.custom-fields'); 30 - $specs = array(); 31 - foreach ($fields as $aux => $info) { 32 - $spec = new ManiphestAuxiliaryFieldDefaultSpecification(); 33 - $spec->setAuxiliaryKey($aux); 34 - $spec->setLabel(idx($info, 'label')); 35 - $spec->setCaption(idx($info, 'caption')); 36 - $spec->setFieldType(idx($info, 'type')); 37 - $spec->setRequired(idx($info, 'required')); 38 - 39 - $spec->setCheckboxLabel(idx($info, 'checkbox-label')); 40 - $spec->setCheckboxValue(idx($info, 'checkbox-value', 1)); 41 - 42 - if ($spec->getFieldType() == 43 - ManiphestAuxiliaryFieldDefaultSpecification::TYPE_SELECT) { 44 - $spec->setSelectOptions(idx($info, 'options')); 45 - } 46 - 47 - $spec->setShouldCopyWhenCreatingSimilarTask(idx($info, 'copy')); 48 - 49 - $spec->setDefaultValue(idx($info, 'default')); 50 - 51 - $specs[] = $spec; 52 - } 53 - 54 - return $specs; 29 + return array(); 55 30 } 56 31 57 32 public function getFieldType() {
+3 -3
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 59 59 $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; 60 60 61 61 return array( 62 - $this->newOption('maniphest.custom-fields', 'wild', array()) 62 + $this->newOption('maniphest.custom-field-definitions', 'wild', array()) 63 63 ->setSummary(pht("Custom Maniphest fields.")) 64 64 ->setDescription( 65 65 pht( ··· 67 67 "adding custom fields to Maniphest, see 'Maniphest User Guide: ". 68 68 "Adding Custom Fields'.")) 69 69 ->addExample( 70 - '{"mycompany:estimated-hours": {"label": "Estimated Hours", '. 70 + '{"mycompany:estimated-hours": {"name": "Estimated Hours", '. 71 71 '"type": "int", "caption": "Estimated number of hours this will '. 72 - 'take.", "required": false}}', 72 + 'take."}}', 73 73 pht('Valid Setting')), 74 74 $this->newOption('maniphest.fields', $custom_field_type, $default_fields) 75 75 ->setCustomData(id(new ManiphestTask())->getCustomFieldBaseClass())
+15 -3
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 229 229 ManiphestTransactionType::TYPE_AUXILIARY); 230 230 $aux_key = $aux_field->getFieldKey(); 231 231 $transaction->setMetadataValue('aux:key', $aux_key); 232 - $transaction->setOldValue(idx($old_values, $aux_key)); 233 - $transaction->setNewValue( 234 - $aux_field->getNewValueForApplicationTransactions()); 232 + $old = idx($old_values, $aux_key); 233 + $new = $aux_field->getNewValueForApplicationTransactions(); 234 + 235 + // TODO: This is a ghetto check for transactions with no effect. 236 + if (!is_array($old) && !is_array($new)) { 237 + if ((string)$old === (string)$new) { 238 + continue; 239 + } 240 + } else if ($old == $new) { 241 + continue; 242 + } 243 + 244 + $transaction->setOldValue($old); 245 + $transaction->setNewValue($new); 246 + 235 247 $transactions[] = $transaction; 236 248 } 237 249 }
+22
src/applications/maniphest/field/ManiphestConfiguredCustomField.php
··· 1 + <?php 2 + 3 + final class ManiphestConfiguredCustomField 4 + extends ManiphestCustomField 5 + implements PhabricatorStandardCustomFieldInterface { 6 + 7 + public function getStandardCustomFieldNamespace() { 8 + return 'maniphest'; 9 + } 10 + 11 + public function createFields() { 12 + $config = PhabricatorEnv::getEnvConfig( 13 + 'maniphest.custom-field-definitions', 14 + array()); 15 + $fields = PhabricatorStandardCustomField::buildStandardFields( 16 + $this, 17 + $config); 18 + 19 + return $fields; 20 + } 21 + 22 + }
+7 -2
src/applications/maniphest/field/ManiphestCustomField.php
··· 81 81 public function renderTransactionDescription( 82 82 ManiphestTransaction $transaction, 83 83 $target) { 84 - return 'updated a custom field'; 84 + $old = $transaction->getOldValue(); 85 + $new = $transaction->getNewValue(); 86 + return pht( 87 + 'updated field %s from %s to %s', 88 + $this->getFieldName(), 89 + $old, 90 + $new); 85 91 } 86 92 87 93 public function getMarkupFields() { 88 94 return array(); 89 95 } 90 - 91 96 92 97 }
+7 -16
src/docs/user/userguide/maniphest_custom.diviner
··· 22 22 can add simple fields. These allow you to attach things like strings, numbers, 23 23 and dropdown menus to the task template. 24 24 25 - Customize Maniphest fields by setting ##maniphest.custom-fields## in your 26 - configuration. For example, suppose you want to add "Estimated Hours" and 25 + Customize Maniphest fields by setting `maniphest.custom-field-definitions` in 26 + your configuration. For example, suppose you want to add "Estimated Hours" and 27 27 "Actual Hours" fields. To do this, set your configuration like this: 28 28 29 29 'maniphest.custom-fields' => array( 30 30 'mycompany:estimated-hours' => array( 31 - 'label' => 'Estimated Hours', 31 + 'name' => 'Estimated Hours', 32 32 'type' => 'int', 33 33 'caption' => 'Estimated number of hours this will take.', 34 - 'required' => false, 34 + 'required' => true, 35 35 ), 36 36 'mycompany:actual-hours' => array( 37 - 'label' => 'Actual Hours', 37 + 'name' => 'Actual Hours', 38 38 'type' => 'int', 39 - 'required' => false, 40 39 ), 41 40 ) 42 41 43 42 Each array key must be unique, and is used to organize the internal storage of 44 43 the field. These options are available: 45 44 46 - - **label**: Display label for the field on the edit and detail interfaces. 45 + - **name**: Display label for the field on the edit and detail interfaces. 47 46 - **type**: Field type. The supported field types are: 48 47 - **int**: An integer, rendered as a text field. 49 - - **string**: A string, rendered as a text field. 48 + - **text**: A string, rendered as a text field. 50 49 - **bool**: A boolean value, rendered as a checkbox. 51 50 - **select**: Allows the user to select from several options, rendered 52 51 as a dropdown. 53 52 - **remarkup**: A text area which allows the user to enter markup. 54 - - **user**: A single user typeahead. 55 53 - **users**: A typeahead which allows multiple users to be input. 56 54 - **date**: A date/time picker. 57 55 - **header**: Renders a visual divider which you can use to group fields. ··· 59 57 - **required**: True if the user should be required to provide a value. 60 58 - **options**: If type is set to **select**, provide options for the dropdown 61 59 as a dictionary. 62 - - **checkbox-label**: If type is set to **bool**, an optional string to 63 - show next to the checkbox. 64 - - **checkbox-value**: If type is set to **bool**, the value to show on 65 - the detail view when the checkbox is selected. 66 60 - **default**: Default field value. 67 - - For **date**, you can use a string like `"July 4, 1990"`, `"5PM today"`, 68 - or any other valid input to `strtotime()`. 69 - - For **user** and **users**, you can use an array of user PHIDs. 70 61 - **copy**: When a user creates a task, the UI gives them an option to 71 62 "Create Another Similar Task". Some fields from the original task are copied 72 63 into the new task, while others are not; by default, fields are not copied.
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1604 1604 'type' => 'php', 1605 1605 'name' => $this->getPatchPath('20130915.maniphestmigrate.php'), 1606 1606 ), 1607 + '20130919.mfieldconf.php' => array( 1608 + 'type' => 'php', 1609 + 'name' => $this->getPatchPath('20130919.mfieldconf.php'), 1610 + ), 1607 1611 ); 1608 1612 } 1609 1613 }