2020-08-12 11:22:28 +03:00
|
|
|
|
import * as React from "react";
|
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
|
import * as Strings from "~/common/strings";
|
2020-09-08 00:45:58 +03:00
|
|
|
|
import * as SVG from "~/common/svg";
|
2020-10-27 05:01:33 +03:00
|
|
|
|
import * as Window from "~/common/window";
|
2020-11-22 00:25:40 +03:00
|
|
|
|
import * as UserBehaviors from "~/common/user-behaviors";
|
2020-11-28 07:39:01 +03:00
|
|
|
|
import * as Events from "~/common/custom-events";
|
2021-05-27 11:20:34 +03:00
|
|
|
|
import * as Styles from "~/common/styles";
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
2021-05-06 03:08:14 +03:00
|
|
|
|
import { Link } from "~/components/core/Link";
|
2020-11-30 08:24:22 +03:00
|
|
|
|
import { css } from "@emotion/react";
|
2020-09-08 00:45:58 +03:00
|
|
|
|
import { Boundary } from "~/components/system/components/fragments/Boundary";
|
|
|
|
|
import { PopoverNavigation } from "~/components/system/components/PopoverNavigation";
|
2020-09-18 06:40:10 +03:00
|
|
|
|
import { CheckBox } from "~/components/system/components/CheckBox";
|
|
|
|
|
import { Table } from "~/components/core/Table";
|
2020-09-18 07:28:32 +03:00
|
|
|
|
import { FileTypeIcon } from "~/components/core/FileTypeIcon";
|
2020-10-20 12:25:46 +03:00
|
|
|
|
import { ButtonPrimary, ButtonWarning } from "~/components/system/components/Buttons";
|
2021-02-04 20:59:15 +03:00
|
|
|
|
import { GroupSelectable, Selectable } from "~/components/core/Selectable/";
|
2021-05-27 11:20:34 +03:00
|
|
|
|
import { ConfirmationModal } from "~/components/core/ConfirmationModal";
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
2020-10-20 12:25:46 +03:00
|
|
|
|
import FilePreviewBubble from "~/components/core/FilePreviewBubble";
|
2021-05-27 11:20:34 +03:00
|
|
|
|
import ObjectPreview from "~/components/core/ObjectPreview";
|
2021-03-30 20:36:26 +03:00
|
|
|
|
import isEqual from "lodash/isEqual";
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
2020-09-18 06:40:10 +03:00
|
|
|
|
const STYLES_CONTAINER_HOVER = css`
|
|
|
|
|
display: flex;
|
|
|
|
|
:hover {
|
2021-07-07 22:14:51 +03:00
|
|
|
|
color: ${Constants.system.blue};
|
2020-09-18 06:40:10 +03:00
|
|
|
|
}
|
|
|
|
|
`;
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
2020-09-19 22:36:58 +03:00
|
|
|
|
const STYLES_ICON_BOX = css`
|
|
|
|
|
height: 32px;
|
|
|
|
|
width: 32px;
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
margin-left: 16px;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
|
const STYLES_CANCEL_BOX = css`
|
|
|
|
|
height: 16px;
|
|
|
|
|
width: 16px;
|
2021-07-07 22:14:51 +03:00
|
|
|
|
background-color: ${Constants.system.blue};
|
2020-09-23 23:52:00 +03:00
|
|
|
|
border-radius: 3px;
|
|
|
|
|
position: relative;
|
|
|
|
|
right: 3px;
|
|
|
|
|
cursor: pointer;
|
2021-07-07 22:14:51 +03:00
|
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.blue};
|
2020-09-23 23:52:00 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-09-19 22:36:58 +03:00
|
|
|
|
const STYLES_HEADER_LINE = css`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-top: 80px;
|
2020-09-23 23:52:00 +03:00
|
|
|
|
margin-bottom: 30px;
|
2020-09-19 22:36:58 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
|
const STYLES_LINK = css`
|
2020-09-18 06:40:10 +03:00
|
|
|
|
display: inline;
|
2020-08-12 11:22:28 +03:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: 200ms ease all;
|
2020-09-08 00:45:58 +03:00
|
|
|
|
font-size: 0.9rem;
|
|
|
|
|
padding: 12px 0px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
2020-10-22 08:27:49 +03:00
|
|
|
|
max-width: 320px;
|
|
|
|
|
@media (max-width: ${Constants.sizes.tablet}px) {
|
|
|
|
|
max-width: 120px;
|
|
|
|
|
}
|
2020-08-12 11:22:28 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-09-08 00:45:58 +03:00
|
|
|
|
const STYLES_VALUE = css`
|
|
|
|
|
font-size: 0.9rem;
|
|
|
|
|
padding: 12px 0px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-19 22:36:58 +03:00
|
|
|
|
const STYLES_ICON_BOX_HOVER = css`
|
2020-09-18 06:40:10 +03:00
|
|
|
|
display: inline-flex;
|
2020-09-08 00:45:58 +03:00
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
:hover {
|
2021-07-07 22:14:51 +03:00
|
|
|
|
color: ${Constants.system.blue};
|
2020-09-08 00:45:58 +03:00
|
|
|
|
}
|
2020-08-12 11:22:28 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-09-24 03:03:26 +03:00
|
|
|
|
const STYLES_ICON_BOX_BACKGROUND = css`
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
height: 25px;
|
|
|
|
|
width: 25px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
background-color: rgba(255, 255, 255, 0.75);
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 8px;
|
|
|
|
|
right: 8px;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
|
const STYLES_ACTION_BAR = css`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
border-radius: 4px;
|
2020-12-06 06:15:26 +03:00
|
|
|
|
padding: 0px 32px;
|
2020-09-27 23:11:04 +03:00
|
|
|
|
box-sizing: border-box;
|
2021-07-07 22:24:01 +03:00
|
|
|
|
background-color: ${Constants.semantic.textGrayDark};
|
2020-12-06 06:15:26 +03:00
|
|
|
|
width: 90vw;
|
|
|
|
|
max-width: 878px;
|
|
|
|
|
height: 48px;
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_ACTION_BAR_CONTAINER = css`
|
2020-09-27 23:11:04 +03:00
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 12px;
|
2020-12-06 06:15:26 +03:00
|
|
|
|
left: 0px;
|
|
|
|
|
width: 100vw;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
z-index: ${Constants.zindex.header};
|
2020-09-27 23:11:04 +03:00
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-11-28 02:02:16 +03:00
|
|
|
|
display: none;
|
2020-09-27 23:11:04 +03:00
|
|
|
|
}
|
2020-09-23 23:52:00 +03:00
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_RIGHT = css`
|
|
|
|
|
flex-shrink: 0;
|
2020-09-19 22:36:58 +03:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_LEFT = css`
|
|
|
|
|
width: 100%;
|
|
|
|
|
min-width: 10%;
|
2020-09-24 03:03:26 +03:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2020-09-19 22:36:58 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
|
const STYLES_FILES_SELECTED = css`
|
|
|
|
|
font-family: ${Constants.font.semiBold};
|
2020-12-06 06:15:26 +03:00
|
|
|
|
color: ${Constants.system.white};
|
2020-09-27 23:11:04 +03:00
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2020-09-19 22:36:58 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2020-09-08 00:45:58 +03:00
|
|
|
|
const STYLES_COPY_INPUT = css`
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
position: absolute;
|
|
|
|
|
opacity: 0;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_IMAGE_GRID = css`
|
2020-09-23 23:52:00 +03:00
|
|
|
|
display: grid;
|
2021-05-27 11:20:34 +03:00
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
|
|
|
|
|
grid-gap: 20px 12px;
|
|
|
|
|
|
2020-10-01 03:41:53 +03:00
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2021-05-27 11:20:34 +03:00
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
|
2020-10-01 03:41:53 +03:00
|
|
|
|
}
|
2020-09-08 00:45:58 +03:00
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_IMAGE_BOX = css`
|
2020-11-28 02:02:16 +03:00
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2020-09-08 00:45:58 +03:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
cursor: pointer;
|
2020-09-24 03:03:26 +03:00
|
|
|
|
position: relative;
|
2020-10-01 03:41:53 +03:00
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
|
margin: 12px auto;
|
|
|
|
|
}
|
2020-12-09 07:22:17 +03:00
|
|
|
|
:hover {
|
2021-07-07 22:58:14 +03:00
|
|
|
|
box-shadow: 0px 0px 0px 1px ${Constants.semantic.borderLight} inset,
|
2021-05-27 11:20:34 +03:00
|
|
|
|
${Constants.shadow.lightSmall};
|
2020-12-09 07:22:17 +03:00
|
|
|
|
}
|
2020-10-01 03:41:53 +03:00
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_MOBILE_HIDDEN = css`
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2020-08-12 11:22:28 +03:00
|
|
|
|
`;
|
|
|
|
|
|
2021-03-30 05:06:42 +03:00
|
|
|
|
const STYLES_TAGS_WRAPPER = css`
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
display: block;
|
|
|
|
|
width: 100%;
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_LIST = css`
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const STYLES_TAG = css`
|
|
|
|
|
list-style-type: none;
|
|
|
|
|
border-radius: 4px;
|
2021-07-07 22:18:11 +03:00
|
|
|
|
background: ${Constants.semantic.bgLight};
|
2021-07-07 22:14:51 +03:00
|
|
|
|
color: ${Constants.system.black};
|
2021-03-30 05:06:42 +03:00
|
|
|
|
font-family: ${Constants.font.text};
|
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
margin: 8px 8px 0 0;
|
|
|
|
|
span {
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
&:hover {
|
2021-07-07 21:56:04 +03:00
|
|
|
|
background: ${Constants.system.grayLight4};
|
2021-03-30 05:06:42 +03:00
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-03-30 20:36:26 +03:00
|
|
|
|
class Tags extends React.Component {
|
|
|
|
|
state = {
|
|
|
|
|
isTruncated: false,
|
|
|
|
|
truncateIndex: 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
listWrapper = React.createRef();
|
|
|
|
|
listEl = React.createRef();
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this._handleTruncate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
|
if (!isEqual(prevProps.tags, this.props.tags)) {
|
|
|
|
|
this._handleTruncate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_handleTruncate = () => {
|
|
|
|
|
const listWrapper = this.listWrapper.current?.getBoundingClientRect();
|
|
|
|
|
const tagNodes = this.listEl.current?.querySelectorAll("li");
|
|
|
|
|
const tagElems = Array.from(tagNodes);
|
|
|
|
|
|
|
|
|
|
let total = 0;
|
|
|
|
|
const truncateIndex = tagElems.findIndex((tagElem) => {
|
|
|
|
|
const { width } = tagElem?.getBoundingClientRect();
|
|
|
|
|
total += width;
|
|
|
|
|
|
|
|
|
|
if (total >= listWrapper.width - 50) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (truncateIndex > 0) {
|
|
|
|
|
this.setState({ isTruncated: true, truncateIndex });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState({ isTruncated: false, truncateIndex: tagElems.length });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { tags } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div css={STYLES_TAGS_WRAPPER}>
|
|
|
|
|
<div ref={this.listWrapper} style={{ width: 340 }}>
|
|
|
|
|
<ul css={STYLES_LIST} ref={this.listEl}>
|
|
|
|
|
{(this.state.isTruncated ? tags.slice(0, this.state.truncateIndex) : tags).map(
|
|
|
|
|
(tag) => (
|
|
|
|
|
<li key={tag} css={STYLES_TAG}>
|
|
|
|
|
<span>{tag}</span>
|
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
</ul>
|
|
|
|
|
{this.state.isTruncated && <span>...</span>}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
|
export default class DataView extends React.Component {
|
2020-09-09 07:12:54 +03:00
|
|
|
|
_mounted = false;
|
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
|
state = {
|
2020-09-08 00:45:58 +03:00
|
|
|
|
menu: null,
|
2020-09-19 22:36:58 +03:00
|
|
|
|
checked: {},
|
2020-10-25 06:35:10 +03:00
|
|
|
|
viewLimit: 40,
|
2020-10-21 04:57:05 +03:00
|
|
|
|
scrollDebounce: false,
|
2020-11-28 02:02:16 +03:00
|
|
|
|
imageSize: 100,
|
2021-05-12 17:17:24 +03:00
|
|
|
|
modalShow: false,
|
2020-08-12 11:22:28 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-12-02 02:27:50 +03:00
|
|
|
|
isShiftDown = false;
|
|
|
|
|
lastSelectedItemIndex = null;
|
|
|
|
|
|
2020-11-30 17:42:18 +03:00
|
|
|
|
gridWrapperEl = React.createRef();
|
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
|
async componentDidMount() {
|
2020-11-28 02:02:16 +03:00
|
|
|
|
this.calculateWidth();
|
|
|
|
|
this.debounceInstance = Window.debounce(this.calculateWidth, 200);
|
2020-11-13 01:36:20 +03:00
|
|
|
|
if (!this._mounted) {
|
|
|
|
|
this._mounted = true;
|
|
|
|
|
window.addEventListener("scroll", this._handleCheckScroll);
|
2020-11-28 02:02:16 +03:00
|
|
|
|
window.addEventListener("resize", this.debounceInstance);
|
2020-11-30 17:42:18 +03:00
|
|
|
|
window.addEventListener("keydown", this._handleKeyDown);
|
|
|
|
|
window.addEventListener("keyup", this._handleKeyUp);
|
2020-11-30 18:50:46 +03:00
|
|
|
|
|
|
|
|
|
if (this.gridWrapperEl.current) {
|
|
|
|
|
this.gridWrapperEl.current.addEventListener("selectstart", this._handleSelectStart);
|
|
|
|
|
}
|
2020-09-09 07:12:54 +03:00
|
|
|
|
}
|
2020-08-12 11:22:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
|
componentWillUnmount() {
|
2020-11-13 01:36:20 +03:00
|
|
|
|
this._mounted = false;
|
2020-10-21 05:16:48 +03:00
|
|
|
|
window.removeEventListener("scroll", this._handleCheckScroll);
|
2020-11-28 02:02:16 +03:00
|
|
|
|
window.removeEventListener("resize", this.debounceInstance);
|
2020-11-30 17:42:18 +03:00
|
|
|
|
window.removeEventListener("keydown", this._handleKeyDown);
|
|
|
|
|
window.removeEventListener("keyup", this._handleKeyUp);
|
2020-11-30 18:50:46 +03:00
|
|
|
|
|
|
|
|
|
if (this.gridWrapperEl.current) {
|
|
|
|
|
this.gridWrapperEl.current.removeEventListener("selectstart", this._handleSelectStart);
|
|
|
|
|
}
|
2020-09-09 07:12:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-28 02:02:16 +03:00
|
|
|
|
calculateWidth = () => {
|
|
|
|
|
let windowWidth = window.innerWidth;
|
|
|
|
|
let imageSize;
|
|
|
|
|
if (windowWidth < Constants.sizes.mobile) {
|
|
|
|
|
imageSize = (windowWidth - 2 * 24 - 20) / 2;
|
|
|
|
|
} else {
|
|
|
|
|
imageSize = (windowWidth - 2 * 56 - 4 * 20) / 5;
|
|
|
|
|
}
|
|
|
|
|
this.setState({ imageSize });
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-20 09:53:58 +03:00
|
|
|
|
_handleScroll = (e) => {
|
|
|
|
|
const windowHeight =
|
|
|
|
|
"innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight;
|
|
|
|
|
const body = document.body;
|
|
|
|
|
const html = document.documentElement;
|
|
|
|
|
const docHeight = Math.max(
|
|
|
|
|
body.scrollHeight,
|
|
|
|
|
body.offsetHeight,
|
|
|
|
|
html.clientHeight,
|
|
|
|
|
html.scrollHeight,
|
|
|
|
|
html.offsetHeight
|
|
|
|
|
);
|
2020-10-23 07:34:02 +03:00
|
|
|
|
const windowBottom = windowHeight + window.pageYOffset;
|
2020-10-25 06:35:10 +03:00
|
|
|
|
if (windowBottom >= docHeight - 600) {
|
2020-10-23 06:49:18 +03:00
|
|
|
|
this.setState({ viewLimit: this.state.viewLimit + 30 });
|
2020-09-19 22:36:58 +03:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-27 11:23:54 +03:00
|
|
|
|
_handleCheckScroll = Window.debounce(this._handleScroll, 200);
|
2020-10-21 05:16:48 +03:00
|
|
|
|
|
2020-12-02 02:27:50 +03:00
|
|
|
|
/* NOTE(daniel): This disable text selection while pressing shift key */
|
2020-11-30 17:42:18 +03:00
|
|
|
|
_handleSelectStart = (e) => {
|
2020-12-02 02:27:50 +03:00
|
|
|
|
if (this.isShiftDown) {
|
2020-11-30 17:42:18 +03:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-09 21:10:31 +03:00
|
|
|
|
_addSelectedItemsOnDrag = (e) => {
|
2021-02-05 21:29:12 +03:00
|
|
|
|
let selectedItems = {};
|
|
|
|
|
for (const i of e) {
|
|
|
|
|
selectedItems[i] = true;
|
|
|
|
|
}
|
2021-02-09 21:38:19 +03:00
|
|
|
|
this.setState({ checked: { ...this.state.checked, ...selectedItems } });
|
2021-02-04 20:59:15 +03:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-09 21:10:31 +03:00
|
|
|
|
_removeSelectedItemsOnDrag = (e) => {
|
|
|
|
|
const selectedItems = { ...this.state.checked };
|
|
|
|
|
for (const i in selectedItems) {
|
|
|
|
|
selectedItems[i] = selectedItems[i] && !e.includes(+i);
|
|
|
|
|
if (!selectedItems[i]) delete selectedItems[i];
|
|
|
|
|
}
|
|
|
|
|
this.setState({ checked: selectedItems, ...selectedItems });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_handleDragAndSelect = (e, { isAltDown }) => {
|
|
|
|
|
if (isAltDown) {
|
|
|
|
|
this._removeSelectedItemsOnDrag(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._addSelectedItemsOnDrag(e);
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-30 17:42:18 +03:00
|
|
|
|
_handleKeyUp = (e) => {
|
2020-12-02 02:27:50 +03:00
|
|
|
|
if (e.keyCode === 16 && this.isShiftDown) {
|
|
|
|
|
this.isShiftDown = false;
|
2020-11-30 17:42:18 +03:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_handleKeyDown = (e) => {
|
2020-12-02 02:27:50 +03:00
|
|
|
|
if (e.keyCode === 16 && !this.isShiftDown) {
|
|
|
|
|
this.isShiftDown = true;
|
2020-11-30 17:42:18 +03:00
|
|
|
|
}
|
2021-02-11 09:59:28 +03:00
|
|
|
|
|
|
|
|
|
let numChecked = Object.keys(this.state.checked).length || 0;
|
|
|
|
|
if (e.keyCode === 27 && numChecked) {
|
|
|
|
|
this._handleUncheckAll();
|
|
|
|
|
}
|
2020-11-30 17:42:18 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-12-02 02:27:50 +03:00
|
|
|
|
_handleCheckBox = (e, i) => {
|
2020-11-30 17:42:18 +03:00
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
let checked = this.state.checked;
|
2020-12-02 02:27:50 +03:00
|
|
|
|
if (this.isShiftDown && this.lastSelectedItemIndex !== i) {
|
2020-11-30 19:17:48 +03:00
|
|
|
|
return this._handleShiftClick({
|
|
|
|
|
currentSelectedItemIndex: i,
|
2020-12-02 02:27:50 +03:00
|
|
|
|
lastSelectedItemIndex: this.lastSelectedItemIndex,
|
2020-11-30 19:17:48 +03:00
|
|
|
|
checked,
|
|
|
|
|
});
|
2020-11-30 17:42:18 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (checked[i]) {
|
|
|
|
|
delete checked[i];
|
|
|
|
|
} else {
|
|
|
|
|
checked[i] = true;
|
|
|
|
|
}
|
2020-12-02 02:27:50 +03:00
|
|
|
|
this.setState({ checked });
|
|
|
|
|
this.lastSelectedItemIndex = i;
|
2020-11-30 17:42:18 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-11-30 19:17:48 +03:00
|
|
|
|
_handleShiftClick = ({ currentSelectedItemIndex, lastSelectedItemIndex, checked }) => {
|
|
|
|
|
const start = Math.min(currentSelectedItemIndex, lastSelectedItemIndex);
|
|
|
|
|
const stop = Math.max(currentSelectedItemIndex, lastSelectedItemIndex) + 1;
|
|
|
|
|
|
|
|
|
|
let rangeSelected = {};
|
|
|
|
|
|
|
|
|
|
for (let i = start; i < stop; i++) {
|
|
|
|
|
if (checked[currentSelectedItemIndex]) {
|
|
|
|
|
delete checked[i];
|
|
|
|
|
} else {
|
|
|
|
|
rangeSelected[i] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let newSelection = Object.assign({}, checked, rangeSelected);
|
2020-12-02 02:27:50 +03:00
|
|
|
|
this.setState({ checked: newSelection });
|
|
|
|
|
this.lastSelectedItemIndex = currentSelectedItemIndex;
|
2020-11-30 19:17:48 +03:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-03 11:48:59 +03:00
|
|
|
|
_handleDownloadFiles = async () => {
|
2021-05-06 03:08:14 +03:00
|
|
|
|
if (!this.props.viewer) {
|
|
|
|
|
Events.dispatchCustomEvent({ name: "slate-global-open-cta", detail: {} });
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-03 11:48:59 +03:00
|
|
|
|
const selectedFiles = this.props.items.filter((_, i) => this.state.checked[i]);
|
2021-03-05 10:32:08 +03:00
|
|
|
|
UserBehaviors.compressAndDownloadFiles({
|
|
|
|
|
files: selectedFiles,
|
|
|
|
|
resourceURI: this.props.resources.download,
|
|
|
|
|
});
|
2021-03-03 13:01:34 +03:00
|
|
|
|
this.setState({ checked: {} });
|
2021-03-02 16:33:10 +03:00
|
|
|
|
};
|
2021-03-03 11:48:59 +03:00
|
|
|
|
|
2021-05-12 17:17:24 +03:00
|
|
|
|
_handleDelete = (res, id) => {
|
|
|
|
|
if (!res) {
|
|
|
|
|
this.setState({ modalShow: false });
|
2020-09-19 22:36:58 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-25 12:17:37 +03:00
|
|
|
|
|
2020-11-30 02:47:08 +03:00
|
|
|
|
let ids;
|
2021-03-07 23:53:54 +03:00
|
|
|
|
if (id) {
|
2020-11-30 02:47:08 +03:00
|
|
|
|
ids = [id];
|
2020-10-05 00:30:28 +03:00
|
|
|
|
} else {
|
2020-11-30 02:47:08 +03:00
|
|
|
|
ids = Object.keys(this.state.checked).map((id) => {
|
|
|
|
|
let index = parseInt(id);
|
2021-03-07 23:53:54 +03:00
|
|
|
|
let item = this.props.viewer.library[index];
|
2020-11-30 02:47:08 +03:00
|
|
|
|
return item.id;
|
|
|
|
|
});
|
2020-10-05 00:30:28 +03:00
|
|
|
|
}
|
2020-11-25 12:17:37 +03:00
|
|
|
|
|
2021-04-20 04:07:19 +03:00
|
|
|
|
let library = this.props.viewer.library.filter((obj) => !ids.includes(obj.id));
|
2021-05-06 03:08:14 +03:00
|
|
|
|
this.props.onAction({ type: "UPDATE_VIEWER", viewer: { library } });
|
2020-12-15 04:43:16 +03:00
|
|
|
|
|
2021-03-07 23:53:54 +03:00
|
|
|
|
UserBehaviors.deleteFiles(ids);
|
2021-05-12 17:17:24 +03:00
|
|
|
|
this.setState({ checked: {}, modalShow: false });
|
2020-09-19 22:36:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
2021-03-31 00:31:29 +03:00
|
|
|
|
_handleCheckBoxMouseEnter = (i) => {
|
2021-03-31 22:21:02 +03:00
|
|
|
|
if (this.props.isOwner) {
|
|
|
|
|
this.setState({ hover: i });
|
|
|
|
|
}
|
2021-02-05 21:29:12 +03:00
|
|
|
|
};
|
|
|
|
|
|
2021-03-31 00:31:29 +03:00
|
|
|
|
_handleCheckBoxMouseLeave = (i) => {
|
2021-03-31 22:21:02 +03:00
|
|
|
|
if (this.props.isOwner) {
|
|
|
|
|
this.setState({ hover: null });
|
|
|
|
|
}
|
2021-02-05 21:29:12 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-09-08 00:45:58 +03:00
|
|
|
|
_handleCopy = (e, value) => {
|
|
|
|
|
e.stopPropagation();
|
2020-09-13 03:53:36 +03:00
|
|
|
|
this._handleHide();
|
2020-09-08 00:45:58 +03:00
|
|
|
|
this.setState({ copyValue: value }, () => {
|
|
|
|
|
this._ref.select();
|
|
|
|
|
document.execCommand("copy");
|
2020-08-20 08:45:43 +03:00
|
|
|
|
});
|
2020-08-12 11:22:28 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-09-08 00:45:58 +03:00
|
|
|
|
_handleHide = (e) => {
|
|
|
|
|
this.setState({ menu: null });
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
|
_handleClick = (e) => {
|
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
|
_handleAddToSlate = (e) => {
|
2021-05-06 03:08:14 +03:00
|
|
|
|
if (!this.props.viewer) {
|
|
|
|
|
Events.dispatchCustomEvent({ name: "slate-global-open-cta", detail: {} });
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-07 23:53:54 +03:00
|
|
|
|
let userFiles = this.props.viewer.library;
|
2020-10-20 12:25:46 +03:00
|
|
|
|
let files = Object.keys(this.state.checked).map((index) => userFiles[index]);
|
2020-09-23 23:52:00 +03:00
|
|
|
|
this.props.onAction({
|
|
|
|
|
type: "SIDEBAR",
|
|
|
|
|
value: "SIDEBAR_ADD_FILE_TO_SLATE",
|
|
|
|
|
data: { files },
|
|
|
|
|
});
|
|
|
|
|
this._handleUncheckAll();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_handleUncheckAll = () => {
|
2020-12-02 02:27:50 +03:00
|
|
|
|
this.setState({ checked: {} });
|
|
|
|
|
this.lastSelectedItemIndex = null;
|
2020-09-23 23:52:00 +03:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-12 18:12:20 +03:00
|
|
|
|
/** Note(Amine): These methods will stop collision between
|
|
|
|
|
Drag to desktop event and drop to upload
|
|
|
|
|
*/
|
|
|
|
|
_stopPropagation = (e) => e.stopPropagation();
|
|
|
|
|
|
|
|
|
|
_disableDragAndDropUploadEvent = () => {
|
|
|
|
|
document.addEventListener("dragenter", this._stopPropagation);
|
|
|
|
|
document.addEventListener("drop", this._stopPropagation);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_enableDragAndDropUploadEvent = () => {
|
|
|
|
|
document.removeEventListener("dragenter", this._stopPropagation);
|
|
|
|
|
document.removeEventListener("drop", this._stopPropagation);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_handleDragToDesktop = (e, object) => {
|
2021-03-07 23:53:54 +03:00
|
|
|
|
const url = Strings.getURLfromCID(object.cid);
|
|
|
|
|
const title = object.filename || object.data.name;
|
|
|
|
|
const type = object.data.type;
|
2021-05-27 11:20:34 +03:00
|
|
|
|
console.log(e.dataTransfer, e.dataTransfer.setData);
|
2021-02-12 18:12:20 +03:00
|
|
|
|
e.dataTransfer.setData("DownloadURL", `${type}:${title}:${url}`);
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-30 05:06:42 +03:00
|
|
|
|
getCommonTagFromSelectedItems = () => {
|
|
|
|
|
const { items } = this.props;
|
|
|
|
|
const { checked } = this.state;
|
|
|
|
|
|
|
|
|
|
if (!Object.keys(checked).length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let allTagsFromSelectedItems = Object.keys(checked).map((index) =>
|
2021-04-20 04:07:19 +03:00
|
|
|
|
items[index].data.tags ? items[index].data.tags : []
|
2021-03-30 05:06:42 +03:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let sortedItems = allTagsFromSelectedItems.sort((a, b) => a.length - b.length);
|
2021-04-01 13:12:48 +03:00
|
|
|
|
if (sortedItems.length === 0) {
|
2021-03-30 05:06:42 +03:00
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let commonTags = sortedItems.shift().reduce((acc, cur) => {
|
|
|
|
|
if (acc.indexOf(cur) === -1 && sortedItems.every((item) => item.indexOf(cur) !== -1)) {
|
|
|
|
|
acc.push(cur);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return commonTags;
|
|
|
|
|
};
|
2020-08-12 11:22:28 +03:00
|
|
|
|
render() {
|
2020-09-27 07:43:25 +03:00
|
|
|
|
let numChecked = Object.keys(this.state.checked).length || 0;
|
2020-12-18 00:49:39 +03:00
|
|
|
|
// const header = (
|
|
|
|
|
// <div css={STYLES_HEADER_LINE}>
|
|
|
|
|
// <span css={STYLES_MOBILE_HIDDEN}>
|
|
|
|
|
// <div
|
|
|
|
|
// css={STYLES_ICON_BOX}
|
|
|
|
|
// onClick={() => {
|
|
|
|
|
// this.setState({ view: "grid", menu: null });
|
|
|
|
|
// }}
|
|
|
|
|
// >
|
|
|
|
|
// <SVG.GridView
|
|
|
|
|
// style={{
|
|
|
|
|
// color: this.props.view === 0 ? Constants.system.black : "rgba(0,0,0,0.25)",
|
|
|
|
|
// }}
|
|
|
|
|
// height="24px"
|
|
|
|
|
// />
|
|
|
|
|
// </div>
|
|
|
|
|
// </span>
|
|
|
|
|
// <span css={STYLES_MOBILE_HIDDEN}>
|
|
|
|
|
// <div
|
|
|
|
|
// css={STYLES_ICON_BOX}
|
|
|
|
|
// onClick={() => {
|
|
|
|
|
// this.setState({ view: "list", menu: null });
|
|
|
|
|
// }}
|
|
|
|
|
// >
|
|
|
|
|
// <SVG.TableView
|
|
|
|
|
// style={{
|
|
|
|
|
// color: this.state.view === "list" ? Constants.system.black : "rgba(0,0,0,0.25)",
|
|
|
|
|
// }}
|
|
|
|
|
// height="24px"
|
|
|
|
|
// />
|
|
|
|
|
// </div>
|
|
|
|
|
// </span>
|
|
|
|
|
// </div>
|
|
|
|
|
// );
|
2021-05-12 17:17:24 +03:00
|
|
|
|
|
2020-09-19 22:44:04 +03:00
|
|
|
|
const footer = (
|
2020-09-23 23:52:00 +03:00
|
|
|
|
<React.Fragment>
|
2020-09-24 03:03:26 +03:00
|
|
|
|
{numChecked ? (
|
2020-12-06 06:15:26 +03:00
|
|
|
|
<div css={STYLES_ACTION_BAR_CONTAINER}>
|
|
|
|
|
<div css={STYLES_ACTION_BAR}>
|
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
|
<span css={STYLES_FILES_SELECTED}>
|
|
|
|
|
{numChecked} file{numChecked > 1 ? "s" : ""} selected
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div css={STYLES_RIGHT}>
|
2020-12-22 04:20:24 +03:00
|
|
|
|
<ButtonPrimary
|
|
|
|
|
transparent
|
|
|
|
|
style={{ color: Constants.system.white }}
|
|
|
|
|
onClick={this._handleAddToSlate}
|
|
|
|
|
>
|
2021-04-23 08:18:46 +03:00
|
|
|
|
Add to collection
|
2020-12-22 04:20:24 +03:00
|
|
|
|
</ButtonPrimary>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
{this.props.isOwner && (
|
|
|
|
|
<ButtonPrimary
|
|
|
|
|
transparent
|
|
|
|
|
style={{ color: Constants.system.white }}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
this.props.onAction({
|
|
|
|
|
type: "SIDEBAR",
|
|
|
|
|
value: "SIDEBAR_EDIT_TAGS",
|
|
|
|
|
data: {
|
|
|
|
|
numChecked,
|
|
|
|
|
commonTags: this.getCommonTagFromSelectedItems(),
|
|
|
|
|
objects: this.props.items,
|
|
|
|
|
checked: this.state.checked,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Edit tags
|
|
|
|
|
</ButtonPrimary>
|
|
|
|
|
)}
|
2021-03-02 16:33:10 +03:00
|
|
|
|
<ButtonWarning
|
|
|
|
|
transparent
|
|
|
|
|
style={{ marginLeft: 8, color: Constants.system.white }}
|
|
|
|
|
onClick={() => this._handleDownloadFiles()}
|
|
|
|
|
>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
Download
|
2021-03-02 16:33:10 +03:00
|
|
|
|
</ButtonWarning>
|
2021-03-07 23:53:54 +03:00
|
|
|
|
{this.props.isOwner && (
|
|
|
|
|
<ButtonWarning
|
|
|
|
|
transparent
|
|
|
|
|
style={{ marginLeft: 8, color: Constants.system.white }}
|
2021-05-12 17:17:24 +03:00
|
|
|
|
onClick={() => this.setState({ modalShow: true })}
|
2021-03-07 23:53:54 +03:00
|
|
|
|
>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
Delete
|
2021-03-07 23:53:54 +03:00
|
|
|
|
</ButtonWarning>
|
|
|
|
|
)}
|
2021-05-12 17:17:24 +03:00
|
|
|
|
{this.state.modalShow && (
|
2021-05-06 03:08:14 +03:00
|
|
|
|
<ConfirmationModal
|
2021-05-12 17:17:24 +03:00
|
|
|
|
type={"DELETE"}
|
|
|
|
|
withValidation={false}
|
2021-05-06 03:08:14 +03:00
|
|
|
|
callback={this._handleDelete}
|
2021-05-12 17:17:24 +03:00
|
|
|
|
header={`Are you sure you want to delete the selected files?`}
|
|
|
|
|
subHeader={`These files will be deleted from all connected collections and your file library. You can’t undo this action.`}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2020-12-06 06:15:26 +03:00
|
|
|
|
<div
|
|
|
|
|
css={STYLES_ICON_BOX}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
this.setState({ checked: {} });
|
|
|
|
|
this.lastSelectedItemIndex = null;
|
|
|
|
|
}}
|
|
|
|
|
>
|
2021-07-07 22:58:14 +03:00
|
|
|
|
<SVG.Dismiss height="20px" style={{ color: Constants.system.grayLight2 }} />
|
2020-12-06 06:15:26 +03:00
|
|
|
|
</div>
|
2020-09-24 03:03:26 +03:00
|
|
|
|
</div>
|
2020-09-23 23:52:00 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
</React.Fragment>
|
2020-09-19 22:44:04 +03:00
|
|
|
|
);
|
2021-05-06 03:08:14 +03:00
|
|
|
|
if (this.props.view === "grid") {
|
2020-09-08 00:45:58 +03:00
|
|
|
|
return (
|
2020-09-19 22:36:58 +03:00
|
|
|
|
<React.Fragment>
|
2021-02-09 21:38:19 +03:00
|
|
|
|
<GroupSelectable onSelection={this._handleDragAndSelect}>
|
2021-05-27 11:20:34 +03:00
|
|
|
|
<div css={Styles.OBJECTS_PREVIEW_GRID} ref={this.gridWrapperEl}>
|
2021-02-04 20:59:15 +03:00
|
|
|
|
{this.props.items.slice(0, this.state.viewLimit).map((each, i) => {
|
|
|
|
|
return (
|
2021-05-06 03:08:14 +03:00
|
|
|
|
<Link
|
2021-02-05 21:29:12 +03:00
|
|
|
|
key={each.id}
|
2021-05-06 03:08:14 +03:00
|
|
|
|
redirect
|
|
|
|
|
params={{ ...this.props.page?.params, cid: each.cid }}
|
|
|
|
|
onAction={this.props.onAction}
|
2021-02-12 18:12:20 +03:00
|
|
|
|
>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
<Selectable
|
|
|
|
|
key={each.id}
|
|
|
|
|
draggable={!numChecked}
|
|
|
|
|
onDragStart={(e) => {
|
|
|
|
|
this._disableDragAndDropUploadEvent();
|
|
|
|
|
this._handleDragToDesktop(e, each);
|
|
|
|
|
}}
|
|
|
|
|
onDragEnd={this._enableDragAndDropUploadEvent}
|
|
|
|
|
selectableKey={i}
|
|
|
|
|
onMouseEnter={() => this._handleCheckBoxMouseEnter(i)}
|
|
|
|
|
onMouseLeave={() => this._handleCheckBoxMouseLeave(i)}
|
|
|
|
|
>
|
2021-05-27 11:20:34 +03:00
|
|
|
|
<div style={{ position: "relative" }}>
|
|
|
|
|
<ObjectPreview
|
|
|
|
|
viewer={this.props.viewer}
|
|
|
|
|
file={each}
|
|
|
|
|
owner={this.props.user}
|
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
|
isSelected={i in this.state.checked}
|
|
|
|
|
/>
|
|
|
|
|
<span css={STYLES_MOBILE_HIDDEN} style={{ pointerEvents: "auto" }}>
|
|
|
|
|
{numChecked || this.state.hover === i || this.state.menu === each.id ? (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<div
|
|
|
|
|
style={{ position: "absolute", zIndex: 1, left: 16, top: 16 }}
|
|
|
|
|
onClick={(e) => this._handleCheckBox(e, i)}
|
|
|
|
|
>
|
|
|
|
|
<CheckBox
|
|
|
|
|
name={i}
|
|
|
|
|
value={!!this.state.checked[i]}
|
|
|
|
|
boxStyle={{
|
|
|
|
|
height: 24,
|
|
|
|
|
width: 24,
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
boxShadow: `0 0 0 1px ${Constants.system.white}`,
|
|
|
|
|
backgroundColor: this.state.checked[i]
|
|
|
|
|
? Constants.system.blue
|
|
|
|
|
: "rgba(255, 255, 255, 0.75)",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
) : null}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
</Selectable>
|
|
|
|
|
</Link>
|
2021-02-04 20:59:15 +03:00
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
{[0, 1, 2, 3].map((i) => (
|
|
|
|
|
<div
|
|
|
|
|
key={i}
|
|
|
|
|
css={STYLES_IMAGE_BOX}
|
|
|
|
|
style={{ boxShadow: "none", cursor: "default" }}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</GroupSelectable>
|
2020-09-19 22:44:04 +03:00
|
|
|
|
{footer}
|
2020-09-24 03:03:26 +03:00
|
|
|
|
<input
|
|
|
|
|
ref={(c) => {
|
|
|
|
|
this._ref = c;
|
|
|
|
|
}}
|
|
|
|
|
readOnly
|
|
|
|
|
value={this.state.copyValue}
|
|
|
|
|
css={STYLES_COPY_INPUT}
|
|
|
|
|
/>
|
2020-09-19 22:36:58 +03:00
|
|
|
|
</React.Fragment>
|
2020-09-08 00:45:58 +03:00
|
|
|
|
);
|
|
|
|
|
}
|
2020-09-13 03:53:36 +03:00
|
|
|
|
|
2020-09-18 06:40:10 +03:00
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
key: "checkbox",
|
2020-09-24 03:03:26 +03:00
|
|
|
|
name: numChecked ? (
|
2020-11-30 18:50:46 +03:00
|
|
|
|
<div
|
|
|
|
|
css={STYLES_CANCEL_BOX}
|
2020-12-02 02:27:50 +03:00
|
|
|
|
onClick={() => {
|
|
|
|
|
this.setState({ checked: {} });
|
|
|
|
|
this.lastSelectedItemIndex = null;
|
|
|
|
|
}}
|
2020-11-30 18:50:46 +03:00
|
|
|
|
>
|
2020-10-20 12:25:46 +03:00
|
|
|
|
<SVG.Minus height="16px" style={{ color: Constants.system.white }} />
|
2020-09-23 23:52:00 +03:00
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<span />
|
|
|
|
|
),
|
2020-09-18 06:40:10 +03:00
|
|
|
|
width: "24px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: "name",
|
|
|
|
|
name: <div style={{ fontSize: "0.9rem", padding: "18px 0" }}>Name</div>,
|
|
|
|
|
width: "100%",
|
|
|
|
|
},
|
2021-03-30 05:06:42 +03:00
|
|
|
|
{
|
|
|
|
|
key: "tags",
|
|
|
|
|
name: <div style={{ fontSize: "0.9rem", padding: "18px 0" }}>Tags</div>,
|
2021-03-30 20:36:26 +03:00
|
|
|
|
width: "360px",
|
2021-03-30 05:06:42 +03:00
|
|
|
|
},
|
2020-09-18 06:40:10 +03:00
|
|
|
|
{
|
|
|
|
|
key: "size",
|
|
|
|
|
name: <div style={{ fontSize: "0.9rem", padding: "18px 0" }}>Size</div>,
|
|
|
|
|
width: "104px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: "more",
|
|
|
|
|
name: <span />,
|
|
|
|
|
width: "48px",
|
|
|
|
|
},
|
|
|
|
|
];
|
2021-03-30 05:06:42 +03:00
|
|
|
|
|
2020-11-13 01:36:20 +03:00
|
|
|
|
const rows = this.props.items.slice(0, this.state.viewLimit).map((each, index) => {
|
2020-11-28 04:19:30 +03:00
|
|
|
|
const cid = each.cid;
|
2020-11-13 01:36:20 +03:00
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...each,
|
|
|
|
|
checkbox: (
|
2020-12-02 02:27:50 +03:00
|
|
|
|
<div onClick={(e) => this._handleCheckBox(e, index)}>
|
|
|
|
|
<CheckBox
|
|
|
|
|
name={index}
|
|
|
|
|
value={!!this.state.checked[index]}
|
|
|
|
|
boxStyle={{ height: 16, width: 16 }}
|
|
|
|
|
style={{
|
|
|
|
|
position: "relative",
|
|
|
|
|
right: 3,
|
|
|
|
|
margin: "12px 0",
|
|
|
|
|
opacity: numChecked > 0 || this.state.hover === index ? "100%" : "0%",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2020-11-13 01:36:20 +03:00
|
|
|
|
),
|
|
|
|
|
name: (
|
2021-02-12 21:08:07 +03:00
|
|
|
|
<Selectable
|
|
|
|
|
key={each.id}
|
|
|
|
|
selectableKey={index}
|
|
|
|
|
draggable={!numChecked}
|
|
|
|
|
onDragStart={(e) => {
|
|
|
|
|
this._disableDragAndDropUploadEvent();
|
|
|
|
|
this._handleDragToDesktop(e, each);
|
|
|
|
|
}}
|
|
|
|
|
onDragEnd={this._enableDragAndDropUploadEvent}
|
|
|
|
|
>
|
2021-03-07 23:53:54 +03:00
|
|
|
|
<FilePreviewBubble cid={cid} type={each.data.type}>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
<Link
|
|
|
|
|
redirect
|
|
|
|
|
params={{ ...this.props.page.params, cid: each.cid }}
|
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
|
>
|
|
|
|
|
<div css={STYLES_CONTAINER_HOVER}>
|
|
|
|
|
<div css={STYLES_ICON_BOX_HOVER} style={{ paddingLeft: 0, paddingRight: 18 }}>
|
2021-07-07 23:50:57 +03:00
|
|
|
|
<FileTypeIcon file={each} height="24px" />
|
2021-05-06 03:08:14 +03:00
|
|
|
|
</div>
|
|
|
|
|
<div css={STYLES_LINK}>{each.data.name || each.filename}</div>
|
2021-02-05 21:29:12 +03:00
|
|
|
|
</div>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
</Link>
|
2021-02-05 21:29:12 +03:00
|
|
|
|
</FilePreviewBubble>
|
|
|
|
|
</Selectable>
|
2020-11-13 01:36:20 +03:00
|
|
|
|
),
|
2021-07-14 02:03:01 +03:00
|
|
|
|
tags: <>{each.data.tags?.length ? <Tags tags={each.data.tags} /> : null}</>,
|
2021-04-20 01:44:48 +03:00
|
|
|
|
size: <div css={STYLES_VALUE}>{Strings.bytesToSize(each.data.size)}</div>,
|
2021-05-06 03:08:14 +03:00
|
|
|
|
more: this.props.isOwner ? (
|
2020-11-13 01:36:20 +03:00
|
|
|
|
<div
|
|
|
|
|
css={STYLES_ICON_BOX_HOVER}
|
2020-12-22 04:20:24 +03:00
|
|
|
|
onClick={() =>
|
|
|
|
|
this.setState({
|
|
|
|
|
menu: this.state.menu === each.id ? null : each.id,
|
|
|
|
|
})
|
2020-11-13 01:36:20 +03:00
|
|
|
|
}
|
|
|
|
|
>
|
2020-12-22 04:20:24 +03:00
|
|
|
|
<SVG.MoreHorizontal height="24px" />
|
2020-11-13 01:36:20 +03:00
|
|
|
|
{this.state.menu === each.id ? (
|
|
|
|
|
<Boundary
|
|
|
|
|
captureResize={true}
|
|
|
|
|
captureScroll={false}
|
|
|
|
|
enabled
|
|
|
|
|
onOutsideRectEvent={this._handleHide}
|
|
|
|
|
>
|
|
|
|
|
<PopoverNavigation
|
|
|
|
|
style={{
|
|
|
|
|
top: "48px",
|
|
|
|
|
right: "40px",
|
|
|
|
|
}}
|
|
|
|
|
navigation={[
|
2021-05-06 03:08:14 +03:00
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
text: "Copy CID",
|
|
|
|
|
onClick: (e) => this._handleCopy(e, cid),
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// text: "Copy link",
|
|
|
|
|
// onClick: (e) => this._handleCopy(e, Strings.getURLfromCID(cid)),
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
text: "Delete",
|
|
|
|
|
onClick: (e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
this.setState({ menu: null, modalShow: true });
|
|
|
|
|
},
|
2020-11-13 01:36:20 +03:00
|
|
|
|
},
|
2021-05-06 03:08:14 +03:00
|
|
|
|
],
|
2020-11-13 01:36:20 +03:00
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</Boundary>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
2021-05-06 03:08:14 +03:00
|
|
|
|
) : null,
|
2020-11-13 01:36:20 +03:00
|
|
|
|
};
|
|
|
|
|
});
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
columns,
|
|
|
|
|
rows,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2020-09-18 06:40:10 +03:00
|
|
|
|
<React.Fragment>
|
2021-02-09 21:38:19 +03:00
|
|
|
|
<GroupSelectable enabled={true} onSelection={this._handleDragAndSelect}>
|
2021-02-08 11:21:44 +03:00
|
|
|
|
{({ isSelecting }) => (
|
|
|
|
|
<Table
|
|
|
|
|
data={data}
|
|
|
|
|
rowStyle={{
|
|
|
|
|
padding: "10px 16px",
|
|
|
|
|
textAlign: "left",
|
|
|
|
|
backgroundColor: Constants.system.white,
|
|
|
|
|
}}
|
|
|
|
|
topRowStyle={{
|
|
|
|
|
padding: "0px 16px",
|
|
|
|
|
textAlign: "left",
|
|
|
|
|
backgroundColor: Constants.system.white,
|
|
|
|
|
}}
|
|
|
|
|
onMouseEnter={(i) => {
|
|
|
|
|
if (isSelecting) return;
|
|
|
|
|
this._handleCheckBoxMouseEnter(i);
|
|
|
|
|
}}
|
|
|
|
|
onMouseLeave={() => {
|
|
|
|
|
if (isSelecting) return;
|
|
|
|
|
this._handleCheckBoxMouseEnter();
|
|
|
|
|
}}
|
|
|
|
|
isShiftDown={this.isShiftDown}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2021-02-05 21:29:12 +03:00
|
|
|
|
</GroupSelectable>
|
2020-09-19 22:44:04 +03:00
|
|
|
|
{footer}
|
2020-09-08 00:45:58 +03:00
|
|
|
|
<input
|
|
|
|
|
ref={(c) => {
|
|
|
|
|
this._ref = c;
|
|
|
|
|
}}
|
2020-09-13 03:53:36 +03:00
|
|
|
|
readOnly
|
2020-09-08 00:45:58 +03:00
|
|
|
|
value={this.state.copyValue}
|
|
|
|
|
css={STYLES_COPY_INPUT}
|
|
|
|
|
/>
|
2020-09-18 06:40:10 +03:00
|
|
|
|
</React.Fragment>
|
2020-08-12 11:22:28 +03:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|