import React from 'react'; import PropTypes from 'prop-types'; import { NgIf, Icon } from '../../components/'; import { Share } from '../../model/'; import { randomString, notify } from '../../helpers/'; import './share.scss'; export class ShareComponent extends React.Component { constructor(props){ super(props); this.state = { show_advanced: false, role: null, id: randomString(7), existings: [ {id: "dflkjse", role: "UPLOADER", path: "./test/test"}, {id: "dflkjse", role: "VIEWER", path: "./test/test", password: "xxxx"}, {id: "dflkjse", role: "EDITOR", path: "./test/test"}, {id: "dflkjse", role: "VIEWER", path: "./test/test", password: "xxxx"}, {id: "dflkjse", role: "EDITOR", path: "./test/test"}, {id: "dflkjse", role: "UPLOADER", path: "./test/test"}, ] }; } updateState(key, value){ if(this.state[key] === value){ this.setState({[key]: null}); }else{ this.setState({[key]: value}); } if(key === "role" && value && window.innerHeight < 500){ window.dispatchEvent(new Event('resize')); } } registerLink(e){ e.target.setSelectionRange(0, e.target.value.length); let st = Object.assign({}, this.state); delete st.existings; delete st.show_advanced; this.setState({existing: [st].concat(this.state.existings)}); return Share.upsert(st) .catch((err) => { notify.send(err, "error"); this.setState({ existings: this.state.existings.slice(0, this.state.existings.length) }); }); } onLoad(link){ let st = Object.assign({}, link); st.show_advanced = false; st.link_id = st.id; st.role = (st.role || "").toLowerCase(); this.setState(st); } onDelete(link_id){ return Share.remove(link_id) .then(() => { console.log("HERE"); }) .catch((err) => notify.send(err, "error")); } render(){ return (

Create a New Link

Uploader
Viewer
Editor
0}>

Existing Links

5 ? '90px' : 'inherit'}}> { this.state.existings && this.state.existings.map((link, i) => { return (
{link.role} {link.path}
); }) }

Restrictions

Advanced

{}}/>
); } } const SuperCheckbox = (props) => { const onCheckboxTick = (e) => { return props.onChange(e.target.checked ? "" : null); }; const onValueChange = (e) => { props.onChange(e.target.value); }; const _is_expended = function(val){ return val === null || val === undefined ? false : true; }(props.value); return (
); }; SuperCheckbox.PropTypes = { label: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, inputType: PropTypes.string, placeholder: PropTypes.string, value: PropTypes.string };