javascript - How can you control who sees a button on a page using Meteor and React -
i building first application using meteor , react. have modal:
import react, { component } 'react'; import { modal, button, tooltip, link, controllabel } 'react-bootstrap'; import reactplayer 'react-player'; import { browserhistory } 'react-router'; import { removecomment } '../../api/comments/methods.js'; var rand const handleremove = (_id) => { if (confirm('are sure? permanent!')) { removecomment.call({ _id }, (error) => { if (error) { bert.alert(error.reason, 'danger'); } else { bert.alert('comment deleted!', 'success'); } }); } }; const handleedit = (_id) => { browserhistory.push(`/comments/${_id}/edit`); } export class commentsmodaluser extends component { constructor(props) { super(props); this.state = { showmodal: false, }; this.close = this.close.bind(this); this.open = this.open.bind(this); } close() { this.setstate({ showmodal: false }); this.props.playvideo(); } open() { this.setstate({ showmodal: true }); this.props.stopvideo(); } render() { const { newtimestamp, city, person, location, title, content, filelink, mediadata, timestamp, _id, votes } = this.props.comment; if (mediadata){ var links = []; (var = 0; < mediadata.length; i++) { var item = mediadata[i]; links.push(<div><reactplayer controls="true" width="100%" url={item.link}/><br/><controllabel><p>{item.content}</p></controllabel></div>); } } return ( <div classname="flex"> <div classname="invis-container"> <a onclick={this.open}><div classname="upper-spark"><img src="/images/grijze_bliksem.png"/></div></a> </div> <span classname="modal-bg"><span style={{ height: votes }} classname="modal-color" ></span></span> <modal show={this.state.showmodal} onhide={this.close} bssize="lg"> <modal.header closebutton> <modal.title ><span>️️⚡️highlight</span><h3>{title}</h3></modal.title> </modal.header> <modal.body> <controllabel><img src={filelink} width="100%"/></controllabel> <controllabel><div dangerouslysetinnerhtml={{__html: content}} /></controllabel> <p>media highlight:</p> {links} </modal.body> <modal.footer> <button onclick={ () => handleremove(_id) } classname="text-danger">delete</button> <button onclick={this.close}>close</button> <button onclick={ () => handleedit(_id) } classname="text-danger">edit</button> </modal.footer> </modal> </div> ); } }
i learn how can control sees these buttons:
<button onclick={ () => handleremove(_id) } classname="text-danger">delete</button> <button onclick={this.close}>close</button> <button onclick={ () => handleedit(_id) } classname="text-danger">edit</button>
i want able show edit button person created post. , want have same delete button. there way achieve this? i'm not sure start.
have great day , not forget smile!
Comments
Post a Comment