Update support for moving/renaming files and folders

This commit is contained in:
Dane Everitt 2019-05-04 16:04:59 -07:00
parent eed4be49ab
commit 811026895b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 97 additions and 41 deletions

View file

@ -1,23 +0,0 @@
import {withCredentials} from "@/api/http";
import {ServerApplicationCredentials} from "@/store/types";
import { join } from 'path';
type RenameObject = {
path: string,
fromName: string,
toName: string,
}
/**
* Renames a file or folder on the server using the node.
*/
export function renameElement(server: string, credentials: ServerApplicationCredentials, data: RenameObject): Promise<void> {
return new Promise((resolve, reject) => {
withCredentials(server, credentials).post('/v1/server/file/rename', {
from: join(data.path, data.fromName),
to: join(data.path, data.toName),
})
.then(() => resolve())
.catch(reject);
});
}

View file

@ -0,0 +1,12 @@
import http from "@/api/http";
export function renameFile(server: string, renameFrom: string, renameTo: string): Promise<void> {
return new Promise((resolve, reject) => {
http.put(`/api/client/servers/${server}/files/rename`, {
rename_from: renameFrom,
rename_to: renameTo,
})
.then(() => resolve())
.catch(reject);
});
}