<template>
  <div @click.stop class="flex no-wrap items-center q-ml-auto">
    <ui-btn-menu
      v-if="notification.actions.length > 1"
      dense
      class="q-mr-xs"
      :class="{ 'bg-blue-grey-8 text-white': dark }"
    >
      <ui-menu>
        <ui-menu-group>
          <ui-menu-item
            v-for="(action, index) in notification.actions"
            :key="`${index}-action-${notification.id}`"
            tag="a"
            target="_blank"
            :href="action.link"
          >
            {{ action.label }}
          </ui-menu-item>
        </ui-menu-group>
      </ui-menu>
    </ui-btn-menu>
    <ui-btn-close @click="close" dense />
  </div>
</template>

<script lang="ts">
import { Component, Emit, Prop, Vue } from 'vue-property-decorator'
import { NotificationEvent } from '../types/NotificationEvent'
import UiBtnClose from '../../../buttons/UiBtnClose.vue'
import UiBtnMenu from '../../../buttons/UiBtnMenu.vue'
import UiMenu from '../../../menu/UiMenu.vue'
import UiMenuGroup from '../../../menu/UiMenuGroup.vue'
import UiMenuItem from '../../../menu/UiMenuItem.vue'

@Component({
  components: { UiMenuItem, UiMenuGroup, UiMenu, UiBtnMenu, UiBtnClose },
  inheritAttrs: false,
})
export default class UiNotificationItemActions extends Vue {
  @Prop(Object) notification!: NotificationEvent
  @Prop(Boolean) dark?: boolean

  @Emit()
  close() {
    return true
  }
}
</script>
