Web: Files: moved SimpleFilesRow to a separate file, removed the bind

This commit is contained in:
Nikita Gopienko 2020-10-15 14:40:17 +03:00
parent 3e66f95546
commit 43dc6d81a5
2 changed files with 56 additions and 32 deletions

View File

@ -0,0 +1,55 @@
import React from "react";
import styled from "styled-components";
import { Row } from "asc-web-components";
import { connect } from "react-redux";
import { withRouter } from "react-router";
import { setSelected, setSelection } from "../../../../../store/files/actions";
import { getSelected } from "../../../../../store/files/selectors";
const StyledSimpleFilesRow = styled(Row)`
${(props) =>
!props.contextOptions &&
`
& > div:last-child {
width: 0px;
}
`}
.share-button-icon {
margin-right: 8px;
}
.share-button,
.share-button-icon:hover {
cursor: pointer;
div {
color: "#657077";
}
}
`;
const SimpleFilesRow = (props) => {
const { children, selected, setSelected, setSelection, data, ...rest } = props;
const onSelectItem = () => {
selected === "close" && setSelected("none");
setSelection([data]);
};
return (
<StyledSimpleFilesRow {...rest} data={data} selectItem={onSelectItem}>
{children}
</StyledSimpleFilesRow>
);
};
const mapStateToProps = (state) => {
return {
selected: getSelected(state),
};
};
export default connect(mapStateToProps, {
setSelection,
setSelected,
})(withRouter(SimpleFilesRow));

View File

@ -9,7 +9,6 @@ import styled from "styled-components";
import queryString from "query-string";
import {
IconButton,
Row,
RowContainer,
Link,
DragAndDrop,
@ -21,6 +20,7 @@ import FilesRowContent from "./FilesRowContent";
import FilesTileContent from "./FilesTileContent";
import TileContainer from "./TileContainer";
import Tile from "./Tile";
import SimpleFilesRow from "./SimpleFilesRow";
import {
api,
@ -43,7 +43,6 @@ import {
setUpdateTree,
setProgressBarData,
setSelected,
setSelection,
setTreeFolders,
loopFilesOperations,
} from "../../../../../store/files/actions";
@ -113,28 +112,6 @@ const CustomTooltip = styled.div`
-webkit-box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.13);
`;
const SimpleFilesRow = styled(Row)`
${(props) =>
!props.contextOptions &&
`
& > div:last-child {
width: 0px;
}
`}
.share-button-icon {
margin-right: 8px;
}
.share-button,
.share-button-icon:hover {
cursor: pointer;
div {
color: "#657077";
}
}
`;
class SectionBodyContent extends React.Component {
constructor(props) {
super(props);
@ -1206,12 +1183,6 @@ class SectionBodyContent extends React.Component {
});
};
onSelectItem = (item) => {
const { selected, setSelected, setSelection } = this.props;
selected === "close" && setSelected("none");
setSelection([item]);
};
onCreateAddTempItem = (items, folderId, fileAction) => {
if (items.length && items[0].id === -1) return; //TODO: if change media collection from state remove this;
const icon = fileAction.extension
@ -1477,7 +1448,6 @@ class SectionBodyContent extends React.Component {
{...checkedProps}
{...contextOptionsProps}
needForUpdate={this.needForUpdate}
selectItem={this.onSelectItem.bind(this, item)}
contextButtonSpacerWidth={displayShareButton}
>
<FilesRowContent
@ -1576,7 +1546,6 @@ export default connect(mapStateToProps, {
setDragItem,
setMediaViewerData,
setProgressBarData,
setSelection,
setSelected,
setUpdateTree,
setIsLoading,