DocSpace-client/packages/asc-web-common/components/PageLayout/sub-components/section-body.js
Alexey Safronov 3aeac42444 Merge branch 'master' into develop
# Conflicts:
#	common/ASC.Core.Common/Data/DbSubscriptionService.cs
#	common/ASC.Core.Common/Notify/Signalr/SignalrServiceClient.cs
#	common/services/ASC.ElasticSearch/Engine/FactoryIndexer.cs
#	common/services/ASC.ElasticSearch/Service/Settings.cs
#	common/services/ASC.Socket.IO.Svc/ASC.Socket.IO.Svc.csproj
#	common/services/ASC.Socket.IO.Svc/SocketServiceLauncher.cs
#	packages/asc-web-components/combobox/index.js
#	packages/asc-web-components/table-container/StyledTableContainer.js
#	packages/asc-web-components/table-container/TableGroupMenu.js
#	packages/asc-web-components/table-container/TableHeader.js
#	packages/asc-web-components/table-container/TableHeaderCell.js
#	packages/asc-web-components/table-container/TableRow.js
#	products/ASC.Files/Client/public/locales/az/Home.json
#	products/ASC.Files/Client/public/locales/bg/Home.json
#	products/ASC.Files/Client/public/locales/bg/Translations.json
#	products/ASC.Files/Client/public/locales/cs/Home.json
#	products/ASC.Files/Client/public/locales/de/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/de/Home.json
#	products/ASC.Files/Client/public/locales/de/Translations.json
#	products/ASC.Files/Client/public/locales/de/UploadPanel.json
#	products/ASC.Files/Client/public/locales/el/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/el/Home.json
#	products/ASC.Files/Client/public/locales/en/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/en/Home.json
#	products/ASC.Files/Client/public/locales/en/Translations.json
#	products/ASC.Files/Client/public/locales/en/UploadPanel.json
#	products/ASC.Files/Client/public/locales/es/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/es/Home.json
#	products/ASC.Files/Client/public/locales/es/UploadPanel.json
#	products/ASC.Files/Client/public/locales/fi/Home.json
#	products/ASC.Files/Client/public/locales/fr/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/fr/Home.json
#	products/ASC.Files/Client/public/locales/fr/Translations.json
#	products/ASC.Files/Client/public/locales/it/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/it/Home.json
#	products/ASC.Files/Client/public/locales/it/Translations.json
#	products/ASC.Files/Client/public/locales/it/UploadPanel.json
#	products/ASC.Files/Client/public/locales/ja/Home.json
#	products/ASC.Files/Client/public/locales/ja/UploadPanel.json
#	products/ASC.Files/Client/public/locales/lv/Home.json
#	products/ASC.Files/Client/public/locales/nl/Home.json
#	products/ASC.Files/Client/public/locales/nl/Translations.json
#	products/ASC.Files/Client/public/locales/pl/Home.json
#	products/ASC.Files/Client/public/locales/pt-BR/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/pt-BR/Home.json
#	products/ASC.Files/Client/public/locales/pt-BR/Translations.json
#	products/ASC.Files/Client/public/locales/ro/Home.json
#	products/ASC.Files/Client/public/locales/ro/UploadPanel.json
#	products/ASC.Files/Client/public/locales/ru/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/ru/Home.json
#	products/ASC.Files/Client/public/locales/ru/Translations.json
#	products/ASC.Files/Client/public/locales/ru/UploadPanel.json
#	products/ASC.Files/Client/public/locales/sk/Home.json
#	products/ASC.Files/Client/public/locales/tr/Home.json
#	products/ASC.Files/Client/public/locales/uk/Home.json
#	products/ASC.Files/Client/public/locales/vi/ConvertDialog.json
#	products/ASC.Files/Client/public/locales/vi/Home.json
#	products/ASC.Files/Client/public/locales/zh-CN/Home.json
#	products/ASC.Files/Client/public/locales/zh-CN/UploadPanel.json
#	products/ASC.Files/Client/src/HOCs/withBadges.js
#	products/ASC.Files/Client/src/HOCs/withContent.js
#	products/ASC.Files/Client/src/components/Badges.js
#	products/ASC.Files/Client/src/components/EditingWrapperComponent.js
#	products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js
#	products/ASC.Files/Client/src/components/panels/SharingPanel/index.js
#	products/ASC.Files/Client/src/components/panels/UploadPanel/FileRow.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/TableView/TableHeader.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/TableView/TableRow.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/TilesView/FileTile.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/TilesView/sub-components/Tile.js
#	products/ASC.Files/Client/src/pages/Home/Section/Body/index.js
#	products/ASC.Files/Client/src/store/DialogsStore.js
#	products/ASC.Files/Client/src/store/FilesActionsStore.js
#	products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs
#	products/ASC.Files/Core/Utils/FileConverter.cs
#	products/ASC.Files/Server/Helpers/FilesControllerHelper.cs
#	products/ASC.Files/Service/Thumbnail/Builder.cs
#	products/ASC.Files/Service/Thumbnail/ThumbnailSettings.cs
#	products/ASC.Files/Service/Thumbnail/Worker.cs
#	products/ASC.People/Client/src/pages/Home/Section/Body/TableView/TableRow.js
#	public/locales/de/Common.json
2022-02-21 22:22:38 +03:00

254 lines
5.7 KiB
JavaScript

