 {Emitter} = require 'atom'
 
+typeIcons =
+  fatal: 'bug'
+  error: 'flame'
+  warning: 'alert'
+  info: 'info'
+  success: 'check'
+
 module.exports = class NotificationsLog
-  typesShown:
-    fatal: true
-    error: true
-    warning: true
-    info: true
-    success: true
-
   constructor: ->
     @render()
     @emitter = new Emitter


  toggle: -> atom.workspace.toggle(this)

  toggleType: (type) ->
    show = not @typesShown[type]
    @typesShown[type] = show
    button = @header.querySelector(".notification-type.#{type}")
    @list.classList.toggle("hide-#{type}", not show)
    button.classList.toggle('show-type', show)

  addNotification: (notification) ->
    # TODO: should probably create new element instead of cloning

    @element.classList.add('notifications-log')

    # Add Header
    header = document.createElement('header')
    @element.appendChild(header)

    # Add Container
    @list = document.createElement('ul')
    @element.appendChild(@list)

    # Add Buttons
    for type, icon of typeIcons
      button = document.createElement('button')
      button.classList.add('notification-type', 'btn', 'icon', "icon-#{icon}", 'show-type', type)
      button.dataset.type = type
      button.addEventListener 'click', (e) => @toggleType(e.target.dataset.type)
      atom.tooltips.add(button, {title: "Toggle #{type} notifications"})
      header.appendChild(button)

    # Add Notifications
    for notification in atom.notifications.getNotifications()
