SYNC: Merge pull request #12 from dbgate/feature/team-files

This commit is contained in:
Jan Prochazka
2025-09-26 12:44:08 +02:00
committed by Diflow
parent 925e3a67da
commit 494b33bd7a
15 changed files with 510 additions and 104 deletions

View File

@@ -184,6 +184,12 @@ const cloudContentListLoader = () => ({
reloadTrigger: { key: `cloud-content-changed` },
});
const teamFilesLoader = () => ({
url: 'team-files/list',
params: {},
reloadTrigger: { key: `team-files-changed` },
});
async function getCore(loader, args) {
const { url, params, reloadTrigger, transform, onLoaded, errorValue } = loader(args);
const key = stableStringify({ url, ...params });
@@ -523,3 +529,10 @@ export function getCloudContentList(args) {
export function useCloudContentList(args = {}) {
return useCore(cloudContentListLoader, args);
}
export function getTeamFiles(args) {
return getCore(teamFilesLoader, args);
}
export function useTeamFiles(args) {
return useCore(teamFilesLoader, args);
}

View File

@@ -15,11 +15,14 @@ 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, savedCloudFolderId, savedCloudContentId } =
const { savedFile, savedFilePath, savedFolder, savedCloudFolderId, savedCloudContentId, savedTeamFileId } =
tabs.find(x => x.tabid == tabid).props || {};
const handleSave = async () => {
if (savedCloudFolderId && savedCloudContentId) {
if (savedTeamFileId) {
const resp = await apiCall('team-files/update', { teamFileId: savedTeamFileId, data });
markTabSaved(tabid);
} else if (savedCloudFolderId && savedCloudContentId) {
const resp = await apiCall('cloud/save-file', {
folid: savedCloudFolderId,
fileName: savedFile,