mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 05:43:58 +00:00
cloud file, folder operations
This commit is contained in:
@@ -15,16 +15,31 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
|
||||
const tabs = get(openedTabs);
|
||||
const tabid = editor.activator.tabid;
|
||||
const data = editor.getData();
|
||||
const { savedFile, savedFilePath, savedFolder } = tabs.find(x => x.tabid == tabid).props || {};
|
||||
const { savedFile, savedFilePath, savedFolder, savedCloudFolderId, savedCloudContentId } =
|
||||
tabs.find(x => x.tabid == tabid).props || {};
|
||||
|
||||
const handleSave = async () => {
|
||||
if (savedFile) {
|
||||
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
|
||||
if (savedCloudFolderId && savedCloudContentId) {
|
||||
const resp = await apiCall('cloud/save-file', {
|
||||
folid: savedCloudFolderId,
|
||||
fileName: savedFile,
|
||||
data,
|
||||
contentFolder: folder,
|
||||
format,
|
||||
cntid: savedCloudContentId,
|
||||
});
|
||||
if (resp.cntid) {
|
||||
markTabSaved(tabid);
|
||||
}
|
||||
} else {
|
||||
if (savedFile) {
|
||||
await apiCall('files/save', { folder: savedFolder || folder, file: savedFile, data, format });
|
||||
}
|
||||
if (savedFilePath) {
|
||||
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
|
||||
}
|
||||
markTabSaved(tabid);
|
||||
}
|
||||
if (savedFilePath) {
|
||||
await apiCall('files/save-as', { filePath: savedFilePath, data, format });
|
||||
}
|
||||
markTabSaved(tabid);
|
||||
};
|
||||
|
||||
const onSave = (title, newProps) => {
|
||||
@@ -60,6 +75,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
|
||||
savedFile: null,
|
||||
savedFolder: null,
|
||||
savedFilePath: file,
|
||||
savedCloudFolderId: null,
|
||||
savedCloudContentId: null,
|
||||
});
|
||||
}
|
||||
} else if ((savedFile || savedFilePath) && saveMode == 'save') {
|
||||
@@ -73,6 +90,8 @@ export default async function saveTabFile(editor, saveMode, folder, format, file
|
||||
name: savedFile || 'newFile',
|
||||
filePath: savedFilePath,
|
||||
onSave,
|
||||
folid: savedCloudFolderId,
|
||||
// cntid: savedCloudContentId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user