mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Enable deletebtn
This commit is contained in:
@@ -298,12 +298,16 @@ editorEl.innerHTML = '';
|
||||
};
|
||||
|
||||
renameBtn.onclick = async () => {
|
||||
if (renameBtn.classList.contains('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentParts = currentFile.split('/');
|
||||
|
||||
const prefill = currentParts.length === 1
|
||||
? ''
|
||||
: `${currentParts.slice(0, -1).join('/')}/`;
|
||||
|
||||
|
||||
const popup = await Swal.fire({
|
||||
title: 'Rename File',
|
||||
input: 'text',
|
||||
@@ -317,6 +321,27 @@ editorEl.innerHTML = '';
|
||||
changeFile(newFile);
|
||||
}
|
||||
};
|
||||
|
||||
deleteBtn.onclick = async () => {
|
||||
if (deleteBtn.classList.contains('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const popup = await Swal.fire({
|
||||
title: 'Delete File',
|
||||
text: `Are you sure you want to delete ${currentFile}?`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Delete',
|
||||
cancelButtonText: 'Cancel',
|
||||
});
|
||||
|
||||
if (popup.isConfirmed) {
|
||||
const idx = Math.max(0, fs.list.indexOf(currentFile) - 1);
|
||||
fs.write(currentFile, nil);
|
||||
changeFile(fs.list[idx]);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
Reference in New Issue
Block a user