Info prompt for results encoding when saving to JSON (#14533)

* encoding message prompt added.

* added don't show again prompt

* global scope added

* utc8 warning added.

* Remove extra space
This commit is contained in:
Alex Ma
2021-03-08 14:05:05 -08:00
committed by GitHub
parent 9d1db372f0
commit 16556b8316

View File

@@ -8,9 +8,10 @@ import { localize } from 'vs/nls';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Table } from 'sql/base/browser/ui/table/table';
import { QueryEditor } from './queryEditor';
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
import { CellSelectionModel } from 'sql/base/browser/ui/table/plugins/cellSelectionModel.plugin';
import { IGridDataProvider } from 'sql/workbench/services/query/common/gridDataProvider';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { INotificationService, Severity, NeverShowAgainScope } from 'vs/platform/notification/common/notification';
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
import { GridTableState } from 'sql/workbench/common/editor/query/gridTableState';
import * as Constants from 'sql/workbench/contrib/extensions/common/constants';
@@ -61,12 +62,24 @@ export class SaveResultAction extends Action {
label: string,
icon: string,
private format: SaveFormat,
@INotificationService private notificationService: INotificationService
@INotificationService private notificationService: INotificationService,
@IEditorService private editorService: IEditorService,
) {
super(id, label, icon);
}
public async run(context: IGridActionContext): Promise<boolean> {
const activeEditor = this.editorService.activeEditorPane as QueryEditor;
let input = activeEditor.input as UntitledQueryEditorInput;
if (input.getEncoding() !== 'utf8') {
this.notificationService.notify({
severity: Severity.Info,
message: localize('jsonEncoding', "Results encoding will not be saved when exporting to JSON, remember to save with desired encoding once file is created."),
neverShowAgain: { id: 'ignoreJsonEncoding', scope: NeverShowAgainScope.GLOBAL }
});
}
if (!context.gridDataProvider.canSerialize) {
this.notificationService.warn(localize('saveToFileNotSupported', "Save to file is not supported by the backing data source"));
return false;