mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Add online services option to the search funnel (#147643)
This commit is contained in:
parent
e3e9e76355
commit
f291d53d74
|
@ -34,7 +34,7 @@ import { ConfigureLanguageBasedSettingsAction } from 'vs/workbench/contrib/prefe
|
|||
import { SettingsEditorContribution } from 'vs/workbench/contrib/preferences/browser/preferencesEditor';
|
||||
import { preferencesOpenSettingsIcon } from 'vs/workbench/contrib/preferences/browser/preferencesIcons';
|
||||
import { SettingsEditor2, SettingsFocusContext } from 'vs/workbench/contrib/preferences/browser/settingsEditor2';
|
||||
import { CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, CONTEXT_KEYBINDING_FOCUS, CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, CONTEXT_WHEN_FOCUS, KEYBINDINGS_EDITOR_COMMAND_ADD, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND_TITLE, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_DEFINE_WHEN, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SEARCH, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_SORTBY_PRECEDENCE, KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_EXTENSION_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS, MODIFIED_SETTING_TAG, REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, CONTEXT_KEYBINDING_FOCUS, CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR, CONTEXT_SETTINGS_ROW_FOCUS, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, CONTEXT_WHEN_FOCUS, KEYBINDINGS_EDITOR_COMMAND_ADD, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND_TITLE, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_DEFINE_WHEN, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SEARCH, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_SORTBY_PRECEDENCE, KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_EXTENSION_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS, REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { PreferencesContribution } from 'vs/workbench/contrib/preferences/common/preferencesContribution';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
@ -54,7 +54,6 @@ const SETTINGS_EDITOR_COMMAND_FOCUS_CONTROL = 'settings.action.focusSettingContr
|
|||
const SETTINGS_EDITOR_COMMAND_FOCUS_UP = 'settings.action.focusLevelUp';
|
||||
|
||||
const SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON = 'settings.switchToJSON';
|
||||
const SETTINGS_EDITOR_COMMAND_FILTER_MODIFIED = 'settings.filterByModified';
|
||||
const SETTINGS_EDITOR_COMMAND_FILTER_ONLINE = 'settings.filterByOnline';
|
||||
const SETTINGS_EDITOR_COMMAND_FILTER_TELEMETRY = 'settings.filterByTelemetry';
|
||||
const SETTINGS_EDITOR_COMMAND_FILTER_UNTRUSTED = 'settings.filterUntrusted';
|
||||
|
@ -393,36 +392,15 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
|
|||
return accessor.get(IPreferencesService).openFolderSettings({ folderUri: resource });
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FILTER_MODIFIED,
|
||||
title: { value: nls.localize('filterModifiedLabel', "Show modified settings"), original: 'Show modified settings' },
|
||||
menu: {
|
||||
id: MenuId.EditorTitle,
|
||||
group: '1_filter',
|
||||
order: 1,
|
||||
when: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR.toNegated())
|
||||
}
|
||||
});
|
||||
}
|
||||
run(accessor: ServicesAccessor, resource: URI) {
|
||||
const editorPane = accessor.get(IEditorService).activeEditorPane;
|
||||
if (editorPane instanceof SettingsEditor2) {
|
||||
editorPane.focusSearch(`@${MODIFIED_SETTING_TAG}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FILTER_ONLINE,
|
||||
title: { value: nls.localize('filterOnlineServicesLabel', "Show settings for online services"), original: 'Show settings for online services' },
|
||||
title: nls.localize({ key: 'miOpenOnlineSettings', comment: ['&& denotes a mnemonic'] }, "&&Online Services Settings"),
|
||||
menu: {
|
||||
id: MenuId.EditorTitle,
|
||||
group: '1_filter',
|
||||
id: MenuId.MenubarPreferencesMenu,
|
||||
group: '1_settings',
|
||||
order: 2,
|
||||
when: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR.toNegated())
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -435,22 +413,6 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
|
|||
}
|
||||
}
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '1_settings',
|
||||
command: {
|
||||
id: SETTINGS_EDITOR_COMMAND_FILTER_ONLINE,
|
||||
title: nls.localize({ key: 'miOpenOnlineSettings', comment: ['&& denotes a mnemonic'] }, "&&Online Services Settings")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: SETTINGS_EDITOR_COMMAND_FILTER_ONLINE,
|
||||
title: nls.localize('onlineServices', "Online Services Settings")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestCont
|
|||
import { localize } from 'vs/nls';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { SuggestEnabledInput } from 'vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput';
|
||||
import { EXTENSION_SETTING_TAG, FEATURE_SETTING_TAG, GENERAL_TAG_SETTING_TAG, ID_SETTING_TAG, LANGUAGE_SETTING_TAG, MODIFIED_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { EXTENSION_SETTING_TAG, FEATURE_SETTING_TAG, GENERAL_TAG_SETTING_TAG, LANGUAGE_SETTING_TAG, MODIFIED_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
|
||||
export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
|
||||
private readonly suggestController: SuggestController | null;
|
||||
|
@ -47,6 +47,9 @@ export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenu
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The created action appends a query to the search widget search string. It optionally triggers suggestions.
|
||||
*/
|
||||
private createAction(id: string, label: string, tooltip: string, queryToAppend: string, triggerSuggest: boolean): IAction {
|
||||
return {
|
||||
id,
|
||||
|
@ -60,24 +63,30 @@ export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenu
|
|||
};
|
||||
}
|
||||
|
||||
private createModifiedAction(): IAction {
|
||||
// The modified action works slightly differently than the other actions.
|
||||
// It is more like a checkbox on/off toggle.
|
||||
const queryContainsModifiedTag = this.searchWidget.getValue().split(' ').some(word => word === `@${MODIFIED_SETTING_TAG}`);
|
||||
/**
|
||||
* The created action appends a query to the search widget search string, if the query does not exist.
|
||||
* Otherwise, it removes the query from the search widget search string.
|
||||
* The action does not trigger suggestions after adding or removing the query.
|
||||
*/
|
||||
private createToggleAction(id: string, label: string, tooltip: string, queryToAppend: string): IAction {
|
||||
const splitCurrentQuery = this.searchWidget.getValue().split(' ');
|
||||
const queryContainsQueryToAppend = splitCurrentQuery.includes(queryToAppend);
|
||||
return {
|
||||
id: 'modifiedSettingsSearch',
|
||||
label: localize('modifiedSettingsSearch', "Modified"),
|
||||
tooltip: localize('modifiedSettingsSearchTooltip', "View modified settings only"),
|
||||
id,
|
||||
label,
|
||||
tooltip,
|
||||
class: undefined,
|
||||
enabled: true,
|
||||
checked: queryContainsModifiedTag,
|
||||
checked: queryContainsQueryToAppend,
|
||||
run: () => {
|
||||
// Append the tag, otherwise remove it from the query.
|
||||
if (!queryContainsModifiedTag) {
|
||||
this.searchWidget.setValue(this.searchWidget.getValue().trimEnd() + ` @${MODIFIED_SETTING_TAG}`);
|
||||
if (!queryContainsQueryToAppend) {
|
||||
const trimmedCurrentQuery = this.searchWidget.getValue().trimEnd();
|
||||
const newQuery = trimmedCurrentQuery ? trimmedCurrentQuery + ' ' + queryToAppend : queryToAppend;
|
||||
this.searchWidget.setValue(newQuery);
|
||||
} else {
|
||||
const queryWithoutModifiedTag = this.searchWidget.getValue().split(' ').filter(word => word !== `@${MODIFIED_SETTING_TAG}`).join(' ');
|
||||
this.searchWidget.setValue(queryWithoutModifiedTag);
|
||||
const queryWithRemovedTags = this.searchWidget.getValue().split(' ')
|
||||
.filter(word => word !== queryToAppend).join(' ');
|
||||
this.searchWidget.setValue(queryWithRemovedTags);
|
||||
}
|
||||
this.searchWidget.focus();
|
||||
},
|
||||
|
@ -87,7 +96,12 @@ export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenu
|
|||
|
||||
getActions(): IAction[] {
|
||||
return [
|
||||
this.createModifiedAction(),
|
||||
this.createToggleAction(
|
||||
'modifiedSettingsSearch',
|
||||
localize('modifiedSettingsSearch', "Modified"),
|
||||
localize('modifiedSettingsSearchTooltip', "Add or remove modified settings filter"),
|
||||
`@${MODIFIED_SETTING_TAG}`
|
||||
),
|
||||
this.createAction(
|
||||
'extSettingsSearch',
|
||||
localize('extSettingsSearch', "Extension ID..."),
|
||||
|
@ -116,12 +130,11 @@ export class SettingsSearchFilterDropdownMenuActionViewItem extends DropdownMenu
|
|||
`@${LANGUAGE_SETTING_TAG}`,
|
||||
true
|
||||
),
|
||||
this.createAction(
|
||||
'idSettingsSearch',
|
||||
localize('idSettingsSearch', "Setting ID..."),
|
||||
localize('idSettingsSearchTooltip', "Add setting ID filter"),
|
||||
`@${ID_SETTING_TAG}`,
|
||||
false
|
||||
this.createToggleAction(
|
||||
'onlineSettingsSearch',
|
||||
localize('onlineSettingsSearch', "Online services"),
|
||||
localize('onlineSettingsSearchTooltip', "Show settings for online services"),
|
||||
'@tag:usesOnlineServices'
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue