Skip to content

Commit ef4f2f1

Browse files
authored
Merge pull request #178 from ty-d/DeleteAfterUserAction
Add AfterUserAction support when deleting files
2 parents 74cfce9 + d7dd8e9 commit ef4f2f1

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/commands/delete.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { RootNode } from "../explorer/models/rootNode";
77
import { RoutineNode } from "../explorer/models/routineNode";
88
import { explorerProvider } from "../extension";
99
import { outputChannel } from "../utils";
10+
import { OtherStudioAction, fireOtherStudioAction } from "./studio";
11+
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
1012

1113
function deleteList(items: string[], workspaceFolder: string): Promise<any> {
1214
if (!items || !items.length) {
@@ -16,6 +18,12 @@ function deleteList(items: string[], workspaceFolder: string): Promise<any> {
1618
const api = new AtelierAPI();
1719
api.setConnection(workspaceFolder);
1820
return Promise.all(items.map((item) => api.deleteDoc(item))).then((files) => {
21+
files.forEach((file) => {
22+
if (file.result.ext) {
23+
const uri = DocumentContentProvider.getUri(file.result.name);
24+
fireOtherStudioAction(OtherStudioAction.DeletedDocument, uri, file.result.ext);
25+
}
26+
});
1927
outputChannel.appendLine(`Deleted items: ${files.filter((el) => el.result).length}`);
2028
const failed = files.filter((el) => !el.result).map((el) => `${el.file} - ${el.error}`);
2129
if (files.find((el) => !el.result)) {

src/commands/studio.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class StudioActions {
340340
.then((action) => this.userAction(action));
341341
}
342342

343-
public fireOtherStudioAction(action: OtherStudioAction) {
343+
public fireOtherStudioAction(action: OtherStudioAction, userAction?) {
344344
const actionObject = {
345345
id: action.toString(),
346346
label: getOtherStudioActionLabel(action),
@@ -354,6 +354,14 @@ class StudioActions {
354354
this.userAction(actionObject, false, "", "", 1);
355355
}
356356
});
357+
} else if (userAction) {
358+
this.processUserAction(userAction).then((answer) => {
359+
if (answer) {
360+
answer.msg || answer.msg === ""
361+
? this.userAction(actionObject, true, answer.answer, answer.msg, 1)
362+
: this.userAction(actionObject, true, answer, "", 1);
363+
}
364+
});
357365
} else {
358366
this.userAction(actionObject, false, "", "", 1);
359367
}
@@ -420,7 +428,7 @@ export async function _contextMenu(sourceControl: boolean, node: PackageNode | C
420428
return studioActions && studioActions.getMenu(StudioMenuType.Context, sourceControl);
421429
}
422430

423-
export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vscode.Uri): Promise<void> {
431+
export async function fireOtherStudioAction(action: OtherStudioAction, uri?: vscode.Uri, userAction?): Promise<void> {
424432
const studioActions = new StudioActions(uri);
425-
return studioActions && studioActions.fireOtherStudioAction(action);
433+
return studioActions && studioActions.fireOtherStudioAction(action, userAction);
426434
}

src/providers/DocumentContentProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
2828
vfs = config("serverSideEditing");
2929
}
3030
workspaceFolder = workspaceFolder && workspaceFolder !== "" ? workspaceFolder : currentWorkspaceFolder();
31+
const isCsp = name.includes("/");
3132
const wFolderUri = workspaceFolderUri(workspaceFolder);
3233
let uri: vscode.Uri;
3334
if (wFolderUri.scheme === FILESYSTEM_SCHEMA) {
@@ -61,7 +62,6 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
6162
});
6263
}
6364
}
64-
const isCsp = name.includes("/");
6565
if (namespace && namespace !== "") {
6666
if (isCsp) {
6767
uri = uri.with({

0 commit comments

Comments
 (0)