               .set 'isApproved', yes
 ]
 
+teamStackTemplates = [
+  TeamStackTemplatesStore
+  stacks
+  (templates, _stacks) ->
+    baseStackIds = _stacks.toList().toArray().map (s) -> s.get 'baseStackId'
+    templates.map (template) ->
+      template
+        .set 'inUse', template.get('_id') in baseStackIds
+        .set 'isDefault', template.get('_id') in (getGroup().stackTemplates or [])
+]
+
+inUseTeamStackTemplates = [
+  teamStackTemplates
+  (templates) -> templates.filter (t) -> t.get('inUse')
+]
+
 module.exports = {
   stacks
   ownMachines

ActiveLeavingSharedMachineIdStore = ['ActiveLeavingSharedMachineIdStore']
DifferentStackResourcesStore      = ['DifferentStackResourcesStore']
ActiveStackStore                  = ['ActiveStackStore']


workspacesWithChannels = [

  activeInvitationMachineId: ActiveInvitationMachineIdStore
  activeLeavingSharedMachineId: ActiveLeavingSharedMachineIdStore
  differentStackResourcesStore : DifferentStackResourcesStore
  teamStackTemplates
  inUseTeamStackTemplates
}
