From a789253eefe356adf046ce4499bac52f350f32f6 Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 29 Mar 2024 14:57:24 +0500 Subject: [PATCH 1/5] Web: Client: added convert xml dialog --- .../public/locales/en/ConvertDialog.json | 4 +- .../components/dialogs/ConvertDialog/index.js | 60 +++++++++++++++++-- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/packages/client/public/locales/en/ConvertDialog.json b/packages/client/public/locales/en/ConvertDialog.json index 69be045472..49e9027c45 100644 --- a/packages/client/public/locales/en/ConvertDialog.json +++ b/packages/client/public/locales/en/ConvertDialog.json @@ -7,5 +7,7 @@ "HideMessage": "Do not show this message again", "InfoCreateFileIn": "The new '{{fileTitle}}' file is created in '{{folderTitle}}'", "OpenFileMessage": "The document file you open will be converted to the Office Open XML format for quick viewing and editing.", - "SaveOriginalFormatMessage": "Save the file copy in the original format" + "SaveOriginalFormatMessage": "Save the file copy in the original format", + "ConversionXmlMessage": "The document file you open will be converted to the Office Open XML format (docx, xlsx or pptx) for faster viewing and editing.", + "SelectFileType": "Please select a file type:" } diff --git a/packages/client/src/components/dialogs/ConvertDialog/index.js b/packages/client/src/components/dialogs/ConvertDialog/index.js index f66932ac93..1a716df85b 100644 --- a/packages/client/src/components/dialogs/ConvertDialog/index.js +++ b/packages/client/src/components/dialogs/ConvertDialog/index.js @@ -30,7 +30,9 @@ import ModalDialogContainer from "../ModalDialogContainer"; import { ModalDialog } from "@docspace/shared/components/modal-dialog"; import { Button } from "@docspace/shared/components/button"; import { Text } from "@docspace/shared/components/text"; +import { Box } from "@docspace/shared/components/box"; import { Checkbox } from "@docspace/shared/components/checkbox"; +import { RadioButtonGroup } from "@docspace/shared/components/radio-button-group"; import { withTranslation, Trans } from "react-i18next"; import { inject, observer } from "mobx-react"; @@ -56,6 +58,23 @@ const ConvertDialogComponent = (props) => { setIsConvertSingleFile, } = props; + const options = [ + { + label: t("Document"), + value: "Document", + }, + { + label: t("Spreadsheet"), + value: "Spreadsheet", + }, + { + label: t("Presentation"), + value: "Presentation", + }, + ]; + + const isXML = convertItem?.fileExst?.includes(".xml"); + let rootFolderTitle = ""; const convertSingleFile = !!convertItem; const sortedFolder = isRecentFolder || isFavoritesFolder || isShareFolder; @@ -67,11 +86,23 @@ const ConvertDialogComponent = (props) => { } const [hideMessage, setHideMessage] = useState(false); + const [selectedOptionType, setSelectedOptionType] = useState( + options[0].value, + ); + + const onChangeRadioButton = (e) => { + setSelectedOptionType(e.target.value); + setIsConvertSingleFile(false); + }; const onChangeFormat = () => setStoreOriginal(!storeOriginalFiles, "storeOriginalFiles"); const onChangeMessageVisible = () => setHideMessage(!hideMessage); - const onClose = () => setConvertDialogVisible(false); + + const onClose = () => { + setConvertDialogVisible(false); + setIsConvertSingleFile(false); + }; const onConvert = () => { onClose(); @@ -82,6 +113,7 @@ const ConvertDialogComponent = (props) => { fileId: convertItem.id, toFolderId: folderId, action: "convert", + format: selectedOptionType, // need backend }; item.fileInfo = convertItem; convertFile(item, t, convertItem.isOpen); @@ -97,16 +129,36 @@ const ConvertDialogComponent = (props) => { visible={visible} onClose={onClose} withFooterCheckboxes + autoMaxHeight > {convertSingleFile ? t("DocumentConversionTitle") : t("FileUploadTitle")} - + - {convertSingleFile ? t("OpenFileMessage") : t("ConversionMessage")} + {convertSingleFile + ? isXML + ? t("ConversionXmlMessage") + : t("OpenFileMessage") + : t("ConversionMessage")} + + {isXML && ( + + {t("SelectFileType")} + + + )}
@@ -165,7 +217,7 @@ const ConvertDialogComponent = (props) => { ); }; -const ConvertDialog = withTranslation(["ConvertDialog", "Common"])( +const ConvertDialog = withTranslation(["ConvertDialog", "Common", "Files"])( ConvertDialogComponent, ); From 01e7eefb52921eb43233c4b2ea40ab5909e9d58a Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 29 Mar 2024 14:58:23 +0500 Subject: [PATCH 2/5] Web: Client: disabled auto convert file for xml --- packages/client/src/store/UploadDataStore.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/client/src/store/UploadDataStore.js b/packages/client/src/store/UploadDataStore.js index c87eb78008..cfc53c4e61 100644 --- a/packages/client/src/store/UploadDataStore.js +++ b/packages/client/src/store/UploadDataStore.js @@ -1019,6 +1019,10 @@ class UploadDataStore { if (!currentFile) return resolve(); const { needConvert } = currentFile; + const isXML = currentFile.fileInfo?.fileExst?.includes(".xml"); + + if (isXML) return resolve(); + if (needConvert) { runInAction(() => (currentFile.action = "convert")); From f7fd3bc30df32dcdc2d011ff29b55a984c702bec Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 29 Mar 2024 15:49:22 +0500 Subject: [PATCH 3/5] Web: Client: the format parameter is added by condition --- .../client/src/components/dialogs/ConvertDialog/index.js | 8 +++++++- packages/client/src/store/UploadDataStore.js | 4 ++-- packages/shared/api/files/index.ts | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/dialogs/ConvertDialog/index.js b/packages/client/src/components/dialogs/ConvertDialog/index.js index 1a716df85b..7a3feab93e 100644 --- a/packages/client/src/components/dialogs/ConvertDialog/index.js +++ b/packages/client/src/components/dialogs/ConvertDialog/index.js @@ -113,8 +113,14 @@ const ConvertDialogComponent = (props) => { fileId: convertItem.id, toFolderId: folderId, action: "convert", - format: selectedOptionType, // need backend }; + + if (isXML) { + item.format = selectedOptionType; + } else { + item.format = null; + } + item.fileInfo = convertItem; convertFile(item, t, convertItem.isOpen); } else { diff --git a/packages/client/src/store/UploadDataStore.js b/packages/client/src/store/UploadDataStore.js index cfc53c4e61..94e12cc669 100644 --- a/packages/client/src/store/UploadDataStore.js +++ b/packages/client/src/store/UploadDataStore.js @@ -447,7 +447,7 @@ class UploadDataStore { while (index < len) { const conversionItem = filesToConversion[index]; - const { fileId, toFolderId, password } = conversionItem; + const { fileId, toFolderId, password, format } = conversionItem; const itemPassword = password ? password : null; const file = this.files.find((f) => f.fileId === fileId); if (file) runInAction(() => (file.inConversion = true)); @@ -459,7 +459,7 @@ class UploadDataStore { const numberFiles = this.files.filter((f) => f.needConvert).length; - const res = convertFile(fileId, itemPassword) + const res = convertFile(fileId, format, itemPassword) .then((res) => res) .catch(() => { const error = t("FailedToConvert"); diff --git a/packages/shared/api/files/index.ts b/packages/shared/api/files/index.ts index eef9a0092c..553b27cf31 100644 --- a/packages/shared/api/files/index.ts +++ b/packages/shared/api/files/index.ts @@ -764,10 +764,11 @@ export async function getNewFiles(folderId: number) { // TODO: update res type export async function convertFile( fileId: string | number | null, + format = null, password = null, sync = false, ) { - const data = { password, sync }; + const data = { password, sync, format }; const res = (await request({ method: "put", From bb31e9a89dc33ac7dfb794538a928eaa0c4735fb Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 19 Jul 2024 17:45:43 +0500 Subject: [PATCH 4/5] =?UTF-8?q?Web:=20Client:=20Dialogs:=20ConvertDialog.?= =?UTF-8?q?=20the=20values=20=E2=80=8B=E2=80=8Bfor=20conversion=20have=20b?= =?UTF-8?q?een=20changed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/src/components/dialogs/ConvertDialog/index.js | 6 +++--- packages/shared/api/files/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/dialogs/ConvertDialog/index.js b/packages/client/src/components/dialogs/ConvertDialog/index.js index 7a3feab93e..0939f3ba23 100644 --- a/packages/client/src/components/dialogs/ConvertDialog/index.js +++ b/packages/client/src/components/dialogs/ConvertDialog/index.js @@ -61,15 +61,15 @@ const ConvertDialogComponent = (props) => { const options = [ { label: t("Document"), - value: "Document", + value: ".docx", }, { label: t("Spreadsheet"), - value: "Spreadsheet", + value: ".xlsx", }, { label: t("Presentation"), - value: "Presentation", + value: ".pptx", }, ]; diff --git a/packages/shared/api/files/index.ts b/packages/shared/api/files/index.ts index 327e1e4ba8..0075e4bd03 100644 --- a/packages/shared/api/files/index.ts +++ b/packages/shared/api/files/index.ts @@ -789,11 +789,11 @@ export async function getNewFiles(folderId: number) { // TODO: update res type export async function convertFile( fileId: string | number | null, - format = null, + outputType = null, password = null, sync = false, ) { - const data = { password, sync, format }; + const data = { password, sync, outputType }; const res = (await request({ method: "put", From c623f214b8a6667dba663808de16b93349fe6abe Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 19 Jul 2024 20:06:12 +0500 Subject: [PATCH 5/5] =?UTF-8?q?Web:=20Client:=20Dialogs:=20ConvertDialog.?= =?UTF-8?q?=20=D1=81onversion=20to=20pptx=20has=20been=20removed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/client/public/locales/en/ConvertDialog.json | 2 +- packages/client/src/components/dialogs/ConvertDialog/index.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/client/public/locales/en/ConvertDialog.json b/packages/client/public/locales/en/ConvertDialog.json index 49e9027c45..91aabb7f8f 100644 --- a/packages/client/public/locales/en/ConvertDialog.json +++ b/packages/client/public/locales/en/ConvertDialog.json @@ -8,6 +8,6 @@ "InfoCreateFileIn": "The new '{{fileTitle}}' file is created in '{{folderTitle}}'", "OpenFileMessage": "The document file you open will be converted to the Office Open XML format for quick viewing and editing.", "SaveOriginalFormatMessage": "Save the file copy in the original format", - "ConversionXmlMessage": "The document file you open will be converted to the Office Open XML format (docx, xlsx or pptx) for faster viewing and editing.", + "ConversionXmlMessage": "The document file you open will be converted to the Office Open XML format (docx or xlsx) for faster viewing and editing.", "SelectFileType": "Please select a file type:" } diff --git a/packages/client/src/components/dialogs/ConvertDialog/index.js b/packages/client/src/components/dialogs/ConvertDialog/index.js index 0939f3ba23..76286df1b0 100644 --- a/packages/client/src/components/dialogs/ConvertDialog/index.js +++ b/packages/client/src/components/dialogs/ConvertDialog/index.js @@ -67,10 +67,6 @@ const ConvertDialogComponent = (props) => { label: t("Spreadsheet"), value: ".xlsx", }, - { - label: t("Presentation"), - value: ".pptx", - }, ]; const isXML = convertItem?.fileExst?.includes(".xml");