mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 01:25:38 -05:00
Adds functionality to copy table column headers (#21564)
* Adds functionality to copy table column headers * Minor clean up * Code review changes * Removes unneeded comma
This commit is contained in:
@@ -23,6 +23,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { getChartMaxRowCount, notifyMaxRowCountExceeded } from 'sql/workbench/contrib/charts/browser/utils';
|
||||
import { IEncodingSupport } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
||||
export interface IGridActionContext {
|
||||
gridDataProvider: IGridDataProvider;
|
||||
@@ -122,6 +123,26 @@ export class CopyResultAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
export class CopyHeadersAction extends Action {
|
||||
private static ID = 'grid.copyHeaders';
|
||||
private static LABEL = localize('copyHeaders', 'Copy Headers');
|
||||
|
||||
constructor(
|
||||
@IClipboardService private clipboardService: IClipboardService
|
||||
) {
|
||||
super(CopyHeadersAction.ID, CopyHeadersAction.LABEL);
|
||||
}
|
||||
|
||||
public override async run(context: IGridActionContext): Promise<void> {
|
||||
// Starting at index 1 to ignore the first column of row numbers
|
||||
const columnHeaders = context.table.columns.slice(1, context.table.columns.length)
|
||||
.map(c => c.name ? c.name : '')
|
||||
.join(',');
|
||||
|
||||
await this.clipboardService.writeText(columnHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
export class SelectAllGridAction extends Action {
|
||||
public static ID = 'grid.selectAll';
|
||||
public static LABEL = localize('selectAll', "Select All");
|
||||
|
||||
Reference in New Issue
Block a user