mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 08:36:13 +01:00
83f66ce55e
Summary: Moves Settings to use a normal side navigation vs. a two column side navigation. It also updates Edit Engine to do the same, but I don't think there are other callsites. Added a consistent header for better clarification if you were editng your settings, global settings, or a bot's settings. Test Plan: Test each page on a personal account, create global settings, test each page there, create a bot account, and test each page on the bot account. Anything else? Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D18342
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
abstract class PhabricatorEditEngineSettingsPanel
|
|
extends PhabricatorSettingsPanel {
|
|
|
|
final public function processRequest(AphrontRequest $request) {
|
|
$viewer = $this->getViewer();
|
|
$user = $this->getUser();
|
|
|
|
if ($user && ($user->getPHID() === $viewer->getPHID())) {
|
|
$is_self = true;
|
|
} else {
|
|
$is_self = false;
|
|
}
|
|
|
|
if ($user && $user->getPHID()) {
|
|
$profile_uri = '/people/manage/'.$user->getID().'/';
|
|
} else {
|
|
$profile_uri = null;
|
|
}
|
|
|
|
$engine = id(new PhabricatorSettingsEditEngine())
|
|
->setController($this->getController())
|
|
->setNavigation($this->getNavigation())
|
|
->setIsSelfEdit($is_self)
|
|
->setProfileURI($profile_uri);
|
|
|
|
$preferences = $this->getPreferences();
|
|
|
|
$engine->setTargetObject($preferences);
|
|
|
|
return $engine->buildResponse();
|
|
}
|
|
|
|
final public function isEnabled() {
|
|
// Only enable the panel if it has any fields.
|
|
$field_keys = $this->getPanelSettingsKeys();
|
|
return (bool)$field_keys;
|
|
}
|
|
|
|
final public function newEditEnginePage() {
|
|
$field_keys = $this->getPanelSettingsKeys();
|
|
if (!$field_keys) {
|
|
return null;
|
|
}
|
|
|
|
$key = $this->getPanelKey();
|
|
$label = $this->getPanelName();
|
|
$panel_uri = $this->getPanelURI();
|
|
|
|
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');
|
|
}
|
|
|
|
}
|