mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add refresh/edit columns resource viewer actions (#12161)
* Add refresh/edit columns resource viewer actions * add actions
This commit is contained in:
@@ -30,9 +30,7 @@ export class ResourceViewerInput extends EditorInput {
|
|||||||
|
|
||||||
constructor(private _providerId: string, @IDataGridProviderService private _dataGridProvider: IDataGridProviderService) {
|
constructor(private _providerId: string, @IDataGridProviderService private _dataGridProvider: IDataGridProviderService) {
|
||||||
super();
|
super();
|
||||||
this.fetchColumns();
|
this.refresh().catch(err => onUnexpectedError(err));
|
||||||
this.fetchItems();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTypeId(): string {
|
public getTypeId(): string {
|
||||||
@@ -64,6 +62,13 @@ export class ResourceViewerInput extends EditorInput {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async refresh(): Promise<void> {
|
||||||
|
await Promise.all([
|
||||||
|
this.fetchColumns(),
|
||||||
|
this.fetchItems()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
private fetchColumns(): void {
|
private fetchColumns(): void {
|
||||||
this._dataGridProvider.getDataGridColumns(this._providerId).then(columns => {
|
this._dataGridProvider.getDataGridColumns(this._providerId).then(columns => {
|
||||||
this.columns = columns.map(col => {
|
this.columns = columns.map(col => {
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { Action } from 'vs/base/common/actions';
|
||||||
|
import * as nls from 'vs/nls';
|
||||||
|
import { ResourceViewerInput } from 'sql/workbench/browser/editor/resourceViewer/resourceViewerInput';
|
||||||
|
|
||||||
|
export class ResourceViewerEditColumns extends Action {
|
||||||
|
public static readonly ID = 'resourceViewer.editColumns';
|
||||||
|
public static readonly LABEL = nls.localize('resourceViewer.editColumns', "Edit Columns");
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(ResourceViewerEditColumns.ID, ResourceViewerEditColumns.LABEL, 'codicon edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(input: ResourceViewerInput): Promise<void> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ResourceViewerRefresh extends Action {
|
||||||
|
public static readonly ID = 'resourceViewer.refresh';
|
||||||
|
public static readonly LABEL = nls.localize('resourceViewer.refresh', "Refresh");
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(ResourceViewerRefresh.ID, ResourceViewerRefresh.LABEL, 'codicon refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(input: ResourceViewerInput): Promise<void> {
|
||||||
|
this.enabled = false;
|
||||||
|
try {
|
||||||
|
await input.refresh();
|
||||||
|
} finally {
|
||||||
|
this.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import { ResourceViewerInput } from 'sql/workbench/browser/editor/resourceViewer/resourceViewerInput';
|
import { ResourceViewerInput } from 'sql/workbench/browser/editor/resourceViewer/resourceViewerInput';
|
||||||
import { ResourceViewerTable } from 'sql/workbench/contrib/resourceViewer/browser/resourceViewerTable';
|
import { ResourceViewerTable } from 'sql/workbench/contrib/resourceViewer/browser/resourceViewerTable';
|
||||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||||
|
import { ResourceViewerEditColumns, ResourceViewerRefresh } from 'sql/workbench/contrib/resourceViewer/browser/resourceViewerActions';
|
||||||
|
|
||||||
export class ResourceViewerEditor extends EditorPane {
|
export class ResourceViewerEditor extends EditorPane {
|
||||||
public static readonly ID: string = 'workbench.editor.resource-viewer';
|
public static readonly ID: string = 'workbench.editor.resource-viewer';
|
||||||
@@ -50,8 +51,11 @@ export class ResourceViewerEditor extends EditorPane {
|
|||||||
header.className = 'resource-viewer-header';
|
header.className = 'resource-viewer-header';
|
||||||
this._actionBar = this._register(new Taskbar(header));
|
this._actionBar = this._register(new Taskbar(header));
|
||||||
|
|
||||||
|
const editColumnsAction = this._register(this._instantiationService.createInstance(ResourceViewerEditColumns));
|
||||||
|
const refreshAction = this._register(this._instantiationService.createInstance(ResourceViewerRefresh));
|
||||||
this._actionBar.setContent([
|
this._actionBar.setContent([
|
||||||
// TODO - chgagnon add actions
|
{ action: editColumnsAction },
|
||||||
|
{ action: refreshAction }
|
||||||
]);
|
]);
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
@@ -67,7 +71,7 @@ export class ResourceViewerEditor extends EditorPane {
|
|||||||
return resourceViewerTableContainer;
|
return resourceViewerTableContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get input(): ResourceViewerInput {
|
public get input(): ResourceViewerInput | undefined {
|
||||||
return this._input as ResourceViewerInput;
|
return this._input as ResourceViewerInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user