       kd.singletons.computeController.reset yes, =>
         @emit 'RestartIDE', @machine
         @destroy()
+
+  removeMachine: ->
+
+    kd.singletons.computeController.destroy @machine

kd   = require 'kd'
view = require './view'
ManagedVMBaseModal = require './basemodal'

module.exports = class FindManagedNodesModal extends ManagedVMBaseModal


      listKites: (data) =>

        {loader, message, list,
         button_assign, button_reload} = view.addTo @container,
          message_warn  :
            text        : "We are unable to reach your managed vm
                          (#{@machine.ipAddress}), but we've found following
                          klient kites registered with your account."
            cssClass    : 'warning'
          list          : { data }
          button_assign :
            title       : 'Use Selected Kite'
            cssClass    : 'green'
            callback    : =>
              kite = list.controller.selectedItems.first.getData()
              if kite.machine
                message.show()
              else
                message.hide()
                @assignKite kite
          button_delete :
            title       : 'Delete VM'
            cssClass    : 'red'
            callback    : @bound 'removeMachine'
          button_reload :
            iconOnly    : yes
            cssClass    : 'retry'
            callback    : =>
              button_reload.hide()
              message.hide()
              loader.show()
              @fetchKites()
          loader        :
            cssClass    : 'inline'
          message       :
            text        : 'This kite is in use.'
            cssClass    : 'inline hidden'

        list.controller

          .on 'ItemDeselectionPerformed', ->
            button_assign.disable()
            message.hide()

          .on 'ItemSelectionPerformed', button_assign.bound 'enable'


    if container = @getOption 'container'
      kd.utils.defer => container.addSubView this


  assignKite: (kite)->
