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";
|
|
|
|
import * as System from "~/components/system";
|
|
|
|
import * as Actions from "~/common/actions";
|
2020-09-08 00:45:58 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-08-12 11:22:28 +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-08 08:36:01 +03:00
|
|
|
import { LoaderSpinner } from "~/components/system/components/Loaders";
|
2020-09-09 07:12:54 +03:00
|
|
|
import { dispatchCustomEvent } from "~/common/custom-events";
|
|
|
|
import { generateLayout } from "~/components/core/Slate";
|
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-09-23 23:52:00 +03:00
|
|
|
import {
|
|
|
|
ButtonPrimary,
|
|
|
|
ButtonWarning,
|
|
|
|
} from "~/components/system/components/Buttons";
|
2020-09-19 22:36:58 +03:00
|
|
|
import { TabGroup } from "~/components/core/TabGroup";
|
2020-08-12 11:22:28 +03:00
|
|
|
|
2020-08-20 23:33:08 +03:00
|
|
|
import SlateMediaObject from "~/components/core/SlateMediaObject";
|
2020-09-08 00:45:58 +03:00
|
|
|
import SlateMediaObjectPreview from "~/components/core/SlateMediaObjectPreview";
|
2020-08-12 11:22:28 +03:00
|
|
|
|
2020-09-19 22:36:58 +03:00
|
|
|
const VIEW_LIMIT = 20;
|
|
|
|
|
2020-09-18 06:40:10 +03:00
|
|
|
const STYLES_CONTAINER_HOVER = css`
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
|
|
|
`;
|
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;
|
|
|
|
background-color: ${Constants.system.brand};
|
|
|
|
border-radius: 3px;
|
|
|
|
position: relative;
|
|
|
|
right: 3px;
|
|
|
|
cursor: pointer;
|
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.brand};
|
|
|
|
`;
|
|
|
|
|
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-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 {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
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_ARROWS = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ACTION_BAR = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
2020-09-27 00:15:37 +03:00
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.lightBorder} inset,
|
2020-09-27 23:11:04 +03:00
|
|
|
0 0 4px 2px ${Constants.system.shadow};
|
2020-09-23 23:52:00 +03:00
|
|
|
border-radius: 4px;
|
|
|
|
padding: 12px 32px;
|
2020-09-27 23:11:04 +03:00
|
|
|
box-sizing: border-box;
|
|
|
|
background-color: ${Constants.system.foreground};
|
|
|
|
position: fixed;
|
|
|
|
bottom: 12px;
|
|
|
|
width: calc(100vw - ${Constants.sizes.sidebar}px + 32px);
|
|
|
|
max-width: ${Constants.sizes.desktop}px;
|
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
width: calc(100vw - ${Constants.sizes.mobileSidebar}px - 64px);
|
|
|
|
}
|
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-09-27 23:11:04 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-09-19 22:36:58 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ICON_ELEMENT = css`
|
|
|
|
height: 40px;
|
|
|
|
width: 40px;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
color: #565151;
|
|
|
|
user-select: none;
|
|
|
|
cursor: pointer;
|
|
|
|
pointer-events: auto;
|
|
|
|
margin: 16px 8px;
|
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
|
|
|
|
|
|
|
svg {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
transition: 200ms ease transform;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
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;
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(214px, 1fr));
|
2020-09-08 00:45:58 +03:00
|
|
|
margin: 0 -27px;
|
2020-10-01 03:41:53 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
margin: 0px -12px;
|
|
|
|
}
|
2020-09-08 00:45:58 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_IMAGE_BOX = css`
|
|
|
|
width: 160px;
|
|
|
|
height: 160px;
|
|
|
|
margin: 27px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-09-27 00:15:37 +03:00
|
|
|
box-shadow: 0px 0px 0px 1px ${Constants.system.lightBorder} inset,
|
2020-09-23 23:52:00 +03:00
|
|
|
0 0 40px 0 ${Constants.system.shadow};
|
2020-09-08 00:45:58 +03:00
|
|
|
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) {
|
|
|
|
width: 144px;
|
|
|
|
height: 144px;
|
|
|
|
margin: 12px auto;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MOBILE_HIDDEN = css`
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-08-12 11:22:28 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const delay = (ms) => new Promise((resolve) => window.setTimeout(resolve, ms));
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
let mounted = false;
|
|
|
|
|
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-08 08:36:01 +03:00
|
|
|
loading: {},
|
2020-09-19 22:36:58 +03:00
|
|
|
startIndex: 0,
|
|
|
|
checked: {},
|
|
|
|
view: "grid",
|
2020-08-12 11:22:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
async componentDidMount() {
|
2020-09-09 07:12:54 +03:00
|
|
|
if (!mounted) {
|
|
|
|
mounted = true;
|
|
|
|
window.addEventListener("remote-data-deletion", this._handleDataDeletion);
|
|
|
|
window.addEventListener(
|
|
|
|
"remote-slate-object-remove",
|
|
|
|
this._handleRemoteSlateObjectRemove
|
|
|
|
);
|
|
|
|
window.addEventListener(
|
|
|
|
"remote-slate-object-add",
|
|
|
|
this._handleRemoteSlateObjectAdd
|
|
|
|
);
|
2020-09-23 23:52:00 +03:00
|
|
|
window.addEventListener("remote-update-carousel", this._handleUpdate);
|
2020-09-09 07:12:54 +03:00
|
|
|
}
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
await this._handleUpdate();
|
|
|
|
}
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
componentWillUnmount() {
|
|
|
|
mounted = false;
|
|
|
|
|
|
|
|
window.removeEventListener(
|
|
|
|
"remote-data-deletion",
|
|
|
|
this._handleDataDeletion
|
|
|
|
);
|
|
|
|
window.removeEventListener(
|
|
|
|
"remote-slate-object-remove",
|
|
|
|
this._handleRemoteSlateObjectRemove
|
|
|
|
);
|
|
|
|
window.removeEventListener(
|
|
|
|
"remote-slate-object-add",
|
|
|
|
this._handleRemoteSlateObjectAdd
|
|
|
|
);
|
2020-09-23 23:52:00 +03:00
|
|
|
window.removeEventListener("remote-update-carousel", this._handleUpdate);
|
2020-09-09 07:12:54 +03:00
|
|
|
}
|
|
|
|
|
2020-09-19 22:36:58 +03:00
|
|
|
_increment = (direction) => {
|
|
|
|
if (
|
|
|
|
direction > 0 &&
|
|
|
|
this.state.startIndex + VIEW_LIMIT <
|
|
|
|
this.props.viewer.library[0].children.length
|
|
|
|
) {
|
|
|
|
this.setState({ startIndex: this.state.startIndex + VIEW_LIMIT });
|
|
|
|
} else if (direction < 0 && this.state.startIndex - VIEW_LIMIT >= 0) {
|
|
|
|
this.setState({ startIndex: this.state.startIndex - VIEW_LIMIT });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleCheckBox = (e) => {
|
|
|
|
let checked = this.state.checked;
|
|
|
|
if (e.target.value === false) {
|
|
|
|
delete checked[e.target.name];
|
|
|
|
this.setState({ checked });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
checked: { ...this.state.checked, [e.target.name]: true },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleDeleteFiles = async (e) => {
|
2020-09-27 07:49:38 +03:00
|
|
|
const message = `Are you sure you want to delete these files? They will be deleted from your slates as well`;
|
2020-09-19 22:36:58 +03:00
|
|
|
if (!window.confirm(message)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let cids = Object.keys(this.state.checked).map((id) => {
|
2020-09-23 23:52:00 +03:00
|
|
|
let index = parseInt(id);
|
2020-09-19 22:36:58 +03:00
|
|
|
return this.props.viewer.library[0].children[index].ipfs.replace(
|
|
|
|
"/ipfs/",
|
|
|
|
""
|
|
|
|
);
|
|
|
|
});
|
|
|
|
this._handleLoading({ cids });
|
|
|
|
|
|
|
|
const response = await Actions.deleteBucketItems({ cids });
|
|
|
|
if (!response) {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this._handleLoading({ cids });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (response.error) {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: { alert: { decorator: response.decorator } },
|
|
|
|
});
|
|
|
|
this._handleLoading({ cids });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await this.props.onRehydrate();
|
|
|
|
await this._handleUpdate();
|
|
|
|
this._handleLoading({ cids });
|
|
|
|
this.setState({ checked: {} });
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: { message: "Files successfully deleted!", status: "INFO" },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleDelete = async (cid) => {
|
|
|
|
this._handleLoading({ cids: [cid] });
|
|
|
|
|
|
|
|
if (
|
|
|
|
!window.confirm(
|
|
|
|
"Are you sure you want to delete this? It will be removed from your Slates too."
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
this._handleLoading({ cids: [cid] });
|
|
|
|
return;
|
2020-09-08 07:04:24 +03:00
|
|
|
}
|
2020-09-19 22:36:58 +03:00
|
|
|
|
|
|
|
const response = await Actions.deleteBucketItem({ cid });
|
|
|
|
|
|
|
|
if (!response) {
|
|
|
|
this._handleLoading({ cids: [cid] });
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
this._handleLoading({ cids: [cid] });
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: { alert: { decorator: response.decorator } },
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.props.onRehydrate();
|
|
|
|
await this._handleUpdate();
|
|
|
|
this._handleLoading({ cids: [cid] });
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: { message: "File successfully deleted!", status: "INFO" },
|
|
|
|
},
|
|
|
|
});
|
2020-09-08 07:04:24 +03:00
|
|
|
};
|
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
_handleUpdate = async () => {
|
|
|
|
// NOTE(jim): Hack to handle some race conditions.
|
|
|
|
await delay(200);
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-create",
|
2020-08-12 11:22:28 +03:00
|
|
|
detail: {
|
|
|
|
slides: this.props.items.map((each) => {
|
|
|
|
const cid = each.ipfs.replace("/ipfs/", "");
|
2020-08-25 21:25:26 +03:00
|
|
|
const url = Strings.getCIDGatewayURL(cid);
|
|
|
|
const data = { ...each, url, cid };
|
2020-08-21 10:07:39 +03:00
|
|
|
|
2020-08-12 11:22:28 +03:00
|
|
|
return {
|
2020-08-25 21:25:26 +03:00
|
|
|
id: data.id,
|
2020-09-09 07:12:54 +03:00
|
|
|
slates: this.props.viewer.slates,
|
2020-08-12 11:22:28 +03:00
|
|
|
cid,
|
2020-08-25 21:25:26 +03:00
|
|
|
data,
|
2020-09-09 07:12:54 +03:00
|
|
|
renderDataControls: true,
|
2020-08-25 21:25:26 +03:00
|
|
|
component: <SlateMediaObject key={data.id} data={data} />,
|
2020-09-09 07:12:54 +03:00
|
|
|
onDataDelete: () => {
|
|
|
|
return dispatchCustomEvent({
|
|
|
|
name: "remote-data-deletion",
|
|
|
|
detail: { cid },
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onRemoveFromSlate: (data) => {
|
|
|
|
return dispatchCustomEvent({
|
|
|
|
name: "remote-slate-object-remove",
|
|
|
|
detail: { ...data },
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onAddToSlate: (data) => {
|
|
|
|
return dispatchCustomEvent({
|
|
|
|
name: "remote-slate-object-add",
|
|
|
|
detail: { ...data },
|
|
|
|
});
|
|
|
|
},
|
2020-08-12 11:22:28 +03:00
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleSelect = (index) => {
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-open",
|
2020-08-12 11:22:28 +03:00
|
|
|
detail: { index },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
_handleDataDeletion = (e) => {
|
|
|
|
this._handleDelete(e.detail.cid);
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleRemoteSlateObjectAdd = async ({ detail }) => {
|
|
|
|
const { id, slate, data } = detail;
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: { id: slate.id } },
|
|
|
|
});
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
const addResponse = await Actions.addFileToSlate({
|
|
|
|
slate,
|
|
|
|
data: [{ title: data.name, ...data }],
|
2020-09-09 07:12:54 +03:00
|
|
|
});
|
|
|
|
|
2020-09-12 01:25:33 +03:00
|
|
|
if (!addResponse) {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return null;
|
2020-09-24 22:42:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (addResponse.error) {
|
2020-09-12 01:25:33 +03:00
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: { alert: { decorator: addResponse.decorator } },
|
|
|
|
});
|
2020-09-09 07:12:54 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-09-24 22:42:32 +03:00
|
|
|
const { added, skipped } = addResponse;
|
|
|
|
let message = `${added || 0} file${added !== 1 ? "s" : ""} uploaded. `;
|
|
|
|
if (skipped) {
|
|
|
|
message += `${skipped || 0} duplicate / existing file${
|
|
|
|
added !== 1 ? "s were" : " was"
|
|
|
|
} skipped.`;
|
|
|
|
}
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: { message, status: !added ? null : "INFO" },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
await this.props.onRehydrate();
|
|
|
|
await this._handleUpdate();
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: false },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleRemoteSlateObjectRemove = async ({ detail }) => {
|
|
|
|
const { id, slate } = detail;
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: { id: slate.id } },
|
|
|
|
});
|
|
|
|
|
|
|
|
const objects = slate.data.objects.filter((o, i) => {
|
|
|
|
return o.id !== id;
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO(jim): This is a brute force way to handle this.
|
|
|
|
const layouts = { lg: generateLayout(objects) };
|
|
|
|
|
|
|
|
const response = await Actions.updateSlate({
|
|
|
|
id: slate.id,
|
|
|
|
data: {
|
|
|
|
name: slate.data.name,
|
|
|
|
objects,
|
|
|
|
layouts,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!response) {
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: false },
|
|
|
|
});
|
|
|
|
|
2020-09-12 01:25:33 +03:00
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now and weren't able to delete that. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-09-09 07:12:54 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: false },
|
|
|
|
});
|
|
|
|
|
2020-09-12 01:25:33 +03:00
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
decorator: response.decorator,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-09-09 07:12:54 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.props.onRehydrate();
|
|
|
|
await this._handleUpdate();
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
2020-09-13 03:53:36 +03:00
|
|
|
name: "cid-viewer-loading",
|
2020-09-09 07:12:54 +03:00
|
|
|
detail: { loading: false },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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-09-19 22:36:58 +03:00
|
|
|
_handleLoading = ({ cids }) => {
|
|
|
|
let loading = this.state.loading;
|
|
|
|
for (let cid of cids) {
|
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "cid-viewer-loading",
|
|
|
|
detail: { loading: !this.state.loading[cid] },
|
2020-09-12 01:25:33 +03:00
|
|
|
});
|
2020-09-19 22:36:58 +03:00
|
|
|
loading[cid] = !this.state.loading[cid];
|
2020-08-12 11:22:28 +03:00
|
|
|
}
|
2020-09-19 22:36:58 +03:00
|
|
|
this.setState({ loading });
|
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) => {
|
|
|
|
let userFiles = this.props.viewer.library[0].children;
|
|
|
|
let files = Object.keys(this.state.checked).map(
|
|
|
|
(index) => userFiles[index]
|
|
|
|
);
|
|
|
|
this.props.onAction({
|
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_ADD_FILE_TO_SLATE",
|
|
|
|
data: { files },
|
|
|
|
});
|
|
|
|
this._handleUncheckAll();
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleUncheckAll = () => {
|
|
|
|
this.setState({ checked: {} });
|
|
|
|
};
|
|
|
|
|
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-09-19 22:36:58 +03:00
|
|
|
const header = (
|
|
|
|
<div css={STYLES_HEADER_LINE}>
|
|
|
|
<TabGroup disabled tabs={["Uploads"]} style={{ margin: 0 }} />
|
2020-10-01 03:41:53 +03:00
|
|
|
<span css={STYLES_MOBILE_HIDDEN}>
|
2020-09-19 22:36:58 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX}
|
|
|
|
onClick={() => {
|
2020-09-24 03:03:26 +03:00
|
|
|
this.setState({ view: "grid", menu: null });
|
2020-09-19 22:36:58 +03:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<SVG.GridView
|
|
|
|
style={{
|
|
|
|
color:
|
|
|
|
this.state.view === "grid"
|
|
|
|
? Constants.system.black
|
|
|
|
: "rgba(0,0,0,0.25)",
|
|
|
|
}}
|
|
|
|
height="24px"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX}
|
|
|
|
onClick={() => {
|
2020-09-24 03:03:26 +03:00
|
|
|
this.setState({ view: "list", menu: null });
|
2020-09-19 22:36:58 +03:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<SVG.ListView
|
|
|
|
style={{
|
|
|
|
color:
|
|
|
|
this.state.view === "list"
|
|
|
|
? Constants.system.black
|
|
|
|
: "rgba(0,0,0,0.25)",
|
|
|
|
}}
|
|
|
|
height="24px"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-10-01 03:41:53 +03:00
|
|
|
</span>
|
2020-09-19 22:36:58 +03:00
|
|
|
</div>
|
|
|
|
);
|
2020-09-19 22:44:04 +03:00
|
|
|
const footer = (
|
2020-09-23 23:52:00 +03:00
|
|
|
<React.Fragment>
|
|
|
|
<div css={STYLES_ARROWS}>
|
2020-09-19 22:44:04 +03:00
|
|
|
<span
|
|
|
|
css={STYLES_ICON_ELEMENT}
|
|
|
|
style={
|
|
|
|
this.state.startIndex - VIEW_LIMIT >= 0
|
|
|
|
? null
|
|
|
|
: {
|
|
|
|
cursor: "not-allowed",
|
|
|
|
color: Constants.system.border,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClick={() => this._increment(-1)}
|
|
|
|
>
|
|
|
|
<SVG.NavigationArrow
|
|
|
|
height="24px"
|
|
|
|
style={{ transform: `rotate(180deg)` }}
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
css={STYLES_ICON_ELEMENT}
|
|
|
|
style={
|
|
|
|
this.state.startIndex + VIEW_LIMIT <
|
|
|
|
this.props.viewer.library[0].children.length
|
|
|
|
? null
|
|
|
|
: {
|
|
|
|
cursor: "not-allowed",
|
|
|
|
color: Constants.system.border,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClick={() => this._increment(1)}
|
|
|
|
>
|
|
|
|
<SVG.NavigationArrow height="24px" />
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-09-24 03:03:26 +03:00
|
|
|
{numChecked ? (
|
2020-09-23 23:52:00 +03:00
|
|
|
<div css={STYLES_ACTION_BAR}>
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
<span css={STYLES_FILES_SELECTED}>
|
2020-09-24 03:03:26 +03:00
|
|
|
{numChecked} file{numChecked > 1 ? "s" : ""} selected
|
2020-09-23 23:52:00 +03:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_RIGHT}>
|
|
|
|
<ButtonPrimary transparent onClick={this._handleAddToSlate}>
|
|
|
|
Add to slate
|
|
|
|
</ButtonPrimary>
|
|
|
|
<ButtonWarning
|
|
|
|
transparent
|
2020-09-24 03:03:26 +03:00
|
|
|
style={{ marginLeft: 8 }}
|
2020-09-23 23:52:00 +03:00
|
|
|
onClick={this._handleDeleteFiles}
|
|
|
|
loading={
|
|
|
|
this.state.loading &&
|
|
|
|
Object.values(this.state.loading).some((elem) => {
|
|
|
|
return !!elem;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
Delete files
|
|
|
|
</ButtonWarning>
|
2020-09-24 03:03:26 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX}
|
|
|
|
onClick={() => this.setState({ checked: {} })}
|
|
|
|
>
|
2020-09-24 22:42:32 +03:00
|
|
|
<SVG.Dismiss
|
|
|
|
height="20px"
|
|
|
|
style={{ color: Constants.system.darkGray }}
|
|
|
|
/>
|
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
|
|
|
);
|
2020-09-19 22:36:58 +03:00
|
|
|
if (this.state.view === "grid") {
|
2020-09-08 00:45:58 +03:00
|
|
|
return (
|
2020-09-19 22:36:58 +03:00
|
|
|
<React.Fragment>
|
|
|
|
{header}
|
|
|
|
<div css={STYLES_IMAGE_GRID}>
|
|
|
|
{this.props.items
|
|
|
|
.slice(this.state.startIndex, this.state.startIndex + VIEW_LIMIT)
|
2020-09-24 03:03:26 +03:00
|
|
|
.map((each, i) => {
|
|
|
|
const cid = each.ipfs.replace("/ipfs/", "");
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={each.id}
|
|
|
|
css={STYLES_IMAGE_BOX}
|
|
|
|
onClick={() =>
|
|
|
|
this._handleSelect(i + this.state.startIndex)
|
|
|
|
}
|
|
|
|
onMouseEnter={() => this.setState({ hover: i })}
|
|
|
|
onMouseLeave={() => this.setState({ hover: null })}
|
|
|
|
>
|
|
|
|
<SlateMediaObjectPreview
|
|
|
|
url={`${Constants.gateways.ipfs}/${each.ipfs.replace(
|
|
|
|
"/ipfs/",
|
|
|
|
""
|
|
|
|
)}`}
|
|
|
|
title={each.file || each.name}
|
|
|
|
type={each.type || each.icon}
|
|
|
|
/>
|
2020-10-01 03:41:53 +03:00
|
|
|
<span css={STYLES_MOBILE_HIDDEN}>
|
|
|
|
{numChecked ||
|
|
|
|
this.state.hover === i ||
|
|
|
|
this.state.menu === each.id ? (
|
|
|
|
<React.Fragment>
|
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX_BACKGROUND}
|
|
|
|
onClick={
|
|
|
|
this.state.loading[cid]
|
|
|
|
? () => {}
|
|
|
|
: (e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.setState({
|
|
|
|
menu:
|
|
|
|
this.state.menu === each.id
|
|
|
|
? null
|
|
|
|
: each.id,
|
|
|
|
});
|
|
|
|
}
|
2020-09-24 03:03:26 +03:00
|
|
|
}
|
2020-10-01 03:41:53 +03:00
|
|
|
>
|
|
|
|
{this.state.loading[cid] ? (
|
|
|
|
<LoaderSpinner
|
|
|
|
style={{ height: 24, width: 24 }}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<SVG.MoreHorizontal height="24px" />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{this.state.menu === each.id ? (
|
|
|
|
<Boundary
|
|
|
|
captureResize={true}
|
|
|
|
captureScroll={false}
|
|
|
|
enabled
|
|
|
|
onOutsideRectEvent={this._handleHide}
|
|
|
|
>
|
|
|
|
<PopoverNavigation
|
|
|
|
style={{
|
|
|
|
top: "32px",
|
|
|
|
right: "0px",
|
|
|
|
}}
|
|
|
|
navigation={[
|
|
|
|
{
|
|
|
|
text: "Copy CID",
|
|
|
|
onClick: (e) => this._handleCopy(e, cid),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Copy link",
|
|
|
|
onClick: (e) =>
|
|
|
|
this._handleCopy(
|
|
|
|
e,
|
|
|
|
`${Constants.gateways.ipfs}/${cid}`
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Delete",
|
|
|
|
onClick: (e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.setState({ menu: null }, () =>
|
|
|
|
this._handleDelete(cid)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Boundary>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
let checked = this.state.checked;
|
|
|
|
if (checked[this.state.startIndex + i]) {
|
|
|
|
delete checked[this.state.startIndex + i];
|
|
|
|
} else {
|
|
|
|
checked[this.state.startIndex + i] = true;
|
|
|
|
}
|
|
|
|
this.setState({ checked });
|
2020-09-24 03:03:26 +03:00
|
|
|
}}
|
2020-10-01 03:41:53 +03:00
|
|
|
>
|
|
|
|
<CheckBox
|
|
|
|
name={this.state.startIndex + i}
|
|
|
|
value={
|
|
|
|
!!this.state.checked[this.state.startIndex + i]
|
|
|
|
}
|
|
|
|
onChange={this._handleCheckBox}
|
|
|
|
boxStyle={{
|
|
|
|
height: 24,
|
|
|
|
width: 24,
|
|
|
|
backgroundColor: this.state.checked[
|
|
|
|
this.state.startIndex + i
|
|
|
|
]
|
|
|
|
? Constants.system.brand
|
|
|
|
: "rgba(255, 255, 255, 0.75)",
|
|
|
|
}}
|
|
|
|
style={{
|
|
|
|
position: "absolute",
|
|
|
|
bottom: 8,
|
|
|
|
left: 8,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
) : null}
|
|
|
|
</span>
|
2020-09-24 03:03:26 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
2020-09-19 22:36:58 +03:00
|
|
|
</div>
|
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-09-23 23:52:00 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_CANCEL_BOX}
|
|
|
|
onClick={() => this.setState({ checked: {} })}
|
|
|
|
>
|
|
|
|
<SVG.Minus
|
|
|
|
height="16px"
|
|
|
|
style={{ color: Constants.system.white }}
|
|
|
|
/>
|
|
|
|
</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%",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "size",
|
|
|
|
name: <div style={{ fontSize: "0.9rem", padding: "18px 0" }}>Size</div>,
|
|
|
|
width: "104px",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "more",
|
|
|
|
name: <span />,
|
|
|
|
width: "48px",
|
|
|
|
},
|
|
|
|
];
|
2020-09-19 22:36:58 +03:00
|
|
|
const rows = this.props.items
|
|
|
|
.slice(this.state.startIndex, this.state.startIndex + VIEW_LIMIT)
|
|
|
|
.map((each, index) => {
|
|
|
|
const cid = each.ipfs.replace("/ipfs/", "");
|
|
|
|
const isOnNetwork = each.networks && each.networks.includes("FILECOIN");
|
|
|
|
|
|
|
|
return {
|
|
|
|
...each,
|
2020-09-23 23:52:00 +03:00
|
|
|
checkbox: (
|
2020-09-27 23:11:04 +03:00
|
|
|
<CheckBox
|
|
|
|
name={this.state.startIndex + index}
|
|
|
|
value={!!this.state.checked[this.state.startIndex + index]}
|
|
|
|
onChange={this._handleCheckBox}
|
|
|
|
boxStyle={{ height: 16, width: 16 }}
|
2020-09-19 22:36:58 +03:00
|
|
|
style={{
|
2020-09-27 23:11:04 +03:00
|
|
|
position: "relative",
|
|
|
|
right: 3,
|
2020-09-19 22:36:58 +03:00
|
|
|
margin: "12px 0",
|
2020-09-27 23:11:04 +03:00
|
|
|
opacity:
|
|
|
|
numChecked > 0 || this.state.hover === index ? "100%" : "0%",
|
2020-09-19 22:36:58 +03:00
|
|
|
}}
|
2020-09-27 23:11:04 +03:00
|
|
|
/>
|
2020-09-19 22:36:58 +03:00
|
|
|
),
|
|
|
|
name: (
|
|
|
|
<div
|
|
|
|
css={STYLES_CONTAINER_HOVER}
|
2020-09-27 07:43:25 +03:00
|
|
|
onClick={() => this._handleSelect(this.state.startIndex + index)}
|
2020-09-19 22:36:58 +03:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX_HOVER}
|
|
|
|
style={{ paddingLeft: 0, paddingRight: 18 }}
|
2020-09-08 00:45:58 +03:00
|
|
|
>
|
2020-09-19 22:36:58 +03:00
|
|
|
<FileTypeIcon type={each.type} height="24px" />
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_LINK}>{each.file || each.name}</div>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
size: <div css={STYLES_VALUE}>{Strings.bytesToSize(each.size)}</div>,
|
|
|
|
more: (
|
|
|
|
<div
|
|
|
|
css={STYLES_ICON_BOX_HOVER}
|
|
|
|
onClick={
|
|
|
|
this.state.loading[cid]
|
|
|
|
? () => {}
|
2020-09-24 03:03:26 +03:00
|
|
|
: () =>
|
|
|
|
this.setState({
|
|
|
|
menu: this.state.menu === each.id ? null : each.id,
|
|
|
|
})
|
2020-09-19 22:36:58 +03:00
|
|
|
}
|
|
|
|
>
|
|
|
|
{this.state.loading[cid] ? (
|
|
|
|
<LoaderSpinner style={{ height: 24, width: 24 }} />
|
|
|
|
) : (
|
|
|
|
<SVG.MoreHorizontal height="24px" />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{this.state.menu === each.id ? (
|
|
|
|
<Boundary
|
|
|
|
captureResize={true}
|
|
|
|
captureScroll={false}
|
|
|
|
enabled
|
|
|
|
onOutsideRectEvent={this._handleHide}
|
|
|
|
>
|
|
|
|
<PopoverNavigation
|
|
|
|
style={{
|
|
|
|
top: "48px",
|
|
|
|
right: "40px",
|
|
|
|
}}
|
|
|
|
navigation={[
|
|
|
|
{
|
|
|
|
text: "Copy CID",
|
|
|
|
onClick: (e) => this._handleCopy(e, cid),
|
2020-09-08 00:45:58 +03:00
|
|
|
},
|
2020-09-19 22:36:58 +03:00
|
|
|
{
|
|
|
|
text: "Copy link",
|
|
|
|
onClick: (e) =>
|
|
|
|
this._handleCopy(
|
|
|
|
e,
|
|
|
|
`${Constants.gateways.ipfs}/${cid}`
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Delete",
|
|
|
|
onClick: (e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.setState({ menu: null }, () =>
|
|
|
|
this._handleDelete(cid)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Boundary>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
};
|
|
|
|
});
|
2020-08-12 11:22:28 +03:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
columns,
|
|
|
|
rows,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2020-09-18 06:40:10 +03:00
|
|
|
<React.Fragment>
|
2020-09-19 22:36:58 +03:00
|
|
|
{header}
|
2020-09-18 06:40:10 +03:00
|
|
|
<Table
|
2020-09-13 03:53:36 +03:00
|
|
|
data={data}
|
2020-09-18 06:40:10 +03:00
|
|
|
rowStyle={{ padding: "10px 16px" }}
|
|
|
|
topRowStyle={{ padding: "0px 16px" }}
|
|
|
|
onMouseEnter={(i) => this.setState({ hover: i })}
|
|
|
|
onMouseLeave={() => this.setState({ hover: null })}
|
2020-08-12 11:22:28 +03:00
|
|
|
/>
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|