Web: Client: Settings: refactoring portal access page, add mobile layout

This commit is contained in:
Viktor Fomin 2022-03-30 20:56:40 +03:00
parent 2dcace061b
commit dbfae6d641
5 changed files with 154 additions and 135 deletions

View File

@ -0,0 +1,69 @@
import styled from "styled-components";
import ArrowRightIcon from "@appserver/studio/public/images/arrow.right.react.svg";
import commonIconsStyles from "@appserver/components/utils/common-icons-style";
import { Base } from "@appserver/components/themes";
export const StyledArrowRightIcon = styled(ArrowRightIcon)`
${commonIconsStyles}
path {
fill: ${(props) => props.theme.studio.settings.security.arrowFill};
}
`;
StyledArrowRightIcon.defaultProps = { theme: Base };
export const MainContainer = styled.div`
width: 100%;
.subtitle {
margin-bottom: 20px;
}
.settings_tabs {
padding-bottom: 16px;
}
.page_loader {
position: fixed;
left: 50%;
}
.category-title {
margin-bottom: 16px;
}
.category-item-wrapper {
margin-bottom: 40px;
.category-item-heading {
display: flex;
align-items: center;
margin-bottom: 5px;
}
.category-item-subheader {
font-size: 13px;
font-weight: 600;
margin-bottom: 5px;
}
.category-item-description {
color: ${(props) =>
props.theme.studio.settings.security.descriptionColor};
font-size: 12px;
max-width: 1024px;
}
.inherit-title-link {
margin-right: 7px;
font-size: 19px;
font-weight: 600;
}
.link-text {
margin: 0;
}
}
`;
MainContainer.defaultProps = { theme: Base };

View File

@ -1,129 +0,0 @@
import React, { PureComponent } from "react";
import { withRouter } from "react-router";
import { withTranslation } from "react-i18next";
import styled from "styled-components";
import OwnerSettings from "./sub-components/owner";
// import ModulesSettings from "./sub-components/modules";
import { setDocumentTitle } from "../../../../../helpers/utils";
import Link from "@appserver/components/link";
import Text from "@appserver/components/text";
import toastr from "@appserver/components/toast/toastr";
import { inject } from "mobx-react";
import isEmpty from "lodash/isEmpty";
import { combineUrl, showLoader, hideLoader } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
import commonIconsStyles from "@appserver/components/utils/common-icons-style";
import ArrowRightIcon from "@appserver/studio/public/images/arrow.right.react.svg";
import { Base } from "@appserver/components/themes";
import commonSettingsStyles from "../../utils/commonSettingsStyles";
const StyledArrowRightIcon = styled(ArrowRightIcon)`
${commonIconsStyles}
path {
fill: ${(props) => props.theme.studio.settings.security.arrowFill};
}
`;
StyledArrowRightIcon.defaultProps = { theme: Base };
const MainContainer = styled.div`
width: 100%;
.settings_tabs {
padding-bottom: 16px;
}
.page_loader {
position: fixed;
left: 50%;
}
.category-item-wrapper {
margin-bottom: 40px;
.category-item-heading {
display: flex;
align-items: center;
margin-bottom: 5px;
}
.category-item-subheader {
font-size: 13px;
font-weight: 600;
margin-bottom: 5px;
}
.category-item-description {
color: ${(props) => props.theme.studio.settings.security.descriptionColor}
font-size: 12px;
max-width: 1024px;
}
.inherit-title-link {
margin-right: 7px;
font-size: 19px;
font-weight: 600;
}
.link-text {
margin: 0;
}
}
`;
MainContainer.defaultProps = { theme: Base };
class AccessPortal extends PureComponent {
constructor(props) {
super(props);
const { t } = props;
setDocumentTitle(t("PortalAccess"));
}
componentDidMount() {
showLoader();
hideLoader();
}
onClickLink = (e) => {
e.preventDefault();
const { history } = this.props;
history.push(e.target.pathname);
};
render() {
const { t } = this.props;
return (
<MainContainer>
<div className="category-item-wrapper">
<div className="category-item-heading">
<Link
className="inherit-title-link header"
onClick={this.onClickLink}
truncate={true}
href={combineUrl(
AppServerConfig.proxyURL,
"/settings/security/access-portal/tfa"
)}
>
{t("TwoFactorAuth")}
</Link>
<StyledArrowRightIcon size="small" />
</div>
<Text className="category-item-description">
{t("TwoFactorAuthDescription")}
</Text>
</div>
</MainContainer>
);
}
}
export default inject(({ auth }) => {
return {
organizationName: auth.settingsStore.organizationName,
};
})(withTranslation("Settings")(withRouter(AccessPortal)));

View File

@ -0,0 +1,31 @@
import React, { useEffect } from "react";
import { withRouter } from "react-router";
import { withTranslation } from "react-i18next";
import Text from "@appserver/components/text";
import { setDocumentTitle } from "../../../../../../helpers/utils";
import { MainContainer } from "../StyledSecurity";
import TfaSection from "../sub-components/tfa";
import MobileView from "./mobileView";
import { isMobile } from "react-device-detect";
const AccessPortal = (props) => {
const { t } = props;
useEffect(() => {
setDocumentTitle(t("PortalAccess"));
}, []);
if (isMobile) return <MobileView />;
return (
<MainContainer className="desktop-view">
<Text className="subtitle">{t("PortalAccessSubTitle")} </Text>
<Text className="category-title" fontSize="16px" fontWeight="700">
{t("TwoFactorAuth")}
</Text>
<TfaSection />
</MainContainer>
);
};
export default withTranslation("Settings")(withRouter(AccessPortal));

View File

@ -0,0 +1,48 @@
import React, { useEffect } from "react";
import { withRouter } from "react-router";
import { withTranslation } from "react-i18next";
import Link from "@appserver/components/link";
import Text from "@appserver/components/text";
import { combineUrl } from "@appserver/common/utils";
import { AppServerConfig } from "@appserver/common/constants";
import { setDocumentTitle } from "../../../../../../helpers/utils";
import { MainContainer, StyledArrowRightIcon } from "../StyledSecurity";
const MobileView = (props) => {
const { t, history } = props;
useEffect(() => {
setDocumentTitle(t("PortalAccess"));
}, []);
const onClickLink = (e) => {
e.preventDefault();
history.push(e.target.pathname);
};
return (
<MainContainer>
<div className="category-item-wrapper">
<div className="category-item-heading">
<Link
className="inherit-title-link header"
onClick={onClickLink}
truncate={true}
href={combineUrl(
AppServerConfig.proxyURL,
"/settings/security/access-portal/tfa"
)}
>
{t("TwoFactorAuth")}
</Link>
<StyledArrowRightIcon size="small" />
</div>
<Text className="category-item-description">
{t("TwoFactorAuthDescription")}
</Text>
</div>
</MainContainer>
);
};
export default withTranslation("Settings")(withRouter(MobileView));

View File

@ -7,22 +7,22 @@ import { combineUrl } from "@appserver/common/utils";
import config from "../../../../../../package.json";
import AccessRights from "./access-rights";
import PortalAccess from "./access-portal";
import AccessPortal from "./access-portal/index.js";
const SecurityWrapper = (props) => {
const { t, history } = props;
const data = [
{
id: "access-rights",
name: t("AccessRights"),
content: <AccessPortal />,
},
{
id: "access-portal",
name: t("PortalAccess"),
content: <AccessRights />,
},
{
id: "access-rights",
name: t("AccessRights"),
content: <PortalAccess />,
},
];
const onSelect = (e) => {