Skip to content

Commit

Permalink
Merge pull request #6145 from WoltLab/6.1-file-processor-delete-confirm
Browse files Browse the repository at this point in the history
Ask the user if they really want to delete the file
  • Loading branch information
Cyperghost authored Dec 16, 2024
2 parents 560572b + 519b844 commit cef743b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "WoltLabSuite/Core/Component/File/Helper";
import { clearPreviousErrors } from "WoltLabSuite/Core/Component/File/Upload";
import { innerError } from "WoltLabSuite/Core/Dom/Util";
import { confirmationFactory } from "WoltLabSuite/Core/Component/Confirmation";

type FileId = string;
const fileProcessors = new Map<FileId, FileProcessor>();
Expand Down Expand Up @@ -130,6 +131,10 @@ export class FileProcessor {
deleteButton.classList.add("button", "small");
deleteButton.textContent = getPhrase("wcf.global.button.delete");
deleteButton.addEventListener("click", async () => {
if (!(await confirmationFactory().delete())) {
return;
}

const result = await deleteFile(element.fileId!);
if (result.ok) {
this.#unregisterFile(element);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cef743b

Please sign in to comment.