2020-07-27 06:20:34 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
2020-08-03 02:29:11 +03:00
|
|
|
import * as Actions from "~/common/actions";
|
2020-08-07 09:33:44 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2020-10-01 03:41:53 +03:00
|
|
|
import * as Validations from "~/common/validations";
|
2020-09-05 02:15:29 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-09-14 03:34:58 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
2020-09-03 10:03:32 +03:00
|
|
|
import * as Window from "~/common/window";
|
2020-07-27 06:20:34 +03:00
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
2020-09-03 00:08:32 +03:00
|
|
|
import { ProcessedText } from "~/components/system/components/Typography";
|
2020-09-15 00:29:41 +03:00
|
|
|
import {
|
|
|
|
ButtonPrimary,
|
|
|
|
ButtonSecondary,
|
|
|
|
} from "~/components/system/components/Buttons";
|
2020-09-20 21:31:08 +03:00
|
|
|
import { dispatchCustomEvent } from "~/common/custom-events";
|
2020-07-27 06:20:34 +03:00
|
|
|
|
|
|
|
import ScenePage from "~/components/core/ScenePage";
|
2020-08-22 07:25:34 +03:00
|
|
|
import ScenePageHeader from "~/components/core/ScenePageHeader";
|
2020-08-22 20:30:03 +03:00
|
|
|
import Slate, { generateLayout } from "~/components/core/Slate";
|
2020-08-20 23:33:08 +03:00
|
|
|
import SlateMediaObject from "~/components/core/SlateMediaObject";
|
2020-08-27 07:27:50 +03:00
|
|
|
import CircleButtonGray from "~/components/core/CircleButtonGray";
|
2020-09-14 08:22:19 +03:00
|
|
|
import EmptyState from "~/components/core/EmptyState";
|
2020-09-04 01:42:08 +03:00
|
|
|
|
2020-09-14 08:22:19 +03:00
|
|
|
const STYLES_ICONS = css`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
`;
|
|
|
|
|
2020-10-01 03:41:53 +03:00
|
|
|
const STYLES_ACTIONS = css`
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding-left: 24px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-31 21:19:46 +03:00
|
|
|
const STYLES_USERNAME = css`
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-10-01 03:41:53 +03:00
|
|
|
const STYLES_MOBILE_HIDDEN = css`
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MOBILE_ONLY = css`
|
|
|
|
@media (min-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-22 12:32:40 +03:00
|
|
|
const moveIndex = (set, fromIndex, toIndex) => {
|
|
|
|
const element = set[fromIndex];
|
|
|
|
set.splice(fromIndex, 1);
|
|
|
|
set.splice(toIndex, 0, element);
|
|
|
|
|
|
|
|
return set;
|
|
|
|
};
|
|
|
|
|
2020-09-03 00:04:47 +03:00
|
|
|
const setStateData = (source) => {
|
2020-09-02 21:54:43 +03:00
|
|
|
return {
|
|
|
|
objects: source.data.objects,
|
|
|
|
layouts: source.data.layouts
|
|
|
|
? source.data.layouts
|
|
|
|
: { lg: generateLayout(source.data.objects) },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-09 07:12:54 +03:00
|
|
|
let isMounted = false;
|
|
|
|
|
2020-07-27 06:20:34 +03:00
|
|
|
export default class SceneSlate extends React.Component {
|
2020-09-03 09:00:02 +03:00
|
|
|
_timeout = null;
|
|
|
|
_remoteLock = false;
|
|
|
|
|
2020-08-03 02:29:11 +03:00
|
|
|
state = {
|
2020-09-03 03:10:17 +03:00
|
|
|
...setStateData(this.props.current, this.props.viewer),
|
2020-08-03 02:29:11 +03:00
|
|
|
loading: false,
|
2020-09-03 00:04:47 +03:00
|
|
|
saving: "IDLE",
|
2020-09-03 03:10:17 +03:00
|
|
|
editing: this.props.current.data.ownerId === this.props.viewer.id,
|
2020-09-15 00:29:41 +03:00
|
|
|
followLoading: false,
|
2020-08-03 02:29:11 +03:00
|
|
|
};
|
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
// NOTE(jim):
|
|
|
|
// The purpose of this is to update the Scene appropriately when
|
|
|
|
// it changes but isn't mounted.
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (prevProps.current.id !== this.props.current.id) {
|
|
|
|
this.setState({
|
|
|
|
...setStateData(this.props.current, this.props.viewer),
|
|
|
|
loading: false,
|
|
|
|
saving: "IDLE",
|
|
|
|
editing: this.props.current.data.ownerId === this.props.viewer.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._handleUpdateCarousel({
|
|
|
|
objects: this.props.current.data.objects,
|
|
|
|
editing: this.state.editing,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
componentDidMount() {
|
2020-09-09 07:12:54 +03:00
|
|
|
if (isMounted) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
isMounted = true;
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
this._handleUpdateCarousel(this.state);
|
2020-09-03 09:00:02 +03:00
|
|
|
window.addEventListener(
|
|
|
|
"remote-update-slate-screen",
|
|
|
|
this._handleRemoteUpdate
|
|
|
|
);
|
2020-09-03 10:03:32 +03:00
|
|
|
window.addEventListener(
|
|
|
|
"remote-delete-object",
|
|
|
|
this._handleRemoteDeleteObject
|
|
|
|
);
|
2020-09-03 10:10:09 +03:00
|
|
|
window.addEventListener(
|
|
|
|
"remote-object-update",
|
|
|
|
this._handleRemoteSaveObject
|
|
|
|
);
|
2020-08-09 11:08:46 +03:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
componentWillUnmount() {
|
2020-09-09 07:12:54 +03:00
|
|
|
isMounted = false;
|
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
window.removeEventListener(
|
2020-09-21 06:58:15 +03:00
|
|
|
"remote-update-slate-screen",
|
2020-09-03 09:00:02 +03:00
|
|
|
this._handleRemoteUpdate
|
|
|
|
);
|
2020-09-03 10:03:32 +03:00
|
|
|
window.removeEventListener(
|
|
|
|
"remote-delete-object",
|
|
|
|
this._handleRemoteDeleteObject
|
|
|
|
);
|
2020-09-03 10:10:09 +03:00
|
|
|
window.removeEventListener(
|
|
|
|
"remote-object-update",
|
|
|
|
this._handleRemoteSaveObject
|
|
|
|
);
|
2020-09-03 09:00:02 +03:00
|
|
|
}
|
2020-08-22 08:19:11 +03:00
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
_handleRemoteUpdate = async ({ detail }) => {
|
|
|
|
if (!this._remoteLock) {
|
|
|
|
this._remoteLock = true;
|
|
|
|
const response = await Actions.getSlateById({
|
|
|
|
id: this.props.current.id,
|
|
|
|
});
|
2020-08-09 11:08:46 +03:00
|
|
|
|
2020-09-13 03:42:46 +03:00
|
|
|
if (!response) {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
2020-09-20 21:31:08 +03:00
|
|
|
"We're having trouble refreshing right now. Please try again later",
|
2020-09-13 03:42:46 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this._remoteLock = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
decorator: response.error,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-09-03 09:00:02 +03:00
|
|
|
this._remoteLock = false;
|
|
|
|
return;
|
2020-09-03 00:04:47 +03:00
|
|
|
}
|
2020-08-20 23:33:08 +03:00
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
this.setState({ layouts: null, objects: null });
|
2020-09-03 00:04:47 +03:00
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
const { slate } = response;
|
|
|
|
|
|
|
|
await this._handleSave(null, slate.data.objects, slate.data.layouts);
|
|
|
|
this._remoteLock = false;
|
|
|
|
}
|
|
|
|
};
|
2020-08-03 02:29:11 +03:00
|
|
|
|
2020-09-15 00:29:41 +03:00
|
|
|
_handleFollow = () => {
|
|
|
|
this.setState({ followLoading: true }, async () => {
|
|
|
|
let response = await Actions.createSubscription({
|
|
|
|
slateId: this.props.current.id,
|
|
|
|
});
|
|
|
|
await this.props.onRehydrate();
|
|
|
|
this.setState({ followLoading: false });
|
2020-09-03 02:17:31 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-08-22 20:30:03 +03:00
|
|
|
_handleChangeLayout = async (layout, layouts) => {
|
2020-09-03 09:00:02 +03:00
|
|
|
this.setState({ layouts, saving: "IDLE" });
|
2020-08-22 20:30:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleSaveLayout = async () => {
|
|
|
|
await this._handleSave(null, null, this.state.layouts);
|
|
|
|
};
|
|
|
|
|
2020-08-22 12:32:40 +03:00
|
|
|
_handleMoveIndex = async (from, to) => {
|
|
|
|
const objects = moveIndex(this.state.objects, from.index, to.index);
|
|
|
|
this.setState({ objects });
|
|
|
|
await this._handleSave(null, objects);
|
|
|
|
};
|
|
|
|
|
2020-08-22 20:30:03 +03:00
|
|
|
_handleSave = async (e, objects, layouts) => {
|
2020-09-03 09:00:02 +03:00
|
|
|
this.setState({ loading: true, saving: "SAVING" });
|
2020-08-03 02:29:11 +03:00
|
|
|
|
|
|
|
const response = await Actions.updateSlate({
|
2020-09-03 03:10:17 +03:00
|
|
|
id: this.props.current.id,
|
2020-08-03 02:29:11 +03:00
|
|
|
data: {
|
2020-09-03 09:00:02 +03:00
|
|
|
name: this.props.current.data.name,
|
2020-08-21 10:07:39 +03:00
|
|
|
objects: objects ? objects : this.state.objects,
|
2020-08-22 20:30:03 +03:00
|
|
|
layouts: layouts ? layouts : this.state.layouts,
|
2020-08-03 02:29:11 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!response) {
|
2020-09-03 00:04:47 +03:00
|
|
|
this.setState({ loading: false, saving: "ERROR" });
|
2020-09-12 01:25:33 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-08-03 02:29:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
2020-09-03 00:04:47 +03:00
|
|
|
this.setState({ loading: false, saving: "ERROR" });
|
2020-09-12 01:25:33 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: { alert: { decorator: response.decorator } },
|
|
|
|
});
|
2020-08-03 02:29:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
await this.props.onRehydrate();
|
2020-08-09 11:08:46 +03:00
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
this.setState({
|
|
|
|
saving: "SAVED",
|
|
|
|
layouts: layouts ? layouts : this.state.layouts,
|
|
|
|
objects: objects ? objects : this.state.objects,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._handleUpdateCarousel({
|
|
|
|
objects: objects ? objects : this.state.objects,
|
|
|
|
editing: this.state.editing,
|
|
|
|
});
|
2020-08-03 02:29:11 +03:00
|
|
|
};
|
|
|
|
|
2020-09-03 10:10:09 +03:00
|
|
|
_handleRemoteSaveObject = async ({ detail }) => {
|
|
|
|
const { object } = detail;
|
|
|
|
|
2020-08-21 10:07:39 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { saving: true },
|
|
|
|
});
|
|
|
|
|
|
|
|
const objects = [...this.state.objects];
|
|
|
|
for (let i = 0; i < objects.length; i++) {
|
|
|
|
if (objects[i].id === object.id) {
|
|
|
|
objects[i] = object;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await this._handleSave(null, objects);
|
|
|
|
|
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { saving: false },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
_handleUpdateCarousel = (state) => {
|
2020-09-03 10:03:32 +03:00
|
|
|
const objects = [...state.objects];
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "slate-global-create-carousel",
|
|
|
|
detail: {
|
2020-09-03 10:03:32 +03:00
|
|
|
slides: objects.map((each) => {
|
2020-08-25 21:39:14 +03:00
|
|
|
// NOTE(jim):
|
|
|
|
// This is a hack to catch this undefined case I don't want to track down yet.
|
|
|
|
const url = each.url.replace("https://undefined", "https://");
|
2020-09-14 03:34:58 +03:00
|
|
|
const cid = Strings.getCIDFromIPFS(url);
|
2020-08-25 21:39:14 +03:00
|
|
|
const data = { ...each, cid, url };
|
|
|
|
|
2020-08-09 11:38:16 +03:00
|
|
|
return {
|
2020-09-03 10:03:32 +03:00
|
|
|
onDelete: () =>
|
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "remote-delete-object",
|
|
|
|
detail: { id: data.id },
|
|
|
|
}),
|
2020-09-03 10:10:09 +03:00
|
|
|
onObjectSave: (object) =>
|
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "remote-object-update",
|
|
|
|
detail: { object },
|
|
|
|
}),
|
2020-08-25 21:39:14 +03:00
|
|
|
id: data.id,
|
2020-08-21 10:07:39 +03:00
|
|
|
cid,
|
2020-08-25 21:39:14 +03:00
|
|
|
data,
|
2020-09-14 05:58:33 +03:00
|
|
|
username: this.props.viewer.username,
|
|
|
|
slatename: this.props.current.slatename,
|
2020-08-31 21:19:46 +03:00
|
|
|
editing: this.state.editing,
|
2020-09-03 10:03:32 +03:00
|
|
|
component: <SlateMediaObject key={each.id} data={data} />,
|
2020-08-09 11:38:16 +03:00
|
|
|
};
|
2020-08-09 11:08:46 +03:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2020-08-07 05:17:49 +03:00
|
|
|
|
2020-09-03 10:03:32 +03:00
|
|
|
_handleRemoteDeleteObject = async ({ detail }) => {
|
|
|
|
const { id } = detail;
|
|
|
|
|
2020-08-09 11:38:16 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { loading: true },
|
|
|
|
});
|
2020-08-07 05:17:49 +03:00
|
|
|
|
2020-08-23 23:20:16 +03:00
|
|
|
const objects = this.state.objects.filter((o, i) => {
|
|
|
|
return o.id !== id;
|
|
|
|
});
|
|
|
|
|
2020-09-03 09:00:02 +03:00
|
|
|
// TODO(jim): This is a brute force way to handle this.
|
|
|
|
const layouts = { lg: generateLayout(objects) };
|
2020-09-03 10:03:32 +03:00
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
const response = await Actions.updateSlate({
|
2020-09-03 10:03:32 +03:00
|
|
|
id: this.props.current.id,
|
2020-08-09 11:08:46 +03:00
|
|
|
data: {
|
2020-09-03 09:00:02 +03:00
|
|
|
name: this.props.current.data.name,
|
2020-08-23 23:20:16 +03:00
|
|
|
objects,
|
|
|
|
layouts,
|
2020-08-09 11:08:46 +03:00
|
|
|
},
|
2020-08-07 05:17:49 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!response) {
|
2020-08-09 11:38:16 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { loading: false },
|
|
|
|
});
|
2020-09-12 01:25:33 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: {
|
|
|
|
alert: {
|
|
|
|
message:
|
|
|
|
"We're having trouble connecting right now. Please try again later",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-08-07 05:17:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
2020-08-09 11:38:16 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { loading: false },
|
|
|
|
});
|
2020-09-12 01:25:33 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "create-alert",
|
|
|
|
detail: { alert: { decorator: response.decorator } },
|
|
|
|
});
|
2020-08-07 05:17:49 +03:00
|
|
|
}
|
|
|
|
|
2020-09-03 10:03:32 +03:00
|
|
|
this._handleUpdateCarousel({
|
|
|
|
objects: response.slate.data.objects,
|
|
|
|
editing: this.state.editing,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
objects: response.slate.data.objects,
|
|
|
|
layouts: response.slate.data.layouts,
|
|
|
|
});
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
await this.props.onRehydrate();
|
2020-08-03 02:29:11 +03:00
|
|
|
|
2020-08-09 11:38:16 +03:00
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "state-global-carousel-loading",
|
|
|
|
detail: { loading: false },
|
|
|
|
});
|
2020-08-03 02:29:11 +03:00
|
|
|
};
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
_handleSelect = (index) =>
|
|
|
|
System.dispatchCustomEvent({
|
|
|
|
name: "slate-global-open-carousel",
|
|
|
|
detail: { index },
|
|
|
|
});
|
2020-07-27 11:33:39 +03:00
|
|
|
|
2020-09-08 07:04:24 +03:00
|
|
|
_handleAdd = async () => {
|
|
|
|
await this.props.onAction({
|
2020-08-09 11:08:46 +03:00
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_ADD_FILE_TO_BUCKET",
|
2020-09-03 03:10:17 +03:00
|
|
|
data: this.props.current,
|
2020-08-09 11:08:46 +03:00
|
|
|
});
|
2020-09-08 07:04:24 +03:00
|
|
|
this._handleUpdateCarousel({
|
|
|
|
objects: this.props.current.data.objects,
|
|
|
|
editing: this.state.editing,
|
|
|
|
});
|
2020-08-09 11:08:46 +03:00
|
|
|
};
|
2020-07-27 11:33:39 +03:00
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
_handleShowSettings = () => {
|
|
|
|
return this.props.onAction({
|
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_SINGLE_SLATE_SETTINGS",
|
2020-09-03 03:10:17 +03:00
|
|
|
data: this.props.current,
|
2020-08-09 11:08:46 +03:00
|
|
|
});
|
|
|
|
};
|
2020-07-27 11:33:39 +03:00
|
|
|
|
2020-09-28 23:12:43 +03:00
|
|
|
_handleSlateLink = async () => {
|
|
|
|
//NOTE(martina): not needed if links only happen on your own slate (know your own username already)
|
|
|
|
// const response = await Actions.getUsername({
|
|
|
|
// id: this.props.current.data.ownerId,
|
|
|
|
// });
|
|
|
|
// const username = response.data;
|
2020-09-08 01:47:54 +03:00
|
|
|
|
|
|
|
return window.open(
|
2020-09-28 23:12:43 +03:00
|
|
|
`/${this.props.viewer.username}/${this.props.current.slatename}`
|
2020-09-08 01:47:54 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-08-09 11:08:46 +03:00
|
|
|
render() {
|
2020-09-28 23:12:43 +03:00
|
|
|
const { id, user, data, slatename } = this.props.current;
|
|
|
|
const { body = "" } = data;
|
2020-09-03 09:00:02 +03:00
|
|
|
const { objects, layouts } = this.state;
|
2020-09-27 08:38:19 +03:00
|
|
|
const isPublic = data.public;
|
2020-09-08 01:47:54 +03:00
|
|
|
|
2020-09-04 01:42:08 +03:00
|
|
|
let following = !!this.props.viewer.subscriptions.filter((subscription) => {
|
|
|
|
return subscription.target_slate_id === this.props.current.id;
|
|
|
|
}).length;
|
2020-09-03 03:10:17 +03:00
|
|
|
|
2020-10-01 03:41:53 +03:00
|
|
|
let onMobile = Validations.onMobile();
|
|
|
|
let actions = this.state.editing ? (
|
|
|
|
<span css={STYLES_ACTIONS}>
|
|
|
|
<CircleButtonGray onClick={this._handleAdd} style={{ marginRight: 16 }}>
|
|
|
|
<SVG.Plus height="16px" />
|
|
|
|
</CircleButtonGray>
|
|
|
|
{isPublic ? (
|
|
|
|
<CircleButtonGray
|
|
|
|
onClick={() => this._handleSlateLink()}
|
|
|
|
style={{ marginRight: 16 }}
|
|
|
|
>
|
|
|
|
<SVG.DeepLink height="16px" />
|
|
|
|
</CircleButtonGray>
|
|
|
|
) : null}
|
|
|
|
<CircleButtonGray onClick={this._handleShowSettings}>
|
|
|
|
<SVG.Settings height="16px" />
|
|
|
|
</CircleButtonGray>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<div onClick={this._handleFollow}>
|
|
|
|
{following ? (
|
|
|
|
<ButtonSecondary
|
|
|
|
transparent
|
|
|
|
style={{ minWidth: 120, paddingLeft: 0 }}
|
|
|
|
loading={this.state.followLoading}
|
|
|
|
>
|
|
|
|
Unfollow
|
|
|
|
</ButtonSecondary>
|
|
|
|
) : (
|
|
|
|
<ButtonPrimary
|
|
|
|
transparent
|
|
|
|
style={{ minWidth: 120, paddingLeft: 0 }}
|
|
|
|
loading={this.state.followLoading}
|
|
|
|
>
|
|
|
|
Follow
|
|
|
|
</ButtonPrimary>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2020-07-27 11:33:39 +03:00
|
|
|
return (
|
2020-09-08 05:23:23 +03:00
|
|
|
<ScenePage
|
2020-09-10 06:28:48 +03:00
|
|
|
style={{ paddingLeft: "24px", paddingRight: "24px" }}
|
2020-09-20 21:31:08 +03:00
|
|
|
contentstyle={{ maxWidth: "1660px" }}
|
2020-09-08 05:23:23 +03:00
|
|
|
>
|
2020-08-22 07:25:34 +03:00
|
|
|
<ScenePageHeader
|
|
|
|
style={{ padding: `0 24px 0 24px` }}
|
2020-08-31 21:19:46 +03:00
|
|
|
title={
|
2020-09-04 01:42:08 +03:00
|
|
|
user ? (
|
2020-08-31 21:19:46 +03:00
|
|
|
<span>
|
|
|
|
<span
|
|
|
|
onClick={() =>
|
|
|
|
this.props.onAction({
|
|
|
|
type: "NAVIGATE",
|
|
|
|
value: this.props.sceneId,
|
2020-09-04 01:42:08 +03:00
|
|
|
scene: "PUBLIC_PROFILE",
|
|
|
|
data: user,
|
2020-08-31 21:19:46 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
css={STYLES_USERNAME}
|
|
|
|
>
|
2020-09-04 01:42:08 +03:00
|
|
|
{user.username}
|
2020-08-31 21:19:46 +03:00
|
|
|
</span>{" "}
|
2020-09-05 07:45:50 +03:00
|
|
|
/ {data.name}
|
2020-08-31 21:19:46 +03:00
|
|
|
</span>
|
|
|
|
) : (
|
2020-09-05 07:45:50 +03:00
|
|
|
data.name
|
2020-08-31 21:19:46 +03:00
|
|
|
)
|
|
|
|
}
|
2020-10-01 03:51:25 +03:00
|
|
|
actions={<span css={STYLES_MOBILE_HIDDEN}>{actions}</span>}
|
2020-08-25 21:39:14 +03:00
|
|
|
>
|
2020-09-03 00:08:32 +03:00
|
|
|
<ProcessedText text={body} />
|
2020-08-22 07:25:34 +03:00
|
|
|
</ScenePageHeader>
|
2020-10-01 03:41:53 +03:00
|
|
|
<span css={STYLES_MOBILE_ONLY}>{actions}</span>
|
2020-09-14 11:21:06 +03:00
|
|
|
{objects && objects.length ? (
|
2020-09-14 08:22:19 +03:00
|
|
|
layouts ? (
|
|
|
|
<Slate
|
2020-10-01 03:41:53 +03:00
|
|
|
editing={onMobile ? false : this.state.editing}
|
2020-09-14 08:22:19 +03:00
|
|
|
saving={this.state.saving}
|
|
|
|
items={objects}
|
|
|
|
layouts={layouts}
|
|
|
|
onLayoutChange={this._handleChangeLayout}
|
|
|
|
onLayoutSave={this._handleSaveLayout}
|
|
|
|
onMoveIndex={this._handleMoveIndex}
|
|
|
|
onSelect={this._handleSelect}
|
|
|
|
/>
|
|
|
|
) : null
|
|
|
|
) : this.state.editing ? (
|
|
|
|
<div style={{ padding: "24px" }}>
|
|
|
|
<EmptyState>
|
|
|
|
<div css={STYLES_ICONS}>
|
|
|
|
<SVG.Sound height="24px" style={{ margin: "0 16px" }} />
|
|
|
|
<SVG.Document height="24px" style={{ margin: "0 16px" }} />
|
|
|
|
<SVG.Image height="24px" style={{ margin: "0 16px" }} />
|
|
|
|
<SVG.Book height="24px" style={{ margin: "0 16px" }} />
|
|
|
|
<SVG.Video height="24px" style={{ margin: "0 16px" }} />
|
|
|
|
</div>
|
|
|
|
<div style={{ marginTop: 24 }}>
|
|
|
|
Drag and drop files to add them to this slate
|
|
|
|
</div>
|
|
|
|
</EmptyState>
|
|
|
|
</div>
|
2020-09-03 09:00:02 +03:00
|
|
|
) : null}
|
2020-07-27 11:33:39 +03:00
|
|
|
</ScenePage>
|
|
|
|
);
|
2020-07-27 06:20:34 +03:00
|
|
|
}
|
|
|
|
}
|