From f9fb0e1964aeb62bcabfc25b8b950a0f0f60512f Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Mon, 8 Jul 2024 16:19:51 +0300 Subject: [PATCH] Fixed Bug 68975 - Rooms.FormRoom.Quota. There is no message about quota being exceeded when trying to copy a PDF form into Form Room through the Start filling button in the editor. --- .../src/hooks/useStartFillingSelectDialog.ts | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/packages/doceditor/src/hooks/useStartFillingSelectDialog.ts b/packages/doceditor/src/hooks/useStartFillingSelectDialog.ts index fbdcd43897..6f5fbd3f97 100644 --- a/packages/doceditor/src/hooks/useStartFillingSelectDialog.ts +++ b/packages/doceditor/src/hooks/useStartFillingSelectDialog.ts @@ -27,7 +27,7 @@ import { useCallback, useRef, useState } from "react"; import { ConflictResolveType } from "@docspace/shared/enums"; -import { checkFileConflicts, copyToFolder } from "@docspace/shared/api/files"; +import { copyToFolder, getProgress } from "@docspace/shared/api/files"; // import { getOperationProgress } from "@docspace/shared/utils/getOperationProgress"; import type { @@ -40,9 +40,13 @@ import type { import type { TRoomSecurity } from "@docspace/shared/api/rooms/types"; import type { TBreadCrumb } from "@docspace/shared/components/selector/Selector.types"; import type { TSelectedFileInfo } from "@docspace/shared/selectors/Files/FilesSelector.types"; -import type { ConflictStateType } from "@/types"; +import { toastr } from "@docspace/shared/components/toast"; +import { TData } from "@docspace/shared/components/toast/Toast.type"; + // import { useTranslation } from "react-i18next"; +import type { ConflictStateType } from "@/types"; + const DefaultConflictDataDialogState: ConflictStateType = { visible: false, resolve: () => {}, @@ -115,7 +119,6 @@ const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => { const url = new URL(`${window.location.origin}/rooms/shared/filter`); url.searchParams.set("folder", selectedItemId.toString()); - window.location.replace(url.toString()); // const hasConfictFiles = await checkFileConflicts( // selectedItemId, @@ -136,17 +139,38 @@ const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => { // } // } - copyToFolder( - Number(selectedItemId), - [], - [fileInfo.id], - conflictResolve, - false, - ); + try { + await copyToFolder( + Number(selectedItemId), + [], + [fileInfo.id], + conflictResolve, + false, + ); - requestRunning.current = false; + const error = await new Promise((resolve) => { + const interval = setInterval(async () => { + const [progress] = await getProgress(); - onClose(); + if (progress?.finished) { + clearInterval(interval); + resolve(progress.error); + } + }, 1000); + }); + + if (error) { + toastr.error(error); + } else { + window.location.replace(url.toString()); + onClose(); + } + } catch (e) { + toastr.error(e as TData); + onClose(); + } finally { + requestRunning.current = false; + } }; const getIsDisabled = (