rename archive file

This commit is contained in:
Jan Prochazka 2021-11-10 18:04:00 +01:00
parent 25fe1df43b
commit 241c7746c2
2 changed files with 19 additions and 0 deletions

View File

@ -84,6 +84,12 @@ module.exports = {
socket.emitChanged(`archive-files-changed-${folder}`);
},
renameFile_meta: 'post',
async renameFile({ folder, file, newFile }) {
await fs.rename(path.join(resolveArchiveFolder(folder), `${file}.jsonl`), path.join(resolveArchiveFolder(folder), `${newFile}.jsonl`));
socket.emitChanged(`archive-files-changed-${folder}`);
},
deleteFolder_meta: 'post',
async deleteFolder({ folder }) {
if (!folder) throw new Error('Missing folder parameter');

View File

@ -67,9 +67,21 @@
import openNewTab from '../utility/openNewTab';
import AppObjectCore from './AppObjectCore.svelte';
import getConnectionLabel from '../utility/getConnectionLabel';
import InputTextModal from '../modals/InputTextModal.svelte';
export let data;
const handleRename = () => {
showModal(InputTextModal, {
value: data.file,
label: 'New file name',
header: 'Rename file',
onConfirm: newFile => {
axiosInstance.post('archive/rename-file', { file: data.fileName, folder: data.folderName, newFile });
},
});
};
const handleDelete = () => {
axiosInstance.post('archive/delete-file', { file: data.fileName, folder: data.folderName });
};
@ -115,6 +127,7 @@
data.fileType == 'jsonl' && { text: 'Open (readonly)', onClick: handleOpenRead },
data.fileType == 'jsonl' && { text: 'Open in free table editor', onClick: handleOpenWrite },
{ text: 'Delete', onClick: handleDelete },
{ text: 'Rename', onClick: handleRename },
data.fileType == 'jsonl' &&
createQuickExportMenu($extensions, fmt => async () => {
exportElectronFile(