Skip to content

Commit

Permalink
Move Data Explorer action bar actions to Editor Actions and the Edito…
Browse files Browse the repository at this point in the history
…r Action Bar (#6000)
  • Loading branch information
softwarenerd authored Jan 15, 2025
1 parent 70f4a72 commit ebd0e02
Show file tree
Hide file tree
Showing 22 changed files with 562 additions and 80 deletions.
6 changes: 4 additions & 2 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3149,8 +3149,10 @@ class EditorActionBar extends BaseEditorOption<EditorOption.actionBar, IEditorAc
'editor.actionBar.enabled': {
type: 'boolean',
default: defaults.enabled,
description: nls.localize('actionBar.enabled', "Controls whether the action bar is shown."),

description: nls.localize(
'actionBar.enabled',
"Controls whether the action bar is shown."
),
}
}
);
Expand Down
8 changes: 8 additions & 0 deletions src/vs/platform/action/common/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export interface ICommandAction {
* or define toggle-info including an icon and a title that goes well with a checkmark.
*/
toggled?: ContextKeyExpression | ICommandActionToggleInfo;

// --- Start Positron
/**
* Gets or sets a value which indicates whether to display the title for the action when it
* appears on an action bar.
*/
displayTitleOnActionBar?: boolean;
// --- End Positron
}

