2022-02-02 11:24:35 +00:00
|
|
|
import React from "react";
|
2022-03-03 07:06:47 +00:00
|
|
|
import styled, { css } from "styled-components";
|
2022-02-02 11:24:35 +00:00
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import ContextMenuButton from "@appserver/components/context-menu-button";
|
2022-02-03 08:06:36 +00:00
|
|
|
import IconButton from "@appserver/components/icon-button";
|
2022-03-03 07:04:27 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
|
|
|
import { tablet } from "@appserver/components/utils/device";
|
2022-03-29 10:59:56 +00:00
|
|
|
import { Base } from "@appserver/components/themes";
|
2022-05-06 12:11:04 +00:00
|
|
|
import ToggleInfoPanelButton from "./toggle-infopanel-btn";
|
2021-10-15 07:07:15 +00:00
|
|
|
|
|
|
|
const StyledContainer = styled.div`
|
2022-02-18 09:56:42 +00:00
|
|
|
margin-left: 20px;
|
2021-10-15 07:07:15 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2022-03-03 07:04:27 +00:00
|
|
|
|
2022-05-06 09:25:19 +00:00
|
|
|
height: 32px;
|
|
|
|
|
2022-03-03 07:04:27 +00:00
|
|
|
.add-button {
|
2022-04-20 10:04:31 +00:00
|
|
|
margin-right: 16px;
|
|
|
|
min-width: 15px;
|
2022-03-03 07:04:27 +00:00
|
|
|
|
2022-05-06 07:40:37 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
display: none;
|
|
|
|
}
|
2022-03-03 07:04:27 +00:00
|
|
|
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
2022-05-06 07:40:37 +00:00
|
|
|
display: none;
|
2022-03-03 07:04:27 +00:00
|
|
|
`}
|
|
|
|
}
|
|
|
|
|
|
|
|
.option-button {
|
2022-04-20 10:04:31 +00:00
|
|
|
margin-right: 16px;
|
|
|
|
min-width: 15px;
|
2022-05-17 14:54:32 +00:00
|
|
|
|
|
|
|
@media ${tablet} {
|
|
|
|
margin-right: 9px;
|
|
|
|
}
|
2022-03-03 07:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.trash-button {
|
2022-04-20 10:04:31 +00:00
|
|
|
margin-right: 16px;
|
|
|
|
min-width: 15px;
|
2022-03-03 07:04:27 +00:00
|
|
|
}
|
2021-10-15 07:07:15 +00:00
|
|
|
`;
|
|
|
|
|
2022-03-17 14:16:21 +00:00
|
|
|
const StyledInfoPanelToggleWrapper = styled.div`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
align-self: center;
|
|
|
|
justify-content: center;
|
2022-04-07 14:59:03 +00:00
|
|
|
margin-left: auto;
|
2022-03-17 14:16:21 +00:00
|
|
|
|
2022-04-20 10:04:31 +00:00
|
|
|
@media ${tablet} {
|
2022-04-20 13:03:55 +00:00
|
|
|
margin-left: ${(props) => (props.isRootFolder ? "auto" : "0")};
|
2022-04-20 10:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
2022-04-20 13:03:55 +00:00
|
|
|
margin-left: ${(props) => (props.isRootFolder ? "auto" : "0")};
|
2022-04-20 10:04:31 +00:00
|
|
|
`}
|
|
|
|
|
2022-03-17 14:16:21 +00:00
|
|
|
.info-panel-toggle-bg {
|
2022-04-26 10:22:50 +00:00
|
|
|
height: 32px;
|
|
|
|
width: 32px;
|
2022-03-17 14:16:21 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
border-radius: 50%;
|
|
|
|
background-color: ${(props) =>
|
2022-03-29 10:59:56 +00:00
|
|
|
props.isInfoPanelVisible
|
|
|
|
? props.theme.infoPanel.sectionHeaderToggleBgActive
|
|
|
|
: props.theme.infoPanel.sectionHeaderToggleBg};
|
|
|
|
|
|
|
|
path {
|
|
|
|
fill: ${(props) =>
|
|
|
|
props.isInfoPanelVisible
|
|
|
|
? props.theme.infoPanel.sectionHeaderToggleIconActive
|
|
|
|
: props.theme.infoPanel.sectionHeaderToggleIcon};
|
|
|
|
}
|
2022-03-17 14:16:21 +00:00
|
|
|
}
|
|
|
|
`;
|
2022-03-29 10:59:56 +00:00
|
|
|
StyledInfoPanelToggleWrapper.defaultProps = { theme: Base };
|
2022-03-17 14:16:21 +00:00
|
|
|
|
2021-10-15 07:07:15 +00:00
|
|
|
const ControlButtons = ({
|
|
|
|
personal,
|
2022-03-10 11:00:15 +00:00
|
|
|
isDropBox,
|
2021-10-15 07:07:15 +00:00
|
|
|
isRootFolder,
|
|
|
|
canCreate,
|
|
|
|
getContextOptionsFolder,
|
|
|
|
getContextOptionsPlus,
|
2022-02-03 08:06:36 +00:00
|
|
|
isRecycleBinFolder,
|
|
|
|
isEmptyFilesList,
|
|
|
|
clearTrash,
|
2022-03-17 14:16:21 +00:00
|
|
|
isInfoPanelVisible,
|
2022-03-24 14:57:36 +00:00
|
|
|
toggleInfoPanel,
|
2022-04-20 09:24:14 +00:00
|
|
|
toggleDropBox,
|
2022-04-29 13:48:30 +00:00
|
|
|
isDesktop,
|
2022-05-13 16:33:16 +00:00
|
|
|
titles,
|
2021-10-15 07:07:15 +00:00
|
|
|
}) => {
|
2022-04-20 09:24:14 +00:00
|
|
|
const toggleInfoPanelAction = () => {
|
|
|
|
toggleInfoPanel && toggleInfoPanel();
|
|
|
|
toggleDropBox && toggleDropBox();
|
|
|
|
};
|
|
|
|
|
2022-03-03 07:04:27 +00:00
|
|
|
return (
|
2022-03-10 11:00:15 +00:00
|
|
|
<StyledContainer isDropBox={isDropBox}>
|
2022-03-28 09:33:57 +00:00
|
|
|
{!isRootFolder && canCreate ? (
|
|
|
|
<>
|
2022-05-04 09:07:12 +00:00
|
|
|
{!isMobile && (
|
|
|
|
<ContextMenuButton
|
2022-05-04 11:42:27 +00:00
|
|
|
zIndex={402}
|
2022-05-04 09:07:12 +00:00
|
|
|
className="add-button"
|
|
|
|
directionX="right"
|
|
|
|
iconName="images/plus.svg"
|
|
|
|
size={15}
|
|
|
|
isFill
|
|
|
|
getData={getContextOptionsPlus}
|
|
|
|
isDisabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
2022-03-28 09:33:57 +00:00
|
|
|
{!personal && (
|
|
|
|
<ContextMenuButton
|
2022-05-11 09:33:52 +00:00
|
|
|
zIndex={402}
|
2022-03-28 09:33:57 +00:00
|
|
|
className="option-button"
|
|
|
|
directionX="right"
|
|
|
|
iconName="images/vertical-dots.react.svg"
|
2022-04-20 10:04:31 +00:00
|
|
|
size={15}
|
2022-03-28 09:33:57 +00:00
|
|
|
isFill
|
|
|
|
getData={getContextOptionsFolder}
|
|
|
|
isDisabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
2022-04-29 13:48:30 +00:00
|
|
|
{!isDesktop && (
|
2022-05-06 12:11:04 +00:00
|
|
|
<ToggleInfoPanelButton
|
2022-04-29 13:48:30 +00:00
|
|
|
isRootFolder={isRootFolder}
|
|
|
|
isInfoPanelVisible={isInfoPanelVisible}
|
2022-05-11 15:06:23 +00:00
|
|
|
toggleInfoPanel={toggleInfoPanelAction}
|
2022-05-06 12:11:04 +00:00
|
|
|
/>
|
2022-04-29 13:48:30 +00:00
|
|
|
)}
|
2022-03-28 09:33:57 +00:00
|
|
|
</>
|
|
|
|
) : canCreate ? (
|
2022-04-20 10:04:31 +00:00
|
|
|
<>
|
2022-05-04 09:07:12 +00:00
|
|
|
{!isMobile && (
|
|
|
|
<ContextMenuButton
|
2022-05-04 11:42:27 +00:00
|
|
|
zIndex={402}
|
2022-05-04 09:07:12 +00:00
|
|
|
className="add-button"
|
|
|
|
directionX="right"
|
|
|
|
iconName="images/plus.svg"
|
|
|
|
size={15}
|
|
|
|
isFill
|
|
|
|
getData={getContextOptionsPlus}
|
|
|
|
isDisabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
2022-05-06 12:11:04 +00:00
|
|
|
{!isDesktop && (
|
|
|
|
<ToggleInfoPanelButton
|
|
|
|
isRootFolder={isRootFolder}
|
|
|
|
isInfoPanelVisible={isInfoPanelVisible}
|
2022-05-11 07:58:24 +00:00
|
|
|
toggleInfoPanel={toggleInfoPanelAction}
|
2022-05-06 12:11:04 +00:00
|
|
|
/>
|
|
|
|
)}
|
2022-04-20 10:04:31 +00:00
|
|
|
</>
|
2022-03-28 09:33:57 +00:00
|
|
|
) : isRecycleBinFolder && !isEmptyFilesList ? (
|
2022-04-20 10:04:31 +00:00
|
|
|
<>
|
2022-03-17 14:16:21 +00:00
|
|
|
<IconButton
|
2022-04-20 10:04:31 +00:00
|
|
|
iconName="images/clear.active.react.svg"
|
|
|
|
size={15}
|
2022-03-17 14:16:21 +00:00
|
|
|
isFill={true}
|
2022-04-20 10:04:31 +00:00
|
|
|
onClick={clearTrash}
|
|
|
|
className="trash-button"
|
2022-05-13 16:33:16 +00:00
|
|
|
title={(titles && titles["trash"]) || ""}
|
2022-03-17 14:16:21 +00:00
|
|
|
/>
|
2022-05-06 12:11:04 +00:00
|
|
|
{!isDesktop && (
|
|
|
|
<ToggleInfoPanelButton
|
|
|
|
isRootFolder={isRootFolder}
|
|
|
|
isInfoPanelVisible={isInfoPanelVisible}
|
2022-05-11 15:06:23 +00:00
|
|
|
toggleInfoPanel={toggleInfoPanelAction}
|
2022-05-06 12:11:04 +00:00
|
|
|
/>
|
|
|
|
)}
|
2022-04-20 10:04:31 +00:00
|
|
|
</>
|
|
|
|
) : (
|
2022-04-26 14:41:07 +00:00
|
|
|
<>
|
2022-05-06 12:11:04 +00:00
|
|
|
{!isDesktop && (
|
|
|
|
<ToggleInfoPanelButton
|
|
|
|
isRootFolder={isRootFolder}
|
|
|
|
isInfoPanelVisible={isInfoPanelVisible}
|
2022-05-11 15:06:23 +00:00
|
|
|
toggleInfoPanel={toggleInfoPanelAction}
|
2022-05-06 12:11:04 +00:00
|
|
|
/>
|
|
|
|
)}
|
2022-04-26 14:41:07 +00:00
|
|
|
</>
|
2022-04-20 10:04:31 +00:00
|
|
|
)}
|
2021-10-15 07:07:15 +00:00
|
|
|
</StyledContainer>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-10-20 09:06:59 +00:00
|
|
|
ControlButtons.propTypes = {
|
|
|
|
personal: PropTypes.bool,
|
|
|
|
isRootFolder: PropTypes.bool,
|
|
|
|
canCreate: PropTypes.bool,
|
|
|
|
getContextOptionsFolder: PropTypes.func,
|
|
|
|
getContextOptionsPlus: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
2021-10-15 07:07:15 +00:00
|
|
|
export default React.memo(ControlButtons);
|