Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15334139
D16017.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
31 KB
Referenced Files
None
Subscribers
None
D16017.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2372,6 +2372,7 @@
'PhabricatorEditEngineQuery' => 'applications/transactions/query/PhabricatorEditEngineQuery.php',
'PhabricatorEditEngineSearchEngine' => 'applications/transactions/query/PhabricatorEditEngineSearchEngine.php',
'PhabricatorEditEngineSelectCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineSelectCommentAction.php',
+ 'PhabricatorEditEngineSettingsPanel' => 'applications/settings/panel/PhabricatorEditEngineSettingsPanel.php',
'PhabricatorEditEngineTokenizerCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineTokenizerCommentAction.php',
'PhabricatorEditField' => 'applications/transactions/editfield/PhabricatorEditField.php',
'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php',
@@ -6167,7 +6168,7 @@
'PhabricatorAccessLog' => 'Phobject',
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorAccessibilitySetting' => 'PhabricatorSelectSetting',
- 'PhabricatorAccountSettingsPanel' => 'PhabricatorSettingsPanel',
+ 'PhabricatorAccountSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
'PhabricatorActionListView' => 'AphrontView',
'PhabricatorActionView' => 'AphrontView',
'PhabricatorActivitySettingsPanel' => 'PhabricatorSettingsPanel',
@@ -6863,7 +6864,7 @@
'PhabricatorDatasourceEditField' => 'PhabricatorTokenizerEditField',
'PhabricatorDatasourceEditType' => 'PhabricatorPHIDListEditType',
'PhabricatorDateFormatSetting' => 'PhabricatorSelectSetting',
- 'PhabricatorDateTimeSettingsPanel' => 'PhabricatorSettingsPanel',
+ 'PhabricatorDateTimeSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
'PhabricatorDebugController' => 'PhabricatorController',
'PhabricatorDefaultRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle',
@@ -6942,6 +6943,7 @@
'PhabricatorEditEngineQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorEditEngineSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorEditEngineSelectCommentAction' => 'PhabricatorEditEngineCommentAction',
+ 'PhabricatorEditEngineSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorEditEngineTokenizerCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditField' => 'Phobject',
'PhabricatorEditPage' => 'Phobject',
diff --git a/src/applications/settings/application/PhabricatorSettingsApplication.php b/src/applications/settings/application/PhabricatorSettingsApplication.php
--- a/src/applications/settings/application/PhabricatorSettingsApplication.php
+++ b/src/applications/settings/application/PhabricatorSettingsApplication.php
@@ -29,7 +29,10 @@
public function getRoutes() {
return array(
'/settings/' => array(
- '(?:(?P<id>\d+)/)?(?:panel/(?P<key>[^/]+)/)?'
+ '(?:(?P<id>\d+)/)?'.
+ '(?:panel/(?P<pageKey>(?P<key>[^/]+))/'.
+ '(?:(?P<formSaved>saved)/)?'.
+ ')?'
=> 'PhabricatorSettingsMainController',
'adjust/' => 'PhabricatorSettingsAdjustController',
'timezone/(?P<offset>[^/]+)/'
diff --git a/src/applications/settings/controller/PhabricatorSettingsMainController.php b/src/applications/settings/controller/PhabricatorSettingsMainController.php
--- a/src/applications/settings/controller/PhabricatorSettingsMainController.php
+++ b/src/applications/settings/controller/PhabricatorSettingsMainController.php
@@ -10,8 +10,14 @@
}
private function isSelf() {
+ $user = $this->getUser();
+ if (!$user) {
+ return false;
+ }
+
+ $user_phid = $user->getPHID();
+
$viewer_phid = $this->getViewer()->getPHID();
- $user_phid = $this->getUser()->getPHID();
return ($viewer_phid == $user_phid);
}
@@ -45,21 +51,19 @@
$key = $nav->selectFilter($key, head($panels)->getPanelKey());
- $panel = $panels[$key];
- $panel->setUser($this->getUser());
- $panel->setViewer($viewer);
+ $panel = $panels[$key]
+ ->setUser($this->getUser())
+ ->setViewer($viewer)
+ ->setController($this)
+ ->setNavigation($nav);
$response = $panel->processRequest($request);
- if ($response instanceof AphrontResponse) {
+ if (($response instanceof AphrontResponse) ||
+ ($response instanceof AphrontResponseProducerInterface)) {
return $response;
}
$crumbs = $this->buildApplicationCrumbs();
- if (!$this->isSelf()) {
- $crumbs->addTextCrumb(
- $this->getUser()->getUsername(),
- '/p/'.$this->getUser()->getUsername().'/');
- }
$crumbs->addTextCrumb($panel->getPanelName());
$title = $panel->getPanelName();
@@ -76,11 +80,7 @@
}
private function buildPanels() {
- $panels = id(new PhutilClassMapQuery())
- ->setAncestorClass('PhabricatorSettingsPanel')
- ->setExpandMethod('buildPanels')
- ->setUniqueMethod('getPanelKey')
- ->execute();
+ $panels = PhabricatorSettingsPanel::getAllPanels();
$result = array();
foreach ($panels as $key => $panel) {
@@ -107,8 +107,6 @@
$result[$key] = $panel;
}
- $result = msort($result, 'getPanelSortKey');
-
if (!$result) {
throw new Exception(pht('No settings panels are available.'));
}
@@ -145,4 +143,16 @@
return $this->renderSideNav($panels)->getMenu();
}
+ protected function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $user = $this->getUser();
+ if (!$this->isSelf() && $user) {
+ $username = $user->getUsername();
+ $crumbs->addTextCrumb($username, "/p/{$username}/");
+ }
+
+ return $crumbs;
+ }
+
}
diff --git a/src/applications/settings/editor/PhabricatorSettingsEditEngine.php b/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
--- a/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
+++ b/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
@@ -5,6 +5,27 @@
const ENGINECONST = 'settings.settings';
+ private $isSelfEdit;
+ private $profileURI;
+
+ public function setIsSelfEdit($is_self_edit) {
+ $this->isSelfEdit = $is_self_edit;
+ return $this;
+ }
+
+ public function getIsSelfEdit() {
+ return $this->isSelfEdit;
+ }
+
+ public function setProfileURI($profile_uri) {
+ $this->profileURI = $profile_uri;
+ return $this;
+ }
+
+ public function getProfileURI() {
+ return $this->profileURI;
+ }
+
public function isEngineConfigurable() {
return false;
}
@@ -54,6 +75,12 @@
}
protected function getObjectName() {
+ $page = $this->getSelectedPage();
+
+ if ($page) {
+ return $page->getLabel();
+ }
+
return pht('Settings');
}
@@ -74,6 +101,62 @@
return PhabricatorPolicies::POLICY_ADMIN;
}
+ public function getEffectiveObjectEditCancelURI($object) {
+ if ($this->getIsSelfEdit()) {
+ return null;
+ }
+
+ if ($this->getProfileURI()) {
+ return $this->getProfileURI();
+ }
+
+ return parent::getEffectiveObjectEditCancelURI($object);
+ }
+
+ protected function newPages($object) {
+ $viewer = $this->getViewer();
+ $user = $object->getUser();
+
+ $panels = PhabricatorSettingsPanel::getAllPanels();
+
+ foreach ($panels as $key => $panel) {
+ if (!($panel instanceof PhabricatorEditEngineSettingsPanel)) {
+ unset($panels[$key]);
+ continue;
+ }
+
+ $panel->setViewer($viewer);
+ if ($user) {
+ $panel->setUser($user);
+ }
+ }
+
+ $pages = array();
+ $uris = array();
+ foreach ($panels as $key => $panel) {
+ $uris[$key] = $panel->getPanelURI();
+
+ $page = $panel->newEditEnginePage();
+ if (!$page) {
+ continue;
+ }
+ $pages[] = $page;
+ }
+
+ $more_pages = array(
+ id(new PhabricatorEditPage())
+ ->setKey('extra')
+ ->setLabel(pht('Extra Settings'))
+ ->setIsDefault(true),
+ );
+
+ foreach ($more_pages as $page) {
+ $pages[] = $page;
+ }
+
+ return $pages;
+ }
+
protected function buildCustomEditFields($object) {
$viewer = $this->getViewer();
$settings = PhabricatorSetting::getAllEnabledSettings($viewer);
@@ -84,6 +167,8 @@
$settings[$key] = $setting;
}
+ $settings = msortv($settings, 'getSettingOrderVector');
+
$fields = array();
foreach ($settings as $setting) {
foreach ($setting->newCustomEditFields($object) as $field) {
diff --git a/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php b/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php
@@ -1,10 +1,9 @@
<?php
-final class PhabricatorAccountSettingsPanel extends PhabricatorSettingsPanel {
+final class PhabricatorAccountSettingsPanel
+ extends PhabricatorEditEngineSettingsPanel {
- public function getPanelKey() {
- return 'account';
- }
+ const PANELKEY = 'account';
public function getPanelName() {
return pht('Account');
@@ -18,162 +17,4 @@
return true;
}
- public function processRequest(AphrontRequest $request) {
- $viewer = $this->getViewer();
- $user = $this->getUser();
- $username = $user->getUsername();
-
- $preferences = $user->loadPreferences();
-
- $errors = array();
- if ($request->isFormPost()) {
- $sex = $request->getStr('sex');
- $sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE);
- if (in_array($sex, $sexes)) {
- $new_value = $sex;
- } else {
- $new_value = null;
- }
-
- $preferences->setPreference(
- PhabricatorPronounSetting::SETTINGKEY,
- $new_value);
-
- $preferences->setPreference(
- PhabricatorTranslationSetting::SETTINGKEY,
- $request->getStr('translation'));
-
- if (!$errors) {
- $preferences->save();
-
- return id(new AphrontRedirectResponse())
- ->setURI($this->getPanelURI('?saved=true'));
- }
- }
-
- $label_unknown = pht('%s updated their profile', $username);
- $label_her = pht('%s updated her profile', $username);
- $label_his = pht('%s updated his profile', $username);
-
- $sexes = array(
- PhutilPerson::SEX_UNKNOWN => $label_unknown,
- PhutilPerson::SEX_MALE => $label_his,
- PhutilPerson::SEX_FEMALE => $label_her,
- );
-
- $translations = $this->getTranslationOptions();
-
- $form = new AphrontFormView();
- $form
- ->setUser($viewer)
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setOptions($translations)
- ->setLabel(pht('Translation'))
- ->setName('translation')
- ->setValue($user->getTranslation()))
- ->appendRemarkupInstructions(pht('**Choose the pronoun you prefer:**'))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setOptions($sexes)
- ->setLabel(pht('Pronoun'))
- ->setName('sex')
- ->setValue($user->getSex()))
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->setValue(pht('Save Account Settings')));
-
- $form_box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Account Settings'))
- ->setFormSaved($request->getStr('saved'))
- ->setFormErrors($errors)
- ->setForm($form);
-
- return array(
- $form_box,
- );
- }
-
- private function getTranslationOptions() {
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
- $locales = PhutilLocale::loadAllLocales();
-
- $group_labels = array(
- 'normal' => pht('Translations'),
- 'limited' => pht('Limited Translations'),
- 'silly' => pht('Silly Translations'),
- 'test' => pht('Developer/Test Translations'),
- );
-
- $groups = array_fill_keys(array_keys($group_labels), array());
-
- $translations = array();
- foreach ($locales as $locale) {
- $code = $locale->getLocaleCode();
-
- // Get the locale's localized name if it's available. For example,
- // "Deutsch" instead of "German". This helps users who do not speak the
- // current language to find the correct setting.
- $raw_scope = PhabricatorEnv::beginScopedLocale($code);
- $name = $locale->getLocaleName();
- unset($raw_scope);
-
- if ($locale->isSillyLocale()) {
- if ($is_serious) {
- // Omit silly locales on serious business installs.
- continue;
- }
- $groups['silly'][$code] = $name;
- continue;
- }
-
- if ($locale->isTestLocale()) {
- $groups['test'][$code] = $name;
- continue;
- }
-
- $strings = PhutilTranslation::getTranslationMapForLocale($code);
- $size = count($strings);
-
- // If a translation is English, assume it can fall back to the default
- // strings and don't caveat its completeness.
- $is_english = (substr($code, 0, 3) == 'en_');
-
- // Arbitrarily pick some number of available strings to promote a
- // translation out of the "limited" group. The major goal is just to
- // keep locales with very few strings out of the main group, so users
- // aren't surprised if a locale has no upstream translations available.
- if ($size > 512 || $is_english) {
- $type = 'normal';
- } else {
- $type = 'limited';
- }
-
- $groups[$type][$code] = $name;
- }
-
- // TODO: Select a default properly.
- $default = 'en_US';
-
- $results = array();
- foreach ($groups as $key => $group) {
- $label = $group_labels[$key];
- if (!$group) {
- continue;
- }
-
- asort($group);
-
- if ($key == 'normal') {
- $group = array(
- '' => pht('Server Default: %s', $locales[$default]->getLocaleName()),
- ) + $group;
- }
-
- $results[$label] = $group;
- }
-
- return $results;
- }
-
}
diff --git a/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php b/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
@@ -1,10 +1,9 @@
<?php
-final class PhabricatorDateTimeSettingsPanel extends PhabricatorSettingsPanel {
+final class PhabricatorDateTimeSettingsPanel
+ extends PhabricatorEditEngineSettingsPanel {
- public function getPanelKey() {
- return 'datetime';
- }
+ const PANELKEY = 'datetime';
public function getPanelName() {
return pht('Date and Time');
@@ -14,112 +13,8 @@
return pht('Account Information');
}
- public function processRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $username = $user->getUsername();
-
- $pref_timezone = PhabricatorTimezoneSetting::SETTINGKEY;
- $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
- $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
- $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
- $pref_ignore = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY;
- $preferences = $user->loadPreferences();
-
- $errors = array();
- if ($request->isFormPost()) {
- $new_timezone = $request->getStr('timezone');
- if (!in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
- $errors[] = pht('The selected timezone is not a valid timezone.');
- }
-
- $preferences
- ->setPreference($pref_timezone, $new_timezone)
- ->setPreference(
- $pref_time,
- $request->getStr($pref_time))
- ->setPreference(
- $pref_date,
- $request->getStr($pref_date))
- ->setPreference(
- $pref_week_start,
- $request->getStr($pref_week_start))
- ->setPreference($pref_ignore, null);
-
- if (!$errors) {
- $preferences->save();
-
- return id(new AphrontRedirectResponse())
- ->setURI($this->getPanelURI('?saved=true'));
- }
- }
-
- $timezone_ids = DateTimeZone::listIdentifiers();
- $timezone_id_map = array_fuse($timezone_ids);
-
- $form = new AphrontFormView();
- $form
- ->setUser($user)
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Timezone'))
- ->setName('timezone')
- ->setOptions($timezone_id_map)
- ->setValue($user->getTimezoneIdentifier()))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Time-of-Day Format'))
- ->setName($pref_time)
- ->setOptions(array(
- 'g:i A' => pht('12-hour (2:34 PM)'),
- 'H:i' => pht('24-hour (14:34)'),
- ))
- ->setCaption(
- pht('Format used when rendering a time of day.'))
- ->setValue($preferences->getPreference($pref_time)))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Date Format'))
- ->setName($pref_date)
- ->setOptions(array(
- 'Y-m-d' => pht('ISO 8601 (2000-02-28)'),
- 'n/j/Y' => pht('US (2/28/2000)'),
- 'd-m-Y' => pht('European (28-02-2000)'),
- ))
- ->setCaption(
- pht('Format used when rendering a date.'))
- ->setValue($preferences->getPreference($pref_date)))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Week Starts On'))
- ->setOptions($this->getWeekDays())
- ->setName($pref_week_start)
- ->setCaption(
- pht('Calendar weeks will start with this day.'))
- ->setValue($preferences->getPreference($pref_week_start, 0)))
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->setValue(pht('Save Account Settings')));
-
- $form_box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Date and Time Settings'))
- ->setFormSaved($request->getStr('saved'))
- ->setFormErrors($errors)
- ->setForm($form);
-
- return array(
- $form_box,
- );
+ public function isEditableByAdministrators() {
+ return true;
}
- private function getWeekDays() {
- return array(
- pht('Sunday'),
- pht('Monday'),
- pht('Tuesday'),
- pht('Wednesday'),
- pht('Thursday'),
- pht('Friday'),
- pht('Saturday'),
- );
- }
}
diff --git a/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php b/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php
new file mode 100644
--- /dev/null
+++ b/src/applications/settings/panel/PhabricatorEditEngineSettingsPanel.php
@@ -0,0 +1,74 @@
+<?php
+
+abstract class PhabricatorEditEngineSettingsPanel
+ extends PhabricatorSettingsPanel {
+
+ final public function processRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $user = $this->getUser();
+
+ if ($user->getPHID() === $viewer->getPHID()) {
+ $is_self = true;
+ } else {
+ $is_self = false;
+ }
+
+ if ($user->getPHID()) {
+ $profile_uri = '/people/manage/'.$user->getID().'/';
+ } else {
+ $profile_uri = null;
+ }
+
+ $engine = id(new PhabricatorSettingsEditEngine())
+ ->setController($this->getController())
+ ->setNavigation($this->getNavigation())
+ ->setHideHeader(true)
+ ->setIsSelfEdit($is_self)
+ ->setProfileURI($profile_uri);
+
+ $preferences = $user->loadPreferences();
+
+ PhabricatorPolicyFilter::requireCapability(
+ $viewer,
+ $preferences,
+ PhabricatorPolicyCapability::CAN_EDIT);
+
+ $engine->setTargetObject($preferences);
+
+ return $engine->buildResponse();
+ }
+
+ final public function newEditEnginePage() {
+ $field_keys = $this->getPanelSettingsKeys();
+ if (!$field_keys) {
+ return null;
+ }
+
+ $key = $this->getPanelKey();
+ $label = $this->getPanelName();
+ $panel_uri = $this->getPanelURI().'saved/';
+
+ return id(new PhabricatorEditPage())
+ ->setKey($key)
+ ->setLabel($label)
+ ->setViewURI($panel_uri)
+ ->setFieldKeys($field_keys);
+ }
+
+ final public function getPanelSettingsKeys() {
+ $viewer = $this->getViewer();
+ $settings = PhabricatorSetting::getAllEnabledSettings($viewer);
+
+ $this_key = $this->getPanelKey();
+
+ $panel_settings = array();
+ foreach ($settings as $setting) {
+ if ($setting->getSettingPanelKey() == $this_key) {
+ $panel_settings[] = $setting;
+ }
+ }
+
+ return mpull($panel_settings, 'getSettingKey');
+ }
+
+}
diff --git a/src/applications/settings/panel/PhabricatorSettingsPanel.php b/src/applications/settings/panel/PhabricatorSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorSettingsPanel.php
@@ -17,9 +17,10 @@
private $user;
private $viewer;
+ private $controller;
+ private $navigation;
private $overrideURI;
-
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
@@ -43,6 +44,32 @@
return $this;
}
+ final public function setController(PhabricatorController $controller) {
+ $this->controller = $controller;
+ return $this;
+ }
+
+ final public function getController() {
+ return $this->controller;
+ }
+
+ final public function setNavigation(AphrontSideNavFilterView $navigation) {
+ $this->navigation = $navigation;
+ return $this;
+ }
+
+ final public function getNavigation() {
+ return $this->navigation;
+ }
+
+ final public static function getAllPanels() {
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getPanelKey')
+ ->setSortMethod('getPanelSortKey')
+ ->execute();
+ }
+
/* -( Panel Configuration )------------------------------------------------ */
@@ -54,7 +81,9 @@
* @return string Unique panel identifier (used in URIs).
* @task config
*/
- abstract public function getPanelKey();
+ public function getPanelKey() {
+ return $this->getPhobjectClassConstant('PANELKEY');
+ }
/**
@@ -96,23 +125,6 @@
/**
- * You can use this callback to generate multiple similar panels which all
- * share the same implementation. For example, OAuth providers each have a
- * separate panel, but the implementation for each panel is the same.
- *
- * To generate multiple panels, build them here and return a list. By default,
- * the current panel (`$this`) is returned alone. For most panels, this
- * is the right implementation.
- *
- * @return list<PhabricatorSettingsPanel> Zero or more panels.
- * @task config
- */
- public function buildPanels() {
- return array($this);
- }
-
-
- /**
* Return true if this panel is available to administrators while editing
* system agent accounts.
*
diff --git a/src/applications/settings/setting/PhabricatorDateFormatSetting.php b/src/applications/settings/setting/PhabricatorDateFormatSetting.php
--- a/src/applications/settings/setting/PhabricatorDateFormatSetting.php
+++ b/src/applications/settings/setting/PhabricatorDateFormatSetting.php
@@ -13,6 +13,14 @@
return pht('Date Format');
}
+ public function getSettingPanelKey() {
+ return PhabricatorDateTimeSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 200;
+ }
+
protected function getControlInstructions() {
return pht(
'Select the format you prefer for editing dates.');
diff --git a/src/applications/settings/setting/PhabricatorPronounSetting.php b/src/applications/settings/setting/PhabricatorPronounSetting.php
--- a/src/applications/settings/setting/PhabricatorPronounSetting.php
+++ b/src/applications/settings/setting/PhabricatorPronounSetting.php
@@ -9,6 +9,14 @@
return pht('Pronoun');
}
+ public function getSettingPanelKey() {
+ return PhabricatorAccountSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 200;
+ }
+
protected function getControlInstructions() {
return pht('Choose the pronoun you prefer.');
}
@@ -18,6 +26,9 @@
}
protected function getSelectOptions() {
+ // TODO: When editing another user's settings as an administrator, this
+ // is not the best username: the user's username would be better.
+
$viewer = $this->getViewer();
$username = $viewer->getUsername();
diff --git a/src/applications/settings/setting/PhabricatorSetting.php b/src/applications/settings/setting/PhabricatorSetting.php
--- a/src/applications/settings/setting/PhabricatorSetting.php
+++ b/src/applications/settings/setting/PhabricatorSetting.php
@@ -15,6 +15,20 @@
abstract public function getSettingName();
+ public function getSettingPanelKey() {
+ return null;
+ }
+
+ protected function getSettingOrder() {
+ return 1000;
+ }
+
+ public function getSettingOrderVector() {
+ return id(new PhutilSortVector())
+ ->addInt($this->getSettingOrder())
+ ->addString($this->getSettingName());
+ }
+
protected function getControlInstructions() {
return null;
}
diff --git a/src/applications/settings/setting/PhabricatorTimeFormatSetting.php b/src/applications/settings/setting/PhabricatorTimeFormatSetting.php
--- a/src/applications/settings/setting/PhabricatorTimeFormatSetting.php
+++ b/src/applications/settings/setting/PhabricatorTimeFormatSetting.php
@@ -12,6 +12,14 @@
return pht('Time Format');
}
+ public function getSettingPanelKey() {
+ return PhabricatorDateTimeSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 300;
+ }
+
protected function getControlInstructions() {
return pht(
'Select the format you prefer for editing and displaying time.');
diff --git a/src/applications/settings/setting/PhabricatorTimezoneSetting.php b/src/applications/settings/setting/PhabricatorTimezoneSetting.php
--- a/src/applications/settings/setting/PhabricatorTimezoneSetting.php
+++ b/src/applications/settings/setting/PhabricatorTimezoneSetting.php
@@ -9,6 +9,18 @@
return pht('Timezone');
}
+ public function getSettingPanelKey() {
+ return PhabricatorDateTimeSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 100;
+ }
+
+ protected function getControlInstructions() {
+ return pht('Select your local timezone.');
+ }
+
public function getSettingDefaultValue() {
return date_default_timezone_get();
}
diff --git a/src/applications/settings/setting/PhabricatorTranslationSetting.php b/src/applications/settings/setting/PhabricatorTranslationSetting.php
--- a/src/applications/settings/setting/PhabricatorTranslationSetting.php
+++ b/src/applications/settings/setting/PhabricatorTranslationSetting.php
@@ -9,10 +9,23 @@
return pht('Translation');
}
+ public function getSettingPanelKey() {
+ return PhabricatorAccountSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 100;
+ }
+
public function getSettingDefaultValue() {
return 'en_US';
}
+ protected function getControlInstructions() {
+ return pht(
+ 'Choose which language you would like the Phabricator UI to use.');
+ }
+
protected function getSelectOptionGroups() {
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$locales = PhutilLocale::loadAllLocales();
diff --git a/src/applications/settings/setting/PhabricatorWeekStartDaySetting.php b/src/applications/settings/setting/PhabricatorWeekStartDaySetting.php
--- a/src/applications/settings/setting/PhabricatorWeekStartDaySetting.php
+++ b/src/applications/settings/setting/PhabricatorWeekStartDaySetting.php
@@ -9,6 +9,14 @@
return pht('Week Starts On');
}
+ public function getSettingPanelKey() {
+ return PhabricatorDateTimeSettingsPanel::PANELKEY;
+ }
+
+ protected function getSettingOrder() {
+ return 400;
+ }
+
protected function getControlInstructions() {
return pht(
'Choose which day a calendar week should begin on.');
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -26,6 +26,8 @@
private $targetObject;
private $page;
private $pages;
+ private $navigation;
+ private $hideHeader;
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
@@ -80,6 +82,24 @@
return $this->targetObject;
}
+ public function setNavigation(AphrontSideNavFilterView $navigation) {
+ $this->navigation = $navigation;
+ return $this;
+ }
+
+ public function getNavigation() {
+ return $this->navigation;
+ }
+
+ public function setHideHeader($hide_header) {
+ $this->hideHeader = $hide_header;
+ return $this;
+ }
+
+ public function getHideHeader() {
+ return $this->hideHeader;
+ }
+
/* -( Managing Fields )---------------------------------------------------- */
@@ -1090,17 +1110,22 @@
->addSubmitButton($submit_button);
}
- $header = id(new PHUIHeaderView())
- ->setHeader($header_text)
- ->setHeaderIcon($header_icon);
+ $crumbs = $this->buildCrumbs($object, $final = true);
+
+ if ($this->getHideHeader()) {
+ $header = null;
+ $crumbs->setBorder(false);
+ } else {
+ $header = id(new PHUIHeaderView())
+ ->setHeader($header_text)
+ ->setHeaderIcon($header_icon);
+ $crumbs->setBorder(true);
+ }
if ($action_button) {
$header->addActionLink($action_button);
}
- $crumbs = $this->buildCrumbs($object, $final = true);
- $crumbs->setBorder(true);
-
$box = id(new PHUIObjectBoxView())
->setUser($viewer)
->setHeaderText($this->getObjectName())
@@ -1108,12 +1133,30 @@
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($form);
- $view = id(new PHUITwoColumnView())
- ->setHeader($header)
- ->setFooter(array(
- $box,
- $previews,
- ));
+ // This is fairly questionable, but in use by Settings.
+ if ($request->getURIData('formSaved')) {
+ $box->setFormSaved(true);
+ }
+
+ $content = array(
+ $box,
+ $previews,
+ );
+
+ $view = new PHUITwoColumnView();
+
+ if ($header) {
+ $view->setHeader($header);
+ }
+
+ $navigation = $this->getNavigation();
+ if ($navigation) {
+ $view
+ ->setNavigation($navigation)
+ ->setMainColumn($content);
+ } else {
+ $view->setFooter($content);
+ }
return $controller->newPage()
->setTitle($header_text)
@@ -1155,10 +1198,14 @@
}
if (!$request->isAjax()) {
- $form->appendControl(
- id(new AphrontFormSubmitControl())
- ->addCancelButton($cancel_uri)
- ->setValue($submit_button));
+ $buttons = id(new AphrontFormSubmitControl())
+ ->setValue($submit_button);
+
+ if ($cancel_uri) {
+ $buttons->addCancelButton($cancel_uri);
+ }
+
+ $form->appendControl($buttons);
}
return $form;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 9 2025, 7:01 AM (5 w, 4 d ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/mv/n4/3jtehnnqpm3tpsc3
Default Alt Text
D16017.diff (31 KB)
Attached To
Mode
D16017: Convert "Account" and "Date and Time" settings to EditEngine
Attached
Detach File
Event Timeline
Log In to Comment