From 92899d14dfe47684747f851581e6aa88f97fbefc Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 17:04:49 +0300 Subject: [PATCH 01/14] Web: Client: add settings translate --- web/ASC.Web.Client/public/locales/en/Settings.json | 3 +++ web/ASC.Web.Client/public/locales/ru/Settings.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/web/ASC.Web.Client/public/locales/en/Settings.json b/web/ASC.Web.Client/public/locales/en/Settings.json index 536f3573c3..5e02f1025b 100644 --- a/web/ASC.Web.Client/public/locales/en/Settings.json +++ b/web/ASC.Web.Client/public/locales/en/Settings.json @@ -21,6 +21,9 @@ "AdministratorsAddedSuccessfully": "Administrators added successfully", "AdministratorsRemovedSuccessfully": "Administrators removed successfully", "Admins": "Admins", + "AdminsMessage": "Administrator Message Settings", + "AdminsMessageDescription": "Administrator Message Settings is a way to contact the portal administrator.", + "AdminsMessageHelper": "Enable this option to display the contact form on the Sign In page so that people could send the message to the portal administrator in case they have troubles accessing the portal.", "AllDomains": "Any domains", "Backup": "Backup", "BackupCreatedSuccess": "The backup copy has been successfully created.", diff --git a/web/ASC.Web.Client/public/locales/ru/Settings.json b/web/ASC.Web.Client/public/locales/ru/Settings.json index 045983d259..a78371c5c8 100644 --- a/web/ASC.Web.Client/public/locales/ru/Settings.json +++ b/web/ASC.Web.Client/public/locales/ru/Settings.json @@ -22,6 +22,9 @@ "AdministratorsAddedSuccessfully": "Администраторы успешно добавлены", "AdministratorsRemovedSuccessfully": "Администраторы успешно удалены", "Admins": "Администраторы", + "AdminsMessage": "Настройки сообщений администратору", + "AdminsMessageDescription": "Настройки сообщений администратору это способ связаться с администратором портала.", + "AdminsMessageHelper": "Включите эту опцию для отображения формы связи на странице Входа, чтобы пользователи могли отправить сообщение администратору портала в случае, если у них возникают проблемы со входом на портал.", "AllDomains": "Любые домены", "Backup": "Резервное копирование", "BackupCreatedSuccess": "Резервная копия успешно создана.", From 8efae2617d3f0bc93e692fe78c53221f7a50b2e7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 17:10:49 +0300 Subject: [PATCH 02/14] Web: Client: Settings: init admin message setting --- .../security/access-portal/adminMessage.js | 7 +++++++ .../categories/security/access-portal/index.js | 7 +++++++ .../categories/security/access-portal/mobileView.js | 6 ++++++ .../src/components/pages/Settings/index.js | 12 ++++++++++++ .../components/pages/Settings/utils/settingsTree.js | 6 ++++++ 5 files changed, 38 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js new file mode 100644 index 0000000000..42d893d9c8 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -0,0 +1,7 @@ +import React from "react"; + +const AdminMessage = () => { + return

Admin message

; +}; + +export default AdminMessage; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index 46a2ba2932..094173db4f 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -8,6 +8,7 @@ import TfaSection from "./tfa"; import PasswordStrengthSection from "./passwordStrength"; import TrustedMailSection from "./trustedMail"; import IpSecuritySection from "./ipSecurity"; +import AdminMessageSection from "./adminMessage"; import MobileView from "./mobileView"; import CategoryWrapper from "../sub-components/category-wrapper"; import { size } from "@appserver/components/utils/device"; @@ -56,6 +57,12 @@ const AccessPortal = (props) => { tooltipContent={t("IPSecurityDescription")} /> +
+ + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js index b58ba22217..c0b865410b 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js @@ -43,6 +43,12 @@ const MobileView = (props) => { url="/settings/security/access-portal/ip" onClickLink={onClickLink} /> + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/index.js b/web/ASC.Web.Client/src/components/pages/Settings/index.js index 393dd6a077..4b3aa6b1ba 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/index.js @@ -17,6 +17,9 @@ const TrustedMailPage = lazy(() => const IpSecurityPage = lazy(() => import("./categories/security/access-portal/ipSecurity") ); +const AdminMessagePage = lazy(() => + import("./categories/security/access-portal/adminMessage") +); const CommonSettings = lazy(() => import("./categories/common/index.js")); @@ -99,6 +102,10 @@ const IP_SECURITY_PAGE_URL = combineUrl( PROXY_BASE_URL, "/security/access-portal/ip" ); +const ADMIN_MESSAGE_PAGE_URL = combineUrl( + PROXY_BASE_URL, + "/security/access-portal/admin-message" +); const ADMINS_URL = combineUrl(PROXY_BASE_URL, "/security/access-rights/admins"); const THIRD_PARTY_URL = combineUrl( @@ -148,6 +155,11 @@ const Settings = () => { component={TrustedMailPage} /> + Date: Thu, 7 Apr 2022 04:02:34 +0300 Subject: [PATCH 03/14] Web: Common: SettingsStore: add setMessageSettings --- packages/asc-web-common/store/SettingsStore.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index 7086f6ef2f..732efdb206 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -475,6 +475,11 @@ class SettingsStore { console.log("setIpRestrictionsEnable", res); this.ipRestrictionEnabled = enable; }; + + setMessageSettings = async (turnOn) => { + await api.settings.setMessageSettings(turnOn); + this.enableAdmMess = turnOn; + }; } export default SettingsStore; From b07ebbce3bbda48f9b5884358c67f5620665962a Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 04:02:53 +0300 Subject: [PATCH 04/14] Web: Client: delete useless --- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 29569fc270..714be53421 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -231,10 +231,6 @@ class SettingsSetupStore { const res = await api.settings.setMailDomainSettings(dnsName, enable); }; - setMessageSettings = async (turnOn) => { - const res = await api.settings.setMessageSettings(turnOn); - }; - setCookieSettings = async (lifeTime) => { const res = await api.settings.setCookieSettings(lifeTime); }; From a44eaa9ea5fe49f8fbf74b3ec6eea7d08eaa8a37 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 04:03:37 +0300 Subject: [PATCH 05/14] Web: Client: Settings: add admin message setting layout, logic --- .../security/access-portal/adminMessage.js | 155 +++++++++++++++++- 1 file changed, 151 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 42d893d9c8..14b04d00f6 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -1,7 +1,154 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; +import styled from "styled-components"; +import { withRouter } from "react-router"; +import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; +import RadioButtonGroup from "@appserver/components/radio-button-group"; +import Text from "@appserver/components/text"; +import Link from "@appserver/components/link"; +import toastr from "@appserver/components/toast/toastr"; +import SectionLoader from "../sub-components/section-loader"; +import { getLanguage } from "@appserver/common/utils"; +import Buttons from "../sub-components/buttons"; +import { LearnMoreWrapper } from "../StyledSecurity"; +import { size } from "@appserver/components/utils/device"; +import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; -const AdminMessage = () => { - return

Admin message

; +const MainContainer = styled.div` + width: 100%; + + .page-subtitle { + margin-bottom: 10px; + } +`; + +const AdminMessage = (props) => { + const { t, history, enableAdmMess, setMessageSettings } = props; + const [type, setType] = useState(false); + const [showReminder, setShowReminder] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const getSettings = () => { + const currentSettings = getFromSessionStorage( + "currentAdminMessageSettings" + ); + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + + if (defaultSettings) { + saveToSessionStorage("defaultAdminMessageSettings", defaultSettings); + } else { + saveToSessionStorage("defaultAdminMessageSettings", enableAdmMess); + } + + if (currentSettings) { + setType(currentSettings); + } else { + setType(enableAdmMess); + } + setIsLoading(true); + }; + + useEffect(() => { + checkWidth(); + getSettings(); + window.addEventListener("resize", checkWidth); + return () => window.removeEventListener("resize", checkWidth); + }, [isLoading]); + + useEffect(() => { + if (!isLoading) return; + + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + saveToSessionStorage("currentAdminMessageSettings", type); + + if (defaultSettings === type) { + setShowReminder(false); + } else { + setShowReminder(true); + } + }, [type]); + + const checkWidth = () => { + window.innerWidth > size.smallTablet && + history.location.pathname.includes("admin-message") && + history.push("/settings/security/access-portal"); + }; + + const onSelectType = (e) => { + setType(e.target.value === "enable" ? true : false); + }; + + const onSaveClick = () => { + setMessageSettings(type); + toastr.success(t("SuccessfullySaveSettingsMessage")); + saveToSessionStorage("defaultAdminMessageSettings", type); + setShowReminder(false); + }; + + const onCancelClick = () => { + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + setType(defaultSettings); + setShowReminder(false); + }; + + const lng = getLanguage(localStorage.getItem("language") || "en"); + if (!isLoading) return ; + return ( + + + {t("AdminsMessageHelper")} + + {t("Common:LearnMore")} + + + + + + + + ); }; -export default AdminMessage; +export default inject(({ auth }) => { + const { enableAdmMess, setMessageSettings } = auth.settingsStore; + + return { + enableAdmMess, + setMessageSettings, + }; +})(withTranslation(["Settings", "Common"])(withRouter(observer(AdminMessage)))); From ae8da903a80b039016b405e235dfc08c3c7d8078 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:33:58 +0300 Subject: [PATCH 06/14] Web: Client: Settings: fix category wrapper --- .../categories/security/access-portal/adminMessage.js | 3 +-- .../pages/Settings/categories/security/access-portal/index.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 14b04d00f6..b504a94320 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -7,7 +7,6 @@ import RadioButtonGroup from "@appserver/components/radio-button-group"; import Text from "@appserver/components/text"; import Link from "@appserver/components/link"; import toastr from "@appserver/components/toast/toastr"; -import SectionLoader from "../sub-components/section-loader"; import { getLanguage } from "@appserver/common/utils"; import Buttons from "../sub-components/buttons"; import { LearnMoreWrapper } from "../StyledSecurity"; @@ -98,7 +97,7 @@ const AdminMessage = (props) => { }; const lng = getLanguage(localStorage.getItem("language") || "en"); - if (!isLoading) return ; + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index f4577a03c1..a14ce05e28 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -70,8 +70,10 @@ const AccessPortal = (props) => {
From 59e0e53d195cccc5c0fde7f4362941f8b9d33317 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 11:30:43 +0300 Subject: [PATCH 07/14] Web: Client: Settings: use SaveCancelButtons --- .../security/access-portal/adminMessage.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index b504a94320..a9cb058969 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -8,10 +8,10 @@ import Text from "@appserver/components/text"; import Link from "@appserver/components/link"; import toastr from "@appserver/components/toast/toastr"; import { getLanguage } from "@appserver/common/utils"; -import Buttons from "../sub-components/buttons"; import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; +import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; const MainContainer = styled.div` width: 100%; @@ -19,6 +19,10 @@ const MainContainer = styled.div` .page-subtitle { margin-bottom: 10px; } + + .box { + margin-bottom: 24px; + } `; const AdminMessage = (props) => { @@ -133,11 +137,16 @@ const AdminMessage = (props) => { onClick={onSelectType} /> - ); From ea6f80987f43ff9b4be2ae48bc8efd9abd2744a7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:15:13 +0300 Subject: [PATCH 08/14] Web: Client: NavMenu: fix style --- .../src/components/NavMenu/sub-components/header-unauth.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js index 2a8a54f5cd..21bc01d26e 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js @@ -13,10 +13,9 @@ const Header = styled.header` align-items: left; background-color: ${(props) => props.theme.header.backgroundColor}; display: flex; - width: calc(100vw - 64px); + width: 100vw; height: 48px; - justify-content: left; - padding: 0 32px; + justify-content: center; .header-items-wrapper { width: 960px; @@ -25,7 +24,7 @@ const Header = styled.header` width: 475px; } @media (max-width: 375px) { - width: 311px; + padding: 0 16px; } } From daca10d9d6aa2beae7d2223b6f114c3c082095ae Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:20:31 +0300 Subject: [PATCH 09/14] Web: Components: Themes: add recoveryColor --- packages/asc-web-components/themes/base.js | 2 +- packages/asc-web-components/themes/dark.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/asc-web-components/themes/base.js b/packages/asc-web-components/themes/base.js index b64430d563..5d5183378c 100644 --- a/packages/asc-web-components/themes/base.js +++ b/packages/asc-web-components/themes/base.js @@ -1923,7 +1923,7 @@ const Base = { header: { backgroundColor: "#0F4071", - + recoveryColor: "#27537F", linkColor: "#7a95b0", productColor: white, }, diff --git a/packages/asc-web-components/themes/dark.js b/packages/asc-web-components/themes/dark.js index 7da6c1096f..297b1ace2a 100644 --- a/packages/asc-web-components/themes/dark.js +++ b/packages/asc-web-components/themes/dark.js @@ -1924,7 +1924,7 @@ const Dark = { header: { backgroundColor: "#1f1f1f ", - + recoveryColor: "#4C4C4C", linkColor: "#606060", productColor: "#eeeeee", }, From a7b507bc0fd1ab3ff4c50499a16b0b0047b5de82 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:21:03 +0300 Subject: [PATCH 10/14] Web: Client: RecoverAccess: use themes --- .../NavMenu/sub-components/recover-access-container.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js index 9e1e10bbfb..fa31772e42 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js @@ -9,6 +9,7 @@ import UnionIcon from "../svg/union.react.svg"; import RecoverAccessModalDialog from "./recover-access-modal-dialog"; import { sendRecoverRequest } from "@appserver/common/api/settings/index"; import commonIconsStyles from "@appserver/components/utils/common-icons-style"; +import { Base } from "@appserver/components/themes"; const StyledUnionIcon = styled(UnionIcon)` ${commonIconsStyles} @@ -16,6 +17,7 @@ const StyledUnionIcon = styled(UnionIcon)` const RecoverContainer = styled(Box)` cursor: pointer; + background-color: ${(props) => props.theme.header.recoveryColor}; .recover-icon { @media (max-width: 450px) { @@ -29,6 +31,8 @@ const RecoverContainer = styled(Box)` } `; +RecoverContainer.defaultProps = { theme: Base }; + const RecoverAccess = ({ t }) => { const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(false); @@ -88,7 +92,6 @@ const RecoverAccess = ({ t }) => { alignItems="center" > Date: Tue, 12 Apr 2022 14:21:59 +0300 Subject: [PATCH 11/14] Web: Client: NavMenu: fix --- .../src/components/NavMenu/sub-components/header-unauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js index 21bc01d26e..46c03bb2df 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js @@ -109,7 +109,7 @@ export default inject(({ auth }) => { const { enableAdmMess, wizardToken } = settingsStore; return { enableAdmMess, - wizardToken: wizardToken || "/", + wizardToken, isAuthenticated, isLoaded, }; From d7d21f765ec792cdf8a2ddd0497d44a9afb23b76 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 13:47:42 +0300 Subject: [PATCH 12/14] Web: Client: Settings: fix init settings --- .../security/access-portal/adminMessage.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index a9cb058969..9fe519c137 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -26,7 +26,14 @@ const MainContainer = styled.div` `; const AdminMessage = (props) => { - const { t, history, enableAdmMess, setMessageSettings } = props; + const { + t, + history, + enableAdmMess, + setMessageSettings, + initSettings, + isInit, + } = props; const [type, setType] = useState(false); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -55,9 +62,17 @@ const AdminMessage = (props) => { useEffect(() => { checkWidth(); - getSettings(); + + if (!isInit) initSettings().then(() => setIsLoading(true)); + else setIsLoading(true); + window.addEventListener("resize", checkWidth); return () => window.removeEventListener("resize", checkWidth); + }, []); + + useEffect(() => { + if (!isInit) return; + getSettings(); }, [isLoading]); useEffect(() => { @@ -152,11 +167,14 @@ const AdminMessage = (props) => { ); }; -export default inject(({ auth }) => { +export default inject(({ auth, setup }) => { const { enableAdmMess, setMessageSettings } = auth.settingsStore; + const { initSettings, isInit } = setup; return { enableAdmMess, setMessageSettings, + initSettings, + isInit, }; })(withTranslation(["Settings", "Common"])(withRouter(observer(AdminMessage)))); From a1b7a47e45bfdd3e3f94d9d4f6e10612c003c9d4 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 18:25:23 +0300 Subject: [PATCH 13/14] Web: Client: Settings: fix logic --- .../security/access-portal/adminMessage.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 9fe519c137..14f79e2501 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -12,6 +12,7 @@ import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import isEqual from "lodash/isEqual"; const MainContainer = styled.div` width: 100%; @@ -34,7 +35,7 @@ const AdminMessage = (props) => { initSettings, isInit, } = props; - const [type, setType] = useState(false); + const [type, setType] = useState(""); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -42,22 +43,16 @@ const AdminMessage = (props) => { const currentSettings = getFromSessionStorage( "currentAdminMessageSettings" ); - const defaultSettings = getFromSessionStorage( - "defaultAdminMessageSettings" - ); - if (defaultSettings) { - saveToSessionStorage("defaultAdminMessageSettings", defaultSettings); - } else { - saveToSessionStorage("defaultAdminMessageSettings", enableAdmMess); - } + const enable = enableAdmMess ? "enable" : "disabled"; + + saveToSessionStorage("defaultAdminMessageSettings", enable); if (currentSettings) { setType(currentSettings); } else { - setType(enableAdmMess); + setType(enable); } - setIsLoading(true); }; useEffect(() => { @@ -83,7 +78,8 @@ const AdminMessage = (props) => { ); saveToSessionStorage("currentAdminMessageSettings", type); - if (defaultSettings === type) { + if (isEqual(defaultSettings, type)) { + console.log("==="); setShowReminder(false); } else { setShowReminder(true); @@ -97,7 +93,9 @@ const AdminMessage = (props) => { }; const onSelectType = (e) => { - setType(e.target.value === "enable" ? true : false); + if (type !== e.target.value) { + setType(e.target.value); + } }; const onSaveClick = () => { @@ -148,7 +146,7 @@ const AdminMessage = (props) => { value: "enable", }, ]} - selected={type ? "enable" : "disabled"} + selected={type} onClick={onSelectType} /> From 1aa605fb98ef135cfe63ec78ae6cbfc18a2619e5 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 18:27:36 +0300 Subject: [PATCH 14/14] Web: Client: Settings: delete console log --- .../Settings/categories/security/access-portal/adminMessage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 14f79e2501..309294aaf7 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -79,7 +79,6 @@ const AdminMessage = (props) => { saveToSessionStorage("currentAdminMessageSettings", type); if (isEqual(defaultSettings, type)) { - console.log("==="); setShowReminder(false); } else { setShowReminder(true);