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";
|
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
|
|
|
|
|
|
|
.add-button {
|
|
|
|
margin-right: 12px;
|
|
|
|
min-width: 17px;
|
|
|
|
|
|
|
|
@media ${tablet} {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
display: none;
|
|
|
|
`}
|
|
|
|
}
|
|
|
|
|
|
|
|
.option-button {
|
|
|
|
margin-right: 8px;
|
|
|
|
min-width: 17px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.trash-button {
|
|
|
|
min-width: 17px;
|
|
|
|
}
|
2021-10-15 07:07:15 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
const ControlButtons = ({
|
|
|
|
personal,
|
|
|
|
isRootFolder,
|
|
|
|
canCreate,
|
|
|
|
getContextOptionsFolder,
|
|
|
|
getContextOptionsPlus,
|
2022-02-03 08:06:36 +00:00
|
|
|
isRecycleBinFolder,
|
|
|
|
isEmptyFilesList,
|
|
|
|
clearTrash,
|
2021-10-15 07:07:15 +00:00
|
|
|
}) => {
|
2022-03-03 07:04:27 +00:00
|
|
|
return (
|
2021-10-15 07:07:15 +00:00
|
|
|
<StyledContainer>
|
2022-03-03 07:04:27 +00:00
|
|
|
{!isRootFolder && canCreate ? (
|
|
|
|
<>
|
|
|
|
<ContextMenuButton
|
|
|
|
className="add-button"
|
|
|
|
directionX="right"
|
|
|
|
iconName="images/plus.svg"
|
|
|
|
size={17}
|
|
|
|
isFill
|
|
|
|
getData={getContextOptionsPlus}
|
|
|
|
isDisabled={false}
|
|
|
|
/>
|
|
|
|
{!personal && (
|
|
|
|
<ContextMenuButton
|
|
|
|
className="option-button"
|
|
|
|
directionX="right"
|
|
|
|
iconName="images/vertical-dots.react.svg"
|
|
|
|
size={17}
|
|
|
|
isFill
|
|
|
|
getData={getContextOptionsFolder}
|
|
|
|
isDisabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : canCreate ? (
|
2021-10-15 07:07:15 +00:00
|
|
|
<ContextMenuButton
|
2022-03-03 07:04:27 +00:00
|
|
|
className="add-button"
|
2021-10-15 07:07:15 +00:00
|
|
|
directionX="right"
|
2022-03-03 07:04:27 +00:00
|
|
|
iconName="images/plus.svg"
|
2021-10-15 07:07:15 +00:00
|
|
|
size={17}
|
|
|
|
isFill
|
2022-03-03 07:04:27 +00:00
|
|
|
getData={getContextOptionsPlus}
|
2021-10-15 07:07:15 +00:00
|
|
|
isDisabled={false}
|
|
|
|
/>
|
2022-03-03 07:04:27 +00:00
|
|
|
) : isRecycleBinFolder && !isEmptyFilesList ? (
|
|
|
|
<IconButton
|
|
|
|
iconName="images/clear.active.react.svg"
|
|
|
|
size={17}
|
|
|
|
isFill={true}
|
|
|
|
onClick={clearTrash}
|
|
|
|
className="trash-button"
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<></>
|
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);
|