mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fix context menu positioning. (#6992)
* hack in default actions into menu * fix tests
This commit is contained in:
@@ -65,7 +65,7 @@ class ObjectExplorerTester {
|
|||||||
@stressify({ dop: ObjectExplorerTester.ParallelCount })
|
@stressify({ dop: ObjectExplorerTester.ParallelCount })
|
||||||
async sqlDbContextMenuTest(): Promise<void> {
|
async sqlDbContextMenuTest(): Promise<void> {
|
||||||
const server = await getAzureServer();
|
const server = await getAzureServer();
|
||||||
const expectedActions = ['Disconnect', 'Delete Connection', 'Refresh', 'New Query', 'Manage', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
const expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
|
||||||
await this.verifyContextMenu(server, expectedActions);
|
await this.verifyContextMenu(server, expectedActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +75,10 @@ class ObjectExplorerTester {
|
|||||||
let expectedActions: string[] = [];
|
let expectedActions: string[] = [];
|
||||||
// Generate Scripts and Properties come from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
// Generate Scripts and Properties come from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
expectedActions = ['Refresh', 'New Query', 'Manage', 'New Notebook', 'Backup', 'Restore', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard', 'Generate Scripts...', 'Properties'];
|
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Refresh', 'Backup', 'Restore', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard', 'Generate Scripts...', 'Properties'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expectedActions = ['Refresh', 'New Query', 'Manage', 'New Notebook', 'Backup', 'Restore', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard'];
|
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Refresh', 'Backup', 'Restore', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard'];
|
||||||
}
|
}
|
||||||
await this.verifyDBContextMenu(server, 3000, expectedActions);
|
await this.verifyDBContextMenu(server, 3000, expectedActions);
|
||||||
}
|
}
|
||||||
@@ -89,10 +89,10 @@ class ObjectExplorerTester {
|
|||||||
let expectedActions: string[];
|
let expectedActions: string[];
|
||||||
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
expectedActions = ['Disconnect', 'Delete Connection', 'Refresh', 'New Query', 'Manage', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
|
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expectedActions = ['Disconnect', 'Delete Connection', 'Refresh', 'New Query', 'Manage', 'New Notebook', 'Data-tier Application wizard', 'Launch Profiler'];
|
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
|
||||||
}
|
}
|
||||||
await this.verifyContextMenu(server, expectedActions);
|
await this.verifyContextMenu(server, expectedActions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ configurationRegistry.registerConfiguration(dashboardConfig);
|
|||||||
// // Manage
|
// // Manage
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
group: '0_query',
|
group: '0_query',
|
||||||
order: 1,
|
order: 0,
|
||||||
command: {
|
command: {
|
||||||
id: DE_MANAGE_COMMAND_ID,
|
id: DE_MANAGE_COMMAND_ID,
|
||||||
title: localize('manage', "Manage")
|
title: localize('manage', "Manage")
|
||||||
@@ -49,7 +49,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||||
group: '0_query',
|
group: '0_query',
|
||||||
order: 1,
|
order: 0,
|
||||||
command: {
|
command: {
|
||||||
id: OE_MANAGE_COMMAND_ID,
|
id: OE_MANAGE_COMMAND_ID,
|
||||||
title: localize('manage', "Manage")
|
title: localize('manage', "Manage")
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectio
|
|||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
import { MenuId, IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
|
||||||
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
||||||
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
||||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||||
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||||
|
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||||
|
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides actions for the server tree elements
|
* Provides actions for the server tree elements
|
||||||
@@ -88,11 +90,32 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
let menu = this.menuService.createMenu(MenuId.ObjectExplorerItemContext, scopedContextService);
|
let menu = this.menuService.createMenu(MenuId.ObjectExplorerItemContext, scopedContextService);
|
||||||
|
|
||||||
// Fill in all actions
|
// Fill in all actions
|
||||||
let actions = getDefaultActions(context);
|
const builtIn = getDefaultActions(context);
|
||||||
let options = { arg: undefined, shouldForwardArgs: true };
|
const actions = [];
|
||||||
|
const options = { arg: undefined, shouldForwardArgs: true };
|
||||||
const groups = menu.getActions(options);
|
const groups = menu.getActions(options);
|
||||||
|
let insertIndex: number | undefined = 0;
|
||||||
|
const queryIndex = groups.findIndex(v => {
|
||||||
|
if (v[0] === '0_query') {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
insertIndex += v[1].length;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
insertIndex = queryIndex > -1 ? insertIndex + groups[queryIndex][1].length : undefined;
|
||||||
fillInActions(groups, actions, false);
|
fillInActions(groups, actions, false);
|
||||||
|
|
||||||
|
if (insertIndex) {
|
||||||
|
builtIn.unshift(new Separator());
|
||||||
|
actions.splice(insertIndex, 0, ...builtIn);
|
||||||
|
} else {
|
||||||
|
if (actions.length > 0) {
|
||||||
|
builtIn.push(new Separator());
|
||||||
|
}
|
||||||
|
actions.unshift(...builtIn);
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
scopedContextService.dispose();
|
scopedContextService.dispose();
|
||||||
menu.dispose();
|
menu.dispose();
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ new NewQueryTask().registerTask();
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||||
group: '0_query',
|
group: '0_query',
|
||||||
order: 0,
|
order: 1,
|
||||||
command: {
|
command: {
|
||||||
id: OE_NEW_QUERY_ACTION_ID,
|
id: OE_NEW_QUERY_ACTION_ID,
|
||||||
title: localize('newQuery', "New Query")
|
title: localize('newQuery', "New Query")
|
||||||
@@ -83,7 +83,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
// New Query
|
// New Query
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
group: '0_query',
|
group: '0_query',
|
||||||
order: 0,
|
order: 1,
|
||||||
command: {
|
command: {
|
||||||
id: DE_NEW_QUERY_COMMAND_ID,
|
id: DE_NEW_QUERY_COMMAND_ID,
|
||||||
title: localize('newQuery', "New Query")
|
title: localize('newQuery', "New Query")
|
||||||
|
|||||||
Reference in New Issue
Block a user