From 16556b831617c6c57fd41ace03aee6d55c303628 Mon Sep 17 00:00:00 2001 From: Alex Ma Date: Mon, 8 Mar 2021 14:05:05 -0800 Subject: [PATCH] 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 --- .../workbench/contrib/query/browser/actions.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/contrib/query/browser/actions.ts b/src/sql/workbench/contrib/query/browser/actions.ts index 4b01d2e6fe..67c02b614f 100644 --- a/src/sql/workbench/contrib/query/browser/actions.ts +++ b/src/sql/workbench/contrib/query/browser/actions.ts @@ -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 { + + 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;