Add support for renaming files on the fly in the file manager

This commit is contained in:
Dane Everitt 2019-02-18 20:41:58 -08:00
parent 52115b5c77
commit ff820f30ad
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
10 changed files with 230 additions and 37 deletions

View file

@ -0,0 +1,23 @@
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);
});
}