mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -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) {
|
||||
super();
|
||||
this.fetchColumns();
|
||||
this.fetchItems();
|
||||
|
||||
this.refresh().catch(err => onUnexpectedError(err));
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
@@ -64,6 +62,13 @@ export class ResourceViewerInput extends EditorInput {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async refresh(): Promise<void> {
|
||||
await Promise.all([
|
||||
this.fetchColumns(),
|
||||
this.fetchItems()
|
||||
]);
|
||||
}
|
||||
|
||||
private fetchColumns(): void {
|
||||
this._dataGridProvider.getDataGridColumns(this._providerId).then(columns => {
|
||||
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 { ResourceViewerTable } from 'sql/workbench/contrib/resourceViewer/browser/resourceViewerTable';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { ResourceViewerEditColumns, ResourceViewerRefresh } from 'sql/workbench/contrib/resourceViewer/browser/resourceViewerActions';
|
||||
|
||||
export class ResourceViewerEditor extends EditorPane {
|
||||
public static readonly ID: string = 'workbench.editor.resource-viewer';
|
||||
@@ -50,8 +51,11 @@ export class ResourceViewerEditor extends EditorPane {
|
||||
header.className = 'resource-viewer-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([
|
||||
// TODO - chgagnon add actions
|
||||
{ action: editColumnsAction },
|
||||
{ action: refreshAction }
|
||||
]);
|
||||
return header;
|
||||
}
|
||||
@@ -67,7 +71,7 @@ export class ResourceViewerEditor extends EditorPane {
|
||||
return resourceViewerTableContainer;
|
||||
}
|
||||
|
||||
public get input(): ResourceViewerInput {
|
||||
public get input(): ResourceViewerInput | undefined {
|
||||
return this._input as ResourceViewerInput;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user