Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cancel button from deploy progress notification #2514

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion extensions/vscode/src/api/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,6 @@ export interface PublishFailure extends EventStreamMessage {
data: {
dashboardUrl: string;
url: string;
canceled?: string; // not defined if not user cancelled. Value of "true" if true.
// and other non-defined attributes
};
error: string; // translated internally
Expand Down
17 changes: 0 additions & 17 deletions extensions/vscode/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ export class EventStream extends Readable implements Disposable {
private messages: EventStreamMessage[] = [];
// Map to store event callbacks
private callbacks: Map<string, EventStreamRegistration[]> = new Map();
// Cancelled Event Streams - Suppressed when received
private cancelledLocalIDs: string[] = [];

/**
* Creates a new instance of the EventStream class.
Expand Down Expand Up @@ -163,22 +161,7 @@ export class EventStream extends Readable implements Disposable {
this.processMessage(message);
}

/**
* Provide a way to suppress the processing of incoming stream messages
* with a specific data.localId value
* @param localId: string
* @returns undefined
*/
public suppressMessages(localId: string) {
this.cancelledLocalIDs.push(localId);
}

private processMessage(msg: EventStreamMessage) {
const localId = msg.data.localId;
if (localId && this.cancelledLocalIDs.includes(localId)) {
// suppress and ignore
return;
}
// Trace message
// console.debug(
// `eventSource trace: ${event.type}: ${JSON.stringify(event)}`,
Expand Down
34 changes: 6 additions & 28 deletions extensions/vscode/src/views/deployProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,27 @@ import { ProgressLocation, Uri, env, window } from "vscode";
import { EventStreamMessage, eventMsgToString } from "src/api";
import { EventStream, UnregisterCallback } from "src/events";

export function deployProject(localID: string, stream: EventStream) {
export function deployProject(streamID: string, stream: EventStream) {
window.withProgress(
{
location: ProgressLocation.Notification,
title: `Deploying your project`,
cancellable: true,
cancellable: false,
},
(progress, token) => {
(progress) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let resolveCB: (reason?: any) => void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let rejectCB: (reason?: any) => void;
const registrations: UnregisterCallback[] = [];
const promise = new Promise<void>((resolve, reject) => {
resolveCB = resolve;
rejectCB = reject;
});
let streamID = localID;

const unregisterAll = () => {
registrations.forEach((cb) => cb.unregister());
};

token.onCancellationRequested(() => {
streamID = "NEVER_A_VALID_STREAM";
unregisterAll();
// inject a psuedo end of publishing event
stream.injectMessage({
type: "publish/failure",
time: Date.now().toString(),
data: {
dashboardUrl: "",
url: "",
// and other non-defined attributes
localId: localID,
cancelled: "true",
message:
"Deployment has been dismissed (but will continue to be processed on the Connect Server). Deployment status will be reset to the prior known state.",
},
error: "Deployment has been dismissed.",
});
stream.suppressMessages(localID);
resolveCB();
const promise = new Promise<void>((resolve, reject) => {
resolveCB = resolve;
rejectCB = reject;
});

registrations.push(
Expand Down
7 changes: 1 addition & 6 deletions extensions/vscode/src/views/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ export class LogsTreeDataProvider implements TreeDataProvider<LogsTreeItem> {
this.stages.forEach((stage) => {
if (stage.status === LogStageStatus.notStarted) {
stage.status = LogStageStatus.neverStarted;
} else if (stage.status === LogStageStatus.inProgress) {
stage.status = LogStageStatus.failed;
}
});

Expand All @@ -203,10 +201,7 @@ export class LogsTreeDataProvider implements TreeDataProvider<LogsTreeItem> {
if (isCodedEventErrorMessage(msg)) {
errorMessage = handleEventCodedError(msg);
} else {
errorMessage =
msg.data.cancelled === "true"
? `Deployment cancelled: ${msg.data.message}`
: `Deployment failed: ${msg.data.message}`;
errorMessage = `Deployment failed: ${msg.data.message}`;
}
const selection = await window.showErrorMessage(errorMessage, ...options);
if (selection === showLogsOption) {
Expand Down
Loading