 kd = require 'kd'
 React = require 'app/react'
 SidebarWidget = require './widget'
-EnvironmentFlux = require 'app/flux/environment'
-KDReactorMixin = require 'app/flux/base/reactormixin'
-actions = require 'app/flux/environment/actions'
 
 
 PROVIDERS         =

  @defaultProps =
    className : 'ConnectedManagedVm sidebar-info-modal'

  getDataBindings: ->
    connectedManagedMachine: EnvironmentFlux.getters.connectedManagedMachine


  onClose: ->

    kd.utils.defer =>
      actions.hideManagedMachineAddedModal @props.machine.get '_id'


  handleButtonClick: ->

    { router } = kd.singletons
    currentPath = router.getCurrentPath()
    newPath = "/IDE/#{@props.machine.slug}"

    @onClose()
    router.handleRoute newPath  unless newPath is currentPath


  render: ->

    connectedMachine = @state.connectedManagedMachine.get @props.machine.get('_id')

    return null  unless connectedMachine

    provider = if PROVIDERS[connectedMachine.providerName]
    then connectedMachine.providerName
    else 'UnknownProvider'

    <SidebarWidget {...@props} onClose={@bound 'onClose'}>



          <button
            className='GenericButton'
            onClick={@bound 'onButtonClick'}
            children='START CODING' />

        </div>
      </div>

    </SidebarWidget>
