diff --git a/common/Tests/images-tests/src/constants.js b/common/Tests/images-tests/src/constants.js index 9135ffb3ae..411941c3c9 100644 --- a/common/Tests/images-tests/src/constants.js +++ b/common/Tests/images-tests/src/constants.js @@ -42,6 +42,13 @@ const paths = { const imageHelperPath = path.join(commonPath, "/utils/image-helpers.js"); +const wrongImportImages = [ + `"/static/images`, + `"/images`, + `"static/images`, + `"images/`, +]; + module.exports = { imagesPattern, filesPattern, @@ -50,4 +57,5 @@ module.exports = { paths, imageHelperPath, excludePath, + wrongImportImages, }; diff --git a/common/Tests/images-tests/src/index.js b/common/Tests/images-tests/src/index.js index 11da517ea0..f0a0b52849 100644 --- a/common/Tests/images-tests/src/index.js +++ b/common/Tests/images-tests/src/index.js @@ -13,7 +13,7 @@ const { findImagesWithDifferentNameButEqualMD5, } = require("./differentNameEqualMD5"); const { findImagesWithEqualMD5AndEqualName } = require("./equalMD5EqualName"); - +const { findWrongImagesImport } = require("./wrongImagesImport"); const { importImgToImageHelper } = require("./importImgToImageHelper"); const runAllTests = async () => { @@ -66,6 +66,7 @@ const runAllTests = async () => { findImagesWithDifferentMD5ButEqualName(allImgs); findImagesWithDifferentNameButEqualMD5(allImgs); findImagesWithEqualMD5AndEqualName(allImgs); + findWrongImagesImport(allFiles); }; runAllTests(); diff --git a/common/Tests/images-tests/src/wrongImagesImport.js b/common/Tests/images-tests/src/wrongImagesImport.js new file mode 100644 index 0000000000..4d9877b283 --- /dev/null +++ b/common/Tests/images-tests/src/wrongImagesImport.js @@ -0,0 +1,44 @@ +const fs = require("fs"); +const path = require("path"); + +const { wrongImportImages } = require("./constants"); + +const pathToResultFile = path.join( + __dirname, + "..", + "result", + "WrongImagesImport" +); + +const findWrongImagesImport = async (files) => { + let wrongImports = ""; + + files.forEach((file) => { + const data = fs.readFileSync(file.path, "utf8"); + + wrongImportImages.forEach((i) => { + const idx = data.indexOf(i); + + // console.log(file.path.indexOf("\\webpack")); + + if ( + idx > 0 && + file.fileName.indexOf("webpack") === -1 && + file.path.indexOf("common\\utils\\index.ts") === -1 && + file.path.indexOf("context-menu\\sub-components\\sub-menu.js") === -1 && + file.path.indexOf("drop-down-item\\index.js") === -1 && + file.path.indexOf("common\\utils\\index.ts") === -1 && + file.path.indexOf(".html") === -1 && + file.path.indexOf("storybook-static") === -1 + ) { + wrongImports = wrongImports + `${file.path}\n`; + } + }); + }); + + fs.writeFileSync(pathToResultFile, ""); + + fs.appendFileSync(pathToResultFile, `${wrongImports}\n`); +}; + +module.exports = { findWrongImagesImport }; diff --git a/packages/client/public/locales/en/CreateEditRoomDialog.json b/packages/client/public/locales/en/CreateEditRoomDialog.json index 0a047f54e5..c912d9f8dc 100644 --- a/packages/client/public/locales/en/CreateEditRoomDialog.json +++ b/packages/client/public/locales/en/CreateEditRoomDialog.json @@ -1,6 +1,7 @@ { "ChooseRoomType": "Choose room type", "CollaborationRoomDescription": "Collaborate on one or multiple documents with your team", + "CreateRoomConfirmation": "Continue without connecting the storage?\nYou have selected a third-party storage option that is not connected yet. If you proceed without connecting the service, this option will not be added.", "CollaborationRoomTitle": "Collaboration room", "CreateTagOption": "Create tag", "CustomRoomDescription": "Apply your own settings to use this room for any custom purpose", diff --git a/packages/client/public/locales/ru/CreateEditRoomDialog.json b/packages/client/public/locales/ru/CreateEditRoomDialog.json index c1f745148e..bade57831f 100644 --- a/packages/client/public/locales/ru/CreateEditRoomDialog.json +++ b/packages/client/public/locales/ru/CreateEditRoomDialog.json @@ -2,6 +2,7 @@ "ChooseRoomType": "Выберите тип комнаты", "CollaborationRoomDescription": "Совместная работа над одним или несколькими документами с вашей командой", "CollaborationRoomTitle": "Комната для совместного редактирования", + "CreateRoomConfirmation": "Продолжить без подключения хранилища?\nВы выбрали сторонний вариант хранения, который еще не подключен. Если вы продолжите без подключения услуги, эта опция не будет добавлена", "CreateTagOption": "Создать тэг", "CustomRoomDescription": "Примените собственные настройки, чтобы использовать эту комнату для любых пользовательских целей", "CustomRoomTitle": "Пользовательская комната", diff --git a/packages/client/src/components/Article/Body/index.js b/packages/client/src/components/Article/Body/index.js index 7f4c2170ac..b50e20a3cf 100644 --- a/packages/client/src/components/Article/Body/index.js +++ b/packages/client/src/components/Article/Body/index.js @@ -105,9 +105,6 @@ const ArticleBodyContent = (props) => { ); }) .finally(() => { - if (isMobileOnly || isMobile()) { - toggleArticleOpen(); - } if (filesSection) { setIsLoading(false); } else { @@ -139,9 +136,6 @@ const ArticleBodyContent = (props) => { }) .catch((err) => toastr.error(err)) .finally(() => { - if (isMobileOnly || isMobile()) { - toggleArticleOpen(); - } if (filesSection) { setIsLoading(false); } else { @@ -149,6 +143,10 @@ const ArticleBodyContent = (props) => { } }); } + + if (isMobileOnly || isMobile()) { + toggleArticleOpen(); + } }, [categoryType, roomsFolderId, archiveFolderId] ); diff --git a/packages/client/src/components/FilesPanels/index.js b/packages/client/src/components/FilesPanels/index.js index 0cd36fd03a..930611a1ec 100644 --- a/packages/client/src/components/FilesPanels/index.js +++ b/packages/client/src/components/FilesPanels/index.js @@ -22,6 +22,7 @@ import { ConvertDialog, CreateRoomDialog, InviteUsersWarningDialog, + CreateRoomConfirmDialog, } from "../dialogs"; import ConvertPasswordDialog from "../dialogs/ConvertPasswordDialog"; import ArchiveDialog from "../dialogs/ArchiveDialog"; @@ -51,6 +52,8 @@ const Panels = (props) => { invitePanelVisible, convertPasswordDialogVisible, createRoomDialogVisible, + createRoomConfirmDialogVisible, + confirmDialogIsLoading, restoreAllPanelVisible, archiveDialogVisible, inviteUsersWarningDialogVisible, @@ -96,6 +99,9 @@ const Panels = (props) => { ), convertDialogVisible && , createRoomDialogVisible && , + (createRoomConfirmDialogVisible || confirmDialogIsLoading) && ( + + ), selectFileDialogVisible && ( { }; export default inject( - ({ auth, dialogsStore, uploadDataStore, versionHistoryStore, backup }) => { + ({ + auth, + dialogsStore, + uploadDataStore, + versionHistoryStore, + backup, + createEditRoomStore, + }) => { const { sharingPanelVisible, ownerPanelVisible, @@ -144,6 +157,7 @@ export default inject( conflictResolveDialogVisible, convertDialogVisible, createRoomDialogVisible, + createRoomConfirmDialogVisible, convertPasswordDialogVisible, connectItem, //TODO: restoreAllPanelVisible, @@ -161,6 +175,7 @@ export default inject( const { uploadPanelVisible } = uploadDataStore; const { isVisible: versionHistoryPanelVisible } = versionHistoryStore; const { hotkeyPanelVisible } = auth.settingsStore; + const { confirmDialogIsLoading } = createEditRoomStore; return { preparationPortalDialogVisible, @@ -180,6 +195,7 @@ export default inject( conflictResolveDialogVisible, convertDialogVisible, createRoomDialogVisible, + createRoomConfirmDialogVisible, convertPasswordDialogVisible, selectFileDialogVisible, createMasterForm, @@ -189,6 +205,7 @@ export default inject( invitePanelVisible: invitePanelOptions.visible, archiveDialogVisible, inviteUsersWarningDialogVisible, + confirmDialogIsLoading, }; } )(observer(Panels)); diff --git a/packages/client/src/components/GlobalEvents/CreateRoomEvent.js b/packages/client/src/components/GlobalEvents/CreateRoomEvent.js index db67b2017d..872fce5dfb 100644 --- a/packages/client/src/components/GlobalEvents/CreateRoomEvent.js +++ b/packages/client/src/components/GlobalEvents/CreateRoomEvent.js @@ -2,122 +2,43 @@ import React, { useState, useEffect } from "react"; import { inject, observer } from "mobx-react"; import { useTranslation } from "react-i18next"; import { CreateRoomDialog } from "../dialogs"; -import { toastr } from "@docspace/components"; import { isMobile } from "react-device-detect"; const CreateRoomEvent = ({ visible, onClose, - createRoom, - createRoomInThirdpary, - createTag, - addTagsToRoom, - deleteThirdParty, - fetchThirdPartyProviders, - calculateRoomLogoParams, - uploadRoomLogo, - addLogoToRoom, fetchTags, - + setRoomParams, + onCreateRoom, + createRoomConfirmDialogVisible, + setCreateRoomConfirmDialogVisible, + confirmDialogIsLoading, connectDialogVisible, - currentFolderId, - updateCurrentFolder, - - withPaging, + isLoading, + setIsLoading, + setOnClose, setCreateRoomDialogVisible, - fetchFiles, - setInfoPanelIsVisible, - setView, + + fetchThirdPartyProviders, enableThirdParty, + deleteThirdParty, }) => { const { t } = useTranslation(["CreateEditRoomDialog", "Common", "Files"]); const [fetchedTags, setFetchedTags] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const openNewRoom = (id) => { - setView("info_members"); - fetchFiles(id) - .then(() => { - !isMobile && setInfoPanelIsVisible(true); - }) - .finally(() => { - setIsLoading(false); - onClose(); - }); - }; + const onCreate = (roomParams) => { + setRoomParams(roomParams); + setOnClose(onClose); - const onCreate = async (roomParams) => { - const createRoomData = { - roomType: roomParams.type, - title: roomParams.title || t("Files:NewRoom"), - }; - - const createTagsData = roomParams.tags - .filter((t) => t.isNew) - .map((t) => t.name); - const addTagsData = roomParams.tags.map((tag) => tag.name); - - const isThirdparty = roomParams.storageLocation.isThirdparty; - const storageFolderId = roomParams.storageLocation.storageFolderId; - const thirdpartyAccount = roomParams.storageLocation.thirdpartyAccount; - - const uploadLogoData = new FormData(); - uploadLogoData.append(0, roomParams.icon.uploadedFile); - - try { - setIsLoading(true); - - // create room - let room = - isThirdparty && storageFolderId - ? await createRoomInThirdpary(storageFolderId, createRoomData) - : await createRoom(createRoomData); - - room.isLogoLoading = true; - - // delete thirdparty account if not needed - if (!isThirdparty && storageFolderId) - await deleteThirdParty(thirdpartyAccount.providerId); - - // create new tags - for (let i = 0; i < createTagsData.length; i++) - await createTag(createTagsData[i]); - - // add new tags to room - if (!!addTagsData.length) - room = await addTagsToRoom(room.id, addTagsData); - - // calculate and upload logo to room - if (roomParams.icon.uploadedFile) { - await uploadRoomLogo(uploadLogoData).then((response) => { - const url = URL.createObjectURL(roomParams.icon.uploadedFile); - const img = new Image(); - img.onload = async () => { - const { x, y, zoom } = roomParams.icon; - room = await addLogoToRoom(room.id, { - tmpFile: response.data, - ...calculateRoomLogoParams(img, x, y, zoom), - }); - - !withPaging && openNewRoom(room.id); - - URL.revokeObjectURL(img.src); - }; - img.src = url; - }); - } else !withPaging && openNewRoom(room.id); - } catch (err) { - toastr.error(err); - console.log(err); - - setIsLoading(false); - onClose(); - } finally { - if (withPaging) { - await updateCurrentFolder(null, currentFolderId); - } + if ( + roomParams.storageLocation.isThirdparty && + !roomParams.storageLocation.storageFolderId + ) { + setCreateRoomConfirmDialogVisible(true); + } else { + onCreateRoom(); } }; @@ -128,14 +49,18 @@ const CreateRoomEvent = ({ useEffect(() => { setCreateRoomDialogVisible(true); - return () => setCreateRoomDialogVisible(false); }, []); return ( { - const { - createRoom, - createRoomInThirdpary, - addTagsToRoom, - calculateRoomLogoParams, - uploadRoomLogo, - addLogoToRoom, - fetchFiles, - addItem, - } = filesStore; - const { createTag, fetchTags } = tagsStore; - - const { id: currentFolderId } = selectedFolderStore; - const { updateCurrentFolder } = filesActionsStore; - - const { connectDialogVisible, setCreateRoomDialogVisible } = dialogsStore; + const { fetchTags } = tagsStore; const { deleteThirdParty, fetchThirdPartyProviders, } = settingsStore.thirdPartyStore; - const { withPaging } = auth.settingsStore; - - const { - setIsVisible: setInfoPanelIsVisible, - setView, - } = auth.infoPanelStore; - const { enableThirdParty } = settingsStore; - return { - createRoom, - createRoomInThirdpary, - createTag, - fetchTags, - addTagsToRoom, - deleteThirdParty, - fetchThirdPartyProviders, - calculateRoomLogoParams, - uploadRoomLogo, - addLogoToRoom, - + const { + createRoomConfirmDialogVisible, + setCreateRoomConfirmDialogVisible, connectDialogVisible, - currentFolderId, - updateCurrentFolder, - - withPaging, setCreateRoomDialogVisible, - fetchFiles, - setInfoPanelIsVisible, - setView, + } = dialogsStore; + + const { + setRoomParams, + onCreateRoom, + isLoading, + setIsLoading, + setOnClose, + confirmDialogIsLoading, + } = createEditRoomStore; + + return { + fetchTags, + setRoomParams, + onCreateRoom, + createRoomConfirmDialogVisible, + setCreateRoomConfirmDialogVisible, + connectDialogVisible, + isLoading, + setIsLoading, + setOnClose, + confirmDialogIsLoading, + setCreateRoomDialogVisible, + fetchThirdPartyProviders, enableThirdParty, + deleteThirdParty, }; } )(observer(CreateRoomEvent)); diff --git a/packages/client/src/components/NavMenu/sub-components/header-catalog-burger.js b/packages/client/src/components/NavMenu/sub-components/header-catalog-burger.js index 3cd736907e..2aa7697823 100644 --- a/packages/client/src/components/NavMenu/sub-components/header-catalog-burger.js +++ b/packages/client/src/components/NavMenu/sub-components/header-catalog-burger.js @@ -2,7 +2,7 @@ import React from "react"; import styled from "styled-components"; import PropTypes from "prop-types"; import { isMobileOnly } from "react-device-detect"; -import MenuIcon from "../../../../../../public/images/menu.react.svg"; +import MenuIcon from "PUBLIC_DIR/images/menu.react.svg"; import { mobile } from "@docspace/components/utils/device"; import { Base } from "@docspace/components/themes"; diff --git a/packages/client/src/components/PeopleArticle/MainButton/index.js b/packages/client/src/components/PeopleArticle/MainButton/index.js index 34a0bbb8d7..f44728a6c3 100644 --- a/packages/client/src/components/PeopleArticle/MainButton/index.js +++ b/packages/client/src/components/PeopleArticle/MainButton/index.js @@ -1,6 +1,8 @@ import InvitationLinkReactSvgUrl from "PUBLIC_DIR/images/invitation.link.react.svg?url"; import PlaneReactSvgUrl from "PUBLIC_DIR/images/plane.react.svg?url"; import ImportReactSvgUrl from "PUBLIC_DIR/images/import.react.svg?url"; +import AddDepartmentReactSvgUrl from "PUBLIC_DIR/images/add.department.react.svg?url"; +import AddGuestReactSvgUrl from "PUBLIC_DIR/images/add.guest.react.svg?url"; import AddEmployeeReactSvgUrl from "ASSETS/images/add.employee.react.svg?url"; import React from "react"; //import PropTypes from "prop-types"; @@ -110,7 +112,7 @@ class ArticleMainButtonContent extends React.Component { // icon: combineUrl( // window.DocSpaceConfig?.proxy?.url, // homepage, - // "/images/add.guest.react.svg" + // AddGuestReactSvgUrl // ), // label: guestCaption, // onClick: this.goToGuestCreate, @@ -120,7 +122,7 @@ class ArticleMainButtonContent extends React.Component { // icon: combineUrl( // window.DocSpaceConfig?.proxy?.url, // homepage, - // "/images/add.department.react.svg" + // AddDepartmentReactSvgUrl // ), // label: groupCaption, // onClick: this.goToGroupCreate, diff --git a/packages/client/src/components/dialogs/CreateRoomConfirmDialog/index.js b/packages/client/src/components/dialogs/CreateRoomConfirmDialog/index.js new file mode 100644 index 0000000000..99a4e5901b --- /dev/null +++ b/packages/client/src/components/dialogs/CreateRoomConfirmDialog/index.js @@ -0,0 +1,67 @@ +import React, { useState, useEffect } from "react"; +import ModalDialog from "@docspace/components/modal-dialog"; +import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; +import { Button } from "@docspace/components"; + +const CreateRoomConfirmDialog = ({ + t, + + visible, + setVisible, + + confirmDialogIsLoading, + onCreateRoom, +}) => { + const onContinue = async () => { + await onCreateRoom(); + onClose(); + }; + + const onClose = () => setVisible(false); + + return ( + + {t("Common:Warning")} + + {t("CreateEditRoomDialog:CreateRoomConfirmation")} + + +