1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Added Search Box Preferences

Summary:
Resolves T989
- users can now disable the '/' keyboard shortcut which focuses the
  search box
- users can now disable the jump nav functionality of the search box

Test Plan:
- verified that the '/' keyboard shortcut works with preference enabled
  or unset
- verified that '/' no longer has any effect and disappears from
  keyboard shortcuts help overlay with preference disabled
- verified that search boxes have jump nav capabilities with jump nav
  functionality preference unset or enabled
- verified that search boxes do not jump with jump nav preference
  disabled
- verified that the jump nav still works as a jump nav with jump nav
  preference disabled

Reviewers: epriestley

Reviewed By: epriestley

CC: simpkins, aran, epriestley, vrana

Maniphest Tasks: T989

Differential Revision: https://secure.phabricator.com/D1902
This commit is contained in:
David Fisher 2012-03-14 20:47:17 -07:00 committed by epriestley
parent 0c20d7900e
commit 1c9a8ccb7c
11 changed files with 193 additions and 63 deletions

View file

@ -814,7 +814,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-phabricator-keyboard-shortcuts' =>
array(
'uri' => '/res/ea3ea05e/rsrc/js/application/core/behavior-keyboard-shortcuts.js',
'uri' => '/res/825c9eef/rsrc/js/application/core/behavior-keyboard-shortcuts.js',
'type' => 'js',
'requires' =>
array(
@ -1578,17 +1578,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/KeyboardShortcut.js',
),
0 =>
array(
'uri' => '/res/b6096fdd/rsrc/js/javelin/lib/__tests__/URI.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-uri',
1 => 'javelin-php-serializer',
),
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
),
'phabricator-keyboard-shortcut-manager' =>
array(
'uri' => '/res/0be80136/rsrc/js/application/core/KeyboardShortcutManager.js',
@ -1638,6 +1627,17 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/PasteFileUpload.js',
),
0 =>
array(
'uri' => '/res/b6096fdd/rsrc/js/javelin/lib/__tests__/URI.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-uri',
1 => 'javelin-php-serializer',
),
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
),
'phabricator-prefab' =>
array(
'uri' => '/res/956c8474/rsrc/js/application/core/Prefab.js',
@ -2060,6 +2060,28 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/86fc0b0c/maniphest.pkg.js',
'type' => 'js',
),
'c18634d0' =>
array(
'name' => 'core.pkg.js',
'symbols' =>
array(
0 => 'javelin-mask',
1 => 'javelin-workflow',
2 => 'javelin-behavior-workflow',
3 => 'javelin-behavior-aphront-form-disable-on-submit',
4 => 'phabricator-keyboard-shortcut-manager',
5 => 'phabricator-keyboard-shortcut',
6 => 'javelin-behavior-phabricator-keyboard-shortcuts',
7 => 'javelin-behavior-refresh-csrf',
8 => 'javelin-behavior-phabricator-watch-anchor',
9 => 'javelin-behavior-phabricator-autofocus',
10 => 'phabricator-paste-file-upload',
11 => 'phabricator-menu-item',
12 => 'phabricator-dropdown-menu',
),
'uri' => '/res/pkg/c18634d0/core.pkg.js',
'type' => 'js',
),
'd87369d5' =>
array(
'name' => 'differential.pkg.js',
@ -2099,28 +2121,6 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/31583232/maniphest.pkg.css',
'type' => 'css',
),
95944588 =>
array(
'name' => 'core.pkg.js',
'symbols' =>
array(
0 => 'javelin-mask',
1 => 'javelin-workflow',
2 => 'javelin-behavior-workflow',
3 => 'javelin-behavior-aphront-form-disable-on-submit',
4 => 'phabricator-keyboard-shortcut-manager',
5 => 'phabricator-keyboard-shortcut',
6 => 'javelin-behavior-phabricator-keyboard-shortcuts',
7 => 'javelin-behavior-refresh-csrf',
8 => 'javelin-behavior-phabricator-watch-anchor',
9 => 'javelin-behavior-phabricator-autofocus',
10 => 'phabricator-paste-file-upload',
11 => 'phabricator-menu-item',
12 => 'phabricator-dropdown-menu',
),
'uri' => '/res/pkg/95944588/core.pkg.js',
'type' => 'js',
),
),
'reverse' =>
array(
@ -2151,7 +2151,7 @@ celerity_register_resource_map(array(
'javelin-behavior-aphront-basic-tokenizer' => '2af849fb',
'javelin-behavior-aphront-drag-and-drop' => 'd87369d5',
'javelin-behavior-aphront-drag-and-drop-textarea' => 'd87369d5',
'javelin-behavior-aphront-form-disable-on-submit' => '95944588',
'javelin-behavior-aphront-form-disable-on-submit' => 'c18634d0',
'javelin-behavior-buoyant' => 'd87369d5',
'javelin-behavior-differential-accept-with-errors' => 'd87369d5',
'javelin-behavior-differential-add-reviewers-and-ccs' => 'd87369d5',
@ -2167,17 +2167,17 @@ celerity_register_resource_map(array(
'javelin-behavior-maniphest-transaction-controls' => '86fc0b0c',
'javelin-behavior-maniphest-transaction-expand' => '86fc0b0c',
'javelin-behavior-maniphest-transaction-preview' => '86fc0b0c',
'javelin-behavior-phabricator-autofocus' => '95944588',
'javelin-behavior-phabricator-keyboard-shortcuts' => '95944588',
'javelin-behavior-phabricator-autofocus' => 'c18634d0',
'javelin-behavior-phabricator-keyboard-shortcuts' => 'c18634d0',
'javelin-behavior-phabricator-object-selector' => 'd87369d5',
'javelin-behavior-phabricator-watch-anchor' => '95944588',
'javelin-behavior-refresh-csrf' => '95944588',
'javelin-behavior-workflow' => '95944588',
'javelin-behavior-phabricator-watch-anchor' => 'c18634d0',
'javelin-behavior-refresh-csrf' => 'c18634d0',
'javelin-behavior-workflow' => 'c18634d0',
'javelin-dom' => '4fbae2af',
'javelin-event' => '4fbae2af',
'javelin-install' => '4fbae2af',
'javelin-json' => '4fbae2af',
'javelin-mask' => '95944588',
'javelin-mask' => 'c18634d0',
'javelin-request' => '4fbae2af',
'javelin-stratcom' => '4fbae2af',
'javelin-tokenizer' => '2af849fb',
@ -2189,7 +2189,7 @@ celerity_register_resource_map(array(
'javelin-uri' => '4fbae2af',
'javelin-util' => '4fbae2af',
'javelin-vector' => '4fbae2af',
'javelin-workflow' => '95944588',
'javelin-workflow' => 'c18634d0',
'maniphest-task-detail-css' => '31583232',
'maniphest-task-summary-css' => '31583232',
'maniphest-transaction-detail-css' => '31583232',
@ -2199,13 +2199,13 @@ celerity_register_resource_map(array(
'phabricator-core-css' => '78e8854e',
'phabricator-directory-css' => '78e8854e',
'phabricator-drag-and-drop-file-upload' => 'd87369d5',
'phabricator-dropdown-menu' => '95944588',
'phabricator-dropdown-menu' => 'c18634d0',
'phabricator-jump-nav' => '78e8854e',
'phabricator-keyboard-shortcut' => '95944588',
'phabricator-keyboard-shortcut-manager' => '95944588',
'phabricator-menu-item' => '95944588',
'phabricator-keyboard-shortcut' => 'c18634d0',
'phabricator-keyboard-shortcut-manager' => 'c18634d0',
'phabricator-menu-item' => 'c18634d0',
'phabricator-object-selector-css' => '1cb6883c',
'phabricator-paste-file-upload' => '95944588',
'phabricator-paste-file-upload' => 'c18634d0',
'phabricator-remarkup-css' => '78e8854e',
'phabricator-shaped-request' => 'd87369d5',
'phabricator-standard-page-view' => '78e8854e',

View file

@ -844,6 +844,7 @@ phutil_register_library_map(array(
'PhabricatorUserProfileSettingsPanelController' => 'applications/people/controller/settings/panels/profile',
'PhabricatorUserSSHKey' => 'applications/people/storage/usersshkey',
'PhabricatorUserSSHKeysSettingsPanelController' => 'applications/people/controller/settings/panels/sshkeys',
'PhabricatorUserSearchSettingsPanelController' => 'applications/people/controller/settings/panels/search',
'PhabricatorUserSettingsController' => 'applications/people/controller/settings',
'PhabricatorUserSettingsPanelController' => 'applications/people/controller/settings/panels/base',
'PhabricatorUserTestCase' => 'applications/people/storage/user/__tests__',
@ -1593,6 +1594,7 @@ phutil_register_library_map(array(
'PhabricatorUserProfileSettingsPanelController' => 'PhabricatorUserSettingsPanelController',
'PhabricatorUserSSHKey' => 'PhabricatorUserDAO',
'PhabricatorUserSSHKeysSettingsPanelController' => 'PhabricatorUserSettingsPanelController',
'PhabricatorUserSearchSettingsPanelController' => 'PhabricatorUserSettingsPanelController',
'PhabricatorUserSettingsController' => 'PhabricatorPeopleController',
'PhabricatorUserSettingsPanelController' => 'PhabricatorPeopleController',
'PhabricatorUserTestCase' => 'PhabricatorTestCase',

View file

@ -62,6 +62,9 @@ final class PhabricatorUserSettingsController
$delegate = new PhabricatorUserPreferenceSettingsPanelController(
$request);
break;
case 'search':
$delegate = new PhabricatorUserSearchSettingsPanelController($request);
break;
default:
$delegate = new PhabricatorUserOAuthSettingsPanelController($request);
$delegate->setOAuthProvider($oauth_providers[$this->page]);
@ -110,6 +113,7 @@ final class PhabricatorUserSettingsController
$sidenav->addSpacer();
$sidenav->addLabel('Application Settings');
$sidenav->addFilter('preferences', 'Display Preferences');
$sidenav->addFilter('search', 'Search Preferences');
$items = array();
foreach ($oauth_providers as $provider) {

View file

@ -16,6 +16,7 @@ phutil_require_module('phabricator', 'applications/people/controller/settings/pa
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/password');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/preferences');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/profile');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/search');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/sshkeys');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/layout/sidenavfilter');

View file

@ -0,0 +1,82 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorUserSearchSettingsPanelController
extends PhabricatorUserSettingsPanelController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$preferences = $user->loadPreferences();
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
$pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
if ($request->isFormPost()) {
$preferences->setPreference($pref_jump,
$request->getBool($pref_jump));
$preferences->setPreference($pref_shortcut,
$request->getBool($pref_shortcut));
$preferences->save();
return id(new AphrontRedirectResponse())
->setURI('/settings/page/search/?saved=true');
}
$form = id(new AphrontFormView())
->setUser($user)
->setAction('/settings/page/search/')
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox($pref_jump,
1,
'Enable jump nav functionality in all search boxes.',
$preferences->getPreference($pref_jump, 1))
->addCheckbox($pref_shortcut,
1,
'\'/\' focuses search box.',
$preferences->getPreference($pref_shortcut, 1))
)
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save'));
$panel = new AphrontPanelView();
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setHeader('Search Preferences');
$panel->appendChild($form);
$error_view = null;
if ($request->getStr('saved') === 'true') {
$error_view = id(new AphrontErrorView())
->setTitle('Preferences Saved')
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setErrors(array('Your preferences have been saved.'));
}
return id(new AphrontNullView())
->appendChild(
array(
$error_view,
$panel,
));
}
}

View file

@ -0,0 +1,22 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base');
phutil_require_module('phabricator', 'applications/people/storage/preferences');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/checkbox');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/null');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorUserSearchSettingsPanelController.php');

View file

@ -18,13 +18,16 @@
final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_TITLES = 'titles';
const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_TITLES = 'titles';
const PREFERENCE_RE_PREFIX = 're-prefix';
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
const PREFERENCE_MAILTAGS = 'mailtags';
const PREFERENCE_RE_PREFIX = 're-prefix';
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
const PREFERENCE_MAILTAGS = 'mailtags';
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
protected $userPHID;
protected $preferences = array();

View file

@ -44,7 +44,13 @@ final class PhabricatorSearchController
if ($request->isFormPost()) {
$query_str = $request->getStr('query');
$response = PhabricatorJumpNavHandler::jumpPostResponse($query_str);
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
if ($user && $user->loadPreferences()->getPreference($pref_jump, 1)) {
$response = PhabricatorJumpNavHandler::jumpPostResponse($query_str);
} else {
$response = null;
}
if ($response) {
return $response;
} else {

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/people/storage/preferences');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/constants/scope');

View file

@ -160,10 +160,18 @@ final class PhabricatorStandardPageView extends AphrontPageView {
'header' => AphrontRequest::getCSRFHeaderName(),
'current' => $current_token,
));
$pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
if ($user) {
$shortcut = $user->loadPreferences()->getPreference($pref_shortcut, 1);
} else {
$shortcut = 1;
}
Javelin::initBehavior(
'phabricator-keyboard-shortcuts',
array(
'helpURI' => '/help/keyboardshortcut/',
'search_shortcut' => $shortcut,
));
if ($console) {

View file

@ -29,13 +29,14 @@ JX.behavior('phabricator-keyboard-shortcuts', function(config) {
})
.register();
desc = 'Give keyboard focus to the search box.';
new JX.KeyboardShortcut('/', desc)
.setHandler(function() {
var search = JX.$("standard-search-box");
search.focus();
search.select();
})
.register();
if (config.search_shortcut) {
desc = 'Give keyboard focus to the search box.';
new JX.KeyboardShortcut('/', desc)
.setHandler(function() {
var search = JX.$("standard-search-box");
search.focus();
search.select();
})
.register();
}
});