@microsoft/vscode-azext-utils
Advanced tools
Comparing version 2.2.0-agent.4 to 2.2.0-agent.5
@@ -81,2 +81,3 @@ "use strict"; | ||
__exportStar(require("./utils/randomUtils"), exports); | ||
__exportStar(require("./utils/validationUtils"), exports); | ||
__exportStar(require("./wizard/AzureNameStep"), exports); | ||
@@ -83,0 +84,0 @@ __exportStar(require("./wizard/AzureWizard"), exports); |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AzExtUserInput = void 0; | ||
exports.addStepTelemetry = exports.AzExtUserInput = void 0; | ||
const vscode_1 = require("vscode"); | ||
@@ -25,6 +25,6 @@ const errors_1 = require("../errors"); | ||
class AzExtUserInput { | ||
constructor(context) { | ||
this._onDidFinishPromptEmitter = new vscode_1.EventEmitter(); | ||
constructor(context, onDidFinishPromptEmitter) { | ||
this._isPrompting = false; | ||
this._context = context; | ||
this._onDidFinishPromptEmitter = onDidFinishPromptEmitter || new vscode_1.EventEmitter(); | ||
} | ||
@@ -131,2 +131,3 @@ get onDidFinishPrompt() { | ||
} | ||
exports.addStepTelemetry = addStepTelemetry; | ||
function convertToStepName(prompt) { | ||
@@ -133,0 +134,0 @@ return prompt.replace(/\s/g, '').slice(0, 20); |
@@ -17,2 +17,4 @@ "use strict"; | ||
exports.AzExtUserInputWithInputQueue = void 0; | ||
const vscode = require("vscode"); | ||
const errors_1 = require("../errors"); | ||
const AzExtUserInput_1 = require("./AzExtUserInput"); | ||
@@ -23,14 +25,26 @@ /** | ||
* | ||
* @todo Move to vscode-azext-utils, or somewhere that both vscode-azureagent and service extensions have access to. | ||
* | ||
* @todo Should the standard implementation of IAzureUserInput support taking in an {@link AzureUserInputQueue}, or should there | ||
* this new implementation of IAzureUserInput be maintained instead? | ||
* @todo Should the standard implementation of IAzureUserInput support taking in an {@link AzureUserInputQueue} instead of having this classs? | ||
*/ | ||
class AzExtUserInputWithInputQueue { | ||
constructor(context, returnValueQueue) { | ||
this._realAzureUserInput = new AzExtUserInput_1.AzExtUserInput(context); | ||
this._context = context; | ||
this._onDidFinishPromptEmitter = new vscode.EventEmitter(); | ||
this._realAzureUserInput = new AzExtUserInput_1.AzExtUserInput(context, this._onDidFinishPromptEmitter); | ||
this._inputsQueue = returnValueQueue; | ||
this._isPrompting = false; | ||
} | ||
get onDidFinishPrompt() { | ||
return this._onDidFinishPromptEmitter.event; | ||
} | ||
get isPrompting() { | ||
return this._isPrompting; | ||
} | ||
showQuickPick(items, options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
(0, AzExtUserInput_1.addStepTelemetry)(this._context, options.stepName, 'quickPick', options.placeHolder); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
this._isPrompting = true; | ||
let result; | ||
@@ -48,38 +62,78 @@ const nextItemInQueue = this._inputsQueue.shift(); | ||
result = matchingItem; | ||
this._onDidFinishPromptEmitter.fire({ value: result }); | ||
} | ||
this._realAzureUserInput["_onDidFinishPromptEmitter"].fire({ value: result }); | ||
this._isPrompting = false; | ||
return result; | ||
}); | ||
} | ||
showInputBox(_options) { | ||
return this._getNextItemInQueueOrCallRealAzureUserInput(() => __awaiter(this, void 0, void 0, function* () { return this._realAzureUserInput.showInputBox(_options); })); | ||
} | ||
showWarningMessage(message, ...items) { | ||
showInputBox(options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
(0, AzExtUserInput_1.addStepTelemetry)(this._context, options.stepName, 'inputBox', options.prompt); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
this._isPrompting = true; | ||
let result; | ||
const nextItemInQueue = this._inputsQueue.shift(); | ||
if (!nextItemInQueue) { | ||
return this._realAzureUserInput.showWarningMessage(message, ...items); | ||
result = yield this._realAzureUserInput.showInputBox(options); | ||
} | ||
else { | ||
const resolvedItems = yield Promise.resolve(items); | ||
const matchingItem = resolvedItems.find(item => item.title === nextItemInQueue.title); | ||
if (!matchingItem) { | ||
throw new Error(`Could not find item with title "${nextItemInQueue.title}" in quick pick items`); | ||
} | ||
return matchingItem; | ||
result = nextItemInQueue; | ||
this._onDidFinishPromptEmitter.fire({ | ||
value: result, | ||
matchesDefault: result === options.value | ||
}); | ||
} | ||
this._isPrompting = false; | ||
return result; | ||
}); | ||
} | ||
showOpenDialog(options) { | ||
return this._getNextItemInQueueOrCallRealAzureUserInput(() => __awaiter(this, void 0, void 0, function* () { return this._realAzureUserInput.showOpenDialog(options); })); | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
(0, AzExtUserInput_1.addStepTelemetry)(this._context, options.stepName, 'openDialog', options.title); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
this._isPrompting = true; | ||
let result; | ||
const nextItemInQueue = this._inputsQueue.shift(); | ||
if (!nextItemInQueue) { | ||
result = yield this._realAzureUserInput.showOpenDialog(options); | ||
} | ||
else { | ||
result = nextItemInQueue; | ||
this._onDidFinishPromptEmitter.fire({ value: result }); | ||
} | ||
this._isPrompting = false; | ||
return result; | ||
}); | ||
} | ||
get onDidFinishPrompt() { | ||
return this._realAzureUserInput.onDidFinishPrompt; | ||
} | ||
_getNextItemInQueueOrCallRealAzureUserInput(realAzureUserInputMethod) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
showWarningMessage(message, ...args) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let result = this._inputsQueue.shift(); | ||
if (!result) { | ||
result = (yield realAzureUserInputMethod()); | ||
let stepName; | ||
const firstArg = args[0]; | ||
if (typeof firstArg === 'object' && firstArg && 'stepName' in firstArg) { | ||
stepName = firstArg.stepName; | ||
} | ||
(0, AzExtUserInput_1.addStepTelemetry)(this._context, stepName, 'warningMessage', message); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
this._isPrompting = true; | ||
let result; | ||
const nextItemInQueue = this._inputsQueue.shift(); | ||
if (!nextItemInQueue) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment | ||
result = yield this._realAzureUserInput.showWarningMessage(message, ...args); | ||
} | ||
else { | ||
result = nextItemInQueue; | ||
this._onDidFinishPromptEmitter.fire({ value: result }); | ||
} | ||
this._isPrompting = false; | ||
return result; | ||
@@ -86,0 +140,0 @@ }); |
{ | ||
"name": "@microsoft/vscode-azext-utils", | ||
"author": "Microsoft Corporation", | ||
"version": "2.2.0-agent.4", | ||
"version": "2.2.0-agent.5", | ||
"description": "Common UI tools for developing Azure extensions for VS Code", | ||
@@ -6,0 +6,0 @@ "tags": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
418736
88
8150