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

Make the data export format selector remember your last setting

Summary:
Depends on D18956. Ref T13049. Make the "Export Format" selector sticky.

This is partly selfish, since it makes testing format changes a bit easier.

It also seems like it's probably a good behavior in general: if you export to Excel once, that's probably what you're going to pick next time.

Test Plan: Exported to excel. Exported again, got excel as the default option.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13049

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

+56
+2
src/__phutil_library_map__.php
··· 2852 2852 'PhabricatorExportEngineExtension' => 'infrastructure/export/engine/PhabricatorExportEngineExtension.php', 2853 2853 'PhabricatorExportField' => 'infrastructure/export/field/PhabricatorExportField.php', 2854 2854 'PhabricatorExportFormat' => 'infrastructure/export/format/PhabricatorExportFormat.php', 2855 + 'PhabricatorExportFormatSetting' => 'infrastructure/export/engine/PhabricatorExportFormatSetting.php', 2855 2856 'PhabricatorExtendedPolicyInterface' => 'applications/policy/interface/PhabricatorExtendedPolicyInterface.php', 2856 2857 'PhabricatorExtendingPhabricatorConfigOptions' => 'applications/config/option/PhabricatorExtendingPhabricatorConfigOptions.php', 2857 2858 'PhabricatorExtensionsSetupCheck' => 'applications/config/check/PhabricatorExtensionsSetupCheck.php', ··· 8288 8289 'PhabricatorExportEngineExtension' => 'Phobject', 8289 8290 'PhabricatorExportField' => 'Phobject', 8290 8291 'PhabricatorExportFormat' => 'Phobject', 8292 + 'PhabricatorExportFormatSetting' => 'PhabricatorInternalSetting', 8291 8293 'PhabricatorExtendingPhabricatorConfigOptions' => 'PhabricatorApplicationConfigOptions', 8292 8294 'PhabricatorExtensionsSetupCheck' => 'PhabricatorSetupCheck', 8293 8295 'PhabricatorExternalAccount' => array(
+38
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 421 421 $formats = PhabricatorExportFormat::getAllEnabledExportFormats(); 422 422 $format_options = mpull($formats, 'getExportFormatName'); 423 423 424 + // Try to default to the format the user used last time. If you just 425 + // exported to Excel, you probably want to export to Excel again. 426 + $format_key = $this->readExportFormatPreference(); 427 + if (!isset($formats[$format_key])) { 428 + $format_key = head_key($format_options); 429 + } 430 + 424 431 $errors = array(); 425 432 426 433 $e_format = null; ··· 434 441 } 435 442 436 443 if (!$errors) { 444 + $this->writeExportFormatPreference($format_key); 445 + 437 446 $query = $engine->buildQueryFromSavedQuery($saved_query); 438 447 439 448 // NOTE: We aren't reading the pager from the request. Exports always ··· 497 506 ->setName('format') 498 507 ->setLabel(pht('Format')) 499 508 ->setError($e_format) 509 + ->setValue($format_key) 500 510 ->setOptions($format_options)); 501 511 502 512 return $this->newDialog() ··· 910 920 } 911 921 912 922 return true; 923 + } 924 + 925 + private function readExportFormatPreference() { 926 + $viewer = $this->getViewer(); 927 + $export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 928 + return $viewer->getUserSetting($export_key); 929 + } 930 + 931 + private function writeExportFormatPreference($value) { 932 + $viewer = $this->getViewer(); 933 + $request = $this->getRequest(); 934 + 935 + if (!$viewer->isLoggedIn()) { 936 + return; 937 + } 938 + 939 + $export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 940 + $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); 941 + 942 + $editor = id(new PhabricatorUserPreferencesEditor()) 943 + ->setActor($viewer) 944 + ->setContentSourceFromRequest($request) 945 + ->setContinueOnNoEffect(true) 946 + ->setContinueOnMissingFields(true); 947 + 948 + $xactions = array(); 949 + $xactions[] = $preferences->newTransaction($export_key, $value); 950 + $editor->applyTransactions($preferences, $xactions); 913 951 } 914 952 915 953 }
+16
src/infrastructure/export/engine/PhabricatorExportFormatSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorExportFormatSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'export.format'; 7 + 8 + public function getSettingName() { 9 + return pht('Export Format'); 10 + } 11 + 12 + public function getSettingDefaultValue() { 13 + return null; 14 + } 15 + 16 + }