From eb673fd783e49d74914cba7726b548193c469ee2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 3 Jun 2016 05:31:33 -0700 Subject: [PATCH] Formalize and fully modularize settings panel groups Summary: Ref T4103. Settings panels are grouped into categories of similar panels (like "Email" or "Sessions and Logs"). Currently, this is done informally, by just grouping and ordering by strings. This won't work well with translations, since it means the ordering is entirely dependent on the language order, so the first settings panel you see might be something irrelvant or confusing. We'd also potentially break third-party stuff by changing strings, but do so in a silent hard-to-detect way. Provide formal objects and modularize the panel groups completely. Test Plan: Verified all panels still appear properly and in the same groups and order. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16020 --- src/__phutil_library_map__.php | 14 +++++ .../PhabricatorConduitTokensSettingsPanel.php | 4 +- .../DiffusionSetPasswordSettingsPanel.php | 4 +- ...OAuthServerAuthorizationsSettingsPanel.php | 4 +- .../PhabricatorSettingsMainController.php | 9 ++-- .../panel/PhabricatorAccountSettingsPanel.php | 4 +- .../PhabricatorActivitySettingsPanel.php | 8 +-- ...torConpherencePreferencesSettingsPanel.php | 4 +- .../PhabricatorDateTimeSettingsPanel.php | 4 +- ...catorDesktopNotificationsSettingsPanel.php | 4 +- ...catorDeveloperPreferencesSettingsPanel.php | 4 +- ...habricatorDiffPreferencesSettingsPanel.php | 4 +- ...ricatorDisplayPreferencesSettingsPanel.php | 4 +- ...PhabricatorEmailAddressesSettingsPanel.php | 4 +- .../PhabricatorEmailFormatSettingsPanel.php | 4 +- ...abricatorEmailPreferencesSettingsPanel.php | 4 +- ...abricatorExternalAccountsSettingsPanel.php | 8 +-- ...habricatorHomePreferencesSettingsPanel.php | 4 +- .../PhabricatorMultiFactorSettingsPanel.php | 4 +- .../PhabricatorPasswordSettingsPanel.php | 4 +- .../panel/PhabricatorSSHKeysSettingsPanel.php | 4 +- .../PhabricatorSessionsSettingsPanel.php | 4 +- .../panel/PhabricatorSettingsPanel.php | 52 +++++++++++++------ .../panel/PhabricatorTokensSettingsPanel.php | 8 +-- .../PhabricatorSettingsAccountPanelGroup.php | 16 ++++++ ...bricatorSettingsApplicationsPanelGroup.php | 16 ++++++ ...icatorSettingsAuthenticationPanelGroup.php | 16 ++++++ ...PhabricatorSettingsDeveloperPanelGroup.php | 16 ++++++ .../PhabricatorSettingsEmailPanelGroup.php | 16 ++++++ .../PhabricatorSettingsLogsPanelGroup.php | 16 ++++++ .../PhabricatorSettingsPanelGroup.php | 48 +++++++++++++++++ 31 files changed, 240 insertions(+), 75 deletions(-) create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsAccountPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsApplicationsPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsAuthenticationPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsDeveloperPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsEmailPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsLogsPanelGroup.php create mode 100644 src/applications/settings/panelgroup/PhabricatorSettingsPanelGroup.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2180dbb387..593c9b29cf 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3371,14 +3371,21 @@ phutil_register_library_map(array( 'PhabricatorSendGridConfigOptions' => 'applications/config/option/PhabricatorSendGridConfigOptions.php', 'PhabricatorSessionsSettingsPanel' => 'applications/settings/panel/PhabricatorSessionsSettingsPanel.php', 'PhabricatorSetting' => 'applications/settings/setting/PhabricatorSetting.php', + 'PhabricatorSettingsAccountPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsAccountPanelGroup.php', 'PhabricatorSettingsAddEmailAction' => 'applications/settings/action/PhabricatorSettingsAddEmailAction.php', 'PhabricatorSettingsAdjustController' => 'applications/settings/controller/PhabricatorSettingsAdjustController.php', 'PhabricatorSettingsApplication' => 'applications/settings/application/PhabricatorSettingsApplication.php', + 'PhabricatorSettingsApplicationsPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsApplicationsPanelGroup.php', + 'PhabricatorSettingsAuthenticationPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsAuthenticationPanelGroup.php', + 'PhabricatorSettingsDeveloperPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsDeveloperPanelGroup.php', 'PhabricatorSettingsEditController' => 'applications/settings/controller/PhabricatorSettingsEditController.php', 'PhabricatorSettingsEditEngine' => 'applications/settings/editor/PhabricatorSettingsEditEngine.php', + 'PhabricatorSettingsEmailPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsEmailPanelGroup.php', + 'PhabricatorSettingsLogsPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsLogsPanelGroup.php', 'PhabricatorSettingsMainController' => 'applications/settings/controller/PhabricatorSettingsMainController.php', 'PhabricatorSettingsMainMenuBarExtension' => 'applications/settings/extension/PhabricatorSettingsMainMenuBarExtension.php', 'PhabricatorSettingsPanel' => 'applications/settings/panel/PhabricatorSettingsPanel.php', + 'PhabricatorSettingsPanelGroup' => 'applications/settings/panelgroup/PhabricatorSettingsPanelGroup.php', 'PhabricatorSettingsTimezoneController' => 'applications/settings/controller/PhabricatorSettingsTimezoneController.php', 'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php', 'PhabricatorSetupCheckTestCase' => 'applications/config/check/__tests__/PhabricatorSetupCheckTestCase.php', @@ -8125,14 +8132,21 @@ phutil_register_library_map(array( 'PhabricatorSendGridConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorSessionsSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorSetting' => 'Phobject', + 'PhabricatorSettingsAccountPanelGroup' => 'PhabricatorSettingsPanelGroup', 'PhabricatorSettingsAddEmailAction' => 'PhabricatorSystemAction', 'PhabricatorSettingsAdjustController' => 'PhabricatorController', 'PhabricatorSettingsApplication' => 'PhabricatorApplication', + 'PhabricatorSettingsApplicationsPanelGroup' => 'PhabricatorSettingsPanelGroup', + 'PhabricatorSettingsAuthenticationPanelGroup' => 'PhabricatorSettingsPanelGroup', + 'PhabricatorSettingsDeveloperPanelGroup' => 'PhabricatorSettingsPanelGroup', 'PhabricatorSettingsEditController' => 'PhabricatorController', 'PhabricatorSettingsEditEngine' => 'PhabricatorEditEngine', + 'PhabricatorSettingsEmailPanelGroup' => 'PhabricatorSettingsPanelGroup', + 'PhabricatorSettingsLogsPanelGroup' => 'PhabricatorSettingsPanelGroup', 'PhabricatorSettingsMainController' => 'PhabricatorController', 'PhabricatorSettingsMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension', 'PhabricatorSettingsPanel' => 'Phobject', + 'PhabricatorSettingsPanelGroup' => 'Phobject', 'PhabricatorSettingsTimezoneController' => 'PhabricatorController', 'PhabricatorSetupCheck' => 'Phobject', 'PhabricatorSetupCheckTestCase' => 'PhabricatorTestCase', diff --git a/src/applications/conduit/settings/PhabricatorConduitTokensSettingsPanel.php b/src/applications/conduit/settings/PhabricatorConduitTokensSettingsPanel.php index 6f315783cc..80e92d45c9 100644 --- a/src/applications/conduit/settings/PhabricatorConduitTokensSettingsPanel.php +++ b/src/applications/conduit/settings/PhabricatorConduitTokensSettingsPanel.php @@ -15,8 +15,8 @@ final class PhabricatorConduitTokensSettingsPanel return pht('Conduit API Tokens'); } - public function getPanelGroup() { - return pht('Sessions and Logs'); + public function getPanelGroupKey() { + return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php b/src/applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php index 454ed01570..aa1ffb2e43 100644 --- a/src/applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php +++ b/src/applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php @@ -14,8 +14,8 @@ final class DiffusionSetPasswordSettingsPanel extends PhabricatorSettingsPanel { return pht('VCS Password'); } - public function getPanelGroup() { - return pht('Authentication'); + public function getPanelGroupKey() { + return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/oauthserver/panel/PhabricatorOAuthServerAuthorizationsSettingsPanel.php b/src/applications/oauthserver/panel/PhabricatorOAuthServerAuthorizationsSettingsPanel.php index e282a3d5e4..06f26b2ee3 100644 --- a/src/applications/oauthserver/panel/PhabricatorOAuthServerAuthorizationsSettingsPanel.php +++ b/src/applications/oauthserver/panel/PhabricatorOAuthServerAuthorizationsSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorOAuthServerAuthorizationsSettingsPanel return pht('OAuth Authorizations'); } - public function getPanelGroup() { - return pht('Sessions and Logs'); + public function getPanelGroupKey() { + return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/settings/controller/PhabricatorSettingsMainController.php b/src/applications/settings/controller/PhabricatorSettingsMainController.php index b23fd5f73f..a174fa83e8 100644 --- a/src/applications/settings/controller/PhabricatorSettingsMainController.php +++ b/src/applications/settings/controller/PhabricatorSettingsMainController.php @@ -80,7 +80,7 @@ final class PhabricatorSettingsMainController } private function buildPanels() { - $panels = PhabricatorSettingsPanel::getAllPanels(); + $panels = PhabricatorSettingsPanel::getAllDisplayPanels(); $result = array(); foreach ($panels as $key => $panel) { @@ -125,11 +125,12 @@ final class PhabricatorSettingsMainController $nav->setBaseURI(new PhutilURI($this->getApplicationURI($base_uri))); - $group = null; + $group_key = null; foreach ($panels as $panel) { - if ($panel->getPanelGroup() != $group) { + if ($panel->getPanelGroupKey() != $group_key) { + $group_key = $panel->getPanelGroupKey(); $group = $panel->getPanelGroup(); - $nav->addLabel($group); + $nav->addLabel($group->getPanelGroupName()); } $nav->addFilter($panel->getPanelKey(), $panel->getPanelName()); diff --git a/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php b/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php index f06f41ca4f..f1734f1432 100644 --- a/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorAccountSettingsPanel.php @@ -9,8 +9,8 @@ final class PhabricatorAccountSettingsPanel return pht('Account'); } - public function getPanelGroup() { - return pht('Account Information'); + public function getPanelGroupKey() { + return PhabricatorSettingsAccountPanelGroup::PANELGROUPKEY; } public function isEditableByAdministrators() { diff --git a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php index 757ac9c332..23c212bf30 100644 --- a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php @@ -14,12 +14,8 @@ final class PhabricatorActivitySettingsPanel extends PhabricatorSettingsPanel { return pht('Activity Logs'); } - public function getPanelGroup() { - return pht('Sessions and Logs'); - } - - public function isEnabled() { - return true; + public function getPanelGroupKey() { + return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php index 69f84f16a1..87a837c6fb 100644 --- a/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php @@ -16,8 +16,8 @@ final class PhabricatorConpherencePreferencesSettingsPanel return pht('Conpherence Preferences'); } - public function getPanelGroup() { - return pht('Application Settings'); + public function getPanelGroupKey() { + return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php b/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php index 9d9b015fbf..7d554b579c 100644 --- a/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php @@ -9,8 +9,8 @@ final class PhabricatorDateTimeSettingsPanel return pht('Date and Time'); } - public function getPanelGroup() { - return pht('Account Information'); + public function getPanelGroupKey() { + return PhabricatorSettingsAccountPanelGroup::PANELGROUPKEY; } public function isEditableByAdministrators() { diff --git a/src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php b/src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php index 8da45a518c..65beabec6a 100644 --- a/src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php @@ -21,8 +21,8 @@ final class PhabricatorDesktopNotificationsSettingsPanel return pht('Desktop Notifications'); } - public function getPanelGroup() { - return pht('Application Settings'); + public function getPanelGroupKey() { + return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorDeveloperPreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorDeveloperPreferencesSettingsPanel.php index 1d81cc67b2..7892c59a55 100644 --- a/src/applications/settings/panel/PhabricatorDeveloperPreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorDeveloperPreferencesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorDeveloperPreferencesSettingsPanel return pht('Developer Settings'); } - public function getPanelGroup() { - return pht('Developer'); + public function getPanelGroupKey() { + return PhabricatorSettingsDeveloperPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorDiffPreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorDiffPreferencesSettingsPanel.php index 72fca5e879..72a1dcec25 100644 --- a/src/applications/settings/panel/PhabricatorDiffPreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorDiffPreferencesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorDiffPreferencesSettingsPanel return pht('Diff Preferences'); } - public function getPanelGroup() { - return pht('Application Settings'); + public function getPanelGroupKey() { + return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php index 6895aaedc7..ce97caf982 100644 --- a/src/applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorDisplayPreferencesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorDisplayPreferencesSettingsPanel return pht('Display Preferences'); } - public function getPanelGroup() { - return pht('Application Settings'); + public function getPanelGroupKey() { + return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php b/src/applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php index 464214dc73..ac02fae00e 100644 --- a/src/applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorEmailAddressesSettingsPanel return pht('Email Addresses'); } - public function getPanelGroup() { - return pht('Email'); + public function getPanelGroupKey() { + return PhabricatorSettingsEmailPanelGroup::PANELGROUPKEY; } public function isEditableByAdministrators() { diff --git a/src/applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php b/src/applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php index 3396774065..677ccfd647 100644 --- a/src/applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorEmailFormatSettingsPanel return pht('Email Format'); } - public function getPanelGroup() { - return pht('Email'); + public function getPanelGroupKey() { + return PhabricatorSettingsEmailPanelGroup::PANELGROUPKEY; } public function isEditableByAdministrators() { diff --git a/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php index c4142412c6..162ed9ceac 100644 --- a/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorEmailPreferencesSettingsPanel return pht('Email Preferences'); } - public function getPanelGroup() { - return pht('Email'); + public function getPanelGroupKey() { + return PhabricatorSettingsEmailPanelGroup::PANELGROUPKEY; } public function isEditableByAdministrators() { diff --git a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php index c9b6269a87..662d4e6cf6 100644 --- a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php @@ -11,12 +11,8 @@ final class PhabricatorExternalAccountsSettingsPanel return pht('External Accounts'); } - public function getPanelGroup() { - return pht('Authentication'); - } - - public function isEnabled() { - return true; + public function getPanelGroupKey() { + return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php index 06b17fecca..a4c75f88ea 100644 --- a/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorHomePreferencesSettingsPanel return pht('Home Page'); } - public function getPanelGroup() { - return pht('Application Settings'); + public function getPanelGroupKey() { + return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php index 9bcfbba3be..77eb1c55d5 100644 --- a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php @@ -11,8 +11,8 @@ final class PhabricatorMultiFactorSettingsPanel return pht('Multi-Factor Auth'); } - public function getPanelGroup() { - return pht('Authentication'); + public function getPanelGroupKey() { + return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php b/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php index f2db373945..fa91dac210 100644 --- a/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php @@ -10,8 +10,8 @@ final class PhabricatorPasswordSettingsPanel extends PhabricatorSettingsPanel { return pht('Password'); } - public function getPanelGroup() { - return pht('Authentication'); + public function getPanelGroupKey() { + return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php b/src/applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php index 4c716e1dff..f91b17557a 100644 --- a/src/applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php @@ -14,8 +14,8 @@ final class PhabricatorSSHKeysSettingsPanel extends PhabricatorSettingsPanel { return pht('SSH Public Keys'); } - public function getPanelGroup() { - return pht('Authentication'); + public function getPanelGroupKey() { + return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/settings/panel/PhabricatorSessionsSettingsPanel.php b/src/applications/settings/panel/PhabricatorSessionsSettingsPanel.php index 2d38e76225..e3a37c9dfc 100644 --- a/src/applications/settings/panel/PhabricatorSessionsSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorSessionsSettingsPanel.php @@ -10,8 +10,8 @@ final class PhabricatorSessionsSettingsPanel extends PhabricatorSettingsPanel { return pht('Sessions'); } - public function getPanelGroup() { - return pht('Sessions and Logs'); + public function getPanelGroupKey() { + return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY; } public function isEnabled() { diff --git a/src/applications/settings/panel/PhabricatorSettingsPanel.php b/src/applications/settings/panel/PhabricatorSettingsPanel.php index 1f05147daa..27679e733c 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanel.php @@ -7,8 +7,6 @@ * submits the form. By extending this class, you can add new settings * panels. * - * NOTE: This stuff is new and might not be completely stable. - * * @task config Panel Configuration * @task panel Panel Implementation * @task internal Internals @@ -63,11 +61,38 @@ abstract class PhabricatorSettingsPanel extends Phobject { } final public static function getAllPanels() { - return id(new PhutilClassMapQuery()) + $panels = id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getPanelKey') - ->setSortMethod('getPanelSortKey') ->execute(); + return msortv($panels, 'getPanelOrderVector'); + } + + final public static function getAllDisplayPanels() { + $panels = array(); + $groups = PhabricatorSettingsPanelGroup::getAllPanelGroupsWithPanels(); + foreach ($groups as $group) { + foreach ($group->getPanels() as $key => $panel) { + $panels[$key] = $panel; + } + } + + return $panels; + } + + final public function getPanelGroup() { + $group_key = $this->getPanelGroupKey(); + + $groups = PhabricatorSettingsPanelGroup::getAllPanelGroupsWithPanels(); + $group = idx($groups, $group_key); + if (!$group) { + throw new Exception( + pht( + 'No settings panel group with key "%s" exists!', + $group_key)); + } + + return $group; } @@ -97,17 +122,12 @@ abstract class PhabricatorSettingsPanel extends Phobject { /** - * Return a human-readable group name for this panel. For instance, if you - * had several related panels like "Volume Settings" and - * "Microphone Settings", you might put them in a group called "Audio". + * Return a panel group key constant for this panel. * - * When displayed, panels are grouped with other panels that have the same - * group name. - * - * @return string Human-readable panel group name. + * @return const Panel group key. * @task config */ - abstract public function getPanelGroup(); + abstract public function getPanelGroupKey(); /** @@ -192,11 +212,9 @@ abstract class PhabricatorSettingsPanel extends Phobject { * @return string Sortable key. * @task internal */ - final public function getPanelSortKey() { - return sprintf( - '%s'.chr(255).'%s', - $this->getPanelGroup(), - $this->getPanelName()); + final public function getPanelOrderVector() { + return id(new PhutilSortVector()) + ->addString($this->getPanelName()); } } diff --git a/src/applications/settings/panel/PhabricatorTokensSettingsPanel.php b/src/applications/settings/panel/PhabricatorTokensSettingsPanel.php index 030ad37116..d2e0be4a53 100644 --- a/src/applications/settings/panel/PhabricatorTokensSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorTokensSettingsPanel.php @@ -10,12 +10,8 @@ final class PhabricatorTokensSettingsPanel extends PhabricatorSettingsPanel { return pht('Temporary Tokens'); } - public function getPanelGroup() { - return pht('Sessions and Logs'); - } - - public function isEnabled() { - return true; + public function getPanelGroupKey() { + return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY; } public function processRequest(AphrontRequest $request) { diff --git a/src/applications/settings/panelgroup/PhabricatorSettingsAccountPanelGroup.php b/src/applications/settings/panelgroup/PhabricatorSettingsAccountPanelGroup.php new file mode 100644 index 0000000000..f81d5d487a --- /dev/null +++ b/src/applications/settings/panelgroup/PhabricatorSettingsAccountPanelGroup.php @@ -0,0 +1,16 @@ +addInt($this->getPanelGroupOrder()) + ->addString($this->getPanelGroupName()); + } + + final public function getPanelGroupKey() { + return $this->getPhobjectClassConstant('PANELGROUPKEY'); + } + + final public static function getAllPanelGroups() { + $groups = id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getPanelGroupKey') + ->execute(); + + return msortv($groups, 'getPanelGroupOrderVector'); + } + + final public static function getAllPanelGroupsWithPanels() { + $groups = self::getAllPanelGroups(); + + $panels = PhabricatorSettingsPanel::getAllPanels(); + $panels = mgroup($panels, 'getPanelGroupKey'); + foreach ($groups as $key => $group) { + $group->panels = idx($panels, $key, array()); + } + + return $groups; + } + + public function getPanels() { + return $this->panels; + } + +}