@microsoft/vscode-azext-utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -9,5 +9,6 @@ /*--------------------------------------------------------------------------------------------- | ||
import type { Environment } from '@azure/ms-rest-azure-env'; | ||
import { Disposable, Event, ExtensionContext, FileChangeEvent, FileChangeType, FileStat, FileSystemProvider, FileType, InputBoxOptions, MarkdownString, MessageItem, MessageOptions, OpenDialogOptions, OutputChannel, Progress, QuickPickItem, QuickPickOptions, TextDocumentShowOptions, ThemeIcon, TreeDataProvider, TreeItem, Uri } from 'vscode'; | ||
import { CancellationToken, CancellationTokenSource, Disposable, Event, ExtensionContext, FileChangeEvent, FileChangeType, FileStat, FileSystemProvider, FileType, InputBoxOptions, MarkdownString, MessageItem, MessageOptions, OpenDialogOptions, OutputChannel, Progress, QuickPickItem, QuickPickOptions, TextDocumentShowOptions, ThemeIcon, TreeDataProvider, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; | ||
import { TargetPopulation } from 'vscode-tas-client'; | ||
import { AzureExtensionApi, AzureExtensionApiProvider } from './api'; | ||
import { AppResource } from './unified'; | ||
@@ -884,6 +885,50 @@ /** | ||
export interface ActivityTreeItemOptions { | ||
label: string; | ||
contextValuesToAdd?: string[]; | ||
collapsibleState?: TreeItemCollapsibleState; | ||
getChildren?: (parent: AzExtParentTreeItem) => AzExtTreeItem[] | Promise<AzExtTreeItem[]>; | ||
} | ||
type ActivityEventData<T> = ActivityTreeItemOptions & T; | ||
export type OnStartActivityData = ActivityEventData<{}>; | ||
export type OnProgressActivityData = ActivityEventData<{ message?: string }>; | ||
export type OnSuccessActivityData = ActivityEventData<{}>; | ||
export type OnErrorActivityData = ActivityEventData<{ error: unknown }>; | ||
export declare interface Activity { | ||
id: string; | ||
cancellationTokenSource?: CancellationTokenSource; | ||
onStart: Event<OnStartActivityData>; | ||
onProgress: Event<OnProgressActivityData>; | ||
onSuccess: Event<OnSuccessActivityData>; | ||
onError: Event<OnErrorActivityData>; | ||
} | ||
export type ActivityTask<R> = (progress: Progress<{ message?: string, increment?: number }>, cancellationToken: CancellationToken) => Promise<R>; | ||
export abstract class ActivityBase<R> implements Activity { | ||
public readonly onStart: Event<OnStartActivityData>; | ||
public readonly onProgress: Event<OnProgressActivityData>; | ||
public readonly onSuccess: Event<OnSuccessActivityData>; | ||
public readonly onError: Event<OnErrorActivityData>; | ||
public readonly task: ActivityTask<R>; | ||
public readonly id: string; | ||
public readonly cancellationTokenSource: CancellationTokenSource; | ||
abstract initialState(): ActivityTreeItemOptions; | ||
abstract successState(): ActivityTreeItemOptions; | ||
abstract errorState(error: IParsedError): ActivityTreeItemOptions; | ||
public constructor(task: ActivityTask<R>); | ||
public report(progress: { message?: string; increment?: number }): void; | ||
public run(): Promise<void>; | ||
} | ||
/** | ||
* A wizard that links several user input steps together | ||
*/ | ||
export declare class AzureWizard<T extends IActionContext> { | ||
export declare class AzureWizard<T extends IActionContext & Partial<ExecuteActivityContext>> { | ||
/** | ||
@@ -899,2 +944,18 @@ * @param wizardContext A context object that should be used to pass information between steps | ||
export declare interface ExecuteActivityContext { | ||
registerActivity: (activity: Activity) => Promise<void>; | ||
/** | ||
* Becomes label of activity tree item, defaults to wizard title or "Azure Activity" | ||
*/ | ||
activityTitle?: string; | ||
/** | ||
* Set to show a "Click to view resource" child on success. | ||
*/ | ||
activityResult?: AppResource; | ||
/** | ||
* Hide activity notifications | ||
*/ | ||
suppressNotification?: boolean; | ||
} | ||
export declare abstract class AzureWizardExecuteStep<T extends IActionContext> { | ||
@@ -901,0 +962,0 @@ /** |
@@ -52,3 +52,4 @@ "use strict"; | ||
__exportStar(require("./utils/findFreePort"), exports); | ||
__exportStar(require("./activityLog/Activity"), exports); | ||
// NOTE: The auto-fix action "source.organizeImports" does weird things with this file, but there doesn't seem to be a way to disable it on a per-file basis so we'll just let it happen | ||
//# sourceMappingURL=index.js.map |
@@ -19,2 +19,4 @@ "use strict"; | ||
const vscode = require("vscode"); | ||
const vscode_1 = require("vscode"); | ||
const ExecuteActivity_1 = require("../activityLog/activities/ExecuteActivity"); | ||
const errors_1 = require("../errors"); | ||
@@ -135,3 +137,3 @@ const localize_1 = require("../localize"); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield vscode.window.withProgress({ location: vscode.ProgressLocation.Notification }, (progress) => __awaiter(this, void 0, void 0, function* () { | ||
yield this.withProgress({ location: vscode_1.ProgressLocation.Notification }, (progress) => __awaiter(this, void 0, void 0, function* () { | ||
let currentStep = 1; | ||
@@ -162,2 +164,37 @@ const steps = this._executeSteps.sort((a, b) => b.priority - a.priority); | ||
} | ||
withProgress(options, task) { | ||
var _a; | ||
var _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this._context.registerActivity) { | ||
(_a = (_b = this._context).activityTitle) !== null && _a !== void 0 ? _a : (_b.activityTitle = this.title); | ||
const activity = new ExecuteActivity_1.ExecuteActivity({ | ||
context: this._context, | ||
}, (activityProgress) => __awaiter(this, void 0, void 0, function* () { | ||
if (this._context.suppressNotification) { | ||
yield task(activityProgress, activity.cancellationTokenSource.token); | ||
} | ||
else { | ||
yield vscode.window.withProgress(options, (progress, token) => __awaiter(this, void 0, void 0, function* () { | ||
token.onCancellationRequested(() => { | ||
activity.cancellationTokenSource.cancel(); | ||
}); | ||
const internalProgress = { | ||
report: (value) => { | ||
progress.report(value); | ||
activityProgress.report(value); | ||
} | ||
}; | ||
yield task(internalProgress, token); | ||
})); | ||
} | ||
})); | ||
yield this._context.registerActivity(activity); | ||
yield activity.run(); | ||
} | ||
else { | ||
yield vscode.window.withProgress(options, task); | ||
} | ||
}); | ||
} | ||
goBack(currentStep) { | ||
@@ -164,0 +201,0 @@ let step = currentStep; |
{ | ||
"name": "@microsoft/vscode-azext-utils", | ||
"author": "Microsoft Corporation", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Common UI tools for developing Azure extensions for VS Code", | ||
@@ -6,0 +6,0 @@ "tags": [ |
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
262324
57
5216