import React, { Component, PropTypes } from 'react'

export default class LibrairyPicturesListItemMenu extends Component {

  handleRemove(e) {
    // don't follow link
    e.preventDefault()
    // remove pict from portfolio || post || collection
    this.props.removePicture(this.props.pk)
    // close context menu
    this.props.close()
  }

  handleDelete(e) {
    // don't follow link
    e.preventDefault()
    // delete picture from phiroom
    this.props.deletePicture(this.props.pk)
    // close context menu
    this.props.close()
  }

  handleLink(e) {
    // close context menu
    this.props.close()
  }
  
  render() {
    return (
        <ul>
          <li><a
            target="_blank"
            href={'/media/images/previews/large/' + this.props.previews_path}
            onClick={this.handleLink.bind(this)}
          >Open large version in new tab</a></li>
          <li><a
            target="_blank"
            href={'/media/' + this.props.source_file}
            onClick={this.handleLink.bind(this)}
          >Open original in new tab</a></li>
          <li><a
            href=""
            onClick={this.handleRemove.bind(this)}
          >Remove from {this.props.container}</a></li>
          <hr />
          <li><a
            href=""
            onClick={this.handleDelete.bind(this)}
          >Delete from Phiroom</a></li>
        </ul>
    )
  }
}

@@ -610,16 +610,427 @@
 se()%0A  %7D
+%0A%0A  getRemoveLink() %7B%0A    /* %0A     * if picture is removable%0A     * (portfolios, posts, collections)%0A     * show remove link%0A     * else (all pictures, last importation) not%0A     */%0A    if (this.props.removePicture) %7B%0A      return (%0A          %3Cli%3E%3Ca%0A            href=%22%22%0A            onClick=%7Bthis.handleRemove.bind(this)%7D%0A          %3ERemove from %7Bthis.props.container%7D%3C/a%3E%3C/li%3E%0A        )%0A    %7D%0A    return null%0A  %7D
 %0A  %0A  re
@@ -1493,140 +1493,30 @@
     
-%3Cli%3E%3Ca%0A            href=%22%22%0A            onClick=%7Bthis.handleRemove.bind(this)%7D%0A          %3ERemove from %7Bthis.props.container%7D%3C/a%3E%3C/li%3E
+%7Bthis.getRemoveLink()%7D
 %0A   

improve librairy contextual menu.