mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Modernize "favorite project policies" setting
Summary: Ref T4103. Convert this into a proper internal setting and use transactions to mutate it. Also remove some no-longer-used old non-modular settings constants. Test Plan: - Used policy dropdown, saw recently-used projects. - Selected some new projects, saw them appear. - Grepped for all removed constants. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16027
This commit is contained in:
parent
5c8ff3d37c
commit
44e88f186c
7 changed files with 33 additions and 37 deletions
|
@ -3031,6 +3031,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyEditField' => 'applications/transactions/editfield/PhabricatorPolicyEditField.php',
|
'PhabricatorPolicyEditField' => 'applications/transactions/editfield/PhabricatorPolicyEditField.php',
|
||||||
'PhabricatorPolicyException' => 'applications/policy/exception/PhabricatorPolicyException.php',
|
'PhabricatorPolicyException' => 'applications/policy/exception/PhabricatorPolicyException.php',
|
||||||
'PhabricatorPolicyExplainController' => 'applications/policy/controller/PhabricatorPolicyExplainController.php',
|
'PhabricatorPolicyExplainController' => 'applications/policy/controller/PhabricatorPolicyExplainController.php',
|
||||||
|
'PhabricatorPolicyFavoritesSetting' => 'applications/settings/setting/PhabricatorPolicyFavoritesSetting.php',
|
||||||
'PhabricatorPolicyFilter' => 'applications/policy/filter/PhabricatorPolicyFilter.php',
|
'PhabricatorPolicyFilter' => 'applications/policy/filter/PhabricatorPolicyFilter.php',
|
||||||
'PhabricatorPolicyInterface' => 'applications/policy/interface/PhabricatorPolicyInterface.php',
|
'PhabricatorPolicyInterface' => 'applications/policy/interface/PhabricatorPolicyInterface.php',
|
||||||
'PhabricatorPolicyManagementShowWorkflow' => 'applications/policy/management/PhabricatorPolicyManagementShowWorkflow.php',
|
'PhabricatorPolicyManagementShowWorkflow' => 'applications/policy/management/PhabricatorPolicyManagementShowWorkflow.php',
|
||||||
|
@ -7706,6 +7707,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyEditField' => 'PhabricatorEditField',
|
'PhabricatorPolicyEditField' => 'PhabricatorEditField',
|
||||||
'PhabricatorPolicyException' => 'Exception',
|
'PhabricatorPolicyException' => 'Exception',
|
||||||
'PhabricatorPolicyExplainController' => 'PhabricatorPolicyController',
|
'PhabricatorPolicyExplainController' => 'PhabricatorPolicyController',
|
||||||
|
'PhabricatorPolicyFavoritesSetting' => 'PhabricatorInternalSetting',
|
||||||
'PhabricatorPolicyFilter' => 'Phobject',
|
'PhabricatorPolicyFilter' => 'Phobject',
|
||||||
'PhabricatorPolicyInterface' => 'PhabricatorPHIDInterface',
|
'PhabricatorPolicyInterface' => 'PhabricatorPHIDInterface',
|
||||||
'PhabricatorPolicyManagementShowWorkflow' => 'PhabricatorPolicyManagementWorkflow',
|
'PhabricatorPolicyManagementShowWorkflow' => 'PhabricatorPolicyManagementWorkflow',
|
||||||
|
|
|
@ -606,15 +606,6 @@ final class PhabricatorUser
|
||||||
$preferences = new PhabricatorUserPreferences();
|
$preferences = new PhabricatorUserPreferences();
|
||||||
$preferences->setUserPHID($this->getPHID());
|
$preferences->setUserPHID($this->getPHID());
|
||||||
$preferences->attachUser($this);
|
$preferences->attachUser($this);
|
||||||
|
|
||||||
$default_dict = array(
|
|
||||||
PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph',
|
|
||||||
PhabricatorUserPreferences::PREFERENCE_EDITOR => '',
|
|
||||||
PhabricatorUserPreferences::PREFERENCE_MONOSPACED => '',
|
|
||||||
PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE => 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
$preferences->setPreferences($default_dict);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->preferences = $preferences;
|
$this->preferences = $preferences;
|
||||||
|
|
|
@ -281,10 +281,8 @@ final class PhabricatorPolicyEditController
|
||||||
// Save this project as one of the user's most recently used projects,
|
// Save this project as one of the user's most recently used projects,
|
||||||
// so we'll show it by default in future menus.
|
// so we'll show it by default in future menus.
|
||||||
|
|
||||||
$pref_key = PhabricatorUserPreferences::PREFERENCE_FAVORITE_POLICIES;
|
$favorites_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
|
||||||
|
$favorites = $viewer->getUserSetting($favorites_key);
|
||||||
$preferences = $viewer->loadPreferences();
|
|
||||||
$favorites = $preferences->getPreference($pref_key);
|
|
||||||
if (!is_array($favorites)) {
|
if (!is_array($favorites)) {
|
||||||
$favorites = array();
|
$favorites = array();
|
||||||
}
|
}
|
||||||
|
@ -293,8 +291,17 @@ final class PhabricatorPolicyEditController
|
||||||
unset($favorites[$project_phid]);
|
unset($favorites[$project_phid]);
|
||||||
$favorites[$project_phid] = true;
|
$favorites[$project_phid] = true;
|
||||||
|
|
||||||
$preferences->setPreference($pref_key, $favorites);
|
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
|
||||||
$preferences->save();
|
|
||||||
|
$editor = id(new PhabricatorUserPreferencesEditor())
|
||||||
|
->setActor($viewer)
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true);
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
$xactions[] = $preferences->newTransaction($favorites_key, $favorites);
|
||||||
|
$editor->applyTransactions($preferences, $xactions);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'phid' => $project->getPHID(),
|
'phid' => $project->getPHID(),
|
||||||
|
|
|
@ -195,7 +195,7 @@ final class PhabricatorPolicyQuery
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
if ($viewer->getPHID()) {
|
if ($viewer->getPHID()) {
|
||||||
$pref_key = PhabricatorUserPreferences::PREFERENCE_FAVORITE_POLICIES;
|
$pref_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
|
||||||
|
|
||||||
$favorite_limit = 10;
|
$favorite_limit = 10;
|
||||||
$default_limit = 5;
|
$default_limit = 5;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPolicyFavoritesSetting
|
||||||
|
extends PhabricatorInternalSetting {
|
||||||
|
|
||||||
|
const SETTINGKEY = 'policy.favorites';
|
||||||
|
|
||||||
|
public function getSettingName() {
|
||||||
|
return pht('Policy Favorites');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSettingDefaultValue() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,16 +7,6 @@ final class PhabricatorUserPreferences
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorApplicationTransactionInterface {
|
PhabricatorApplicationTransactionInterface {
|
||||||
|
|
||||||
const PREFERENCE_MONOSPACED = 'monospaced';
|
|
||||||
const PREFERENCE_DARK_CONSOLE = 'dark_console';
|
|
||||||
const PREFERENCE_EDITOR = 'editor';
|
|
||||||
const PREFERENCE_MULTIEDIT = 'multiedit';
|
|
||||||
const PREFERENCE_TITLES = 'titles';
|
|
||||||
const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas';
|
|
||||||
const PREFERENCE_DATE_FORMAT = 'date-format';
|
|
||||||
const PREFERENCE_TIME_FORMAT = 'time-format';
|
|
||||||
const PREFERENCE_WEEK_START_DAY = 'week-start-day';
|
|
||||||
|
|
||||||
const PREFERENCE_RE_PREFIX = 're-prefix';
|
const PREFERENCE_RE_PREFIX = 're-prefix';
|
||||||
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
|
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
|
||||||
const PREFERENCE_NO_MAIL = 'no-mail';
|
const PREFERENCE_NO_MAIL = 'no-mail';
|
||||||
|
@ -25,22 +15,12 @@ final class PhabricatorUserPreferences
|
||||||
const PREFERENCE_HTML_EMAILS = 'html-emails';
|
const PREFERENCE_HTML_EMAILS = 'html-emails';
|
||||||
|
|
||||||
const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed';
|
const PREFERENCE_NAV_COLLAPSED = 'nav-collapsed';
|
||||||
const PREFERENCE_NAV_WIDTH = 'nav-width';
|
|
||||||
const PREFERENCE_APP_TILES = 'app-tiles';
|
const PREFERENCE_APP_TILES = 'app-tiles';
|
||||||
const PREFERENCE_APP_PINNED = 'app-pinned';
|
const PREFERENCE_APP_PINNED = 'app-pinned';
|
||||||
|
|
||||||
const PREFERENCE_DIFF_UNIFIED = 'diff-unified';
|
|
||||||
const PREFERENCE_DIFF_FILETREE = 'diff-filetree';
|
|
||||||
const PREFERENCE_DIFF_GHOSTS = 'diff-ghosts';
|
|
||||||
|
|
||||||
const PREFERENCE_CONPH_NOTIFICATIONS = 'conph-notifications';
|
|
||||||
const PREFERENCE_CONPHERENCE_COLUMN = 'conpherence-column';
|
const PREFERENCE_CONPHERENCE_COLUMN = 'conpherence-column';
|
||||||
|
|
||||||
const PREFERENCE_RESOURCE_POSTPROCESSOR = 'resource-postprocessor';
|
|
||||||
const PREFERENCE_DESKTOP_NOTIFICATIONS = 'desktop-notifications';
|
const PREFERENCE_DESKTOP_NOTIFICATIONS = 'desktop-notifications';
|
||||||
|
|
||||||
const PREFERENCE_PROFILE_MENU_COLLAPSED = 'profile-menu.collapsed';
|
const PREFERENCE_PROFILE_MENU_COLLAPSED = 'profile-menu.collapsed';
|
||||||
const PREFERENCE_FAVORITE_POLICIES = 'policy.favorites';
|
|
||||||
|
|
||||||
// These are in an unusual order for historic reasons.
|
// These are in an unusual order for historic reasons.
|
||||||
const MAILTAG_PREFERENCE_NOTIFY = 0;
|
const MAILTAG_PREFERENCE_NOTIFY = 0;
|
||||||
|
|
|
@ -575,7 +575,7 @@ final class PHUICalendarMonthView extends AphrontView {
|
||||||
|
|
||||||
private function getWeekStartAndEnd() {
|
private function getWeekStartAndEnd() {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$week_key = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
|
$week_key = PhabricatorWeekStartDaySetting::SETTINGKEY;
|
||||||
|
|
||||||
$week_start = $viewer->getUserSetting($week_key);
|
$week_start = $viewer->getUserSetting($week_key);
|
||||||
$week_end = ($week_start + 6) % 7;
|
$week_end = ($week_start + 6) % 7;
|
||||||
|
|
Loading…
Reference in a new issue