   WorkspacesStore
   MachinesWorkspacesStore
   (machines, workspaces, machinesWorkspaces) ->
+
     machines.map (machine) ->
-      machine.set 'workspaces', machinesWorkspaces.get(machine.get '_id').map (workspaceId) ->
-        workspaces.get workspaceId
+      machine
+        .set 'workspaces', machinesWorkspaces.get(machine.get '_id')?.map (workspaceId) ->
+          workspaces.get workspaceId
 ]
 
 ownMachines = [
   OwnMachinesStore
   machinesWithWorkspaces
-  (own, machines) -> own.map (id) -> machines.get id
+  (own, machines) -> own.map (id) ->
+    machines.get(id)
+      .set 'type', 'own'
+      .set 'isApproved', yes
+      .set 'isManaged', machineRuleChecker machine, ['managed']
 ]
 
 sharedMachines = [
   SharedMachinesStore
   machinesWithWorkspaces
-  (shared, machines) -> shared.map (id) -> machines.get id
+  (shared, machines) -> shared.map (id) ->
+    machine = machines.get(id)
+    machine
+      .set 'type', 'shared'
+      .set 'owner', getMachineOwner machine
+      .set 'isApproved', machineRuleChecker machine, ['approved']
+      .set 'isPermanent', machineRuleChecker machine, ['permanent']
 ]
 
 collaborationMachines = [
   CollaborationMachinesStore
   machinesWithWorkspaces
-  (collaboration, machines) -> collaboration.map (id) -> machines.get id
+  (collaboration, machines) ->
+    collaboration.map (id) ->
+      machine = machines.get(id)
+      machine
+        .set 'type', 'collaboration'
+        .set 'owner', getMachineOwner machine
+        .set 'isApproved', machineRuleChecker machine, ['approved']
+        .set 'isPermanent', machineRuleChecker machine, ['permanent']
 ]
 
 stacks = [

StacksStore                = ['StacksStore']
MachinesStore              = ['MachinesStore']
WorkspacesStore            = ['WorkspacesStore']

      .sortBy (stack) -> stack.get '_id'
      .map (stack) ->
        stack.update 'machines', (machines) ->
          machines.map (id) ->
            machine = machinesWorkspaces.get(id)
            machine
              .set 'type', 'own'
              .set 'isApproved', yes
]

module.exports = {