export type ISerializableCommandAction = UriDto<ICommandAction>;
12 changes: 12 additions & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ export class MenuItemAction implements IAction {
readonly enabled: boolean;
readonly checked?: boolean;

// --- Start Positron ---
/**
* Gets a value which indicates whether to display the title for the action when it appears on
* an action bar.
*/
readonly displayTitleOnActionBar?: boolean;
// --- End Positron ---

constructor(
item: ICommandAction,
alt: ICommandAction | undefined,
Expand All @@ -528,6 +536,10 @@ export class MenuItemAction implements IAction {
this.enabled = !item.precondition || contextKeyService.contextMatchesRules(item.precondition);
this.checked = undefined;

// --- Start Positron ---
this.displayTitleOnActionBar = item.displayTitleOnActionBar;
// --- End Positron ---

let icon: ThemeIcon | undefined;

if (item.toggled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export const ActionBarActionButton = (props: ActionBarActionButtonProps) => {
action,
!useAlternativeAction
),
text: action instanceof MenuItemAction ?
action.displayTitleOnActionBar ?
action.label :
undefined :
undefined,
disabled: !action.enabled,
onMouseEnter: () => setMouseInside(true),
onMouseLeave: () => setMouseInside(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
text-overflow: ellipsis;
}

.disabled .action-bar-button-text {
color: var(--positronActionBar-disabledForeground);
}

.action-bar-button-icon {
padding: 0 6px;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { IAccessibilityService } from '../../../../platform/accessibility/common
* Constants.
*/
const EDITOR_ACTION_BAR_HEIGHT = 32;
const CONFIGURATION_SETTING = 'editor.actionBar.enabled';
export const EDITOR_ACTION_BAR_CONFIGURATION_SETTING = 'editor.actionBar.enabled';

/**
* EditorActionBarControl class.
Expand Down Expand Up @@ -212,7 +212,7 @@ export class EditorActionBarControlFactory {
@IInstantiationService private readonly _instantiationService: IInstantiationService
) {
// Check if the configuration setting is enabled. If so, create the control.
if (this._configurationService.getValue<boolean>(CONFIGURATION_SETTING)) {
if (this._configurationService.getValue<boolean>(EDITOR_ACTION_BAR_CONFIGURATION_SETTING)) {
this.createControl();
}

Expand All @@ -227,9 +227,9 @@ export class EditorActionBarControlFactory {
// configuration setting.
this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
// Check if the configuration setting has changed.
if (e.affectsConfiguration(CONFIGURATION_SETTING)) {
if (e.affectsConfiguration(EDITOR_ACTION_BAR_CONFIGURATION_SETTING)) {
// Process the change.
if (this._configurationService.getValue(CONFIGURATION_SETTING)) {
if (this._configurationService.getValue(EDITOR_ACTION_BAR_CONFIGURATION_SETTING)) {
// Create the control, if it doesn't exist.
if (!this._control) {
this.createControl();
Expand Down
24 changes: 11 additions & 13 deletions src/vs/workbench/browser/parts/editor/editorActionBarFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,17 @@ export class EditorActionBarFactory extends Disposable {
];

// Splice the move editor to new window command button into the right action bar elements.
if (auxiliaryWindow !== undefined) {
rightActionBarElements.splice(
rightActionBarElements.length - 1,
0,
<ActionBarCommandButton
disabled={auxiliaryWindow}
iconId='positron-open-in-new-window'
tooltip={positronMoveIntoNewWindowTooltip}
ariaLabel={positronMoveIntoNewWindowAriaLabel}
commandId='workbench.action.moveEditorToNewWindow'
/>
);
}
rightActionBarElements.splice(
rightActionBarElements.length - 1,
0,
<ActionBarCommandButton
disabled={auxiliaryWindow}
iconId='positron-open-in-new-window'
tooltip={positronMoveIntoNewWindowTooltip}
ariaLabel={positronMoveIntoNewWindowAriaLabel}
commandId='workbench.action.moveEditorToNewWindow'
/>
);

// Return the action bar.
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
min-width: 0;
min-height: 0;
display: grid;
grid-row: data-explorer-panel / end;
grid-template-rows: [filter-bar] min-content [data-explorer] 1fr [status-bar] 24px [end];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
height: 100%;
min-width: 0;
min-height: 0;
display: grid;
position: relative;
color: var(--vscode-positronDataExplorer-foreground);
background-color: var(--vscode-positronDataExplorer-background);
grid-template-rows: [action-bar] 32px [data-explorer-panel] 1fr [end];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import React, { PropsWithChildren, useEffect, useState } from 'react';
// Other dependencies.
import { DisposableStore } from '../../../base/common/lifecycle.js';
import { ILayoutService } from '../../../platform/layout/browser/layoutService.js';
import { PositronDataExplorerContextProvider } from './positronDataExplorerContext.js';
import { DataExplorerPanel } from './components/dataExplorerPanel/dataExplorerPanel.js';
import { IClipboardService } from '../../../platform/clipboard/common/clipboardService.js';
import { IAccessibilityService } from '../../../platform/accessibility/common/accessibility.js';
import { ActionBar } from './components/actionBar/actionBar.js';
import { PositronActionBarServices } from '../../../platform/positronActionBar/browser/positronActionBarState.js';
import { PositronDataExplorerContextProvider } from './positronDataExplorerContext.js';
import { DataExplorerPanel } from './components/dataExplorerPanel/dataExplorerPanel.js';
import { IPositronDataExplorerInstance } from '../../services/positronDataExplorer/browser/interfaces/positronDataExplorerInstance.js';
import { PositronDataExplorerClosed, PositronDataExplorerClosedStatus } from './components/dataExplorerClosed/positronDataExplorerClosed.js';

Expand Down Expand Up @@ -89,7 +88,6 @@ export const PositronDataExplorer = (props: PropsWithChildren<PositronDataExplor
return (
<PositronDataExplorerContextProvider {...props}>
<div className='positron-data-explorer'>
<ActionBar />
<DataExplorerPanel />
{closed && (
<PositronDataExplorerClosed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ export abstract class DataGridInstance extends Disposable {
*/
protected readonly _onDidUpdateEmitter = this._register(new Emitter<void>);

/**
* The onDidChangeColumnSorting event emitter.
*/
protected readonly _onDidChangeColumnSortingEmitter = this._register(new Emitter<boolean>);

//#endregion Protected Events

//#region Constructor & Dispose
Expand Down Expand Up @@ -1178,6 +1183,13 @@ export abstract class DataGridInstance extends Disposable {
return this._cursorRowIndex;
}

/**
* Gets a value which indicates whether column sorting is active.
*/
get isColumnSorting() {
return this._columnSortKeys.size > 0;
}

//#endregion Public Properties

//#region Public Events
Expand All @@ -1187,6 +1199,11 @@ export abstract class DataGridInstance extends Disposable {
*/
readonly onDidUpdate = this._onDidUpdateEmitter.event;

/**
* onDidChangeColumnSorting event.
*/
readonly onDidChangeColumnSorting = this._onDidChangeColumnSortingEmitter.event;

//#endregion Public Events

//#region Public Methods
Expand Down Expand Up @@ -1433,25 +1450,22 @@ export abstract class DataGridInstance extends Disposable {
columnIndex,
new ColumnSortKeyDescriptor(this._columnSortKeys.size, columnIndex, ascending)
);

// Fire the onDidUpdate event.
this._onDidUpdateEmitter.fire();

// Sort the data.
await this.doSortData();
} else if (ascending !== columnSortKey.ascending) {
// Update the column sort key.
columnSortKey.ascending = ascending;
} else {
// If the sort order has changed, update the column sort key.
if (ascending !== columnSortKey.ascending) {
// Update the sort order.
columnSortKey.ascending = ascending;
// Sorting has not unchanged. Do nothing.
return;
}

// Fire the onDidUpdate event.
this._onDidUpdateEmitter.fire();
// Fire the onDidChangeColumnSorting event.
this._onDidChangeColumnSortingEmitter.fire(true);

// Sort the data.
await this.doSortData();
}
}
// Fire the onDidUpdate event.
this._onDidUpdateEmitter.fire();

// Sort the data.
await this.doSortData();
}

/**
Expand All @@ -1476,6 +1490,9 @@ export abstract class DataGridInstance extends Disposable {
}
});

// Fire the onDidChangeColumnSorting event.
this._onDidChangeColumnSortingEmitter.fire(this._columnSortKeys.size > 0);

// Fire the onDidUpdate event.
this._onDidUpdateEmitter.fire();

Expand All @@ -1492,6 +1509,9 @@ export abstract class DataGridInstance extends Disposable {
// Clear column sort keys.
this._columnSortKeys.clear();

// Fire the onDidChangeColumnSorting event.
this._onDidChangeColumnSortingEmitter.fire(false);

// Fire the onDidUpdate event.
this._onDidUpdateEmitter.fire();

Expand Down
26 changes: 26 additions & 0 deletions src/vs/workbench/browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ import { AccessibilityProgressSignalScheduler } from '../../platform/accessibili
import { setProgressAcccessibilitySignalScheduler } from '../../base/browser/ui/progressbar/progressAccessibilitySignal.js';
import { AccessibleViewRegistry } from '../../platform/accessibility/browser/accessibleViewRegistry.js';
import { NotificationAccessibleView } from './parts/notifications/notificationAccessibleView.js';
// --- Start Positron ---
// eslint-disable-next-line no-duplicate-imports
import { LayoutSettings, EditorActionsLocation } from '../services/layout/browser/layoutService.js';
import { EDITOR_ACTION_BAR_CONFIGURATION_SETTING } from './parts/editor/editorActionBarControl.js';
// --- End Positron ---

export interface IWorkbenchOptions {

Expand Down Expand Up @@ -218,6 +223,27 @@ export class Workbench extends Layout {
// Configuration changes
this._register(configurationService.onDidChangeConfiguration(e => this.updateFontAliasing(e, configurationService)));

// --- Start Positron ---
// Add a onDidChangeConfiguration event listener to listen for changes to the editor action
// bar configuration setting. This is a temporary workaround that hides editor actions when
// the user has configured the editor action bar to be enabled. Eventually, editor actions
// will be replaced by the editor action bar. This approach allows testers to use both the
// editor actions and the editor action bar by adjusting the editor actions location after
// enabling the editor action bar.
this._register(configurationService.onDidChangeConfiguration(async e => {
// Check whether the editor action bar configuration setting has changed.
if (e.affectsConfiguration(EDITOR_ACTION_BAR_CONFIGURATION_SETTING)) {
// Process the editor action bar configuration setting.
await configurationService.updateValue(
LayoutSettings.EDITOR_ACTIONS_LOCATION,
configurationService.getValue(EDITOR_ACTION_BAR_CONFIGURATION_SETTING) ?
EditorActionsLocation.HIDDEN :
EditorActionsLocation.DEFAULT
);
}
}));
// --- End Positron ---

// Font Info
if (isNative) {
this._register(storageService.onWillSaveState(e => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import './inspectEditorTokens/inspectEditorTokens.js';
import './quickaccess/gotoLineQuickAccess.js';
import './quickaccess/gotoSymbolQuickAccess.js';
import './saveParticipants.js';
import './toggleActionBar.js';
import './toggleColumnSelection.js';
import './toggleMinimap.js';
import './toggleMultiCursorModifier.js';
Expand Down
13 changes: 6 additions & 7 deletions src/vs/workbench/contrib/codeEditor/browser/toggleActionBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize, localize2 } from '../../../../nls.js';
import { Action2, MenuId } from '../../../../platform/actions/common/actions.js';
import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
Expand All @@ -27,8 +27,8 @@ export class ToggleActionBarAction extends Action2 {
super({
id: ToggleActionBarAction.ID,
title: {
...localize2('toggleActionBar', "Toggle Editor Action Bar"),
mnemonicTitle: localize({ key: 'miActionBar', comment: ['&& denotes a mnemonic'] }, "&&Editor Action Bar"),
...localize2('toggleActionBar', "Toggle Action Bar"),
mnemonicTitle: localize({ key: 'miActionBar', comment: ['&& denotes a mnemonic'] }, "&&Action Bar"),
},
category: Categories.View,
f1: true,
Expand All @@ -49,8 +49,8 @@ export class ToggleActionBarAction extends Action2 {
// Get the configuration service.
const configurationService = accessor.get(IConfigurationService);

// Update the value.
return configurationService.updateValue(
// Update the action bar enabled state.
await configurationService.updateValue(
'editor.actionBar.enabled',
!configurationService.getValue('editor.actionBar.enabled')
);
Expand All @@ -60,5 +60,4 @@ export class ToggleActionBarAction extends Action2 {
/**
* Registers the action.
*/
// At the moment, do not register the ToggleActionBarAction because it is still experimental.
// registerAction2(ToggleActionBarAction);
registerAction2(ToggleActionBarAction);
Loading

0 comments on commit ebd0e02

Please sign in to comment.