import React from "react";
import PropTypes from "prop-types";
import styled, { css } from "styled-components";
//import equal from "fast-deep-equal/react";
//import { LayoutContextConsumer } from "studio/Layout/context";
import { isMobile } from "react-device-detect";
import { inject, observer } from "mobx-react";
import Scrollbar from "@appserver/components/scrollbar";
import DragAndDrop from "@appserver/components/drag-and-drop";
import { tablet, desktop } from "@appserver/components/utils/device";
const paddingStyles = css`
padding: 17px 7px 16px 20px;
@media ${tablet} {
padding: 16px 0 16px 24px;
}
`;
const commonStyles = css`
flex-grow: 1;
${(props) => (props.isDesktop ? "height: auto" : "height: 100%")};
${(props) => !props.withScroll && `height: 100%;`}
border-left: none;
.section-wrapper {
${(props) =>
!props.withScroll &&
`display: flex; height: 100%; box-sizing:border-box`};
${(props) => !props.withScroll && paddingStyles}
}
.section-wrapper-content {
${paddingStyles}
flex: 1 0 auto;
outline: none;
${(props) =>
props.viewAs == "tile" &&
css`
padding-right: 0;
padding-left: 20px;
`}
.section-wrapper {
display: flex;
flex-direction: column;
min-height: 100%;
}
.people-row-container,
.files-row-container {
margin-top: -22px;
@media ${desktop} {
${(props) => props.viewAs === "row" && `margin-top: -9px;`}
}
}
}
`;
const StyledSectionBody = styled.div`
${commonStyles}
${(props) =>
props.withScroll &&
`
margin-left: -24px;
`}
.additional-scroll-height {
${(props) =>
!props.withScroll &&
!props.pinned &&
` height: 64px;
`}
}
`;
const StyledDropZoneBody = styled(DragAndDrop)`
${commonStyles}
.drag-and-drop {
user-select: none;
height: 100%;
}
${(props) =>
props.withScroll &&
`
margin-left: -24px;
`}
`;
const StyledSpacer = styled.div`
display: none;
min-height: 64px;
@media ${tablet} {
display: ${(props) =>
props.isHomepage || props.pinned ? "none" : "block"};
}
`;
class SectionBody extends React.Component {
constructor(props) {
super(props);
this.focusRef = React.createRef();
}
// shouldComponentUpdate(nextProps) {
// return !equal(this.props, nextProps);
// }
componentDidMount() {
const { withScroll } = this.props;
if (!this.props.autoFocus) return;
if (withScroll) this.focusRef.current.focus();
}
componentWillUnmount() {
this.focusRef = null;
}
render() {
//console.log("PageLayout SectionBody render" );
const {
autoFocus,
children,
onDrop,
pinned,
uploadFiles,
viewAs,
withScroll,
isLoaded,
isDesktop,
isHomepage,
} = this.props;
const focusProps = autoFocus
? {
ref: this.focusRef,
tabIndex: -1,
}
: {};
return uploadFiles ? (
<StyledDropZoneBody
isDropZone
onDrop={onDrop}
withScroll={withScroll}
viewAs={viewAs}
pinned={pinned}
isLoaded={isLoaded}
isDesktop={isDesktop}
className="section-body"
>
{withScroll ? (
!isMobile ? (
<Scrollbar scrollclass="section-scroll" stype="mediumBlack">
<div className="section-wrapper">
<div className="section-wrapper-content" {...focusProps}>
{children}
<StyledSpacer pinned={pinned} />
</div>
</div>
</Scrollbar>
) : (
<div className="section-wrapper">
<div className="section-wrapper-content" {...focusProps}>
{children}
<StyledSpacer pinned={pinned} />
</div>
</div>
)
) : (
<div className="section-wrapper">
{children}
<StyledSpacer pinned={pinned} />
</div>
)}
</StyledDropZoneBody>
) : (
<StyledSectionBody
viewAs={viewAs}
withScroll={withScroll}
pinned={pinned}
isLoaded={isLoaded}
isDesktop={isDesktop}
>
{withScroll ? (
!isMobile ? (
<Scrollbar stype="mediumBlack">
<div className="section-wrapper">
<div className="section-wrapper-content" {...focusProps}>
{children}
<StyledSpacer pinned={pinned} />
</div>
</div>
</Scrollbar>
) : (
<div className="section-wrapper">
<div className="section-wrapper-content" {...focusProps}>
{children}
<StyledSpacer pinned={pinned} isHomepage={isHomepage} />
</div>
</div>
)
) : (
<div className="section-wrapper">{children}</div>
)}
</StyledSectionBody>
);
}
}
SectionBody.displayName = "SectionBody";
SectionBody.propTypes = {
withScroll: PropTypes.bool,
autoFocus: PropTypes.bool,
pinned: PropTypes.bool,
onDrop: PropTypes.func,
uploadFiles: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
PropTypes.any,
]),
viewAs: PropTypes.string,
isLoaded: PropTypes.bool,
isHomepage: PropTypes.bool,
};
SectionBody.defaultProps = {
autoFocus: false,
pinned: false,
uploadFiles: false,
withScroll: true,
isHomepage: false,
};
export default inject(({ auth }) => {
const { settingsStore } = auth;
const { isDesktopClient: isDesktop } = settingsStore;
return {
isLoaded: auth.isLoaded,
isDesktop,
};
})(observer(SectionBody));