 React = require 'react'
+PromiseToSetState = require '../lib/promise-to-set-state'
 ChangeListener = require '../components/change-listener'
 PromiseRenderer = require '../components/promise-renderer'
 auth = require '../api/auth'

                <MarkdownEditor name="introduction" value={@props.project.introduction} onChange={handleProjectChange} /><br />

                Workflows<br />
                <PromiseRenderer promise={@props.project.link 'workflows'}>{(error, workflows) =>
                  if workflows?
                    <ul>
                      {for workflow in workflows
                        <li key={workflow.id}><Link to="edit-workflow" params={id: workflow.id}>{workflow.display_name}</Link></li>}
                    </ul>
                }</PromiseRenderer>

                <button type="submit" disabled={@state.busy or not @props.project.hasUnsavedChanges()}>Save</button><br />
                <button type="button" onClick={@handleDelete}>Delete this project</button><br />

        @setState busy: false

  handleDelete: ->
    if prompt('Enter REALLY to delete this project forever.')?.toUpperCase() is 'REALLY'
      @setState busy: true, =>
        @props.project.delete().then =>
