 SetToggle = require '../lib/set-toggle'
 CollectionRole = require '../lib/collection-role'
 ChangeListener = require '../components/change-listener'
-PromiseRenderer = require '../components/promise-renderer'
 
 CollectionDeleteDialog = React.createClass
   displayName: 'CollectionDeleteDialog'

      @props.collection.private

  render: ->
    <PromiseRenderer promise={@hasSettingsRole()}>{(hasSettingsRole) =>
      if hasSettingsRole
        <div className="collection-settings-tab">
          <ChangeListener target={@props.collection}>{=>
            <DisplayNameSlugEditor resource={@props.collection} resourceType="collection" />
          }</ChangeListener>

          <hr />

          <span className="form-label">Visibility</span>
          <p>
            <label style={whiteSpace: 'nowrap'}>
              <input type="radio" name="private" value={true} data-json-value={true} checked={@props.collection.private} onChange={@set.bind this, 'private', true} />
              Private
            </label>
            &emsp;
            <label style={whiteSpace: 'nowrap'}>
              <input type="radio" name="private" value={false} data-json-value={true} checked={@publicCollection()} onChange={@set.bind this, 'private', false} />
              Public
            </label>
          </p>

          <p className="form-help">Only the assigned <strong>collaborators</strong> can view a private project. Anyone with the URL can access a public project.</p>

          <hr />

          <div className="form-label">Delete this Collection</div>
          <div className="delete-container">
            <button className="error major-button" type="button" onClick={@confirmDelete}>Delete</button>
          </div>
        </div>
      else
        <div className="collection-settings-tab">
          <p>Not allowed to edit this collection</p>
        </div>
    }</PromiseRenderer>

    error: null
    setting:
      private: false
    hasSettingsRole: false

  componentDidMount: ->
    @hasSettingsRole()
      .then (hasSettingsRole) =>
        @setState {hasSettingsRole}
    @props.collection.listen 'delete', @redirect

  componentDidUnMount: ->
