mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Add a global setting for controlling the default main menu search scope
Summary: Fixes T13405. The default behavior of the global search bar isn't currently configurable, but can be made configurable fairly easily. Test Plan: Changed setting as an administrator, saw setting reflected as a user with no previous preference. As a user with an existing preference, saw preference retained. Maniphest Tasks: T13405 Differential Revision: https://secure.phabricator.com/D20787
This commit is contained in:
parent
adc2002d28
commit
7e2bec9280
4 changed files with 75 additions and 5 deletions
|
@ -4655,6 +4655,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSearchScopeSetting' => 'applications/settings/setting/PhabricatorSearchScopeSetting.php',
|
'PhabricatorSearchScopeSetting' => 'applications/settings/setting/PhabricatorSearchScopeSetting.php',
|
||||||
'PhabricatorSearchSelectField' => 'applications/search/field/PhabricatorSearchSelectField.php',
|
'PhabricatorSearchSelectField' => 'applications/search/field/PhabricatorSearchSelectField.php',
|
||||||
'PhabricatorSearchService' => 'infrastructure/cluster/search/PhabricatorSearchService.php',
|
'PhabricatorSearchService' => 'infrastructure/cluster/search/PhabricatorSearchService.php',
|
||||||
|
'PhabricatorSearchSettingsPanel' => 'applications/settings/panel/PhabricatorSearchSettingsPanel.php',
|
||||||
'PhabricatorSearchStringListField' => 'applications/search/field/PhabricatorSearchStringListField.php',
|
'PhabricatorSearchStringListField' => 'applications/search/field/PhabricatorSearchStringListField.php',
|
||||||
'PhabricatorSearchSubscribersField' => 'applications/search/field/PhabricatorSearchSubscribersField.php',
|
'PhabricatorSearchSubscribersField' => 'applications/search/field/PhabricatorSearchSubscribersField.php',
|
||||||
'PhabricatorSearchTextField' => 'applications/search/field/PhabricatorSearchTextField.php',
|
'PhabricatorSearchTextField' => 'applications/search/field/PhabricatorSearchTextField.php',
|
||||||
|
@ -11248,9 +11249,10 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSearchResultBucketGroup' => 'Phobject',
|
'PhabricatorSearchResultBucketGroup' => 'Phobject',
|
||||||
'PhabricatorSearchResultView' => 'AphrontView',
|
'PhabricatorSearchResultView' => 'AphrontView',
|
||||||
'PhabricatorSearchSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
'PhabricatorSearchSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||||
'PhabricatorSearchScopeSetting' => 'PhabricatorInternalSetting',
|
'PhabricatorSearchScopeSetting' => 'PhabricatorSelectSetting',
|
||||||
'PhabricatorSearchSelectField' => 'PhabricatorSearchField',
|
'PhabricatorSearchSelectField' => 'PhabricatorSearchField',
|
||||||
'PhabricatorSearchService' => 'Phobject',
|
'PhabricatorSearchService' => 'Phobject',
|
||||||
|
'PhabricatorSearchSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
|
||||||
'PhabricatorSearchStringListField' => 'PhabricatorSearchField',
|
'PhabricatorSearchStringListField' => 'PhabricatorSearchField',
|
||||||
'PhabricatorSearchSubscribersField' => 'PhabricatorSearchTokenizerField',
|
'PhabricatorSearchSubscribersField' => 'PhabricatorSearchTokenizerField',
|
||||||
'PhabricatorSearchTextField' => 'PhabricatorSearchField',
|
'PhabricatorSearchTextField' => 'PhabricatorSearchField',
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorSearchSettingsPanel
|
||||||
|
extends PhabricatorEditEngineSettingsPanel {
|
||||||
|
|
||||||
|
const PANELKEY = 'search';
|
||||||
|
|
||||||
|
public function getPanelName() {
|
||||||
|
return pht('Search');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPanelMenuIcon() {
|
||||||
|
return 'fa-search';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPanelGroupKey() {
|
||||||
|
return PhabricatorSettingsApplicationsPanelGroup::PANELGROUPKEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isTemplatePanel() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isUserPanel() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorSearchScopeSetting
|
final class PhabricatorSearchScopeSetting
|
||||||
extends PhabricatorInternalSetting {
|
extends PhabricatorSelectSetting {
|
||||||
|
|
||||||
const SETTINGKEY = 'search-scope';
|
const SETTINGKEY = 'search-scope';
|
||||||
|
|
||||||
|
@ -9,8 +9,33 @@ final class PhabricatorSearchScopeSetting
|
||||||
return pht('Search Scope');
|
return pht('Search Scope');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSettingPanelKey() {
|
||||||
|
return PhabricatorSearchSettingsPanel::PANELKEY;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSettingDefaultValue() {
|
public function getSettingDefaultValue() {
|
||||||
return 'all';
|
return 'all';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getControlInstructions() {
|
||||||
|
return pht(
|
||||||
|
'Choose the default behavior of the global search in the main menu.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSelectOptions() {
|
||||||
|
$scopes = PhabricatorMainMenuSearchView::getGlobalSearchScopeItems(
|
||||||
|
$this->getViewer(),
|
||||||
|
new PhabricatorSettingsApplication());
|
||||||
|
|
||||||
|
$scope_map = array();
|
||||||
|
foreach ($scopes as $scope) {
|
||||||
|
if (!isset($scope['value'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$scope_map[$scope['value']] = $scope['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $scope_map;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,9 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildModeSelector($selector_id, $application_id) {
|
public static function getGlobalSearchScopeItems(
|
||||||
$viewer = $this->getViewer();
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorApplication $application) {
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
|
@ -132,7 +133,6 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
|
||||||
|
|
||||||
$application_value = null;
|
$application_value = null;
|
||||||
$application_icon = self::DEFAULT_APPLICATION_ICON;
|
$application_icon = self::DEFAULT_APPLICATION_ICON;
|
||||||
$application = $this->getApplication();
|
|
||||||
if ($application) {
|
if ($application) {
|
||||||
$application_value = get_class($application);
|
$application_value = get_class($application);
|
||||||
if ($application->getApplicationSearchDocumentTypes()) {
|
if ($application->getApplicationSearchDocumentTypes()) {
|
||||||
|
@ -185,6 +185,14 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
|
||||||
'href' => PhabricatorEnv::getDoclink('Search User Guide'),
|
'href' => PhabricatorEnv::getDoclink('Search User Guide'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildModeSelector($selector_id, $application_id) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$items = self::getGlobalSearchScopeItems($viewer, $this->getApplication());
|
||||||
|
|
||||||
$scope_key = PhabricatorSearchScopeSetting::SETTINGKEY;
|
$scope_key = PhabricatorSearchScopeSetting::SETTINGKEY;
|
||||||
$current_value = $viewer->getUserSetting($scope_key);
|
$current_value = $viewer->getUserSetting($scope_key);
|
||||||
|
|
||||||
|
@ -196,6 +204,13 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$application = $this->getApplication();
|
||||||
|
|
||||||
|
$application_value = null;
|
||||||
|
if ($application) {
|
||||||
|
$application_value = get_class($application);
|
||||||
|
}
|
||||||
|
|
||||||
$selector = id(new PHUIButtonView())
|
$selector = id(new PHUIButtonView())
|
||||||
->setID($selector_id)
|
->setID($selector_id)
|
||||||
->addClass('phabricator-main-menu-search-dropdown')
|
->addClass('phabricator-main-menu-search-dropdown')
|
||||||
|
|
Loading…
Reference in a new issue