import * as React from "react"; import * as System from "~/components/system"; import * as Actions from "~/common/actions"; import { css } from "@emotion/react"; import ScenePage from "~/components/core/ScenePage"; import Section from "~/components/core/Section"; const STYLES_GROUP = css` display: flex; align-items: center; justify-content: space-between; width: 100%; overflow-wrap: break-word; white-space: pre-wrap; max-width: 480px; `; const STYLES_LEFT = css` padding: 12px 0 0 0; min-width: 10%; overflow-wrap: break-word; white-space: pre-wrap; `; const STYLES_RIGHT = css` padding-left: 48px; padding-top: 24px; flex-shrink: 0; `; export default class SceneSlate extends React.Component { state = { slatename: this.props.current.slatename, public: this.props.current.data.public, loading: false, }; componentDidUpdate(prevProps) { if (prevProps.current.slatename !== this.props.current.slatename) { this.setState({ slatename: this.props.current.slatename, public: this.props.current.data.public, loading: false, }); } } _handleSave = async (e) => { this.setState({ loading: true }); const response = await Actions.updateSlate({ id: this.props.current.slateId, slatename: this.state.slatename, data: { public: this.state.public, }, }); if (!response) { alert("TODO: Server Error"); return this.setState({ loading: false }); } if (response.error) { alert(`TODO: ${response.decorator}`); return this.setState({ loading: false }); } await this.props.onRehydrate(); this.setState({ loading: false }); }; _handleChange = (e) => { if (e && e.persist) { e.persist(); } this.setState({ [e.target.name]: e.target.value }); }; render() { const { data } = this.props.current; const { slatename } = this.state; const url = `/@${this.props.viewer.username}/${slatename}`; const slates = { columns: [ { key: "name", name: "Data", type: "FILE_LINK", width: "328px" }, { key: "url", name: "Data URL", width: "100%" }, { key: "type", name: "Data type", type: "TEXT_TAG", width: "136px" }, ], rows: data.objects, }; const slateButtons = [ { name: "View slate", type: "NEW_WINDOW", value: url, }, { name: "Upload data", type: "SIDEBAR", value: "SIDEBAR_ADD_FILE_TO_BUCKET", data: this.props.current, }, ]; const slateURL = `https://slate.host/@${this.props.viewer.username}/${slatename}`; return ( https://slate.host/@{this.props.viewer.username}/{slatename}
Changing the slatename will change your public slate URL. Your slate URL is:{" "} {slateURL} } name="slatename" value={this.state.slatename} placeholder="Slatename" onChange={this._handleChange} onSubmit={this._handleSave} />
Save changes
); } }