 
   constructor: (options = {}, data) ->
 
-    { computeController, router } = kd.singletons
-
-    path = router.getCurrentPath()
-
-    machineUid = path.split('/').pop()
-
     options.cssClass = kd.utils.curry 'Build-Logs', options.cssClass
 
     super options, data
 
-    machine = computeController.findMachineFromMachineUId machineUid
 
+  handleAction: (uid) ->
+
+    @destroyViews()
+
+    { computeController } = kd.singletons
+
+    machine = computeController.findMachineFromMachineUId uid
+    path = ''
     return router.handleNotFound path  unless machine
 
-    @machineName = machine.label
+    machineName = machine.label
 
     # Path of cloud-init-output log
     path = '/var/log/cloud-init-output.log'
-    @file = FSHelper.createFileInstance { path, machine }
+    file = FSHelper.createFileInstance { path, machine }
 
-
-    @file.fetchPermissions (err, result) ->
+    file.fetchPermissions (err, result) =>
 
       return showErrorNotification err  if err
 

        IDEHelpers.showFileAccessDeniedError()
        return router.handleRoute '/Home/Stacks/virtual-machines'


  viewAppended: ->

    @addSubView @header = header()


      click : ->
        kd.singletons.router.handleRoute '/Home/Stacks/virtual-machines'

    @addSubView @backLink = new kd.CustomHTMLView
      cssClass : 'pane-header'
      partial : """
        <div class='vm-name'> #{machineName} Build Logs </div>
        <div class='title'> /var/log/cloud-init-output.log</div>
      """

    @addSubView @tailer = new IDETailerPane { cssClass: 'build-logs-view', file, delegate: this }


  destroyViews: ->

    @header?.destroy()
    @backLink?.destroy()
    @tailer?.destroy()

