mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-22 03:47:09 +00:00
New file history (#2359)
This commit is contained in:
committed by
Daniel Pan
parent
5924c65d08
commit
ca0110e996
@@ -1,4 +1,4 @@
|
||||
import { slug, repoID, siteRoot } from '../components/constance';
|
||||
import { slug, repoID, siteRoot, historyRepoID } from '../components/constance';
|
||||
import { SeafileAPI } from 'seafile-js';
|
||||
import cookie from 'react-cookies';
|
||||
|
||||
@@ -9,61 +9,60 @@ seafileAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders });
|
||||
class EditorUtilities {
|
||||
|
||||
getFiles() {
|
||||
return seafileAPI.listWikiDir(slug, "/").then(items => {
|
||||
const files = items.data.dir_file_list.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
type: item.type === 'dir' ? 'dir' : 'file',
|
||||
isExpanded: item.type === 'dir' ? true : false,
|
||||
parent_path: item.parent_dir,
|
||||
last_update_time: item.last_update_time,
|
||||
size: item.size
|
||||
}
|
||||
})
|
||||
return files;
|
||||
})
|
||||
return seafileAPI.listWikiDir(slug, '/').then(items => {
|
||||
const files = items.data.dir_file_list.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
type: item.type === 'dir' ? 'dir' : 'file',
|
||||
isExpanded: item.type === 'dir' ? true : false,
|
||||
parent_path: item.parent_dir,
|
||||
last_update_time: item.last_update_time,
|
||||
size: item.size
|
||||
};
|
||||
});
|
||||
return files;
|
||||
});
|
||||
}
|
||||
|
||||
listRepoDir() {
|
||||
return seafileAPI.listDir(repoID, "/",{recursive: true}).then(items => {
|
||||
const files = items.data.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
type: item.type === 'dir' ? 'dir' : 'file',
|
||||
isExpanded: item.type === 'dir' ? true : false,
|
||||
parent_path: item.parent_dir,
|
||||
last_update_time: item.mtime,
|
||||
size: item.size
|
||||
}
|
||||
})
|
||||
return seafileAPI.listDir(repoID, '/',{recursive: true}).then(items => {
|
||||
const files = items.data.map(item => {
|
||||
return {
|
||||
name: item.name,
|
||||
type: item.type === 'dir' ? 'dir' : 'file',
|
||||
isExpanded: item.type === 'dir' ? true : false,
|
||||
parent_path: item.parent_dir,
|
||||
last_update_time: item.mtime,
|
||||
size: item.size
|
||||
};
|
||||
});
|
||||
|
||||
return files;
|
||||
})
|
||||
return files;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createFile(filePath) {
|
||||
return seafileAPI.createFile(repoID, filePath)
|
||||
return seafileAPI.createFile(repoID, filePath);
|
||||
}
|
||||
|
||||
deleteFile(filePath) {
|
||||
return seafileAPI.deleteFile(repoID, filePath)
|
||||
return seafileAPI.deleteFile(repoID, filePath);
|
||||
}
|
||||
|
||||
renameFile(filePath, newFileName) {
|
||||
return seafileAPI.renameFile(repoID, filePath, newFileName)
|
||||
return seafileAPI.renameFile(repoID, filePath, newFileName);
|
||||
}
|
||||
|
||||
createDir(dirPath) {
|
||||
return seafileAPI.createDir(repoID, dirPath)
|
||||
return seafileAPI.createDir(repoID, dirPath);
|
||||
}
|
||||
|
||||
deleteDir(dirPath) {
|
||||
return seafileAPI.deleteDir(repoID, dirPath)
|
||||
return seafileAPI.deleteDir(repoID, dirPath);
|
||||
}
|
||||
|
||||
renameDir(dirPath, newDirName) {
|
||||
return seafileAPI.renameDir(repoID, dirPath, newDirName)
|
||||
return seafileAPI.renameDir(repoID, dirPath, newDirName);
|
||||
}
|
||||
|
||||
getWikiFileContent(slug, filePath) {
|
||||
@@ -82,6 +81,22 @@ class EditorUtilities {
|
||||
return seafileAPI.getAccountInfo();
|
||||
}
|
||||
|
||||
// file history
|
||||
getFileDownloadLink(filePath) {
|
||||
return seafileAPI.getFileDownloadLink(historyRepoID, filePath);
|
||||
}
|
||||
|
||||
getFileContent(filePath) {
|
||||
return seafileAPI.getFileContent(filePath);
|
||||
}
|
||||
|
||||
getFileHistoryRecord(filePath, page, per_page) {
|
||||
return seafileAPI.getFileHistoryRecord(historyRepoID, filePath, page, per_page);
|
||||
}
|
||||
|
||||
revertFile(filePath, commitID) {
|
||||
return seafileAPI.revertFile(historyRepoID, filePath, commitID);
|
||||
}
|
||||
}
|
||||
|
||||
const editorUtilities = new EditorUtilities();
|
||||
|
Reference in New Issue
Block a user