mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 03:58:33 -05:00
[Notebook] Run Parameters Action UI Component (#14889)
* Run Parameters Action UI Component * Update UX discussion - accept empty string
This commit is contained in:
@@ -442,6 +442,15 @@ Includes non-masked style declarations. */
|
||||
mask-image: url("clear.svg");
|
||||
}
|
||||
|
||||
.codicon:not(.masked-icon).icon-run-with-parameters {
|
||||
background-image: url("run-with-parameters.svg");
|
||||
}
|
||||
|
||||
.codicon.masked-icon.icon-run-with-parameters:before {
|
||||
-webkit-mask-image: url("run-with-parameters.svg");
|
||||
mask-image: url("run-with-parameters.svg");
|
||||
}
|
||||
|
||||
.codicon:not(.masked-icon).icon-shield {
|
||||
background-image: url("shield.svg");
|
||||
}
|
||||
|
||||
4
src/sql/media/icons/run-with-parameters.svg
Normal file
4
src/sql/media/icons/run-with-parameters.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.8874 6.36205V6.24753L13.5352 5.22324L12.5236 2.78658L10.6341 3.21919C10.5323 3.10892 10.4262 3.00289 10.316 2.90109L10.7486 1.01157L8.31192 0L7.28763 1.64777H7.17311C7.13494 1.64353 7.09677 1.64141 7.05859 1.64141C7.02042 1.64141 6.98225 1.64353 6.94408 1.64777H6.82956L5.80527 0L3.36861 1.01157L3.80123 2.90109C3.69095 3.00289 3.58492 3.10892 3.48312 3.21919L1.5936 2.78658L0.582031 5.22324L2.2298 6.24753C2.2298 6.2857 2.22768 6.32387 2.22344 6.36205V6.47656V6.59108C2.22768 6.62925 2.2298 6.66742 2.2298 6.7056L0.582031 7.72989L1.5936 10.1665L3.48312 9.73393C3.58492 9.8442 3.69095 9.95024 3.80123 10.052L3.36861 11.9416L5.80527 12.9531L6.82956 11.3054C6.86773 11.3054 6.9059 11.3075 6.94408 11.3117H7.05859H7.17311C7.21128 11.3075 7.24945 11.3054 7.28763 11.3054L8.31192 12.9531L8.50497 12.873L8.6309 12.0489L8.59821 12.0624L7.66299 10.561L7.35761 10.5864C7.26006 10.5949 7.16039 10.5992 7.05859 10.5992C6.96104 10.5992 6.86137 10.5949 6.75958 10.5864C6.65778 10.578 6.55811 10.5695 6.46056 10.561L5.51898 12.0624L4.19567 11.5153L4.59648 9.79119C4.43531 9.65546 4.28474 9.51974 4.14478 9.38402C4.00905 9.24829 3.87545 9.09984 3.74397 8.93867L2.01985 9.33948L1.47272 8.01618L2.97416 7.08096C2.96568 6.98341 2.95719 6.88373 2.94871 6.78194C2.94023 6.68015 2.93599 6.58048 2.93599 6.48292C2.93599 6.38113 2.94023 6.28146 2.94871 6.18391L2.97416 5.87853L1.47272 4.93695L2.01985 3.61364L3.74397 4.01445C3.87969 3.85328 4.01541 3.70483 4.15114 3.56911C4.28686 3.42914 4.43531 3.29342 4.59648 3.16194L4.19567 1.43782L5.51898 0.890686L6.4542 2.39213C6.55599 2.38365 6.65566 2.37516 6.75322 2.36668C6.85501 2.3582 6.9568 2.35396 7.05859 2.35396C7.15614 2.35396 7.25582 2.3582 7.35761 2.36668C7.4594 2.37516 7.55907 2.38365 7.65663 2.39213L8.59821 0.890686L9.92151 1.43782L9.5207 3.16194C9.68188 3.29766 9.83032 3.43338 9.96605 3.56911C10.106 3.70483 10.2417 3.85328 10.3732 4.01445L12.0973 3.61364L12.6445 4.93695L11.143 5.87217C11.1515 5.96972 11.16 6.06939 11.1685 6.17118C11.177 6.27298 11.1812 6.37265 11.1812 6.4702C11.1812 6.57199 11.177 6.67379 11.1685 6.77558C11.16 6.87313 11.1515 6.9728 11.143 7.07459L12.6445 8.01618L12.1132 9.30122L12.7351 9.65708L13.5352 7.72989L11.8874 6.7056V6.59108C11.8916 6.55291 11.8937 6.51473 11.8937 6.47656C11.8937 6.43839 11.8916 6.40022 11.8874 6.36205ZM7.98745 4.27529C7.69904 4.14805 7.38942 4.08443 7.05859 4.08443C6.72777 4.08443 6.41603 4.14805 6.12337 4.27529C5.83496 4.39829 5.5826 4.56795 5.36629 4.78426C5.14998 5.00057 4.9782 5.25505 4.85096 5.5477C4.72796 5.83612 4.66646 6.14574 4.66646 6.47656C4.66646 6.80739 4.72796 7.11913 4.85096 7.41178C4.9782 7.7002 5.14998 7.95256 5.36629 8.16887C5.5826 8.38518 5.83496 8.55695 6.12337 8.68419C6.41603 8.80719 6.72777 8.86869 7.05859 8.86869C7.38942 8.86869 7.69904 8.80719 7.98745 8.68419C8.28011 8.55695 8.53459 8.38518 8.7509 8.16887C8.96721 7.95256 9.13686 7.7002 9.25986 7.41178C9.3871 7.11913 9.45072 6.80739 9.45072 6.47656C9.45072 6.14574 9.3871 5.83612 9.25986 5.5477C9.13686 5.25505 8.96721 5.00057 8.7509 4.78426C8.53459 4.56795 8.28011 4.39829 7.98745 4.27529ZM7.71388 8.0289C7.5103 8.11373 7.29187 8.15614 7.05859 8.15614C6.82532 8.15614 6.60689 8.11373 6.4033 8.0289C6.19972 7.93983 6.02158 7.81895 5.86889 7.66626C5.7162 7.51358 5.59532 7.33544 5.50625 7.13185C5.42143 6.92827 5.37901 6.70984 5.37901 6.47656C5.37901 6.24329 5.42143 6.02486 5.50625 5.82127C5.59532 5.61769 5.7162 5.43955 5.86889 5.28686C6.02158 5.13417 6.19972 5.01541 6.4033 4.93058C6.60689 4.84152 6.82532 4.79698 7.05859 4.79698C7.29187 4.79698 7.5103 4.84152 7.71388 4.93058C7.91747 5.01541 8.09561 5.13417 8.2483 5.28686C8.40098 5.43955 8.51974 5.61769 8.60457 5.82127C8.69364 6.02486 8.73817 6.24329 8.73817 6.47656C8.73817 6.70984 8.69364 6.92827 8.60457 7.13185C8.51974 7.33544 8.40098 7.51358 8.2483 7.66626C8.09561 7.81895 7.91747 7.93983 7.71388 8.0289Z" fill="#0078D4"/>
|
||||
<path d="M9.58203 16V9L15.418 12.5L9.58203 16ZM10.582 10.766V14.234L13.473 12.5L10.582 10.766Z" fill="#0078D4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -28,7 +28,7 @@ import { INotebookService, INotebookParams, INotebookEditor, INotebookSection, I
|
||||
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { AddCellAction, KernelsDropdown, AttachToDropdown, TrustedAction, RunAllCellsAction, ClearAllOutputsAction, CollapseCellsAction } from 'sql/workbench/contrib/notebook/browser/notebookActions';
|
||||
import { AddCellAction, KernelsDropdown, AttachToDropdown, TrustedAction, RunAllCellsAction, ClearAllOutputsAction, CollapseCellsAction, RunParametersAction } from 'sql/workbench/contrib/notebook/browser/notebookActions';
|
||||
import { DropdownMenuActionViewItem } from 'sql/base/browser/ui/buttonMenu/buttonMenu';
|
||||
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
|
||||
@@ -129,7 +129,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
this.notebookService.removeNotebookEditor(this);
|
||||
}
|
||||
}
|
||||
|
||||
public get model(): NotebookModel | null {
|
||||
return this._model;
|
||||
}
|
||||
@@ -387,6 +386,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
this._trustedAction = this.instantiationService.createInstance(TrustedAction, 'notebook.Trusted', true);
|
||||
this._trustedAction.enabled = false;
|
||||
|
||||
let runParametersAction = this.instantiationService.createInstance(RunParametersAction, 'notebook.runParameters', true, this._notebookParams.notebookUri);
|
||||
|
||||
let taskbar = <HTMLElement>this.toolbar.nativeElement;
|
||||
this._actionBar = new Taskbar(taskbar, { actionViewItemProvider: action => this.actionItemProvider(action as Action) });
|
||||
this._actionBar.context = this._notebookParams.notebookUri;
|
||||
@@ -418,6 +419,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
{ action: collapseCellsAction },
|
||||
{ action: clearResultsButton },
|
||||
{ action: this._trustedAction },
|
||||
{ action: runParametersAction },
|
||||
]);
|
||||
} else {
|
||||
let kernelContainer = document.createElement('div');
|
||||
@@ -458,10 +460,9 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
{ action: this._trustedAction },
|
||||
{ action: this._runAllCellsAction },
|
||||
{ action: clearResultsButton },
|
||||
{ action: collapseCellsAction }
|
||||
{ action: collapseCellsAction },
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected initNavSection(): void {
|
||||
|
||||
@@ -79,6 +79,16 @@
|
||||
padding-left: 18px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.notebookEditor
|
||||
.in-preview
|
||||
.actions-container
|
||||
.action-item
|
||||
.codicon.icon-run-with-parameters:before {
|
||||
padding-left: 20px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.notebookEditor .in-preview .actions-container .action-item:last-child {
|
||||
margin-right: 14px;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import { INotebookService } from 'sql/workbench/services/notebook/browser/notebo
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { CellContext } from 'sql/workbench/contrib/notebook/browser/cellViews/codeActions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
|
||||
const msgLoading = localize('loading', "Loading kernels...");
|
||||
export const msgChanging = localize('changing', "Changing kernel...");
|
||||
@@ -39,6 +40,8 @@ const msgSelectConnection = localize('selectConnection', "Select Connection");
|
||||
const msgLocalHost = localize('localhost', "localhost");
|
||||
|
||||
export const noKernel: string = localize('noKernel', "No Kernel");
|
||||
const baseIconClass = 'codicon';
|
||||
const maskedIconClass = 'masked-icon';
|
||||
|
||||
// Action to add a cell to notebook based on cell type(code/markdown).
|
||||
export class AddCellAction extends Action {
|
||||
@@ -101,17 +104,15 @@ export abstract class TooltipFromLabelAction extends Action {
|
||||
// Action to clear outputs of all code cells.
|
||||
export class ClearAllOutputsAction extends TooltipFromLabelAction {
|
||||
private static readonly label = localize('clearResults', "Clear Results");
|
||||
private static readonly baseClass = 'codicon';
|
||||
private static readonly iconClass = 'icon-clear-results';
|
||||
private static readonly maskedIconClass = 'masked-icon';
|
||||
|
||||
constructor(id: string, toggleTooltip: boolean,
|
||||
@INotebookService private _notebookService: INotebookService) {
|
||||
super(id, {
|
||||
label: ClearAllOutputsAction.label,
|
||||
baseClass: ClearAllOutputsAction.baseClass,
|
||||
baseClass: baseIconClass,
|
||||
iconClass: ClearAllOutputsAction.iconClass,
|
||||
maskedIconClass: ClearAllOutputsAction.maskedIconClass,
|
||||
maskedIconClass: maskedIconClass,
|
||||
shouldToggleTooltip: toggleTooltip
|
||||
});
|
||||
}
|
||||
@@ -170,24 +171,22 @@ export class TrustedAction extends ToggleableAction {
|
||||
// Constants
|
||||
private static readonly trustedLabel = localize('trustLabel', "Trusted");
|
||||
private static readonly notTrustedLabel = localize('untrustLabel', "Not Trusted");
|
||||
private static readonly baseClass = 'codicon';
|
||||
private static readonly previewTrustedCssClass = 'icon-shield';
|
||||
private static readonly trustedCssClass = 'icon-trusted';
|
||||
private static readonly previewNotTrustedCssClass = 'icon-shield-x';
|
||||
private static readonly notTrustedCssClass = 'icon-notTrusted';
|
||||
private static readonly maskedIconClass = 'masked-icon';
|
||||
|
||||
constructor(
|
||||
id: string, toggleTooltip: boolean,
|
||||
@INotebookService private _notebookService: INotebookService
|
||||
) {
|
||||
super(id, {
|
||||
baseClass: TrustedAction.baseClass,
|
||||
baseClass: baseIconClass,
|
||||
toggleOnLabel: TrustedAction.trustedLabel,
|
||||
toggleOnClass: toggleTooltip === true ? TrustedAction.previewTrustedCssClass : TrustedAction.trustedCssClass,
|
||||
toggleOffLabel: TrustedAction.notTrustedLabel,
|
||||
toggleOffClass: toggleTooltip === true ? TrustedAction.previewNotTrustedCssClass : TrustedAction.notTrustedCssClass,
|
||||
maskedIconClass: TrustedAction.maskedIconClass,
|
||||
maskedIconClass: maskedIconClass,
|
||||
shouldToggleTooltip: toggleTooltip,
|
||||
isOn: false
|
||||
});
|
||||
@@ -232,22 +231,20 @@ export class RunAllCellsAction extends Action {
|
||||
export class CollapseCellsAction extends ToggleableAction {
|
||||
private static readonly collapseCells = localize('collapseAllCells', "Collapse Cells");
|
||||
private static readonly expandCells = localize('expandAllCells', "Expand Cells");
|
||||
private static readonly baseClass = 'codicon';
|
||||
private static readonly previewCollapseCssClass = 'icon-collapse-cells';
|
||||
private static readonly collapseCssClass = 'icon-hide-cells';
|
||||
private static readonly previewExpandCssClass = 'icon-expand-cells';
|
||||
private static readonly expandCssClass = 'icon-show-cells';
|
||||
private static readonly maskedIconClass = 'masked-icon';
|
||||
|
||||
constructor(id: string, toggleTooltip: boolean,
|
||||
@INotebookService private _notebookService: INotebookService) {
|
||||
super(id, {
|
||||
baseClass: CollapseCellsAction.baseClass,
|
||||
baseClass: baseIconClass,
|
||||
toggleOnLabel: CollapseCellsAction.expandCells,
|
||||
toggleOnClass: toggleTooltip === true ? CollapseCellsAction.previewExpandCssClass : CollapseCellsAction.expandCssClass,
|
||||
toggleOffLabel: CollapseCellsAction.collapseCells,
|
||||
toggleOffClass: toggleTooltip === true ? CollapseCellsAction.previewCollapseCssClass : CollapseCellsAction.collapseCssClass,
|
||||
maskedIconClass: CollapseCellsAction.maskedIconClass,
|
||||
maskedIconClass: maskedIconClass,
|
||||
shouldToggleTooltip: toggleTooltip,
|
||||
isOn: false
|
||||
});
|
||||
@@ -272,6 +269,101 @@ export class CollapseCellsAction extends ToggleableAction {
|
||||
}
|
||||
}
|
||||
|
||||
export class RunParametersAction extends TooltipFromLabelAction {
|
||||
private static readonly label = localize('runParameters', "Run with Parameters");
|
||||
private static readonly iconClass = 'icon-run-with-parameters';
|
||||
|
||||
constructor(id: string,
|
||||
toggleTooltip: boolean,
|
||||
context: URI,
|
||||
@IQuickInputService private quickInputService: IQuickInputService,
|
||||
@INotebookService private _notebookService: INotebookService,
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
) {
|
||||
super(id, {
|
||||
label: RunParametersAction.label,
|
||||
baseClass: baseIconClass,
|
||||
iconClass: RunParametersAction.iconClass,
|
||||
maskedIconClass: maskedIconClass,
|
||||
shouldToggleTooltip: toggleTooltip
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Default Parameters in Notebook from Parameter Cell
|
||||
* Uses that as Placeholder values for user to inject new values for
|
||||
* Once user enters all values it will open the new parameterized notebook
|
||||
* with injected parameters value from the QuickInput
|
||||
*/
|
||||
public async run(context: URI): Promise<void> {
|
||||
const editor = this._notebookService.findNotebookEditor(context);
|
||||
// Set defaultParameters to the parameter values in parameter cell
|
||||
let defaultParameters = new Map<string, string>();
|
||||
editor.cells.forEach(cell => {
|
||||
if (cell.isParameter) {
|
||||
for (let parameter of cell.source) {
|
||||
let param = parameter.split('=', 2);
|
||||
defaultParameters.set(param[0].trim(), param[1].trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Store new parameters values the user inputs
|
||||
let inputParameters = new Map<string, string>();
|
||||
let uriParams = new URLSearchParams();
|
||||
// Store new parameter values to map based off defaultParameters
|
||||
if (defaultParameters.size === 0) {
|
||||
// If there is no parameter cell indicate to user to create one
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Info,
|
||||
message: localize('noParametersCell', "This notebook cannot run with parameters until a parameter cell is added. [Learn more](https://docs.microsoft.com/sql/azure-data-studio/notebooks/notebooks-parameterization)."),
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
for (let key of defaultParameters.keys()) {
|
||||
let newParameterValue = await this.quickInputService.input({ prompt: key, value: defaultParameters.get(key), ignoreFocusLost: true });
|
||||
// If user cancels or escapes then it stops the action entirely
|
||||
if (newParameterValue === undefined) {
|
||||
return;
|
||||
}
|
||||
inputParameters.set(key, newParameterValue);
|
||||
}
|
||||
// Format the new parameters to be append to the URI
|
||||
for (let key of inputParameters.keys()) {
|
||||
// Will only add new injected parameters when the value is not the same as the defaultParameters values
|
||||
if (inputParameters.get(key) !== defaultParameters.get(key)) {
|
||||
// For empty strings we need to escape the value
|
||||
// so that it is kept when adding uriParams.toString() to filePath
|
||||
if (inputParameters.get(key) === '') {
|
||||
uriParams.append(key, '\'\'');
|
||||
} else {
|
||||
uriParams.append(key, inputParameters.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
let stringParams = unescape(uriParams.toString());
|
||||
context = context.with({ query: stringParams });
|
||||
return this.openParameterizedNotebook(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will be used once the showNotebookDocument can be used
|
||||
* TODO - Call Extensibility API for ShowNotebook
|
||||
* (showNotebookDocument to be utilized in Notebook Service)
|
||||
**/
|
||||
public async openParameterizedNotebook(uri: URI): Promise<void> {
|
||||
// const editor = this._notebookService.findNotebookEditor(uri);
|
||||
// let modelContents = editor.model.toJSON();
|
||||
// let basename = path.basename(uri.fsPath);
|
||||
// let untitledUri = uri.with({ authority: '', scheme: 'untitled', path: basename });
|
||||
// this._notebookService.showNotebookDocument(untitledUri, {
|
||||
// initialContent: modelContents,
|
||||
// preserveFocus: true
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
const showAllKernelsConfigName = 'notebook.showAllKernels';
|
||||
const workbenchPreviewConfigName = 'workbench.enablePreviewFeatures';
|
||||
export const noKernelName = localize('noKernel', "No Kernel");
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import * as azdata from 'azdata';
|
||||
import * as sinon from 'sinon';
|
||||
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
|
||||
import { AddCellAction, ClearAllOutputsAction, CollapseCellsAction, KernelsDropdown, msgChanging, NewNotebookAction, noKernelName, RunAllCellsAction, TrustedAction } from 'sql/workbench/contrib/notebook/browser/notebookActions';
|
||||
import { AddCellAction, ClearAllOutputsAction, CollapseCellsAction, KernelsDropdown, msgChanging, NewNotebookAction, noKernelName, RunAllCellsAction, RunParametersAction, TrustedAction } from 'sql/workbench/contrib/notebook/browser/notebookActions';
|
||||
import { ClientSessionStub, ContextViewProviderStub, NotebookComponentStub, NotebookModelStub, NotebookServiceStub } from 'sql/workbench/contrib/notebook/test/stubs';
|
||||
import { NotebookEditorStub } from 'sql/workbench/contrib/notebook/test/testCommon';
|
||||
import { ICellModel, INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
@@ -24,6 +24,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MockQuickInputService } from 'sql/workbench/contrib/notebook/test/common/quickInputServiceMock';
|
||||
|
||||
class TestClientSession extends ClientSessionStub {
|
||||
private _errorState: boolean = false;
|
||||
@@ -257,6 +258,24 @@ suite('Notebook Actions', function (): void {
|
||||
assert.strictEqual(actualCmdId, NewNotebookAction.INTERNAL_NEW_NOTEBOOK_CMD_ID);
|
||||
});
|
||||
|
||||
test.skip('Run with Parameters Action', async function (): Promise<void> {
|
||||
let mockNotification = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService);
|
||||
mockNotification.setup(n => n.notify(TypeMoq.It.isAny()));
|
||||
let quickInputService = new MockQuickInputService;
|
||||
|
||||
let action = new RunParametersAction('TestId', true, testUri, quickInputService, mockNotebookService.object, mockNotification.object);
|
||||
|
||||
// Normal use case
|
||||
const testCells = [<ICellModel>{
|
||||
isParameter: true,
|
||||
source: ['x=2.0\n', 'y=5.0']
|
||||
}];
|
||||
|
||||
mockNotebookEditor.setup(x => x.cells).returns(() => testCells);
|
||||
|
||||
assert.doesNotThrow(() => action.run(testUri));
|
||||
});
|
||||
|
||||
suite('Kernels dropdown', async () => {
|
||||
let kernelsDropdown: KernelsDropdown;
|
||||
let contextViewProvider: ContextViewProviderStub;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as Types from 'vs/base/common/types';
|
||||
|
||||
import { IInputBox, IInputOptions, IPickOptions, IQuickInputButton, IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
|
||||
export class MockQuickInputService implements IQuickInputService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
readonly onShow = Event.None;
|
||||
readonly onHide = Event.None;
|
||||
|
||||
readonly quickAccess = undefined!;
|
||||
|
||||
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;
|
||||
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;
|
||||
public pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {
|
||||
if (Types.isArray(picks)) {
|
||||
return Promise.resolve(<any>{ label: 'selectedPick', description: 'pick description', value: 'selectedPick' });
|
||||
} else {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
public input(options?: IInputOptions, token?: CancellationToken): Promise<string> {
|
||||
return Promise.resolve(options ? 'resolved' + options.prompt : 'resolved');
|
||||
}
|
||||
|
||||
backButton!: IQuickInputButton;
|
||||
|
||||
createQuickPick<T extends IQuickPickItem>(): IQuickPick<T> {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
createInputBox(): IInputBox {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
toggle(): void {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
accept(): Promise<void> {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
back(): Promise<void> {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
|
||||
cancel(): Promise<void> {
|
||||
throw new Error('not implemented.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user