From b532da942cf606ab0e22af53281536b6fc516242 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 27 Sep 2022 12:02:46 +0300 Subject: [PATCH 01/57] Web: Fixed badge jumps under the tablet view. --- .../pages/Home/Section/Body/RowsView/SimpleFilesRow.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js index 46aba1bd62..e2cd3416e4 100644 --- a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js +++ b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js @@ -136,13 +136,9 @@ const StyledSimpleFilesRow = styled(Row)` margin-right: 8px; } - ${(props) => - props.sectionWidth > 500 && - ` - .badge:last-child { - margin-right: 0px; - } - `} + .badge:last-child { + margin-right: 0px; + } .lock-file { cursor: ${(props) => (props.withAccess ? "pointer" : "default")}; From cb2a38d40d31af5824d54c08ff996b3b5b093974 Mon Sep 17 00:00:00 2001 From: TimofeyBoyko Date: Tue, 27 Sep 2022 14:46:06 +0300 Subject: [PATCH 02/57] Web:Client: fix profile routing for user --- .../src/pages/Profile/Section/Header/index.js | 21 ++++++++++++------- .../client/src/store/ProfileActionsStore.js | 12 +++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index edd7cd7ef7..e064f24d18 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -66,14 +66,20 @@ const Header = (props) => { }; const onClickBack = () => { - const url = filter.toUrlParams(); - const backUrl = combineUrl( - AppServerConfig.proxyURL, - config.homepage, - `/accounts/filter?/${url}` - ); + //TODO: add check manager + if (isAdmin) { + const url = filter.toUrlParams(); + const backUrl = combineUrl( + AppServerConfig.proxyURL, + config.homepage, + `/accounts/filter?/${url}` + ); + + history.push(backUrl, url); + } else { + history.goBack(); + } - history.push(backUrl, url); setFilter(filter); }; @@ -122,6 +128,7 @@ const Header = (props) => { export default withRouter( inject(({ auth, peopleStore }) => { const { isAdmin } = auth; + const { targetUserStore, filterStore } = peopleStore; const { filter, setFilterParams } = filterStore; diff --git a/packages/client/src/store/ProfileActionsStore.js b/packages/client/src/store/ProfileActionsStore.js index 747af1612a..7aa260f989 100644 --- a/packages/client/src/store/ProfileActionsStore.js +++ b/packages/client/src/store/ProfileActionsStore.js @@ -60,8 +60,16 @@ class ProfileActionsStore { }; onProfileClick = () => { - this.selectedFolderStore.setSelectedFolder(null); - this.treeFoldersStore.setSelectedNode(["accounts"]); + //TODO: add check manager + const { isAdmin, isOwner } = this.authStore.userStore.user; + + if (isAdmin || isOwner) { + this.selectedFolderStore.setSelectedFolder(null); + this.treeFoldersStore.setSelectedNode(["accounts"]); + } + + console.log("click"); + history.push(PROFILE_SELF_URL); }; From ef4976b3f7d6a71fc785a8017e92e294596a7817 Mon Sep 17 00:00:00 2001 From: TimofeyBoyko Date: Tue, 27 Sep 2022 14:50:21 +0300 Subject: [PATCH 03/57] Web:Client:Store: delete console log --- packages/client/src/store/ProfileActionsStore.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/client/src/store/ProfileActionsStore.js b/packages/client/src/store/ProfileActionsStore.js index 7aa260f989..59cda303a6 100644 --- a/packages/client/src/store/ProfileActionsStore.js +++ b/packages/client/src/store/ProfileActionsStore.js @@ -68,8 +68,6 @@ class ProfileActionsStore { this.treeFoldersStore.setSelectedNode(["accounts"]); } - console.log("click"); - history.push(PROFILE_SELF_URL); }; From 3a1e76a1adb059854970e4a9197bb9318bd80c76 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 27 Sep 2022 15:00:43 +0300 Subject: [PATCH 04/57] Web: Removed jumps for buttons for tablet view and mobile view. --- .../Section/Body/RowsView/SimpleFilesRow.js | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js index e2cd3416e4..b4fbd5bfab 100644 --- a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js +++ b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js @@ -114,11 +114,11 @@ const StyledSimpleFilesRow = styled(Row)` margin-right: 7px; } - .row_context-menu-wrapper { + /* .row_context-menu-wrapper { width: fit-content; justify-content: space-between; flex: 1 1 auto; - } + } */ .row_content { ${(props) => @@ -157,38 +157,34 @@ const StyledSimpleFilesRow = styled(Row)` padding-top: 7px; } - ${(props) => - ((props.sectionWidth <= 1024 && props.sectionWidth > 500) || isTablet) && - ` - .row_context-menu-wrapper{ - width: min-content; - justify-content: space-between; - flex: 0 1 auto; - } + .row_context-menu-wrapper { + width: min-content; + justify-content: space-between; + flex: 0 1 auto; + } - .row_content { - max-width: none; - min-width: 0; - } + .row_content { + max-width: none; + min-width: 0; + } - .badges { - margin-bottom: 0px; + .badges { + margin-bottom: 0px; + } + + .badge { + margin-right: 24px; + } + + .lock-file { + svg { + height: 16px; } + } - .badge { - margin-right: 24px; - } - - .lock-file{ - svg { - height: 16px; - } - } - - .expandButton { - padding-top: 0px; - } - `} + .expandButton { + padding-top: 0px; + } `; StyledSimpleFilesRow.defaultProps = { theme: Base }; From 21acc0dd25fb89c538ed3b979eb67c2c7c6d6090 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 27 Sep 2022 15:29:56 +0300 Subject: [PATCH 05/57] Web: Removed useless code. --- .../src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js index b4fbd5bfab..0e1b06aa18 100644 --- a/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js +++ b/packages/client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js @@ -114,12 +114,6 @@ const StyledSimpleFilesRow = styled(Row)` margin-right: 7px; } - /* .row_context-menu-wrapper { - width: fit-content; - justify-content: space-between; - flex: 1 1 auto; - } */ - .row_content { ${(props) => props.sectionWidth > 500 && `max-width: fit-content;`}//min-width: auto From 321c5c2ce020f32fa234cc5ae24754ac0365ebd1 Mon Sep 17 00:00:00 2001 From: TimofeyBoyko Date: Tue, 27 Sep 2022 15:59:41 +0300 Subject: [PATCH 06/57] Web:Client:Profile: fix back url for user --- .../src/pages/Profile/Section/Header/index.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index e064f24d18..8d880c83ee 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -22,7 +22,9 @@ const Header = (props) => { history, isAdmin, filter, + roomsFilter, setFilter, + setRoomsFilter, profile, isMe, setChangeEmailVisible, @@ -76,11 +78,18 @@ const Header = (props) => { ); history.push(backUrl, url); + setFilter(filter); } else { - history.goBack(); + const url = roomsFilter.toUrlParams(); + console.log(url); + const backUrl = combineUrl( + AppServerConfig.proxyURL, + config.homepage, + `rooms/shared/filter?/${url}` + ); + history.push(backUrl, url); + setRoomsFilter(roomsFilter); } - - setFilter(filter); }; return ( @@ -126,9 +135,11 @@ const Header = (props) => { }; export default withRouter( - inject(({ auth, peopleStore }) => { + inject(({ auth, peopleStore, filesStore }) => { const { isAdmin } = auth; + const { roomsFilter, setRoomsFilter } = filesStore; + const { targetUserStore, filterStore } = peopleStore; const { filter, setFilterParams } = filterStore; @@ -144,7 +155,9 @@ export default withRouter( return { isAdmin, filter, + roomsFilter, setFilter: setFilterParams, + setRoomsFilter, profile: targetUser, isMe, setChangeEmailVisible, From d4756a445e5a4ffcb96e7c9ecb84171540b2ef62 Mon Sep 17 00:00:00 2001 From: TimofeyBoyko Date: Tue, 27 Sep 2022 16:24:43 +0300 Subject: [PATCH 07/57] Web:Client:Profile: hide back button for user --- .../src/pages/Profile/Section/Header/index.js | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index 8d880c83ee..7e2a873282 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -68,28 +68,15 @@ const Header = (props) => { }; const onClickBack = () => { - //TODO: add check manager - if (isAdmin) { - const url = filter.toUrlParams(); - const backUrl = combineUrl( - AppServerConfig.proxyURL, - config.homepage, - `/accounts/filter?/${url}` - ); + const url = filter.toUrlParams(); + const backUrl = combineUrl( + AppServerConfig.proxyURL, + config.homepage, + `/accounts/filter?/${url}` + ); - history.push(backUrl, url); - setFilter(filter); - } else { - const url = roomsFilter.toUrlParams(); - console.log(url); - const backUrl = combineUrl( - AppServerConfig.proxyURL, - config.homepage, - `rooms/shared/filter?/${url}` - ); - history.push(backUrl, url); - setRoomsFilter(roomsFilter); - } + history.push(backUrl, url); + setFilter(filter); }; return ( @@ -97,7 +84,7 @@ const Header = (props) => { showContextButton={(isAdmin && !profile?.isOwner) || isMe} isVisitor={profile.isVisitor} > - {!profile.isVisitor && ( + {isAdmin && ( Date: Tue, 27 Sep 2022 16:26:15 +0300 Subject: [PATCH 08/57] Web:Client:Profile: fix styles --- packages/client/src/pages/Profile/Section/Header/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index 7e2a873282..92c3445ae1 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -82,7 +82,7 @@ const Header = (props) => { return ( {isAdmin && ( Date: Tue, 27 Sep 2022 16:27:21 +0300 Subject: [PATCH 09/57] Web:Client:Profile: delete useless code --- .../client/src/pages/Profile/Section/Header/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/client/src/pages/Profile/Section/Header/index.js b/packages/client/src/pages/Profile/Section/Header/index.js index 92c3445ae1..a5066aef86 100644 --- a/packages/client/src/pages/Profile/Section/Header/index.js +++ b/packages/client/src/pages/Profile/Section/Header/index.js @@ -22,9 +22,9 @@ const Header = (props) => { history, isAdmin, filter, - roomsFilter, + setFilter, - setRoomsFilter, + profile, isMe, setChangeEmailVisible, @@ -122,11 +122,9 @@ const Header = (props) => { }; export default withRouter( - inject(({ auth, peopleStore, filesStore }) => { + inject(({ auth, peopleStore }) => { const { isAdmin } = auth; - const { roomsFilter, setRoomsFilter } = filesStore; - const { targetUserStore, filterStore } = peopleStore; const { filter, setFilterParams } = filterStore; @@ -142,9 +140,9 @@ export default withRouter( return { isAdmin, filter, - roomsFilter, + setFilter: setFilterParams, - setRoomsFilter, + profile: targetUser, isMe, setChangeEmailVisible, From 94af422f76e8e29ef2bd30143baeb29e2d910d35 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 27 Sep 2022 17:53:05 +0300 Subject: [PATCH 10/57] Web: Removed "share" option. --- .../client/src/store/FilesActionsStore.js | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/packages/client/src/store/FilesActionsStore.js b/packages/client/src/store/FilesActionsStore.js index 7087421e2f..dbbb28d865 100644 --- a/packages/client/src/store/FilesActionsStore.js +++ b/packages/client/src/store/FilesActionsStore.js @@ -1159,8 +1159,6 @@ class FilesActionStore { const { userAccess } = this.filesStore; switch (option) { - case "share": - return isAccessedSelected && !personal; //isFavoritesFolder ||isRecentFolder case "showInfo": case "copy": case "download": @@ -1276,16 +1274,6 @@ class FilesActionStore { } = this.dialogsStore; switch (option) { - case "share": - if (!this.isAvailableOption("share")) return null; - else - return { - label: t("Share"), - onClick: () => setSharingPanelVisible(true), - iconUrl: "/static/images/share.react.svg", - title: t("Translations:ButtonShareAccess"), - }; - case "copy": if (!this.isAvailableOption("copy")) return null; else @@ -1416,7 +1404,6 @@ class FilesActionStore { }; getAnotherFolderOptions = (itemsCollection, t) => { - const share = this.getOption("share", t); const download = this.getOption("download", t); const downloadAs = this.getOption("downloadAs", t); const moveTo = this.getOption("moveTo", t); @@ -1425,7 +1412,6 @@ class FilesActionStore { const showInfo = this.getOption("showInfo", t); itemsCollection - .set("share", share) .set("download", download) .set("downloadAs", downloadAs) .set("moveTo", moveTo) @@ -1437,14 +1423,13 @@ class FilesActionStore { }; getRecentFolderOptions = (itemsCollection, t) => { - const share = this.getOption("share", t); const download = this.getOption("download", t); const downloadAs = this.getOption("downloadAs", t); const copy = this.getOption("copy", t); const showInfo = this.getOption("showInfo", t); itemsCollection - .set("share", share) + .set("download", download) .set("downloadAs", downloadAs) .set("copy", copy) @@ -1456,14 +1441,13 @@ class FilesActionStore { getShareFolderOptions = (itemsCollection, t) => { const { setDeleteDialogVisible, setUnsubscribe } = this.dialogsStore; - const share = this.getOption("share", t); const download = this.getOption("download", t); const downloadAs = this.getOption("downloadAs", t); const copy = this.getOption("copy", t); const showInfo = this.getOption("showInfo", t); itemsCollection - .set("share", share) + .set("download", download) .set("downloadAs", downloadAs) .set("copy", copy) @@ -1497,15 +1481,12 @@ class FilesActionStore { getFavoritesFolderOptions = (itemsCollection, t) => { const { selection } = this.filesStore; - - const share = this.getOption("share", t); const download = this.getOption("download", t); const downloadAs = this.getOption("downloadAs", t); const copy = this.getOption("copy", t); const showInfo = this.getOption("showInfo", t); itemsCollection - .set("share", share) .set("download", download) .set("downloadAs", downloadAs) .set("copy", copy) From 070bba03007c58e15306893ca234cc382ba0b835 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 10:27:06 +0300 Subject: [PATCH 11/57] Web: Fixed scroll shift and page height reduction. --- .../GlobalEvents/sub-components/Dialog.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/GlobalEvents/sub-components/Dialog.js b/packages/client/src/components/GlobalEvents/sub-components/Dialog.js index ee4a0b4bdd..8e2b7e396f 100644 --- a/packages/client/src/components/GlobalEvents/sub-components/Dialog.js +++ b/packages/client/src/components/GlobalEvents/sub-components/Dialog.js @@ -6,6 +6,7 @@ import ModalDialog from "@docspace/components/modal-dialog"; import TextInput from "@docspace/components/text-input"; import Button from "@docspace/components/button"; import ComboBox from "@docspace/components/combobox"; +import { isSafari, isTablet } from "react-device-detect"; const Dialog = ({ t, @@ -43,8 +44,13 @@ const Dialog = ({ e.target.select(); }, []); + const returnWindowPositionAfterKeyboard = () => { + isSafari && isTablet && window.scrollTo(0, 0); + }; + const onSaveAction = React.useCallback( (e) => { + returnWindowPositionAfterKeyboard(); setIsDisabled(true); onSave && onSave(e, value); }, @@ -52,15 +58,21 @@ const Dialog = ({ ); const onCancelAction = React.useCallback((e) => { + returnWindowPositionAfterKeyboard(); onCancel && onCancel(e); }, []); + const onCloseAction = React.useCallback((e) => { + returnWindowPositionAfterKeyboard(); + onClose && onClose(e); + }, []); + return ( {title} From 89fe6385438b22a2e1ef482b991ce83f130b18de Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 12:59:49 +0300 Subject: [PATCH 12/57] Web: Added isLoading state. --- .../components/FolderTreeBody/TreeFolders.js | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/client/src/components/FolderTreeBody/TreeFolders.js b/packages/client/src/components/FolderTreeBody/TreeFolders.js index 4e867d6300..a6cad108b8 100644 --- a/packages/client/src/components/FolderTreeBody/TreeFolders.js +++ b/packages/client/src/components/FolderTreeBody/TreeFolders.js @@ -83,7 +83,7 @@ class TreeFolders extends React.Component { constructor(props) { super(props); - this.state = { isExpand: false }; + this.state = { isExpand: false, isLoading: false }; this.selectionFoldersId = []; } @@ -399,9 +399,12 @@ class TreeFolders extends React.Component { onLoadData = (treeNode, isExpand) => { const { data: incomingDate, certainFolders } = this.props; isExpand && this.setState({ isExpand: true }); - this.props.setIsLoading && this.props.setIsLoading(true); //console.log("load data...", treeNode); + this.setState({ + isLoading: true, + }); + if (this.state.isExpand && !isExpand) { return Promise.resolve(); } @@ -421,8 +424,7 @@ class TreeFolders extends React.Component { }) .catch((err) => console.log("err", err)) .finally(() => { - this.setState({ isExpand: false }); - this.props.setIsLoading && this.props.setIsLoading(false); + this.setState({ isExpand: false, isLoading: false }); }); }; @@ -489,10 +491,8 @@ class TreeFolders extends React.Component { render() { const { selectedKeys, - isLoading, onSelect, dragging, - expandedPanelKeys, treeFolders, data, @@ -502,6 +502,8 @@ class TreeFolders extends React.Component { isLoadingNodes, } = this.props; + const { isLoading } = this.state; + return ( { - const { - selection, - setIsLoading, - isLoading, - dragging, - setDragging, - } = filesStore; + const { selection, dragging, setDragging } = filesStore; const { treeFolders, @@ -577,13 +573,11 @@ export default inject( isPrivacy: isPrivacyFolder, draggableItems: dragging ? selection : null, treeFolders, - isLoading, selectedKeys: useDefaultSelectedKeys ? treeFoldersStore.selectedKeys : selectedKeys, setDragging, - setIsLoading, setTreeFolders, setExpandedPanelKeys, getSubfolders, From 1947af387fd43f1e81ef0e489a7c6a527176c0e1 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 13:05:28 +0300 Subject: [PATCH 13/57] Web: Preventing re-rendering of the tile view. --- packages/client/src/store/FilesActionsStore.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/client/src/store/FilesActionsStore.js b/packages/client/src/store/FilesActionsStore.js index dbbb28d865..6671f9f0c4 100644 --- a/packages/client/src/store/FilesActionsStore.js +++ b/packages/client/src/store/FilesActionsStore.js @@ -689,17 +689,13 @@ class FilesActionStore { }; finalizeVersionAction = (id) => { - const { setFile, setIsLoading } = this.filesStore; + const { setFile } = this.filesStore; - setIsLoading(true); - - return finalizeVersion(id, 0, false) - .then((res) => { - if (res && res[0]) { - setFile(res[0]); - } - }) - .finally(() => setIsLoading(false)); + return finalizeVersion(id, 0, false).then((res) => { + if (res && res[0]) { + setFile(res[0]); + } + }); }; duplicateAction = (item, label) => { From b09476305ec1e2f8662d3e51ce8c94c9e1e0313f Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 13:35:07 +0300 Subject: [PATCH 14/57] Web: Removed user selection of icon. --- .../client/src/components/EmptyContainer/EmptyContainer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/client/src/components/EmptyContainer/EmptyContainer.js b/packages/client/src/components/EmptyContainer/EmptyContainer.js index 49017bf364..85e7fab37e 100644 --- a/packages/client/src/components/EmptyContainer/EmptyContainer.js +++ b/packages/client/src/components/EmptyContainer/EmptyContainer.js @@ -72,6 +72,9 @@ const EmptyFolderWrapper = styled.div` line-height: unset; ${NoUserSelect} } + .empty-folder_container_up-image { + ${NoUserSelect} + } .empty-folder_container-icon { height: 20px; From eb66d3bf57f6a295adde42249454a3f5fd20e9cd Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 13:41:25 +0300 Subject: [PATCH 15/57] Web: Components: fixed InifiniteLoader crash --- packages/components/infinite-loader/infiniteLoaderUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/infinite-loader/infiniteLoaderUtils.js b/packages/components/infinite-loader/infiniteLoaderUtils.js index 64468785ba..4398ecfe91 100644 --- a/packages/components/infinite-loader/infiniteLoaderUtils.js +++ b/packages/components/infinite-loader/infiniteLoaderUtils.js @@ -2,7 +2,7 @@ let timer = null; const startInterval = () => { const elem = document.getElementById("infinite-page-loader"); - elem.style.display = "block"; + if (elem) elem.style.display = "block"; }; export function showLoader() { From 3906f27d50559af828234cf0088ea6ab3c7581da Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 13:44:06 +0300 Subject: [PATCH 16/57] Web: Files: disabled switching to shared folder --- .../components/FolderTreeBody/TreeFolders.js | 74 +++++++++---------- .../panels/SelectFolderDialog/index.js | 11 ++- packages/components/tree-menu/index.js | 16 ++++ 3 files changed, 58 insertions(+), 43 deletions(-) diff --git a/packages/client/src/components/FolderTreeBody/TreeFolders.js b/packages/client/src/components/FolderTreeBody/TreeFolders.js index a6cad108b8..a1fab0ce57 100644 --- a/packages/client/src/components/FolderTreeBody/TreeFolders.js +++ b/packages/client/src/components/FolderTreeBody/TreeFolders.js @@ -2,21 +2,12 @@ import React from "react"; import TreeMenu from "@docspace/components/tree-menu"; import TreeNode from "@docspace/components/tree-menu/sub-components/tree-node"; import styled from "styled-components"; -import { - ConflictResolveType, - FolderType, - ShareAccessRights, -} from "@docspace/common/constants"; -import toastr from "@docspace/components/toast/toastr"; - +import { FolderType, ShareAccessRights } from "@docspace/common/constants"; import { onConvertFiles } from "../../helpers/files-converter"; import { ReactSVG } from "react-svg"; import ExpanderDownIcon from "PUBLIC_DIR/images/expander-down.react.svg"; import ExpanderRightIcon from "PUBLIC_DIR/images/expander-right.react.svg"; import commonIconsStyles from "@docspace/components/utils/common-icons-style"; -import withLoader from "../../HOCs/withLoader"; -import Loaders from "@docspace/common/components/Loaders"; - import { observer, inject } from "mobx-react"; import { runInAction } from "mobx"; import { withTranslation } from "react-i18next"; @@ -181,14 +172,7 @@ class TreeFolders extends React.Component { }; showDragItems = (item) => { - const { - isAdmin, - myId, - commonId, - //rootFolderType, - currentId, - draggableItems, - } = this.props; + const { isAdmin, myId, commonId, currentId, draggableItems } = this.props; if (item.id === currentId) { return false; } @@ -196,10 +180,6 @@ class TreeFolders extends React.Component { if (!draggableItems || draggableItems.find((x) => x.id === item.id)) return false; - // const isMy = rootFolderType === FolderType.USER; - // const isCommon = rootFolderType === FolderType.COMMON; - // const isShare = rootFolderType === FolderType.SHARE; - if ( item.rootFolderType === FolderType.SHARE && item.access === ShareAccessRights.FullAccess @@ -208,7 +188,6 @@ class TreeFolders extends React.Component { } if (isAdmin) { - //if (isMy || isCommon || isShare) { if ( (item.pathParts && (item.pathParts[0] === myId || item.pathParts[0] === commonId)) || @@ -217,24 +196,19 @@ class TreeFolders extends React.Component { ) { return true; } - //} } else { - //if (isMy || isCommon || isShare) { if ( (item.pathParts && item.pathParts[0] === myId) || item.rootFolderType === FolderType.USER ) { return true; } - //} } return false; }; getItems = (data) => { - const { theme } = this.props; - return data.map((item) => { const dragging = this.props.dragging ? this.showDragItems(item) : false; const showBadge = false; @@ -245,9 +219,18 @@ class TreeFolders extends React.Component { disableNodeValue = ""; if (dragging) value = `${item.id} dragging ${provider}`; + const { roomsFolderId, expandedPanelKeys } = this.props; + + let isDisabledNode = false; + if (item.id == roomsFolderId) { + isDisabledNode = expandedPanelKeys.includes(roomsFolderId + ""); + } + if (this.selectionFoldersId && this.selectionFoldersId.includes(item.id)) disableNodeValue = "disable-node"; + if (isDisabledNode) disableNodeValue += " disable-folder "; + if ((item.folders && item.folders.length > 0) || serviceFolder) { return ( { - const { data: incomingDate, certainFolders } = this.props; + const { data: incomingDate, certainFolders, roomsFolderId } = this.props; isExpand && this.setState({ isExpand: true }); //console.log("load data...", treeNode); @@ -421,6 +404,12 @@ class TreeFolders extends React.Component { this.getNewTreeData(treeData, listIds, data.folders, data.level); !certainFolders && this.props.setTreeFolders(treeData); + + if (data.listIds[0] == roomsFolderId && this.props.onSelect) { + const roomsIndex = treeData.findIndex((f) => f.id == roomsFolderId); + const firstRoomsNodeId = treeData[roomsIndex]?.folders[0]?.id; + this.props.onSelect([firstRoomsNodeId], treeNode); + } }) .catch((err) => console.log("err", err)) .finally(() => { @@ -439,6 +428,20 @@ class TreeFolders extends React.Component { this.props.setExpandedPanelKeys(expandedKeys); }; + onSelect = (folder, treeNode) => { + const { onSelect, expandedPanelKeys, roomsFolderId } = this.props; + + const newExpandedPanelKeys = JSON.parse(JSON.stringify(expandedPanelKeys)); + newExpandedPanelKeys.push(folder[0]); + + if (folder[0] == roomsFolderId) { + this.onExpand(newExpandedPanelKeys, treeNode); + return; + } + + onSelect && onSelect(folder, treeNode); + }; + onDragOver = (data) => { const parentElement = data.event.target.parentElement; const existElement = parentElement.classList.contains( @@ -488,16 +491,15 @@ class TreeFolders extends React.Component { firstLoadScroll(); } }; + render() { const { selectedKeys, - onSelect, dragging, expandedPanelKeys, treeFolders, data, disabled, - theme, isPanel, isLoadingNodes, } = this.props; @@ -514,7 +516,7 @@ class TreeFolders extends React.Component { multiple={false} showIcon switcherIcon={this.switcherIcon} - onSelect={onSelect} + onSelect={this.onSelect} selectedKeys={selectedKeys} loadData={this.onLoadData} expandedKeys={expandedPanelKeys} @@ -556,17 +558,14 @@ export default inject( getSubfolders, setIsLoadingNodes, isLoadingNodes, + roomsFolderId, } = treeFoldersStore; - const { - id, - parentId: selectedNodeParentId /* rootFolderType */, - } = selectedFolderStore; + const { id, parentId: selectedNodeParentId } = selectedFolderStore; return { isAdmin: auth.isAdmin, isDesktop: auth.settingsStore.isDesktopClient, dragging, - //rootFolderType, currentId: id, myId: myFolderId, commonId: commonFolderId, @@ -584,6 +583,7 @@ export default inject( setIsLoadingNodes, isLoadingNodes, selectedNodeParentId, + roomsFolderId, }; } )(withTranslation(["Files", "Common"])(observer(TreeFolders))); diff --git a/packages/client/src/components/panels/SelectFolderDialog/index.js b/packages/client/src/components/panels/SelectFolderDialog/index.js index b747e2658c..6611143581 100644 --- a/packages/client/src/components/panels/SelectFolderDialog/index.js +++ b/packages/client/src/components/panels/SelectFolderDialog/index.js @@ -219,6 +219,9 @@ class SelectFolderDialog extends React.Component { const folderSelectionDisabled = folderId === sharedRoomId || folderId === sharedRoomId?.toString(); + const buttonIsDisabled = + isDisableButton || (isRecycleBin && currentFolderId === folderId); + return displayType === "aside" ? ( ) : ( ); } diff --git a/packages/components/tree-menu/index.js b/packages/components/tree-menu/index.js index 862d6d508f..dee56d22d7 100644 --- a/packages/components/tree-menu/index.js +++ b/packages/components/tree-menu/index.js @@ -33,6 +33,22 @@ const StyledTree = styled(Tree)` } } + .disable-folder { + span.rc-tree-node-content-wrapper { + pointer-events: none; + span.rc-tree-iconEle { + svg { + path { + fill: ${(props) => props.theme.treeNode.disableColor}; + } + } + } + span.rc-tree-title { + color: ${(props) => props.theme.treeNode.disableColor} !important; + } + } + } + .rc-tree-treenode { height: 36px; display: flex; From 3ad66b3576f2783157553ea5a548372a41a75c3c Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 13:51:51 +0300 Subject: [PATCH 17/57] Web: Files: fixed form creation from text file --- .../panels/SelectionPanel/ExceptionFoldersConstants.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js b/packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js index af60cfe7f3..95e16cd7b5 100644 --- a/packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js +++ b/packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js @@ -8,4 +8,8 @@ export const exceptSortedByTagsFolders = [ FolderType.Archive, ]; -export const exceptPrivacyTrashFolders = [FolderType.Privacy, FolderType.TRASH]; +export const exceptPrivacyTrashFolders = [ + FolderType.Privacy, + FolderType.TRASH, + FolderType.Archive, +]; From 9ee043a67c95482dd39ca8b04d95297fb93b94ac Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 14:45:05 +0300 Subject: [PATCH 18/57] Web: Fixed navigation path for empty folder. --- .../src/components/EmptyContainer/EmptyFolderContainer.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/client/src/components/EmptyContainer/EmptyFolderContainer.js b/packages/client/src/components/EmptyContainer/EmptyFolderContainer.js index 0787be9a55..47e5943878 100644 --- a/packages/client/src/components/EmptyContainer/EmptyFolderContainer.js +++ b/packages/client/src/components/EmptyContainer/EmptyFolderContainer.js @@ -93,9 +93,11 @@ export default inject(({ filesStore, selectedFolderStore }) => { let isRootRoom, isRoom, id; if (navigationPath && navigationPath.length) { - isRootRoom = navigationPath[navigationPath.length - 1].isRootRoom; - isRoom = navigationPath[navigationPath.length - 1].isRoom; - id = navigationPath[navigationPath.length - 1].id; + const elem = navigationPath[0]; + + isRootRoom = elem.isRootRoom; + isRoom = elem.isRoom; + id = elem.id; } return { From a2678c091643be9c639b0fef3558c05f155d0a0a Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 14:45:39 +0300 Subject: [PATCH 19/57] Web: Added translation for root folder container. --- .../src/components/EmptyContainer/RootFolderContainer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/EmptyContainer/RootFolderContainer.js b/packages/client/src/components/EmptyContainer/RootFolderContainer.js index 25e4caadc9..d9f7314ab8 100644 --- a/packages/client/src/components/EmptyContainer/RootFolderContainer.js +++ b/packages/client/src/components/EmptyContainer/RootFolderContainer.js @@ -277,7 +277,7 @@ const RootFolderContainer = (props) => { alt="plus_icon" /> - Create room + {t("CreateEditRoomDialog:CreateRoom")} ); @@ -391,4 +391,8 @@ export default inject( setIsEmptyPage, }; } -)(withTranslation("Files")(observer(RootFolderContainer))); +)( + withTranslation(["Files", "CreateEditRoomDialog"])( + observer(RootFolderContainer) + ) +); From 83366fe3f83e9cec89523711c27b873b7ee9a51e Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 15:52:14 +0300 Subject: [PATCH 20/57] Web: Files: removed logs --- packages/client/src/store/FilesStore.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/client/src/store/FilesStore.js b/packages/client/src/store/FilesStore.js index f47f7ab9c6..52d52dc9de 100644 --- a/packages/client/src/store/FilesStore.js +++ b/packages/client/src/store/FilesStore.js @@ -2598,13 +2598,13 @@ class FilesStore { // const filterTotal = isRoom ? this.roomsFilterTotal : this.filterTotal; const filterTotal = isRooms ? this.roomsFilter.total : this.filter.total; - console.log("hasMoreFiles isRooms", isRooms); - console.log("hasMoreFiles filesList", this.filesList.length); - console.log("hasMoreFiles this.filterTotal", this.filterTotal); - console.log("hasMoreFiles this.roomsFilterTotal", this.roomsFilterTotal); - console.log("hasMoreFiles filterTotal", filterTotal); - console.log("hasMoreFiles", this.filesList.length < filterTotal); - console.log("----------------------------"); + // console.log("hasMoreFiles isRooms", isRooms); + // console.log("hasMoreFiles filesList", this.filesList.length); + // console.log("hasMoreFiles this.filterTotal", this.filterTotal); + // console.log("hasMoreFiles this.roomsFilterTotal", this.roomsFilterTotal); + // console.log("hasMoreFiles filterTotal", filterTotal); + // console.log("hasMoreFiles", this.filesList.length < filterTotal); + // console.log("----------------------------"); if (this.isLoading) return false; return this.filesList.length < filterTotal; From 0a99a5bcb02018fd50578f67b6ec6d96e46ca8eb Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 15:52:23 +0300 Subject: [PATCH 21/57] Web: Added new translation. --- packages/client/public/locales/en/Files.json | 1 + .../src/components/EmptyContainer/RootFolderContainer.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/client/public/locales/en/Files.json b/packages/client/public/locales/en/Files.json index d3e619460e..23f4b95e9a 100644 --- a/packages/client/public/locales/en/Files.json +++ b/packages/client/public/locales/en/Files.json @@ -84,6 +84,7 @@ "Rename": "Rename", "ReviewRooms": "Review", "RoomEmptyContainerDescription": "Please create the first room.", + "RoomEmptyContainerHeader": "Welcome to {{organizationName}}!", "RoomRemoved": "Room removed", "RoomsRemoved": "Rooms removed", "RestoreAll": "Restore all", diff --git a/packages/client/src/components/EmptyContainer/RootFolderContainer.js b/packages/client/src/components/EmptyContainer/RootFolderContainer.js index d9f7314ab8..41ff6ce6b5 100644 --- a/packages/client/src/components/EmptyContainer/RootFolderContainer.js +++ b/packages/client/src/components/EmptyContainer/RootFolderContainer.js @@ -69,6 +69,12 @@ const RootFolderContainer = (props) => { t("PrivateRoomDescriptionUnbreakable"), ]; + const roomHeader = ( + + Welcome to {{ organizationName }} + + ); + const [showLoader, setShowLoader] = React.useState(false); React.useEffect(() => { @@ -164,7 +170,7 @@ const RootFolderContainer = (props) => { }; case FolderType.Rooms: return { - headerText: "Welcome to DocSpace!", + headerText: roomHeader, descriptionText: roomsDescription, imageSrc: "images/empty_screen_corporate.png", buttons: roomsButtons, From 56c664c9bbd77cfeb8d9fe3953d762a5aefb1788 Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 15:54:36 +0300 Subject: [PATCH 22/57] Web: Files: removed the "Shared" folder from the move/copy dialog if there are no files in the folder --- .../panels/SelectFileDialog/index.js | 19 +++++++++++++++---- .../panels/SelectFolderDialog/index.js | 15 +++++++++++++-- .../SelectionPanel/SelectionPanelBody.js | 11 +++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/panels/SelectFileDialog/index.js b/packages/client/src/components/panels/SelectFileDialog/index.js index 819d6c9ac7..2f4cf81c04 100644 --- a/packages/client/src/components/panels/SelectFileDialog/index.js +++ b/packages/client/src/components/panels/SelectFileDialog/index.js @@ -81,7 +81,6 @@ class SelectFileDialog extends React.Component { async componentDidMount() { const { - treeFolders, foldersType, onSetBaseFolderPath, onSelectFolder, @@ -91,6 +90,7 @@ class SelectFileDialog extends React.Component { setFolderId, folderId, withoutBasicSelection, + roomsFolderId, } = this.props; !displayType && window.addEventListener("resize", this.throttledResize); @@ -99,6 +99,11 @@ class SelectFileDialog extends React.Component { let resultingFolderTree, resultingId; + const treeFolders = await this.props.fetchTreeFolders(); + const roomsFolder = treeFolders.find((f) => f.id == roomsFolderId); + const hasSharedFolder = + roomsFolder && roomsFolder.foldersCount ? true : false; + try { [ resultingFolderTree, @@ -110,7 +115,8 @@ class SelectFileDialog extends React.Component { onSetBaseFolderPath, onSelectFolder, foldersList, - withoutBasicSelection + withoutBasicSelection, + hasSharedFolder ); } catch (e) { toastr.error(e); @@ -329,7 +335,11 @@ export default inject( setFile, } = selectFileDialogStore; - const { treeFolders, setExpandedPanelKeys } = treeFoldersStore; + const { + setExpandedPanelKeys, + fetchTreeFolders, + roomsFolderId, + } = treeFoldersStore; const { filter } = filesStore; const { id: storeFolderId } = selectedFolderStore; @@ -342,12 +352,13 @@ export default inject( setFile, setFolderId, filter, - treeFolders, storeFolderId, folderId, theme: theme, setExpandedPanelKeys, + fetchTreeFolders, + roomsFolderId, }; } )( diff --git a/packages/client/src/components/panels/SelectFolderDialog/index.js b/packages/client/src/components/panels/SelectFolderDialog/index.js index 6611143581..f302a5c592 100644 --- a/packages/client/src/components/panels/SelectFolderDialog/index.js +++ b/packages/client/src/components/panels/SelectFolderDialog/index.js @@ -28,7 +28,6 @@ class SelectFolderDialog extends React.Component { async componentDidMount() { const { - treeFolders, foldersType, onSetBaseFolderPath, onSelectFolder, @@ -41,6 +40,7 @@ class SelectFolderDialog extends React.Component { id, storeFolderId, withoutBasicSelection = false, + roomsFolderId, } = this.props; !displayType && window.addEventListener("resize", this.throttledResize); @@ -49,6 +49,11 @@ class SelectFolderDialog extends React.Component { let resultingFolderTree, resultingId; + const treeFolders = await this.props.fetchTreeFolders(); + const roomsFolder = treeFolders.find((f) => f.id == roomsFolderId); + const hasSharedFolder = + roomsFolder && roomsFolder.foldersCount ? true : false; + if (!withInput && !isNeedArrowIcon) { try { [ @@ -60,7 +65,9 @@ class SelectFolderDialog extends React.Component { initialFolderId, onSetBaseFolderPath, onSelectFolder, - foldersList + foldersList, + false, + hasSharedFolder ); } catch (e) { toastr.error(e); @@ -320,6 +327,8 @@ export default inject( treeFolders, setExpandedPanelKeys, sharedRoomId, + fetchTreeFolders, + roomsFolderId, } = treeFoldersStore; const { filter } = filesStore; @@ -353,6 +362,8 @@ export default inject( filter, setSelectedItems, sharedRoomId, + fetchTreeFolders, + roomsFolderId, }; } )( diff --git a/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js b/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js index bcf4ae35c7..47f04cb9a9 100644 --- a/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js +++ b/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js @@ -18,6 +18,8 @@ import { import { StyledBody, StyledModalDialog } from "./StyledSelectionPanel"; import Text from "@docspace/components/text"; import Loaders from "@docspace/common/components/Loaders"; +import { FolderType } from "@docspace/common/constants"; + const SelectionPanelBody = ({ t, isPanelVisible, @@ -177,7 +179,8 @@ class SelectionPanel extends React.Component { onSetBaseFolderPath, onSelectFolder, foldersList, - withoutBasicSelection = false + withoutBasicSelection = false, + hasSharedFolder ) => { const getRequestFolderTree = () => { switch (foldersType) { @@ -215,10 +218,14 @@ class SelectionPanel extends React.Component { }; const filterFoldersTree = (folders, arrayOfExceptions) => { + const arr = !hasSharedFolder + ? [...arrayOfExceptions, FolderType.Rooms] + : arrayOfExceptions; + let newArray = []; for (let i = 0; i < folders.length; i++) { - if (!arrayOfExceptions.includes(folders[i].rootFolderType)) { + if (!arr.includes(folders[i].rootFolderType)) { newArray.push(folders[i]); } } From b5202a8ec60163bbb378bdb910509508245dcb02 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 16:04:20 +0300 Subject: [PATCH 23/57] Web: Added support for panels on the settings page. --- packages/client/src/pages/PortalSettings/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/client/src/pages/PortalSettings/index.js b/packages/client/src/pages/PortalSettings/index.js index afa4d187d1..4c4a027656 100644 --- a/packages/client/src/pages/PortalSettings/index.js +++ b/packages/client/src/pages/PortalSettings/index.js @@ -4,6 +4,8 @@ import { withRouter } from "react-router"; import Layout from "./Layout"; import { combineUrl } from "@docspace/common/utils"; import AppServerConfig from "@docspace/common/constants/AppServerConfig"; +import Panels from "../../components/FilesPanels"; + const SecuritySettings = lazy(() => import("./categories/security/index.js")); const TfaPage = lazy(() => import("./categories/security/access-portal/tfa")); @@ -159,6 +161,7 @@ const ERROR_404_URL = combineUrl(AppServerConfig.proxyURL, "/error/404"); const Settings = () => { return ( + From af819055beaf275bbc17d653f84d461b0723aac8 Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Wed, 28 Sep 2022 16:18:02 +0300 Subject: [PATCH 24/57] Web: Files: fixed Shared selection --- .../client/src/components/FolderTreeBody/TreeFolders.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/FolderTreeBody/TreeFolders.js b/packages/client/src/components/FolderTreeBody/TreeFolders.js index a1fab0ce57..f9d0bdb882 100644 --- a/packages/client/src/components/FolderTreeBody/TreeFolders.js +++ b/packages/client/src/components/FolderTreeBody/TreeFolders.js @@ -417,12 +417,14 @@ class TreeFolders extends React.Component { }); }; - onExpand = (expandedKeys, treeNode) => { + onExpand = (expandedKeys, treeNode, isRoom = false) => { this.expand = true; if (treeNode.node && !treeNode.node.children) { if (treeNode.expanded) { this.onLoadData(treeNode.node, true); } + } else if (isRoom) { + this.props.onSelect([treeNode.node.children[0].id], treeNode); } this.props.setExpandedPanelKeys(expandedKeys); @@ -435,7 +437,8 @@ class TreeFolders extends React.Component { newExpandedPanelKeys.push(folder[0]); if (folder[0] == roomsFolderId) { - this.onExpand(newExpandedPanelKeys, treeNode); + this.onExpand(newExpandedPanelKeys, treeNode, true); + return; } @@ -553,7 +556,6 @@ export default inject( setTreeFolders, myFolderId, commonFolderId, - isPrivacyFolder, setExpandedPanelKeys, getSubfolders, setIsLoadingNodes, @@ -569,7 +571,6 @@ export default inject( currentId: id, myId: myFolderId, commonId: commonFolderId, - isPrivacy: isPrivacyFolder, draggableItems: dragging ? selection : null, treeFolders, selectedKeys: useDefaultSelectedKeys From 51ba7c8628fbae4d52829ce3b64623a09e0bc168 Mon Sep 17 00:00:00 2001 From: Eugene Kozyrev <67453079+EugeneKozyrev@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:02:59 +0300 Subject: [PATCH 25/57] Feature/Update Windows installation (#857) * Add DocEditor service Update windows installation project on develop * Add ASC.Login service * Delete onlyoffice-login.conf * Add json configs substitutions * Edit StartMigrationRunner custom action * Set service run as NT AUTHORITY\LocalService * Move config file substitutions to project * Remove condition to SetMACHINEKEY * Revert "Set service run as NT AUTHORITY\LocalService" This reverts commit 3e9c578a652e38f346f7e7fd52eca4ab72dcf537. * Fix nginx conf substitution * Add Local Service permitions * Add folders permitions Move node.js service logs * Fix * Edit logpath --- build/install/win/Apache Kafka.aip | 266 ----- build/install/win/Apache ZooKeeper.aip | 197 ---- .../CustomActions/C#/Utils/CustomAction.cs | 102 ++ .../C#/Utils/Properties/AssemblyInfo.cs | 1 + .../win/CustomActions/C#/Utils/Utils.csproj | 7 + .../CustomActions/C#/Utils/packages.config | 4 + .../win/CustomActions/C#/Utils/redis-sharp.cs | 937 ++++++++++++++++++ build/install/win/DocSpace.aip | 616 +++++++++--- build/install/win/backend-build.bat | 10 +- build/install/win/build-batch.bat | 91 +- build/install/win/build-download-prereq.ps1 | 26 +- build/install/win/frontend-build.bat | 5 +- build/install/win/frontend-copy.bat | 6 +- build/install/win/nginx.conf | 47 - build/install/win/publish-script.bat | 31 +- build/install/win/tools/DocEditor.xml | 14 + build/install/win/tools/Login.xml | 14 + build/install/win/tools/Socket.IO.xml | 14 + build/install/win/tools/SsoAuth.xml | 14 + build/install/win/tools/UrlShortener.xml | 14 + build/install/win/tools/kafka.xml | 15 - build/install/win/tools/zookeeper.xml | 15 - 22 files changed, 1672 insertions(+), 774 deletions(-) delete mode 100644 build/install/win/Apache Kafka.aip delete mode 100644 build/install/win/Apache ZooKeeper.aip create mode 100644 build/install/win/CustomActions/C#/Utils/packages.config create mode 100644 build/install/win/CustomActions/C#/Utils/redis-sharp.cs create mode 100644 build/install/win/tools/DocEditor.xml create mode 100644 build/install/win/tools/Login.xml create mode 100644 build/install/win/tools/Socket.IO.xml create mode 100644 build/install/win/tools/SsoAuth.xml create mode 100644 build/install/win/tools/UrlShortener.xml delete mode 100644 build/install/win/tools/kafka.xml delete mode 100644 build/install/win/tools/zookeeper.xml diff --git a/build/install/win/Apache Kafka.aip b/build/install/win/Apache Kafka.aip deleted file mode 100644 index 731c6efca2..0000000000 --- a/build/install/win/Apache Kafka.aip +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/install/win/Apache ZooKeeper.aip b/build/install/win/Apache ZooKeeper.aip deleted file mode 100644 index 07f73daf62..0000000000 --- a/build/install/win/Apache ZooKeeper.aip +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/install/win/CustomActions/C#/Utils/CustomAction.cs b/build/install/win/CustomActions/C#/Utils/CustomAction.cs index 45b43184c3..843e2a1210 100644 --- a/build/install/win/CustomActions/C#/Utils/CustomAction.cs +++ b/build/install/win/CustomActions/C#/Utils/CustomAction.cs @@ -1,11 +1,113 @@ using System; +using System.Collections.Generic; +using System.Text; +using System.Web; using System.Net.Sockets; using Microsoft.Deployment.WindowsInstaller; +using RabbitMQ.Client; namespace Utils { public class CustomActions { + public static string CreateAuthToken(string pkey, string machinekey) + { + using (var hasher = new System.Security.Cryptography.HMACSHA1(Encoding.UTF8.GetBytes(machinekey))) + { + var now = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); + var hash = System.Web.HttpServerUtility.UrlTokenEncode(hasher.ComputeHash(Encoding.UTF8.GetBytes(string.Join("\n", now, pkey)))); + return string.Format("ASC {0}:{1}:{2}", pkey, now, hash); + } + } + + [CustomAction] + public static ActionResult SetVersionReleaseDateSign(Session session) + { + var pkey = Convert.ToString(session["VERSION.RELEASE_DATE"]); + var machineKey = Convert.ToString(session["MACHINE_KEY"]); + + session.Log("SetVersionReleaseDateSign: pkey {0}, machineKey {1}", pkey, machineKey); + + session["VERSION.RELEASE_DATE.SIGN"] = CreateAuthToken(pkey, machineKey); + + session.Log("SetVersionReleaseDateSign End: {0}", session["VERSION.RELEASE_DATE.SIGN"]); + + return ActionResult.Success; + } + + + [CustomAction] + public static ActionResult TestRedisServerConnection(Session session) + { + try + { + using (var redis = new Redis(session["REDIS_HOST_PROP"], Convert.ToInt32(session["REDIS_PORT_PROP"]))) + { + + if (!String.IsNullOrEmpty(session["REDIS_PASSWORD_PROP"].Trim())) + redis.Password = session["REDIS_PASSWORD_PROP"]; + + var pong = redis.Ping("ONLYOFFICE"); + + session.Log("Redis Status: IsConnected is {0}", !String.IsNullOrEmpty(pong)); + session["RedisServerConnectionError"] = !String.IsNullOrEmpty(pong) ? "" : String.Format("Connection Refused HOST:{0},PORT:{1},PASS:{2}", session["REDIS_HOST_PROP"], session["REDIS_PORT_PROP"], session["REDIS_PASSWORD_PROP"]); + + } + } + catch (Exception ex) + { + session.Log("RedisConnectionException '{0}'", ex.Message); + session["RedisServerConnectionError"] = String.Format("Connection Refused HOST:{0},PORT:{1},PASS:{2}", session["REDIS_HOST_PROP"], session["REDIS_PORT_PROP"], session["REDIS_PASSWORD_PROP"]); + } + + return ActionResult.Success; + } + + + [CustomAction] + public static ActionResult TestRabbitMQConnection(Session session) + { + ConnectionFactory factory = new ConnectionFactory(); + + factory.HostName = session["RABBITMQ_HOSTNAME_PROP"]; + factory.Port = Convert.ToInt32(session["RABBITMQ_PORT_PROP"]); + factory.VirtualHost = session["RABBITMQ_VIRTUALHOST_PROP"]; + factory.UserName = session["RABBITMQ_USERNAME_PROP"]; + factory.Password = session["RABBITMQ_PASSWORD_PROP"]; + + try + { + using (IConnection conn = factory.CreateConnection()) + { + session.Log("RabbitMQ Status: IsConnected is {0}", conn.IsOpen); + + session["RabbitMQServerConnectionError"] = conn.IsOpen ? "" : String.Format("Connection Refused HOST:{0}, PORT:{1}, VirtualHost:{2}, UserName:{3}, PASS:{4}", + session["RABBITMQ_HOSTNAME_PROP"], + session["RABBITMQ_PORT_PROP"], + session["RABBITMQ_VIRTUALHOST_PROP"], + session["RABBITMQ_USERNAME_PROP"], + session["RABBITMQ_PASSWORD_PROP"] + ); + } + } + catch (Exception ex) + { + + session.Log("RabbitMQ.Client.Exceptions.BrokerUnreachableException {0}", ex.Message); + session["RabbitMQServerConnectionError"] = String.Format("Connection Refused HOST:{0}, PORT:{1}, VirtualHost:{2}, UserName:{3}, PASS:{4}", + session["RABBITMQ_HOSTNAME_PROP"], + session["RABBITMQ_PORT_PROP"], + session["RABBITMQ_VIRTUALHOST_PROP"], + session["RABBITMQ_USERNAME_PROP"], + session["RABBITMQ_PASSWORD_PROP"] + ); + + } + + return ActionResult.Success; + + } + [CustomAction] public static ActionResult CheckTCPAvailability(Session session) { diff --git a/build/install/win/CustomActions/C#/Utils/Properties/AssemblyInfo.cs b/build/install/win/CustomActions/C#/Utils/Properties/AssemblyInfo.cs index 1c22b2f432..9be1eb3545 100644 --- a/build/install/win/CustomActions/C#/Utils/Properties/AssemblyInfo.cs +++ b/build/install/win/CustomActions/C#/Utils/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/build/install/win/CustomActions/C#/Utils/Utils.csproj b/build/install/win/CustomActions/C#/Utils/Utils.csproj index 2506c1d8be..d6d06a4b91 100644 --- a/build/install/win/CustomActions/C#/Utils/Utils.csproj +++ b/build/install/win/CustomActions/C#/Utils/Utils.csproj @@ -32,6 +32,9 @@ 4 + + packages\RabbitMQ.Client.3.6.5\lib\net45\RabbitMQ.Client.dll + @@ -46,8 +49,12 @@ + + + + \ No newline at end of file diff --git a/build/install/win/CustomActions/C#/Utils/packages.config b/build/install/win/CustomActions/C#/Utils/packages.config new file mode 100644 index 0000000000..97a4445b50 --- /dev/null +++ b/build/install/win/CustomActions/C#/Utils/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/build/install/win/CustomActions/C#/Utils/redis-sharp.cs b/build/install/win/CustomActions/C#/Utils/redis-sharp.cs new file mode 100644 index 0000000000..f0f9eedd1f --- /dev/null +++ b/build/install/win/CustomActions/C#/Utils/redis-sharp.cs @@ -0,0 +1,937 @@ +// +// redis-sharp.cs: ECMA CLI Binding to the Redis key-value storage system +// +// Authors: +// Miguel de Icaza (miguel@gnome.org) +// +// Copyright 2010 Novell, Inc. +// +// Licensed under the same terms of reddis: new BSD license. +// +#define DEBUG + +using System; +using System.IO; +using System.Collections.Generic; +using System.Net.Sockets; +using System.Text; +using System.Diagnostics; +using System.Linq; + +public class Redis : IDisposable { + Socket socket; + BufferedStream bstream; + + public enum KeyType { + None, String, List, Set + } + + public class ResponseException : Exception { + public ResponseException (string code) : base ("Response error") + { + Code = code; + } + + public string Code { get; private set; } + } + + public Redis (string host, int port) + { + if (host == null) + throw new ArgumentNullException ("host"); + + Host = host; + Port = port; + SendTimeout = -1; + } + + public Redis (string host) : this (host, 6379) + { + } + + public Redis () : this ("localhost", 6379) + { + } + + public string Host { get; private set; } + public int Port { get; private set; } + public int RetryTimeout { get; set; } + public int RetryCount { get; set; } + public int SendTimeout { get; set; } + public string Password { get; set; } + + int db; + public int Db { + get { + return db; + } + + set { + db = value; + SendExpectSuccess ("SELECT", db); + } + } + + public string this [string key] { + get { return GetString (key); } + set { Set (key, value); } + } + + public void Set (string key, string value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + + Set (key, Encoding.UTF8.GetBytes (value)); + } + + + public void Set (string key, byte [] value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length > 1073741824) + throw new ArgumentException ("value exceeds 1G", "value"); + + if (!SendDataCommand (value, "SET", key)) + throw new Exception ("Unable to connect"); + ExpectSuccess (); + } + + public bool SetNX (string key, string value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + + return SetNX (key, Encoding.UTF8.GetBytes (value)); + } + + public bool SetNX (string key, byte [] value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length > 1073741824) + throw new ArgumentException ("value exceeds 1G", "value"); + + return SendDataExpectInt (value, "SETNX", key) > 0 ? true : false; + } + + public void Set (IDictionary dict) + { + if (dict == null) + throw new ArgumentNullException ("dict"); + + Set (dict.ToDictionary(k => k.Key, v => Encoding.UTF8.GetBytes(v.Value))); + } + + public void Set (IDictionary dict) + { + if (dict == null) + throw new ArgumentNullException ("dict"); + + MSet (dict.Keys.ToArray (), dict.Values.ToArray ()); + } + + public void MSet (string [] keys, byte [][] values) + { + if (keys.Length != values.Length) + throw new ArgumentException ("keys and values must have the same size"); + + byte [] nl = Encoding.UTF8.GetBytes ("\r\n"); + MemoryStream ms = new MemoryStream (); + + for (int i = 0; i < keys.Length; i++) { + byte [] key = Encoding.UTF8.GetBytes(keys[i]); + byte [] val = values[i]; + byte [] kLength = Encoding.UTF8.GetBytes ("$" + key.Length + "\r\n"); + byte [] k = Encoding.UTF8.GetBytes (keys[i] + "\r\n"); + byte [] vLength = Encoding.UTF8.GetBytes ("$" + val.Length + "\r\n"); + ms.Write (kLength, 0, kLength.Length); + ms.Write (k, 0, k.Length); + ms.Write (vLength, 0, vLength.Length); + ms.Write (val, 0, val.Length); + ms.Write (nl, 0, nl.Length); + } + + SendDataRESP (ms.ToArray (), "*" + (keys.Length * 2 + 1) + "\r\n$4\r\nMSET\r\n"); + ExpectSuccess (); + } + + public byte [] Get (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectData ("GET", key); + } + + public string Ping(String key) + { + return Encoding.UTF8.GetString (SendExpectData("PING", key)); + } + + public string GetString (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return Encoding.UTF8.GetString (Get (key)); + } + + public byte [][] Sort (SortOptions options) + { + return Sort (options.Key, options.StoreInKey, options.ToArgs()); + } + + public byte [][] Sort (string key, string destination, params object [] options) + { + if (key == null) + throw new ArgumentNullException ("key"); + + int offset = string.IsNullOrEmpty (destination) ? 1 : 3; + object [] args = new object [offset + options.Length]; + + args [0] = key; + Array.Copy (options, 0, args, offset, options.Length); + if (offset == 1) { + return SendExpectDataArray ("SORT", args); + } + else { + args [1] = "STORE"; + args [2] = destination; + int n = SendExpectInt ("SORT", args); + return new byte [n][]; + } + } + + public byte [] GetSet (string key, byte [] value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length > 1073741824) + throw new ArgumentException ("value exceeds 1G", "value"); + + if (!SendDataCommand (value, "GETSET", key)) + throw new Exception ("Unable to connect"); + + return ReadData (); + } + + public string GetSet (string key, string value) + { + if (key == null) + throw new ArgumentNullException ("key"); + if (value == null) + throw new ArgumentNullException ("value"); + return Encoding.UTF8.GetString (GetSet (key, Encoding.UTF8.GetBytes (value))); + } + + string ReadLine () + { + StringBuilder sb = new StringBuilder (); + int c; + + while ((c = bstream.ReadByte ()) != -1){ + if (c == '\r') + continue; + if (c == '\n') + break; + sb.Append ((char) c); + } + return sb.ToString (); + } + + void Connect () + { + socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.NoDelay = true; + socket.SendTimeout = SendTimeout; + socket.Connect (Host, Port); + if (!socket.Connected){ + socket.Close (); + socket = null; + return; + } + bstream = new BufferedStream (new NetworkStream (socket), 16*1024); + + if (Password != null) + SendExpectSuccess ("AUTH", Password); + } + + byte [] end_data = new byte [] { (byte) '\r', (byte) '\n' }; + + bool SendDataCommand (byte [] data, string cmd, params object [] args) + { + string resp = "*" + (1 + args.Length + 1).ToString () + "\r\n"; + resp += "$" + cmd.Length + "\r\n" + cmd + "\r\n"; + foreach (object arg in args) { + string argStr = arg.ToString (); + int argStrLength = Encoding.UTF8.GetByteCount(argStr); + resp += "$" + argStrLength + "\r\n" + argStr + "\r\n"; + } + resp += "$" + data.Length + "\r\n"; + + return SendDataRESP (data, resp); + } + + bool SendDataRESP (byte [] data, string resp) + { + if (socket == null) + Connect (); + if (socket == null) + return false; + + byte [] r = Encoding.UTF8.GetBytes (resp); + try { + Log ("C", resp); + socket.Send (r); + if (data != null){ + socket.Send (data); + socket.Send (end_data); + } + } catch (SocketException){ + // timeout; + socket.Close (); + socket = null; + + return false; + } + return true; + } + + bool SendCommand (string cmd, params object [] args) + { + if (socket == null) + Connect (); + if (socket == null) + return false; + + string resp = "*" + (1 + args.Length).ToString () + "\r\n"; + resp += "$" + cmd.Length + "\r\n" + cmd + "\r\n"; + foreach (object arg in args) { + string argStr = arg.ToString (); + int argStrLength = Encoding.UTF8.GetByteCount(argStr); + resp += "$" + argStrLength + "\r\n" + argStr + "\r\n"; + } + + byte [] r = Encoding.UTF8.GetBytes (resp); + try { + Log ("C", resp); + socket.Send (r); + } catch (SocketException){ + // timeout; + socket.Close (); + socket = null; + + return false; + } + return true; + } + + [Conditional ("DEBUG")] + void Log (string id, string message) + { + Console.WriteLine(id + ": " + message.Trim().Replace("\r\n", " ")); + } + + void ExpectSuccess () + { + int c = bstream.ReadByte (); + if (c == -1) + throw new ResponseException ("No more data"); + + string s = ReadLine (); + Log ("S", (char)c + s); + if (c == '-') + throw new ResponseException (s.StartsWith ("ERR ") ? s.Substring (4) : s); + } + + void SendExpectSuccess (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception ("Unable to connect"); + + ExpectSuccess (); + } + + int SendDataExpectInt (byte[] data, string cmd, params object [] args) + { + if (!SendDataCommand (data, cmd, args)) + throw new Exception ("Unable to connect"); + + int c = bstream.ReadByte (); + if (c == -1) + throw new ResponseException ("No more data"); + + string s = ReadLine (); + Log ("S", (char)c + s); + if (c == '-') + throw new ResponseException (s.StartsWith ("ERR ") ? s.Substring (4) : s); + if (c == ':'){ + int i; + if (int.TryParse (s, out i)) + return i; + } + throw new ResponseException ("Unknown reply on integer request: " + c + s); + } + + int SendExpectInt (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception ("Unable to connect"); + + int c = bstream.ReadByte (); + if (c == -1) + throw new ResponseException ("No more data"); + + string s = ReadLine (); + Log ("S", (char)c + s); + if (c == '-') + throw new ResponseException (s.StartsWith ("ERR ") ? s.Substring (4) : s); + if (c == ':'){ + int i; + if (int.TryParse (s, out i)) + return i; + } + throw new ResponseException ("Unknown reply on integer request: " + c + s); + } + + string SendExpectString (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception ("Unable to connect"); + + int c = bstream.ReadByte (); + if (c == -1) + throw new ResponseException ("No more data"); + + string s = ReadLine (); + Log ("S", (char)c + s); + if (c == '-') + throw new ResponseException (s.StartsWith ("ERR ") ? s.Substring (4) : s); + if (c == '+') + return s; + + throw new ResponseException ("Unknown reply on integer request: " + c + s); + } + + // + // This one does not throw errors + // + string SendGetString (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception ("Unable to connect"); + + return ReadLine (); + } + + byte [] SendExpectData (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception ("Unable to connect"); + + return ReadData (); + } + + byte [] ReadData () + { + string s = ReadLine (); + Log ("S", s); + if (s.Length == 0) + throw new ResponseException ("Zero length respose"); + + char c = s [0]; + if (c == '-') + throw new ResponseException (s.StartsWith ("-ERR ") ? s.Substring (5) : s.Substring (1)); + + if (c == '$'){ + if (s == "$-1") + return null; + int n; + + if (Int32.TryParse (s.Substring (1), out n)){ + byte [] retbuf = new byte [n]; + + int bytesRead = 0; + do { + int read = bstream.Read (retbuf, bytesRead, n - bytesRead); + if (read < 1) + throw new ResponseException("Invalid termination mid stream"); + bytesRead += read; + } + while (bytesRead < n); + if (bstream.ReadByte () != '\r' || bstream.ReadByte () != '\n') + throw new ResponseException ("Invalid termination"); + return retbuf; + } + throw new ResponseException ("Invalid length"); + } + + /* don't treat arrays here because only one element works -- use DataArray! + //returns the number of matches + if (c == '*') { + int n; + if (Int32.TryParse(s.Substring(1), out n)) + return n <= 0 ? new byte [0] : ReadData(); + + throw new ResponseException ("Unexpected length parameter" + r); + } + */ + + throw new ResponseException ("Unexpected reply: " + s); + } + + public bool ContainsKey (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("EXISTS", key) == 1; + } + + public bool Remove (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("DEL", key) == 1; + } + + public int Remove (params string [] args) + { + if (args == null) + throw new ArgumentNullException ("args"); + return SendExpectInt ("DEL", args); + } + + public int Increment (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("INCR", key); + } + + public int Increment (string key, int count) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("INCRBY", key, count); + } + + public int Decrement (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("DECR", key); + } + + public int Decrement (string key, int count) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("DECRBY", key, count); + } + + public KeyType TypeOf (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + switch (SendExpectString ("TYPE", key)) { + case "none": + return KeyType.None; + case "string": + return KeyType.String; + case "set": + return KeyType.Set; + case "list": + return KeyType.List; + } + throw new ResponseException ("Invalid value"); + } + + public string RandomKey () + { + return SendExpectString ("RANDOMKEY"); + } + + public bool Rename (string oldKeyname, string newKeyname) + { + if (oldKeyname == null) + throw new ArgumentNullException ("oldKeyname"); + if (newKeyname == null) + throw new ArgumentNullException ("newKeyname"); + return SendGetString ("RENAME", oldKeyname, newKeyname) [0] == '+'; + } + + public bool Expire (string key, int seconds) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("EXPIRE", key, seconds) == 1; + } + + public bool ExpireAt (string key, int time) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("EXPIREAT", key, time) == 1; + } + + public int TimeToLive (string key) + { + if (key == null) + throw new ArgumentNullException ("key"); + return SendExpectInt ("TTL", key); + } + + public int DbSize { + get { + return SendExpectInt ("DBSIZE"); + } + } + + public void Save () + { + SendExpectSuccess ("SAVE"); + } + + public void BackgroundSave () + { + SendExpectSuccess ("BGSAVE"); + } + + public void Shutdown () + { + SendCommand ("SHUTDOWN"); + try { + // the server may return an error + string s = ReadLine (); + Log ("S", s); + if (s.Length == 0) + throw new ResponseException ("Zero length respose"); + throw new ResponseException (s.StartsWith ("-ERR ") ? s.Substring (5) : s.Substring (1)); + } catch (IOException) { + // this is the expected good result + socket.Close (); + socket = null; + } + } + + public void FlushAll () + { + SendExpectSuccess ("FLUSHALL"); + } + + public void FlushDb () + { + SendExpectSuccess ("FLUSHDB"); + } + + const long UnixEpoch = 621355968000000000L; + + public DateTime LastSave { + get { + int t = SendExpectInt ("LASTSAVE"); + + return new DateTime (UnixEpoch) + TimeSpan.FromSeconds (t); + } + } + + public Dictionary GetInfo () + { + byte [] r = SendExpectData ("INFO"); + var dict = new Dictionary(); + + foreach (var line in Encoding.UTF8.GetString (r).Split ('\n')){ + int p = line.IndexOf (':'); + if (p == -1) + continue; + dict.Add (line.Substring (0, p), line.Substring (p+1)); + } + return dict; + } + + public string [] Keys { + get { + return GetKeys("*"); + } + } + + public string [] GetKeys (string pattern) + { + if (pattern == null) + throw new ArgumentNullException ("pattern"); + + return SendExpectStringArray ("KEYS", pattern); + } + + public byte [][] MGet (params string [] keys) + { + if (keys == null) + throw new ArgumentNullException ("keys"); + if (keys.Length == 0) + throw new ArgumentException ("keys"); + + return SendExpectDataArray ("MGET", keys); + } + + + public string [] SendExpectStringArray (string cmd, params object [] args) + { + byte [][] reply = SendExpectDataArray (cmd, args); + string [] keys = new string [reply.Length]; + for (int i = 0; i < reply.Length; i++) + keys[i] = Encoding.UTF8.GetString (reply[i]); + return keys; + } + + public byte[][] SendExpectDataArray (string cmd, params object [] args) + { + if (!SendCommand (cmd, args)) + throw new Exception("Unable to connect"); + int c = bstream.ReadByte(); + if (c == -1) + throw new ResponseException("No more data"); + + string s = ReadLine(); + Log("S", (char)c + s); + if (c == '-') + throw new ResponseException(s.StartsWith("ERR ") ? s.Substring(4) : s); + if (c == '*') { + int count; + if (int.TryParse (s, out count)) { + byte [][] result = new byte [count][]; + + for (int i = 0; i < count; i++) + result[i] = ReadData(); + + return result; + } + } + throw new ResponseException("Unknown reply on multi-request: " + c + s); + } + + #region List commands + public byte[][] ListRange(string key, int start, int end) + { + return SendExpectDataArray ("LRANGE", key, start, end); + } + + public void LeftPush(string key, string value) + { + LeftPush(key, Encoding.UTF8.GetBytes (value)); + } + + public void LeftPush(string key, byte [] value) + { + SendDataCommand (value, "LPUSH", key); + ExpectSuccess(); + } + + public void RightPush(string key, string value) + { + RightPush(key, Encoding.UTF8.GetBytes (value)); + } + + public void RightPush(string key, byte [] value) + { + SendDataCommand (value, "RPUSH", key); + ExpectSuccess(); + } + + public int ListLength (string key) + { + return SendExpectInt ("LLEN", key); + } + + public byte[] ListIndex (string key, int index) + { + SendCommand ("LINDEX", key, index); + return ReadData (); + } + + public byte[] LeftPop(string key) + { + SendCommand ("LPOP", key); + return ReadData (); + } + + public byte[] RightPop(string key) + { + SendCommand ("RPOP", key); + return ReadData (); + } + #endregion + + #region Set commands + public bool AddToSet (string key, byte[] member) + { + return SendDataExpectInt(member, "SADD", key) > 0; + } + + public bool AddToSet (string key, string member) + { + return AddToSet (key, Encoding.UTF8.GetBytes(member)); + } + + public int CardinalityOfSet (string key) + { + return SendExpectInt ("SCARD", key); + } + + public bool IsMemberOfSet (string key, byte[] member) + { + return SendDataExpectInt (member, "SISMEMBER", key) > 0; + } + + public bool IsMemberOfSet(string key, string member) + { + return IsMemberOfSet(key, Encoding.UTF8.GetBytes(member)); + } + + public byte[][] GetMembersOfSet (string key) + { + return SendExpectDataArray ("SMEMBERS", key); + } + + public byte[] GetRandomMemberOfSet (string key) + { + return SendExpectData ("SRANDMEMBER", key); + } + + public byte[] PopRandomMemberOfSet (string key) + { + return SendExpectData ("SPOP", key); + } + + public bool RemoveFromSet (string key, byte[] member) + { + return SendDataExpectInt (member, "SREM", key) > 0; + } + + public bool RemoveFromSet (string key, string member) + { + return RemoveFromSet (key, Encoding.UTF8.GetBytes(member)); + } + + public byte[][] GetUnionOfSets (params string[] keys) + { + if (keys == null) + throw new ArgumentNullException(); + + return SendExpectDataArray ("SUNION", keys); + + } + + void StoreSetCommands (string cmd, params string[] keys) + { + if (String.IsNullOrEmpty(cmd)) + throw new ArgumentNullException ("cmd"); + + if (keys == null) + throw new ArgumentNullException ("keys"); + + SendExpectSuccess (cmd, keys); + } + + public void StoreUnionOfSets (params string[] keys) + { + StoreSetCommands ("SUNIONSTORE", keys); + } + + public byte[][] GetIntersectionOfSets (params string[] keys) + { + if (keys == null) + throw new ArgumentNullException(); + + return SendExpectDataArray ("SINTER", keys); + } + + public void StoreIntersectionOfSets (params string[] keys) + { + StoreSetCommands ("SINTERSTORE", keys); + } + + public byte[][] GetDifferenceOfSets (params string[] keys) + { + if (keys == null) + throw new ArgumentNullException(); + + return SendExpectDataArray ("SDIFF", keys); + } + + public void StoreDifferenceOfSets (params string[] keys) + { + StoreSetCommands ("SDIFFSTORE", keys); + } + + public bool MoveMemberToSet (string srcKey, string destKey, byte[] member) + { + return SendDataExpectInt (member, "SMOVE", srcKey, destKey) > 0; + } + #endregion + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + ~Redis () + { + Dispose (false); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing){ + SendCommand ("QUIT"); + ExpectSuccess (); + socket.Close (); + socket = null; + } + } +} + +public class SortOptions { + public string Key { get; set; } + public bool Descending { get; set; } + public bool Lexographically { get; set; } + public Int32 LowerLimit { get; set; } + public Int32 UpperLimit { get; set; } + public string By { get; set; } + public string StoreInKey { get; set; } + public string Get { get; set; } + + public object [] ToArgs () + { + System.Collections.ArrayList args = new System.Collections.ArrayList(); + + if (LowerLimit != 0 || UpperLimit != 0) { + args.Add ("LIMIT"); + args.Add (LowerLimit); + args.Add (UpperLimit); + } + if (Lexographically) + args.Add("ALPHA"); + if (!string.IsNullOrEmpty (By)) { + args.Add("BY"); + args.Add(By); + } + if (!string.IsNullOrEmpty (Get)) { + args.Add("GET"); + args.Add(Get); + } + return args.ToArray (); + } +} diff --git a/build/install/win/DocSpace.aip b/build/install/win/DocSpace.aip index 30308dae5f..bf153527c1 100644 --- a/build/install/win/DocSpace.aip +++ b/build/install/win/DocSpace.aip @@ -28,7 +28,9 @@ + + @@ -56,8 +58,10 @@ + + @@ -71,8 +75,11 @@ + + + @@ -83,82 +90,163 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -174,20 +262,17 @@ - - + - - - - + + @@ -222,15 +307,79 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -255,7 +404,6 @@ - @@ -265,6 +413,7 @@ + @@ -578,12 +727,72 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -594,6 +803,7 @@ + @@ -620,13 +830,17 @@ + + + + @@ -639,9 +853,10 @@ + - + @@ -675,8 +890,7 @@ - - + @@ -691,8 +905,68 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -702,8 +976,8 @@ - - + + @@ -724,35 +998,42 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + + + - + + @@ -762,6 +1043,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -795,12 +1143,14 @@ + + - + @@ -811,35 +1161,38 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - + + + + + - + @@ -847,25 +1200,28 @@ + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -930,19 +1286,15 @@ - - - - - + + + - - - - - + + + diff --git a/build/install/win/backend-build.bat b/build/install/win/backend-build.bat index f30c9733ca..f7f5256ec3 100644 --- a/build/install/win/backend-build.bat +++ b/build/install/win/backend-build.bat @@ -4,14 +4,12 @@ echo ##################### echo # build backend # echo ##################### +set SRC_PATH=%~s2 + pushd %~1 - call dotnet build ASC.Web.sln - - echo "== Build ASC.Thumbnails ==" - pushd common\ASC.Thumbnails - call yarn install --frozen-lockfile - popd + call dotnet build ASC.Web.slnf + call dotnet build ASC.Migrations.sln -o %SRC_PATH%\services\ASC.Migration.Runner\service echo "== Build ASC.UrlShortener ==" pushd common\ASC.UrlShortener diff --git a/build/install/win/build-batch.bat b/build/install/win/build-batch.bat index 91a8546f6c..efe031de69 100644 --- a/build/install/win/build-batch.bat +++ b/build/install/win/build-batch.bat @@ -1,88 +1,61 @@ REM echo ######## Set variables ######## set "publisher="Ascensio System SIA"" -set "zookeeper_version=3.7.1" -set "kafka_version=2.8.0" set "nginx_version=1.21.1" -set "scala_version=2.12" +set "nuget="%cd%\thirdparty\SimpleRestServices\src\.nuget\NuGet.exe"" REM echo ######## Extracting and preparing files to build ######## %sevenzip% x build\install\win\nginx-%nginx_version%.zip -o"build\install\win\Files" -y xcopy "build\install\win\Files\nginx-%nginx_version%" "build\install\win\Files\nginx" /s /y /b /i rmdir build\install\win\Files\nginx-%nginx_version% /s /q -rmdir build\install\win\kafka-zookeeper /s /q -md build\install\win\kafka-zookeeper md build\install\win\Files\nginx\temp md build\install\win\Files\nginx\logs -%tar% -xvf build\install\win\apache-zookeeper-%zookeeper_version%-bin.tar.gz -C build\install\win\kafka-zookeeper -%tar% -xvf build\install\win\kafka_%scala_version%-%kafka_version%.tgz -C build\install\win\kafka-zookeeper -ren build\install\win\kafka-zookeeper\apache-zookeeper-%zookeeper_version%-bin zookeeper -ren build\install\win\kafka-zookeeper\kafka_%scala_version%-%kafka_version% kafka -md build\install\win\kafka-zookeeper\kafka\tools md build\install\win\Files\tools -copy build\install\win\WinSW.NET4new.exe "build\install\win\kafka-zookeeper\kafka\tools\kafka.exe" /y -copy build\install\win\WinSW.NET4new.exe "build\install\win\kafka-zookeeper\kafka\tools\zookeeper.exe" /y -copy build\install\win\tools\zookeeper.xml "build\install\win\kafka-zookeeper\kafka\tools\zookeeper.xml" /y -copy build\install\win\tools\kafka.xml "build\install\win\kafka-zookeeper\kafka\tools\kafka.xml" /y -del /f /q build\install\win\apache-zookeeper-%zookeeper_version%-bin.* -del /f /q build\install\win\kafka_%scala_version%-%kafka_version%.* -copy build\install\win\WinSW.NET4.exe "build\install\win\Files\tools\proxy.exe" /y -copy build\install\win\tools\proxy.xml "build\install\win\Files\tools\proxy.xml" /y +md build\install\win\Files\Logs +md build\install\win\Files\service\ +md build\install\win\Files\products\ASC.Files\server\temp +md build\install\win\Files\products\ASC.People\server\temp +md build\install\win\Files\services\ASC.Data.Backup\service\temp +md build\install\win\Files\services\ASC.Files.Service\service\temp +md build\install\win\Files\services\ASC.Notify\service\temp +md build\install\win\Files\services\ASC.Studio.Notify\service\temp +md build\install\win\Files\services\ASC.TelegramService\service\temp +md build\install\win\Files\services\ASC.Data.Backup.BackgroundTasks\service\temp +md build\install\win\Files\services\ASC.ClearEvents\service\temp +md build\install\win\Files\services\ASC.Migration\service\temp +md build\install\win\Files\services\ASC.Webhooks.Service\service\temp +md build\install\win\Files\services\ASC.Web.Api\service\temp +md build\install\win\Files\services\ASC.Web.Studio\service\temp +copy build\install\win\WinSW.NET4.exe "build\install\win\Files\tools\Proxy.exe" /y +copy build\install\win\tools\Proxy.xml "build\install\win\Files\tools\Proxy.xml" /y +copy build\install\win\WinSW3.0.0.exe "build\install\win\Files\tools\Socket.IO.exe" /y +copy build\install\win\tools\Socket.IO.xml "build\install\win\Files\tools\Socket.IO.xml" /y +copy build\install\win\WinSW3.0.0.exe "build\install\win\Files\tools\UrlShortener.exe" /y +copy build\install\win\tools\UrlShortener.xml "build\install\win\Files\tools\UrlShortener.xml" /y +copy build\install\win\WinSW3.0.0.exe "build\install\win\Files\tools\SsoAuth.exe" /y +copy build\install\win\tools\SsoAuth.xml "build\install\win\Files\tools\SsoAuth.xml" /y +copy build\install\win\WinSW3.0.0.exe "build\install\win\Files\tools\DocEditor.exe" /y +copy build\install\win\tools\DocEditor.xml "build\install\win\Files\tools\DocEditor.xml" /y +copy build\install\win\WinSW3.0.0.exe "build\install\win\Files\tools\Login.exe" /y +copy build\install\win\tools\Login.xml "build\install\win\Files\tools\Login.xml" /y copy "build\install\win\nginx.conf" "build\install\win\Files\nginx\conf\nginx.conf" /y -copy "build\install\win\kafka-zookeeper\zookeeper\conf\zoo_sample.cfg" "build\install\win\kafka-zookeeper\zookeeper\conf\zoo.cfg" /y -del /f /q "build\install\win\kafka-zookeeper\zookeeper\conf\zoo_sample.cfg" rmdir build\install\win\publish /s /q +del /f /q build\install\win\Files\nginx\conf\onlyoffice-login.conf + REM echo ######## Build Utils ######## +%nuget% install %cd%\build\install\win\CustomActions\C#\Utils\packages.config -OutputDirectory %cd%\build\install\win\CustomActions\C#\Utils\packages %msbuild% build\install\win\CustomActions\C#\Utils\Utils.csproj copy build\install\win\CustomActions\C#\Utils\bin\Debug\Utils.CA.dll build\install\win\Utils.CA.dll /y rmdir build\install\win\CustomActions\C#\Utils\bin /s /q rmdir build\install\win\CustomActions\C#\Utils\obj /s /q -REM echo ######## Edit zookeeper/kafka cfg and proprties files ######## -%sed% -i "s/\(dataDir\).*/\1=.\/..\/zookeeper\/Data/g" build/install/win/kafka-zookeeper/zookeeper/conf/zoo.cfg -%sed% -i "s/\(log.dirs\)=.*/\1=kafka-logs/g" build/install/win/kafka-zookeeper/kafka/config/server.properties -%sed% -i "s/\(zookeeper.connect\)=.*/\1=localhost:2181/g" build/install/win/kafka-zookeeper/kafka/config/server.properties -%sed% -i "s/\(clientPort\)=.*/\1=2181/g" build/install/win/kafka-zookeeper/kafka/config/zookeeper.properties -%sed% -i "s/\(dataDir\).*/\1=.\/..\/zookeeper\/Data/g" build/install/win/kafka-zookeeper/kafka/config/zookeeper.properties -%sed% -i "s/\(bootstrap.servers\)=.*/\1=localhost:9092/g" build/install/win/kafka-zookeeper/kafka/config/consumer.properties -%sed% -i "s/\(bootstrap.servers\)=.*/\1=localhost:9092/g" build/install/win/kafka-zookeeper/kafka/config/connect-standalone.properties -%sed% -i "s/\(offset.storage.file.filename\)=.*/\1=kafka-offsets/g" build/install/win/kafka-zookeeper/kafka/config/connect-standalone.properties -%sed% -i "s/\(logger.kafka.controller\)=.*,/\1=INFO,/g" build/install/win/kafka-zookeeper/kafka/config/log4j.properties -%sed% -i "s/\(logger.state.change.logger\)=.*,/\1=INFO,/g" build/install/win/kafka-zookeeper/kafka/config/log4j.properties -echo log4j.logger.kafka.producer.async.DefaultEventHandler=INFO, kafkaAppender >> build/install/win/kafka-zookeeper/kafka/config/log4j.properties -echo exit /b 1 >> build/install/win/kafka-zookeeper/kafka/bin/windows/zookeeper-server-start.bat -echo exit /b 1 >> build/install/win/kafka-zookeeper/kafka/bin/windows/kafka-server-start.bat - -REM echo ######## Edit nginx conf files ######## -%sed% -i "s!#rewrite!rewrite!g" build/install/win/Files/nginx/conf/onlyoffice.conf -%sed% -i "s!/etc/nginx/includes!includes!g" build/install/win/Files/nginx/conf/onlyoffice.conf -%sed% -i "s!/var/www!..!g" build/install/win/Files/nginx/conf/onlyoffice-*.conf -%sed% -i "s!/var/www!..!g" build/install/win/Files/nginx/conf/includes/onlyoffice-*.conf - -REM echo ######## Edit json files ######## -%sed% -i "s!\(\"machinekey\":\).\".*\"!\1 \"1123askdasjklasbnd\"!g" build/install/win/Files/config/appsettings*.json -%sed% -i "s!\(\"folder\":\).\".*\"!\1 \"{APPDIRCONF}products\"!g" build/install/win/Files/config/appsettings*.json -%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.Socket.IO\/service\"!g" build/install/win/Files/config/socket*.json -%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.Thumbnails\/service\"!g" build/install/win/Files/config/thumb*.json -%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.UrlShortener\/service\/index.js\"!g" build/install/win/Files/config/urlshortener*.json -%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.SsoAuth\/service\"!g" build/install/win/Files/config/ssoauth*.json -%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.UrlShortener\/service\/index.js\"!g" build/install/win/Files/config/appsettings.services.json -%sed% -i "s!\(\"log\":\).\".*\"!\1 \"{APPDIRCONF}Logs\/urlshortener.log\"!g" build/install/win/Files/config/appsettings.services.json - REM echo ######## Delete temp files ######## del /f /q build\install\win\Files\config\sed* del /f /q build\install\win\Files\nginx\conf\sed* del /f /q build\install\win\Files\nginx\conf\includes\sed* -del /f /q build\install\win\kafka-zookeeper\zookeeper\conf\sed* -del /f /q build\install\win\kafka-zookeeper\kafka\config\sed* +del /f /q build\install\win\Files\services\*\service\config\sed* del /f /q build\install\win\*.back.* -REM echo ######## Build kafka/zookeeper ######## -%AdvancedInstaller% /rebuild "build\install\win\Apache ZooKeeper.aip" -copy "build\install\win\publish\Apache ZooKeeper.msi" "build\install\win\Apache ZooKeeper.msi" /y -%AdvancedInstaller% /rebuild "build\install\win\Apache Kafka.aip" -copy "build\install\win\publish\Apache Kafka.msi" "build\install\win\Apache Kafka.msi" /y - REM echo ######## Build MySQL Server Installer ######## iscc /Qp /S"byparam="signtool" sign /a /n "%publisher%" /t http://timestamp.digicert.com $f" "build\install\win\MySQL Server Installer Runner.iss" diff --git a/build/install/win/build-download-prereq.ps1 b/build/install/win/build-download-prereq.ps1 index 0e1eb64c36..e7d48bdf35 100644 --- a/build/install/win/build-download-prereq.ps1 +++ b/build/install/win/build-download-prereq.ps1 @@ -29,9 +29,6 @@ function DownloadComponents { } } -$zookeeper_version = '3.7.1' -$kafka_version = '2.8.0' -$scala_version = '2.12' $nginx_version = '1.21.1' $path_prereq = "${pwd}\build\install\win\" @@ -43,17 +40,6 @@ $prerequisites = @( link = "https://nginx.org/download/nginx-${nginx_version}.zip"; } - @{ - download_allways = $false; - name = "apache-zookeeper-${zookeeper_version}-bin.tar.gz"; - link = "https://dlcdn.apache.org/zookeeper/zookeeper-${zookeeper_version}/apache-zookeeper-${zookeeper_version}-bin.tar.gz"; - } - @{ - download_allways = $false; - name = "kafka_${scala_version}-${kafka_version}.tgz"; - link = "https://archive.apache.org/dist/kafka/${kafka_version}/kafka_${scala_version}-${kafka_version}.tgz"; - } - @{ download_allways = $false; name = "WinSW.NET4new.exe"; @@ -61,4 +47,16 @@ $prerequisites = @( } ) +$path_nuget_packages = "${pwd}\.nuget\packages\" + +$nuget_packages = @( + @{ + download_allways = $false; + name = "rabbitmq.client.3.6.5.nupkg"; + link = "https://www.nuget.org/api/v2/package/RabbitMQ.Client/3.6.5"; + } +) + DownloadComponents $prerequisites $path_prereq + +DownloadComponents $nuget_packages $path_nuget_packages diff --git a/build/install/win/frontend-build.bat b/build/install/win/frontend-build.bat index 5719cddbab..86fd784611 100644 --- a/build/install/win/frontend-build.bat +++ b/build/install/win/frontend-build.bat @@ -4,9 +4,12 @@ echo ###################### echo # build frontend # echo ###################### -pushd %~1 +set DEBUG_INFO=%~2 + +pushd %~s1 call yarn install + if "%DEBUG_INFO%"=="true" yarn debug-info call yarn build call yarn deploy diff --git a/build/install/win/frontend-copy.bat b/build/install/win/frontend-copy.bat index 4703698f89..2fb192bb0d 100644 --- a/build/install/win/frontend-copy.bat +++ b/build/install/win/frontend-copy.bat @@ -17,10 +17,6 @@ if defined SecondArg ( ) xcopy "%PathToRepository%\build\deploy\public" "%PathToAppFolder%\public" /s /y /b /i -xcopy "%PathToRepository%\build\deploy\studio\client" "%PathToAppFolder%\studio\client" /s /y /b /i -xcopy "%PathToRepository%\build\deploy\studio\login" "%PathToAppFolder%\studio\login" /s /y /b /i -xcopy "%PathToRepository%\build\deploy\products\ASC.Files\client" "%PathToAppFolder%\products\ASC.Files\client" /s /y /b /i -xcopy "%PathToRepository%\build\deploy\products\ASC.Files\editor" "%PathToAppFolder%\products\ASC.Files\editor" /s /y /b /i -xcopy "%PathToRepository%\build\deploy\products\ASC.People\client" "%PathToAppFolder%\products\ASC.People\client" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\client" "%PathToAppFolder%\client" /s /y /b /i xcopy "%PathToRepository%\config\nginx" "%PathToAppFolder%\nginx\conf" /s /y /b /i xcopy "%PathToRepository%\config\*" "%PathToAppFolder%\config" /y /b /i diff --git a/build/install/win/nginx.conf b/build/install/win/nginx.conf index e345859092..0044e55a8c 100644 --- a/build/install/win/nginx.conf +++ b/build/install/win/nginx.conf @@ -32,54 +32,7 @@ http { keepalive_timeout 65; #gzip on; - - server { - - set $public_root ../public; - listen 80; - server_name localhost; - - #charset koi8-r; - - #access_log logs/host.access.log main; - - location / { - root html; - index index.html index.htm; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - } include onlyoffice.conf; include onlyoffice-*.conf; - - # HTTPS server - # - #server { - # listen 443 ssl; - # server_name localhost; - - # ssl_certificate cert.pem; - # ssl_certificate_key cert.key; - - # ssl_session_cache shared:SSL:1m; - # ssl_session_timeout 5m; - - # ssl_ciphers HIGH:!aNULL:!MD5; - # ssl_prefer_server_ciphers on; - - # location / { - # root html; - # index index.html index.htm; - # } - #} - } diff --git a/build/install/win/publish-script.bat b/build/install/win/publish-script.bat index 462d4af518..e406797a56 100644 --- a/build/install/win/publish-script.bat +++ b/build/install/win/publish-script.bat @@ -16,34 +16,24 @@ if defined SecondArg ( set PathToAppFolder=%FirstArg%\publish ) -rem publish in directory 'products' -REM dotnet publish "%PathToRepository%\products\ASC.Calendar\server\ASC.Calendar.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Calendar\server" -REM dotnet publish "%PathToRepository%\products\ASC.CRM\server\ASC.CRM.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.CRM\server" +rem backend services (dotnet) in directory 'products' dotnet publish "%PathToRepository%\products\ASC.Files\server\ASC.Files.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Files\server" -REM dotnet publish "%PathToRepository%\products\ASC.Mail\server\ASC.Mail.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Mail\server" dotnet publish "%PathToRepository%\products\ASC.People\server\ASC.People.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.People\server" -REM dotnet publish "%PathToRepository%\products\ASC.Projects\server\ASC.Projects.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Projects\server" -rem publish in directory 'services' -dotnet publish "%PathToRepository%\common\services\ASC.ApiSystem\ASC.ApiSystem.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.ApiSystem\service" +rem backend services (dotnet) in directory 'services' dotnet publish "%PathToRepository%\common\services\ASC.Data.Backup\ASC.Data.Backup.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Backup\service" -dotnet publish "%PathToRepository%\common\services\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Storage.Encryption\service" dotnet publish "%PathToRepository%\products\ASC.Files\service\ASC.Files.Service.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Files.Service\service" -dotnet publish "%PathToRepository%\common\services\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Storage.Migration\service" dotnet publish "%PathToRepository%\common\services\ASC.Notify\ASC.Notify.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Notify\service" -dotnet publish "%PathToRepository%\common\services\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Socket.IO.Svc\service" dotnet publish "%PathToRepository%\common\services\ASC.Studio.Notify\ASC.Studio.Notify.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Studio.Notify\service" dotnet publish "%PathToRepository%\common\services\ASC.TelegramService\ASC.TelegramService.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.TelegramService\service" -dotnet publish "%PathToRepository%\common\services\ASC.Thumbnails.Svc\ASC.Thumbnails.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Thumbnails.Svc\service" -dotnet publish "%PathToRepository%\common\services\ASC.UrlShortener.Svc\ASC.UrlShortener.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.UrlShortener.Svc\service" +dotnet publish "%PathToRepository%\common\services\ASC.Data.Backup.BackgroundTasks\ASC.Data.Backup.BackgroundTasks.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Backup.BackgroundTasks\service" +dotnet publish "%PathToRepository%\common\services\ASC.ClearEvents\ASC.ClearEvents.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.ClearEvents\service" +dotnet publish "%PathToRepository%\common\ASC.Migration\ASC.Migration.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Migration\service" +dotnet publish "%PathToRepository%\common\services\ASC.Webhooks.Service\ASC.Webhooks.Service.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Webhooks.Service\service" dotnet publish "%PathToRepository%\web\ASC.Web.Api\ASC.Web.Api.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Web.Api\service" dotnet publish "%PathToRepository%\web\ASC.Web.Studio\ASC.Web.Studio.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Web.Studio\service" -dotnet publish "%PathToRepository%\common\services\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.SsoAuth.Svc\service" - -rem Publish backend services (Nodejs) -mkdir "%PathToAppFolder%\services\ASC.Thumbnails\service" -xcopy "%PathToRepository%\common\ASC.Thumbnails" "%PathToAppFolder%\services\ASC.Thumbnails\service" /s /y /b /i +rem backend services (Nodejs) in directory 'services' mkdir "%PathToAppFolder%\services\ASC.UrlShortener\service" xcopy "%PathToRepository%\common\ASC.UrlShortener" "%PathToAppFolder%\services\ASC.UrlShortener\service" /s /y /b /i @@ -52,3 +42,10 @@ xcopy "%PathToRepository%\common\ASC.Socket.IO" "%PathToAppFolder%\services\ASC. mkdir "%PathToAppFolder%\services\ASC.SsoAuth\service" xcopy "%PathToRepository%\common\ASC.SsoAuth" "%PathToAppFolder%\services\ASC.SsoAuth\service" /s /y /b /i + +rem backend services (Nodejs) in directory 'products' +mkdir "%PathToAppFolder%\products\ASC.Login\login" +xcopy "%PathToRepository%\build\deploy\login" "%PathToAppFolder%\products\ASC.Login\login" /s /y /b /i + +mkdir "%PathToAppFolder%\products\ASC.Files\editor" +xcopy "%PathToRepository%\build\deploy\editor" "%PathToAppFolder%\products\ASC.Files\editor" /s /y /b /i diff --git a/build/install/win/tools/DocEditor.xml b/build/install/win/tools/DocEditor.xml new file mode 100644 index 0000000000..c6d4b9665f --- /dev/null +++ b/build/install/win/tools/DocEditor.xml @@ -0,0 +1,14 @@ + + ASC.DocEditor + ASC.DocEditor + This service runs ASC.DocEditor + RealTime + Automatic + + node + "{APPDIR}products\ASC.Files\editor\server.js" + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/Login.xml b/build/install/win/tools/Login.xml new file mode 100644 index 0000000000..d1dedd1284 --- /dev/null +++ b/build/install/win/tools/Login.xml @@ -0,0 +1,14 @@ + + ASC.Login + ASC.Login + This service runs ASC.Login + RealTime + Automatic + + node + "{APPDIR}products\ASC.Login\login\server.js" + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/Socket.IO.xml b/build/install/win/tools/Socket.IO.xml new file mode 100644 index 0000000000..bc17e822f9 --- /dev/null +++ b/build/install/win/tools/Socket.IO.xml @@ -0,0 +1,14 @@ + + ASC.Socket.IO + ASC.Socket.IO + This service runs ASC.Socket.IO + RealTime + Automatic + + node + "{APPDIR}services\ASC.Socket.IO\service\server.js" + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/SsoAuth.xml b/build/install/win/tools/SsoAuth.xml new file mode 100644 index 0000000000..0b724a9a34 --- /dev/null +++ b/build/install/win/tools/SsoAuth.xml @@ -0,0 +1,14 @@ + + ASC.SsoAuth + ASC.SsoAuth + This service runs ASC.SsoAuth + RealTime + Automatic + + node + "{APPDIR}services\ASC.SsoAuth\service\app.js" + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/UrlShortener.xml b/build/install/win/tools/UrlShortener.xml new file mode 100644 index 0000000000..d30234fabb --- /dev/null +++ b/build/install/win/tools/UrlShortener.xml @@ -0,0 +1,14 @@ + + ASC.UrlShortener + ASC.UrlShortener + This service runs ASC.UrlShortener + RealTime + Automatic + + node + "{APPDIR}services\ASC.UrlShortener\service\index.js" + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/kafka.xml b/build/install/win/tools/kafka.xml deleted file mode 100644 index 5667b177a4..0000000000 --- a/build/install/win/tools/kafka.xml +++ /dev/null @@ -1,15 +0,0 @@ - - kafka - kafka - This service runs kafka - RealTime - Automatic - - {WindowsVolume}Apache\kafka\bin\windows\kafka-server-start.bat - {WindowsVolume}Apache\kafka\config\server.properties - {WindowsVolume}Apache\kafka - - 10240 - 8 - - \ No newline at end of file diff --git a/build/install/win/tools/zookeeper.xml b/build/install/win/tools/zookeeper.xml deleted file mode 100644 index 9a8d0a8f3d..0000000000 --- a/build/install/win/tools/zookeeper.xml +++ /dev/null @@ -1,15 +0,0 @@ - - zookeeper - zookeeper - This service runs zookeeper - RealTime - Automatic - - {WindowsVolume}Apache\kafka\bin\windows\zookeeper-server-start.bat - {WindowsVolume}Apache\kafka\config\zookeeper.properties - {WindowsVolume}Apache\kafka - - 10240 - 8 - - \ No newline at end of file From 39406f436b5d1e7fe046884949aca016adf60e47 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Wed, 28 Sep 2022 22:47:20 +0300 Subject: [PATCH 26/57] Web: Refactoring, removed api request at component with input. --- .../components/FolderTreeBody/TreeFolders.js | 2 +- .../panels/SelectFileDialog/index.js | 3 - .../panels/SelectFolderDialog/index.js | 133 +++++----- .../panels/SelectFolderInput/index.js | 234 +++++++----------- .../panels/SelectionPanel/FilesListWrapper.js | 8 +- .../SelectionPanel/SelectionPanelBody.js | 64 +---- .../backup/auto-backup/index.js | 198 ++++++++------- .../sub-components/ButtonContainer.js | 18 +- .../auto-backup/sub-components/RoomsModule.js | 1 - .../sub-components/ThirdPartyModule.js | 12 +- .../DirectThirdPartyConnection.js | 4 - .../sub-components/ThirdPartyModule.js | 2 +- packages/client/src/store/BackupStore.js | 10 - .../src/store/SelectFolderDialogStore.js | 64 +++-- 14 files changed, 305 insertions(+), 448 deletions(-) diff --git a/packages/client/src/components/FolderTreeBody/TreeFolders.js b/packages/client/src/components/FolderTreeBody/TreeFolders.js index f9d0bdb882..e363ef9d12 100644 --- a/packages/client/src/components/FolderTreeBody/TreeFolders.js +++ b/packages/client/src/components/FolderTreeBody/TreeFolders.js @@ -223,7 +223,7 @@ class TreeFolders extends React.Component { let isDisabledNode = false; if (item.id == roomsFolderId) { - isDisabledNode = expandedPanelKeys.includes(roomsFolderId + ""); + isDisabledNode = expandedPanelKeys?.includes(roomsFolderId + ""); } if (this.selectionFoldersId && this.selectionFoldersId.includes(item.id)) diff --git a/packages/client/src/components/panels/SelectFileDialog/index.js b/packages/client/src/components/panels/SelectFileDialog/index.js index 2f4cf81c04..87021164c0 100644 --- a/packages/client/src/components/panels/SelectFileDialog/index.js +++ b/packages/client/src/components/panels/SelectFileDialog/index.js @@ -112,10 +112,7 @@ class SelectFileDialog extends React.Component { treeFolders, foldersType, folderId, - onSetBaseFolderPath, - onSelectFolder, foldersList, - withoutBasicSelection, hasSharedFolder ); } catch (e) { diff --git a/packages/client/src/components/panels/SelectFolderDialog/index.js b/packages/client/src/components/panels/SelectFolderDialog/index.js index f302a5c592..3a33db3ec0 100644 --- a/packages/client/src/components/panels/SelectFolderDialog/index.js +++ b/packages/client/src/components/panels/SelectFolderDialog/index.js @@ -7,10 +7,11 @@ import SelectFolderDialogAsideView from "./AsideView"; import utils from "@docspace/components/utils"; import toastr from "@docspace/components/toast/toastr"; import SelectionPanel from "../SelectionPanel/SelectionPanelBody"; -import { FilterType } from "@docspace/common/constants"; +import { FilterType, FolderType } from "@docspace/common/constants"; const { desktop } = utils.device; +let treeFolders = []; class SelectFolderDialog extends React.Component { constructor(props) { super(props); @@ -35,26 +36,30 @@ class SelectFolderDialog extends React.Component { displayType, isNeedArrowIcon = false, folderTree, - setFolderId, - withInput, + setResultingFolderId, + selectFolderInputExist, id, storeFolderId, - withoutBasicSelection = false, - roomsFolderId, + withoutBasicSelection, + setResultingFoldersTree, } = this.props; !displayType && window.addEventListener("resize", this.throttledResize); - const initialFolderId = withInput ? id : storeFolderId; + const initialFolderId = selectFolderInputExist ? id : storeFolderId; let resultingFolderTree, resultingId; - const treeFolders = await this.props.fetchTreeFolders(); - const roomsFolder = treeFolders.find((f) => f.id == roomsFolderId); + treeFolders = await this.props.fetchTreeFolders(); + + const roomsFolder = treeFolders.find( + (f) => f.rootFolderType == FolderType.Rooms + ); + const hasSharedFolder = roomsFolder && roomsFolder.foldersCount ? true : false; - if (!withInput && !isNeedArrowIcon) { + if (!isNeedArrowIcon) { try { [ resultingFolderTree, @@ -63,10 +68,7 @@ class SelectFolderDialog extends React.Component { treeFolders, foldersType, initialFolderId, - onSetBaseFolderPath, - onSelectFolder, foldersList, - false, hasSharedFolder ); } catch (e) { @@ -76,46 +78,28 @@ class SelectFolderDialog extends React.Component { } } - const tree = - isNeedArrowIcon || withInput ? folderTree : resultingFolderTree; + const tree = isNeedArrowIcon ? folderTree : resultingFolderTree; + setResultingFoldersTree(tree); - if (tree.length === 0) { - this.setState({ isAvailable: false }); - onSelectFolder(null); - return; + const resId = isNeedArrowIcon ? id : resultingId; + + if (!withoutBasicSelection) { + onSelectFolder && onSelectFolder(resId); + onSetBaseFolderPath && onSetBaseFolderPath(resId); } - const resId = isNeedArrowIcon || withInput ? id : resultingId; - !withoutBasicSelection && onSelectFolder && onSelectFolder(resId); - //isNeedArrowIcon && onSetBaseFolderPath(resId); - - setFolderId(resId); - - this.setState({ - resultingFolderTree: tree, - }); - } - - componentDidUpdate(prevProps) { - const { isReset } = this.props; - - if (isReset && isReset !== prevProps.isReset) { - this.onResetInfo(); - } + setResultingFolderId(resId); } componentWillUnmount() { - const { setFolderTitle, setProviderKey, setFolderId } = this.props; - //console.log("componentWillUnmount"); + const { toDefault } = this.props; if (this.throttledResize) { this.throttledResize && this.throttledResize.cancel(); window.removeEventListener("resize", this.throttledResize); } - setFolderTitle(""); - setProviderKey(null); - setFolderId(null); + toDefault(); } getDisplayType = () => { const displayType = @@ -131,23 +115,23 @@ class SelectFolderDialog extends React.Component { }; onSelect = async (folder, treeNode) => { - const { setFolderId, folderId } = this.props; + const { setResultingFolderId, resultingFolderId } = this.props; - if (+folderId === +folder[0]) return; + if (+resultingFolderId === +folder[0]) return; - setFolderId(folder[0]); + setResultingFolderId(folder[0]); }; onClose = () => { const { setExpandedPanelKeys, onClose, - treeFolders, - withInput, + + selectFolderInputExist, isNeedArrowIcon, } = this.props; - if (!treeFolders.length && !withInput && !isNeedArrowIcon) { + if (!treeFolders.length && !selectFolderInputExist && !isNeedArrowIcon) { setExpandedPanelKeys(null); } onClose && onClose(); @@ -168,25 +152,20 @@ class SelectFolderDialog extends React.Component { providerKey, folderTitle, - folderId, + resultingFolderId, setSelectedItems, } = this.props; setSelectedItems(); - onSubmit && onSubmit(folderId, folderTitle, providerKey); - onSave && onSave(e, folderId); - onSetNewFolderPath && onSetNewFolderPath(folderId); - onSelectFolder && onSelectFolder(folderId); - + onSubmit && onSubmit(resultingFolderId, folderTitle, providerKey); + onSave && onSave(e, resultingFolderId); + onSetNewFolderPath && onSetNewFolderPath(resultingFolderId); + onSelectFolder && onSelectFolder(resultingFolderId); + //setResultingFolderId(resultingFolderId); !withoutImmediatelyClose && this.onClose(); }; - onResetInfo = async () => { - const { id, setFolderId } = this.props; - setFolderId(id); - }; - render() { const { t, @@ -200,7 +179,7 @@ class SelectFolderDialog extends React.Component { footer, buttonName, isDisableTree, - folderId, + resultingFolderId, folderTitle, expandedKeys, isDisableButton, @@ -208,13 +187,9 @@ class SelectFolderDialog extends React.Component { currentFolderId, selectionFiles, sharedRoomId, - } = this.props; - const { - displayType, - isLoadingData, - isAvailable, resultingFolderTree, - } = this.state; + } = this.props; + const { displayType, isLoadingData, isAvailable } = this.state; const primaryButtonName = buttonName ? buttonName @@ -224,10 +199,12 @@ class SelectFolderDialog extends React.Component { // console.log("Render Folder Component?", this.state); const folderSelectionDisabled = - folderId === sharedRoomId || folderId === sharedRoomId?.toString(); + resultingFolderId === sharedRoomId || + resultingFolderId === sharedRoomId?.toString(); const buttonIsDisabled = - isDisableButton || (isRecycleBin && currentFolderId === folderId); + isDisableButton || + (isRecycleBin && currentFolderId === resultingFolderId); return displayType === "aside" ? ( { const { - treeFolders, setExpandedPanelKeys, sharedRoomId, fetchTreeFolders, - roomsFolderId, } = treeFoldersStore; const { filter } = filesStore; @@ -336,12 +311,16 @@ export default inject( const { id } = selectedFolderStore; const { - setFolderId, + setResultingFolderId, setFolderTitle, setProviderKey, providerKey, folderTitle, - folderId, + resultingFolderId, + setIsLoading, + resultingFolderTree, + setResultingFoldersTree, + toDefault, } = selectFolderDialogStore; const { settingsStore } = auth; @@ -353,17 +332,19 @@ export default inject( storeFolderId: selectedFolderId, providerKey, folderTitle, - folderId, + resultingFolderId, setExpandedPanelKeys, - setFolderId, + setResultingFolderId, setFolderTitle, setProviderKey, - treeFolders, filter, setSelectedItems, sharedRoomId, fetchTreeFolders, - roomsFolderId, + setIsLoading, + resultingFolderTree, + toDefault, + setResultingFoldersTree, }; } )( diff --git a/packages/client/src/components/panels/SelectFolderInput/index.js b/packages/client/src/components/panels/SelectFolderInput/index.js index 64859fbefd..bd8a052e89 100644 --- a/packages/client/src/components/panels/SelectFolderInput/index.js +++ b/packages/client/src/components/panels/SelectFolderInput/index.js @@ -12,111 +12,25 @@ import { FolderType } from "@docspace/common/constants"; class SelectFolderInput extends React.PureComponent { constructor(props) { super(props); - const { id, foldersType, withoutBasicSelection } = this.props; + const { id, withoutBasicSelection, setIsLoading } = this.props; - const isNeedLoader = - !!id || !withoutBasicSelection || foldersType === "common"; - - this.state = { - isLoading: isNeedLoader, - baseFolderPath: "", - newFolderPath: "", - resultingFolderTree: [], - baseId: "", - }; + const isNeedLoadPath = !!id || !withoutBasicSelection; + setIsLoading(isNeedLoadPath); this._isMount = false; } - setBaseInfo = async () => { - const { - foldersType, - id, - onSelectFolder, - foldersList, - withoutBasicSelection, - } = this.props; - - let resultingFolderTree, resultingId; - - try { - [ - resultingFolderTree, - resultingId, - ] = await SelectionPanel.getBasicFolderInfo( - null, - foldersType, - id, - this.onSetBaseFolderPath, - onSelectFolder, - foldersList, - withoutBasicSelection - ); - } catch (e) { - toastr.error(e); - this._isMount && - this.setState({ - isLoading: false, - }); - return; - } - - this._isMount && - this.setState({ - isPathError: false, - resultingFolderTree, - baseId: resultingId, - baseFolderPath: "", - newFolderPath: "", - ...(withoutBasicSelection && { isLoading: false }), - }); - }; - componentDidMount() { this._isMount = true; - const { setFirstLoad, isWaitingUpdate } = this.props; + const { setFirstLoad } = this.props; setFirstLoad(false); - !isWaitingUpdate && this.setBaseInfo(); - } - - componentDidUpdate(prevProps) { - const { - isSuccessSave, - isReset, - id, - - isWaitingUpdate, - } = this.props; - const { newFolderPath, baseFolderPath } = this.state; - - if (!isSuccessSave && isSuccessSave !== prevProps.isSuccessSave) { - newFolderPath && - this.setState({ - baseFolderPath: newFolderPath, - baseId: id, - newId: null, - isPathError: false, - }); - } - - if (!isReset && isReset !== prevProps.isReset) { - this.setState({ - newFolderPath: baseFolderPath, - baseId: id, - newId: null, - isPathError: false, - }); - } - - if (!isWaitingUpdate && isWaitingUpdate !== prevProps.isWaitingUpdate) { - this.setBaseInfo(); - } } componentWillUnmount() { this._isMount = false; + this.props.toDefault(); } setFolderPath = async (folderId) => { const foldersArray = await getFolderPath(folderId); @@ -143,48 +57,53 @@ class SelectFolderInput extends React.PureComponent { return convertFoldersArray; }; onSetNewFolderPath = async (folderId) => { + const { setIsLoading, setNewFolderPath, setIsPathError } = this.props; let timerId = setTimeout(() => { - this._isMount && this.setState({ isLoading: true }); + setIsLoading(true); }, 500); - try { - const convertFoldersArray = await this.setFolderPath(folderId); - clearTimeout(timerId); - timerId = null; - this._isMount && - this.setState({ - newFolderPath: convertFoldersArray, - isLoading: false, - newId: folderId, - isPathError: false, - }); - } catch (e) { - toastr.error(e); - clearTimeout(timerId); - timerId = null; - this._isMount && - this.setState({ - isLoading: false, - isPathError: true, - }); - } - }; - onSetBaseFolderPath = async (folderId) => { + try { const convertFoldersArray = await this.setFolderPath(folderId); - this._isMount && - this.setState({ - baseFolderPath: convertFoldersArray, - isLoading: false, - ...(!convertFoldersArray && { isPathError: true }), - }); + setNewFolderPath(convertFoldersArray); + + clearTimeout(timerId); + timerId = null; + setIsPathError(false); + setIsLoading(false); } catch (e) { toastr.error(e); - this._isMount && - this.setState({ - isLoading: false, - isPathError: true, - }); + clearTimeout(timerId); + setIsLoading(false); + timerId = null; + setIsPathError(true); + } + }; + onSetBaseFolderPath = async (folderId) => { + const { + setIsLoading, + setBaseFolderPath, + setIsPathError, + setResultingFolderId, + resultingFolderTree, + } = this.props; + + try { + const convertFoldersArray = await this.setFolderPath(folderId); + setBaseFolderPath(convertFoldersArray); + setIsLoading(false); + if (!convertFoldersArray) { + setIsPathError(true); + console.log("resultingFolderTree", resultingFolderTree); + this.onSetFolderInfo(resultingFolderTree[0].id); + setResultingFolderId(resultingFolderTree[0].id); + } + } catch (e) { + toastr.error(e); + setIsLoading(false); + setIsPathError(true); + this.onSetFolderInfo(resultingFolderTree[0].id); + setResultingFolderId(resultingFolderTree[0].id); } }; onSelectFolder = (folderId) => { @@ -195,25 +114,19 @@ class SelectFolderInput extends React.PureComponent { }; onSetFolderInfo = (folderId) => { const { setExpandedPanelKeys, setParentId } = this.props; + getFolder(folderId) .then((data) => { const pathParts = data.pathParts.map((item) => item.toString()); pathParts?.pop(); + setExpandedPanelKeys(pathParts); setParentId(data.current.parentId); }) .catch((e) => toastr.error(e)); }; + render() { - const { - isLoading, - baseFolderPath, - newFolderPath, - baseId, - resultingFolderTree, - newId, - isPathError, - } = this.state; const { onClickInput, isError, @@ -222,14 +135,19 @@ class SelectFolderInput extends React.PureComponent { maxInputWidth, isDisabled, isPanelVisible, - id, + theme, isFolderTreeLoading = false, onSelectFolder, + isLoading, + newFolderPath, + baseFolderPath, + isPathError, + isWaitingUpdate, ...rest } = this.props; - const passedId = newId ? newId : baseId; + const isReady = !isFolderTreeLoading && !isWaitingUpdate; return ( @@ -240,19 +158,12 @@ class SelectFolderInput extends React.PureComponent { isError={isError || isPathError} onClickInput={onClickInput} placeholder={placeholder} - isDisabled={ - isFolderTreeLoading || - isDisabled || - isLoading || - resultingFolderTree?.length === 0 - } + isDisabled={isFolderTreeLoading || isDisabled || isLoading} /> - {!isFolderTreeLoading && isPanelVisible && ( + {isReady && ( { const { setFirstLoad } = filesStore; const { setExpandedPanelKeys } = treeFoldersStore; - const { setFolderId } = selectFolderDialogStore; + const { + isLoading, + setIsLoading, + baseFolderPath, + setBaseFolderPath, + newFolderPath, + setNewFolderPath, + toDefault, + setIsPathError, + isPathError, + resultingFolderTree, + setResultingFolderId, + } = selectFolderDialogStore; const { setParentId } = selectedFolderStore; + return { setFirstLoad, - - setFolderId, setExpandedPanelKeys, setParentId, + isLoading, + setIsLoading, + setBaseFolderPath, + baseFolderPath, + newFolderPath, + setNewFolderPath, + toDefault, + setIsPathError, + isPathError, + resultingFolderTree, + setResultingFolderId, }; } )(observer(withTranslation("Translations")(SelectFolderInput))); diff --git a/packages/client/src/components/panels/SelectionPanel/FilesListWrapper.js b/packages/client/src/components/panels/SelectionPanel/FilesListWrapper.js index 2833659676..1da2726e26 100644 --- a/packages/client/src/components/panels/SelectionPanel/FilesListWrapper.js +++ b/packages/client/src/components/panels/SelectionPanel/FilesListWrapper.js @@ -55,7 +55,7 @@ class FilesListWrapper extends React.Component { folderId, setFolderTitle, setProviderKey, - setFolderId, + setResultingFolderId, folderSelection, } = this.props; @@ -89,7 +89,7 @@ class FilesListWrapper extends React.Component { if (page === 0 && folderSelection) { setFolderTitle(data.current.title); setProviderKey(data.current.providerKey); - setFolderId(folderId); + setResultingFolderId(folderId); } const finalData = [...data.files]; @@ -144,7 +144,7 @@ export default inject( ({ selectedFolderStore, selectFolderDialogStore, auth }) => { const { id } = selectedFolderStore; const { - setFolderId, + setResultingFolderId, setFolderTitle, setProviderKey, } = selectFolderDialogStore; @@ -155,7 +155,7 @@ export default inject( return { theme: theme, storeFolderId: id, - setFolderId, + setResultingFolderId, setFolderTitle, setProviderKey, }; diff --git a/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js b/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js index 47f04cb9a9..8a0ba34868 100644 --- a/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js +++ b/packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js @@ -176,47 +176,9 @@ class SelectionPanel extends React.Component { treeFolders, foldersType, id, - onSetBaseFolderPath, - onSelectFolder, - foldersList, - withoutBasicSelection = false, + foldersList = [], hasSharedFolder ) => { - const getRequestFolderTree = () => { - switch (foldersType) { - case "exceptSortedByTags": - case "exceptPrivacyTrashFolders": - try { - return getFoldersTree(); - } catch (err) { - console.error(err); - } - break; - case "common": - try { - return getCommonFoldersTree(); - } catch (err) { - console.error(err); - } - break; - - case "third-party": - try { - return getThirdPartyCommonFolderTree(); - } catch (err) { - console.error(err); - } - break; - - default: - try { - return getFoldersTree(); - } catch (err) { - console.error(err); - } - } - }; - const filterFoldersTree = (folders, arrayOfExceptions) => { const arr = !hasSharedFolder ? [...arrayOfExceptions, FolderType.Rooms] @@ -242,32 +204,12 @@ class SelectionPanel extends React.Component { } }; - let requestedTreeFolders, filteredTreeFolders; + let filteredTreeFolders; - const treeFoldersLength = treeFolders?.length; - - if (treeFoldersLength === 0 || !treeFoldersLength) { - try { - requestedTreeFolders = foldersList - ? foldersList - : await getRequestFolderTree(); - } catch (e) { - toastr.error(e); - return; - } - } - - const foldersTree = - treeFoldersLength > 0 ? treeFolders : requestedTreeFolders; + const foldersTree = foldersList.length > 0 ? foldersList : treeFolders; const passedId = id ? id : foldersTree[0]?.id; - !withoutBasicSelection && - onSetBaseFolderPath && - onSetBaseFolderPath(passedId); - - !withoutBasicSelection && onSelectFolder && onSelectFolder(passedId); - if ( foldersType === "exceptSortedByTags" || foldersType === "exceptPrivacyTrashFolders" diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/index.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/index.js index 1f3cd5816e..3da8ea528b 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/index.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/index.js @@ -115,7 +115,7 @@ class AutomaticBackup extends React.PureComponent { this.setState({ isEmptyContentBeforeLoader: false, isInitialLoading: false, - isEnableAuto: enableAuto, + isEnableAuto: true, }); } catch (error) { toastr.error(error); @@ -213,12 +213,14 @@ class AutomaticBackup extends React.PureComponent { toDefault, isCheckedThirdParty, isCheckedDocuments, - setResetProcess, + resetNewFolderPath, + + defaultFolderId, } = this.props; - + console.log("defaultFolderId", defaultFolderId); toDefault(); - - (isCheckedThirdParty || isCheckedDocuments) && setResetProcess(true); + (isCheckedThirdParty || isCheckedDocuments) && + resetNewFolderPath(defaultFolderId); this.setState({ ...(isError && { isError: false }), }); @@ -232,7 +234,7 @@ class AutomaticBackup extends React.PureComponent { selectedFolderId, isFormReady, } = this.props; - + console.log("selectedFolderId", selectedFolderId); if ( (isCheckedDocuments && !selectedFolderId) || (isCheckedThirdParty && !selectedFolderId) @@ -326,11 +328,11 @@ class AutomaticBackup extends React.PureComponent { isCheckedThirdParty, isCheckedDocuments, - setSavingProcess, + updateBaseFolderPath, } = this.props; try { - (isCheckedThirdParty || isCheckedDocuments) && setSavingProcess(true); + (isCheckedThirdParty || isCheckedDocuments) && updateBaseFolderPath(); await createBackupSchedule( storageType, @@ -354,7 +356,7 @@ class AutomaticBackup extends React.PureComponent { } catch (e) { toastr.error(e); - (isCheckedThirdParty || isCheckedDocuments) && setSavingProcess(true); + (isCheckedThirdParty || isCheckedDocuments) && updateBaseFolderPath(); this.setState({ isLoadingData: false, @@ -498,12 +500,7 @@ class AutomaticBackup extends React.PureComponent { {t("ThirdPartyResourceDescription")} {isCheckedThirdParty && ( - + )} @@ -545,91 +542,100 @@ class AutomaticBackup extends React.PureComponent { ); } } -export default inject(({ auth, backup, treeFoldersStore }) => { - const { language, settingsStore } = auth; - const { organizationName, theme } = settingsStore; - const { - downloadingProgress, - backupSchedule, - //commonThirdPartyList, - clearProgressInterval, - deleteSchedule, - getProgress, - setThirdPartyStorage, - setDefaultOptions, - setBackupSchedule, - selectedStorageType, - seStorageType, - //setCommonThirdPartyList, - selectedPeriodLabel, - selectedWeekdayLabel, - selectedWeekday, - selectedHour, - selectedMonthDay, - selectedMaxCopiesNumber, - selectedPeriodNumber, - selectedFolderId, - selectedStorageId, - toDefault, - isFormReady, - getStorageParams, - setSelectedEnableSchedule, - selectedEnableSchedule, - updatePathSettings, - setSavingProcess, - setResetProcess, - setStorageRegions, - } = backup; +export default inject( + ({ auth, backup, treeFoldersStore, selectFolderDialogStore }) => { + const { language, settingsStore } = auth; + const { organizationName, theme } = settingsStore; + const { + downloadingProgress, + backupSchedule, + //commonThirdPartyList, + clearProgressInterval, + deleteSchedule, + getProgress, + setThirdPartyStorage, + setDefaultOptions, + setBackupSchedule, + selectedStorageType, + seStorageType, + //setCommonThirdPartyList, + selectedPeriodLabel, + selectedWeekdayLabel, + selectedWeekday, + selectedHour, + selectedMonthDay, + selectedMaxCopiesNumber, + selectedPeriodNumber, + selectedFolderId, + selectedStorageId, + toDefault, + isFormReady, + getStorageParams, + setSelectedEnableSchedule, + selectedEnableSchedule, + updatePathSettings, - const isCheckedDocuments = selectedStorageType === `${DocumentModuleType}`; - const isCheckedThirdParty = selectedStorageType === `${ResourcesModuleType}`; - const isCheckedThirdPartyStorage = - selectedStorageType === `${StorageModuleType}`; + setStorageRegions, + defaultFolderId, + } = backup; - const { rootFoldersTitles, fetchTreeFolders } = treeFoldersStore; - return { - fetchTreeFolders, - rootFoldersTitles, - downloadingProgress, - theme, - language, - isFormReady, - organizationName, - backupSchedule, - //commonThirdPartyList, - clearProgressInterval, - deleteSchedule, - getProgress, - setThirdPartyStorage, - setDefaultOptions, - setBackupSchedule, - selectedStorageType, - seStorageType, - //setCommonThirdPartyList, - selectedPeriodLabel, - selectedWeekdayLabel, - selectedWeekday, - selectedHour, - selectedMonthDay, - selectedMaxCopiesNumber, - selectedPeriodNumber, - selectedFolderId, - selectedStorageId, + const { + updateBaseFolderPath, + resetNewFolderPath, + } = selectFolderDialogStore; - toDefault, + const isCheckedDocuments = selectedStorageType === `${DocumentModuleType}`; + const isCheckedThirdParty = + selectedStorageType === `${ResourcesModuleType}`; + const isCheckedThirdPartyStorage = + selectedStorageType === `${StorageModuleType}`; - isCheckedThirdPartyStorage, - isCheckedThirdParty, - isCheckedDocuments, + const { rootFoldersTitles, fetchTreeFolders } = treeFoldersStore; + return { + defaultFolderId, + fetchTreeFolders, + rootFoldersTitles, + downloadingProgress, + theme, + language, + isFormReady, + organizationName, + backupSchedule, + //commonThirdPartyList, + clearProgressInterval, + deleteSchedule, + getProgress, + setThirdPartyStorage, + setDefaultOptions, + setBackupSchedule, + selectedStorageType, + seStorageType, + //setCommonThirdPartyList, + selectedPeriodLabel, + selectedWeekdayLabel, + selectedWeekday, + selectedHour, + selectedMonthDay, + selectedMaxCopiesNumber, + selectedPeriodNumber, + selectedFolderId, + selectedStorageId, - getStorageParams, + toDefault, - setSelectedEnableSchedule, - selectedEnableSchedule, + isCheckedThirdPartyStorage, + isCheckedThirdParty, + isCheckedDocuments, - updatePathSettings, - setSavingProcess, - setResetProcess, - setStorageRegions, - }; -})(withTranslation(["Settings", "Common"])(observer(AutomaticBackup))); + getStorageParams, + + setSelectedEnableSchedule, + selectedEnableSchedule, + + updatePathSettings, + resetNewFolderPath, + setStorageRegions, + updateBaseFolderPath, + }; + } +)(withTranslation(["Settings", "Common"])(observer(AutomaticBackup))); diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ButtonContainer.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ButtonContainer.js index a28fe46129..aa392982cc 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ButtonContainer.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ButtonContainer.js @@ -9,18 +9,11 @@ const ButtonContainer = ({ onCancelModuleSettings, isChanged, isThirdStorageChanged, - setSavingProcess, t, - setResetProcess, }) => { const prevChange = useRef(); - useEffect(() => { - if (!isChanged && isChanged !== prevChange.current) { - setSavingProcess(false); - setResetProcess(false); - } - }, [isChanged]); + useEffect(() => { prevChange.current = isChanged; @@ -50,17 +43,10 @@ const ButtonContainer = ({ }; export default inject(({ backup }) => { - const { - isChanged, - isThirdStorageChanged, - setSavingProcess, - setResetProcess, - } = backup; + const { isChanged, isThirdStorageChanged } = backup; return { isChanged, isThirdStorageChanged, - setSavingProcess, - setResetProcess, }; })(observer(ButtonContainer)); diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/RoomsModule.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/RoomsModule.js index 495a520a8b..4a0c0d9d1b 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/RoomsModule.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/RoomsModule.js @@ -55,7 +55,6 @@ class RoomsModule extends React.PureComponent { isDisabled={isLoadingData} id={passedId} isReset={isResetProcess} - isSuccessSave={isSavingProcess} withoutBasicSelection={isDocumentsDefault ? false : true} /> diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ThirdPartyModule.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ThirdPartyModule.js index 455dec81d6..960ec619cc 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ThirdPartyModule.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/auto-backup/sub-components/ThirdPartyModule.js @@ -55,12 +55,10 @@ class ThirdPartyModule extends React.PureComponent { isError, isLoadingData, isReset, - isSuccessSave, + passedId, //commonThirdPartyList, isResourcesDefault, - isResetProcess, - isSavingProcess, t, ...rest } = this.props; @@ -79,7 +77,7 @@ class ThirdPartyModule extends React.PureComponent { isDisabled={commonThirdPartyList.length === 0 || isLoadingData} id={passedId} isReset={isResetProcess} - isSuccessSave={isSavingProcess} + foldersList={commonThirdPartyList} withoutBasicSelection={isResourcesDefault ? false : true} /> @@ -98,8 +96,6 @@ class ThirdPartyModule extends React.PureComponent { isPanelVisible={isPanelVisible} withoutBasicSelection={isResourcesDefault ? false : true} isError={isError} - isReset={isResetProcess} - isSuccessSave={isSavingProcess} id={passedId} /> @@ -115,8 +111,6 @@ export default inject(({ backup }) => { defaultStorageType, commonThirdPartyList, defaultFolderId, - isResetProcess, - isSavingProcess, } = backup; const isResourcesDefault = @@ -124,8 +118,6 @@ export default inject(({ backup }) => { const passedId = isResourcesDefault ? defaultFolderId : ""; return { - isResetProcess, - isSavingProcess, setSelectedFolder, passedId, commonThirdPartyList, diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/common-container/DirectThirdPartyConnection.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/common-container/DirectThirdPartyConnection.js index e419c613aa..d0b2264c36 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/common-container/DirectThirdPartyConnection.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/common-container/DirectThirdPartyConnection.js @@ -33,8 +33,6 @@ const DirectThirdPartyConnection = (props) => { isPanelVisible, isError, id, - isReset, - isSuccessSave, withoutBasicSelection, onSelectFile, isFileSelection = false, @@ -372,8 +370,6 @@ const DirectThirdPartyConnection = (props) => { isError={isError} foldersList={[folderList]} withoutBasicSelection={withoutBasicSelection} - isReset={isReset} - isSuccessSave={isSuccessSave} isWaitingUpdate={isInitialLoading || isUpdatingInfo ? true : false} /> )} diff --git a/packages/client/src/pages/PortalSettings/categories/data-management/backup/manual-backup/sub-components/ThirdPartyModule.js b/packages/client/src/pages/PortalSettings/categories/data-management/backup/manual-backup/sub-components/ThirdPartyModule.js index 9d7fd8ef5e..d4e6fc56e5 100644 --- a/packages/client/src/pages/PortalSettings/categories/data-management/backup/manual-backup/sub-components/ThirdPartyModule.js +++ b/packages/client/src/pages/PortalSettings/categories/data-management/backup/manual-backup/sub-components/ThirdPartyModule.js @@ -176,7 +176,7 @@ class ThirdPartyModule extends React.Component { label={t("Common:Duplicate")} onClick={this.onMakeCopy} primary - isDisabled={isModuleDisabled || selectedFolder?.trim() === ""} + isDisabled={isModuleDisabled || selectedFolder === ""} size={buttonSize} /> diff --git a/packages/client/src/store/BackupStore.js b/packages/client/src/store/BackupStore.js index 7101ed5004..62fd973616 100644 --- a/packages/client/src/store/BackupStore.js +++ b/packages/client/src/store/BackupStore.js @@ -62,9 +62,6 @@ class BackupStore { selectedEnableSchedule = false; defaultEnableSchedule = false; - isSavingProcess = false; - isResetProcess = false; - storageRegions = []; constructor() { @@ -574,13 +571,6 @@ class BackupStore { const isEnable = this.selectedEnableSchedule; this.selectedEnableSchedule = !isEnable; }; - setSavingProcess = (process) => { - if (process !== this.isSavingProcess) this.isSavingProcess = process; - }; - - setResetProcess = (process) => { - if (process !== this.isResetProcess) this.isResetProcess = process; - }; convertServiceName = (serviceName) => { //Docusign, OneDrive, Wordpress diff --git a/packages/client/src/store/SelectFolderDialogStore.js b/packages/client/src/store/SelectFolderDialogStore.js index cd8ef2c852..99e534dc52 100644 --- a/packages/client/src/store/SelectFolderDialogStore.js +++ b/packages/client/src/store/SelectFolderDialogStore.js @@ -1,27 +1,55 @@ -import { makeObservable, action, observable } from "mobx"; +import { makeAutoObservable, action, observable } from "mobx"; class SelectFolderDialogStore { - folderId = null; + resultingFolderId = null; fileInfo = null; folderTitle = ""; providerKey = null; baseFolderPath = ""; + newFolderPath = ""; + isPathError = false; + isLoading = false; + resultingFolderTree = []; constructor() { - makeObservable(this, { - fileInfo: observable, - folderId: observable, - folderTitle: observable, - providerKey: observable, - - setFolderId: action, - setProviderKey: action, - setFolderTitle: action, - }); + makeAutoObservable(this); } - setFolderId = (id) => { - this.folderId = id; + toDefault = () => { + this.resultingFolderId = null; + this.resultingFolderTree = []; + this.baseFolderPath = ""; + this.newFolderPath = ""; + this.folderTitle = ""; + this.isLoading = false; + this.isPathError = false; + this.setProviderKey(null); + }; + + updateBaseFolderPath = () => { + this.baseFolderPath = this.newFolderPath; + this.setIsPathError(false); + }; + + resetNewFolderPath = (id) => { + this.newFolderPath = this.baseFolderPath; + this.setIsPathError(false); + this.setResultingFolderId(id); + }; + + setBaseFolderPath = (baseFolderPath) => { + this.baseFolderPath = baseFolderPath; + }; + + setIsPathError = (isPathError) => { + this.isPathError = isPathError; + }; + + setNewFolderPath = (newFolderPath) => { + this.newFolderPath = newFolderPath; + }; + setResultingFolderId = (id) => { + this.resultingFolderId = id; }; setFolderTitle = (title) => { @@ -31,6 +59,14 @@ class SelectFolderDialogStore { setProviderKey = (providerKey) => { this.providerKey = providerKey; }; + + setIsLoading = (isLoading) => { + this.isLoading = isLoading; + }; + + setResultingFoldersTree = (tree) => { + this.resultingFolderTree = tree; + }; } export default new SelectFolderDialogStore(); From e5a33626f4d64eb28157020fb6bfb07f69578938 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Thu, 29 Sep 2022 10:15:27 +0300 Subject: [PATCH 27/57] Web: Refactoring, deleted useless code. --- .../panels/SelectFileDialog/AsideView.js | 2 +- .../panels/SelectFileDialog/ModalView.js | 280 ------------------ .../panels/SelectFileDialog/index.js | 8 +- .../panels/SelectFolderDialog/AsideView.js | 4 +- .../panels/SelectFolderDialog/index.js | 45 ++- .../sub-components/ThirdPartyModule.js | 21 -- .../DirectThirdPartyConnection.js | 4 +- .../sub-components/ThirdPartyModule.js | 36 --- 8 files changed, 39 insertions(+), 361 deletions(-) delete mode 100644 packages/client/src/components/panels/SelectFileDialog/ModalView.js diff --git a/packages/client/src/components/panels/SelectFileDialog/AsideView.js b/packages/client/src/components/panels/SelectFileDialog/AsideView.js index ee6237dc58..fc6daeac0f 100644 --- a/packages/client/src/components/panels/SelectFileDialog/AsideView.js +++ b/packages/client/src/components/panels/SelectFileDialog/AsideView.js @@ -70,7 +70,7 @@ const SelectFileDialogAsideView = ({ files={files} folderTree={resultingFolderTree} isFolderTreeLoading={!!!resultingFolderTree} - isNeedArrowIcon + withFileSelectDialog maxInputWidth={maxInputWidth ? maxInputWidth : "446px"} /> diff --git a/packages/client/src/components/panels/SelectFileDialog/ModalView.js b/packages/client/src/components/panels/SelectFileDialog/ModalView.js deleted file mode 100644 index e211695539..0000000000 --- a/packages/client/src/components/panels/SelectFileDialog/ModalView.js +++ /dev/null @@ -1,280 +0,0 @@ -import React from "react"; -import { StyledAsidePanel, StyledSelectFilePanel } from "../StyledPanels"; -import ModalDialog from "@docspace/components/modal-dialog"; -import SelectFolderDialog from "../SelectFolderDialog"; -import FolderTreeBody from "../../FolderTreeBody"; -import FilesListBody from "./FilesListBody"; -import Button from "@docspace/components/button"; -import Text from "@docspace/components/text"; -import { isArrayEqual } from "@docspace/components/utils/array"; -import { getFoldersTree } from "@docspace/common/api/files"; -import { - exceptSortedByTagsFolders, - exceptPrivacyTrashFolders, -} from "../SelectFolderDialog/ExceptionFoldersConstants"; - -class SelectFileDialogModalView extends React.Component { - constructor(props) { - super(props); - this.state = { - isLoading: true, - isAvailable: true, - }; - this.folderList = ""; - this.noTreeSwitcher = false; - } - - componentDidMount() { - const { onSetLoadingData } = this.props; - this.setState({ isLoadingData: true }, function () { - onSetLoadingData && onSetLoadingData(true); - - this.trySwitch(); - }); - } - trySwitch = async () => { - const { - foldersType, - onSelectFolder, - selectedFolder, - passedId, - foldersList, - } = this.props; - switch (foldersType) { - case "exceptSortedByTags": - try { - const foldersTree = await getFoldersTree(); - [ - this.folderList, - this.noTreeSwitcher, - ] = SelectFolderDialog.convertFolders( - foldersTree, - exceptSortedByTagsFolders - ); - this.onSetSelectedFolder(); - } catch (err) { - console.error(err); - } - - this.loadersCompletes(); - break; - case "exceptPrivacyTrashFolders": - try { - const foldersTree = await getFoldersTree(); - [ - this.folderList, - this.noTreeSwitcher, - ] = SelectFolderDialog.convertFolders( - foldersTree, - exceptPrivacyTrashFolders - ); - this.onSetSelectedFolder(); - } catch (err) { - console.error(err); - } - this.loadersCompletes(); - break; - case "common": - try { - this.folderList = await SelectFolderDialog.getCommonFolders(); - - !selectedFolder && - onSelectFolder && - onSelectFolder( - `${ - selectedFolder - ? selectedFolder - : passedId - ? passedId - : this.folderList[0].id - }` - ); - } catch (err) { - console.error(err); - } - - this.loadersCompletes(); - break; - case "third-party": - try { - this.folderList = foldersList - ? foldersList - : await SelectFolderDialog.getCommonThirdPartyList(); - this.folderList.length !== 0 - ? this.onSetSelectedFolder() - : this.setState({ isAvailable: false }); - } catch (err) { - console.error(err); - } - - this.loadersCompletes(); - break; - } - }; - - loadersCompletes = () => { - const { onSetLoadingData } = this.props; - onSetLoadingData && onSetLoadingData(false); - - this.setState({ - isLoading: false, - }); - }; - - onSetSelectedFolder = () => { - const { onSelectFolder, selectedFolder, passedId } = this.props; - - onSelectFolder && - onSelectFolder( - `${ - selectedFolder - ? selectedFolder - : passedId - ? passedId - : this.folderList[0].id - }` - ); - }; - onSelect = (folder) => { - const { onSelectFolder, selectedFolder } = this.props; - - if (isArrayEqual([folder[0]], [selectedFolder])) { - return; - } - - onSelectFolder && onSelectFolder(folder[0]); - }; - - onMouseEvent = (event) => { - event.stopPropagation(); - }; - render() { - const { - t, - isPanelVisible, - onClose, - zIndex, - withoutProvider, - expandedKeys, - filter, - onSelectFile, - filesList, - hasNextPage, - isNextPageLoading, - loadNextPage, - selectedFolder, - titleFilesList, - loadingText, - selectedFile, - onClickSave, - headerName, - primaryButtonName, - theme, - } = this.props; - - const { isLoading, isAvailable } = this.state; - - const isHeaderChildren = !!titleFilesList; - - return ( - - - - {headerName ? headerName : t("SelectFile")} - - - -
-
- -
-
- <> - {titleFilesList && ( - - {titleFilesList} - - )} - {selectedFolder && ( - - )} - -
-
-
-
- -