Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NotificationGroup.vue « Notification « src « vue « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f581822ba6254b3f6dbeb38236d001992fa3dbbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!--
  Matomo - free/libre analytics platform
  @link https://matomo.org
  @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
-->

<template>
  <div class="notification-group">
    <Notification
      v-for="(notification, index) in notifications"
      :key="notification.id || `no-id-${index}`"
      :notification-id="notification.id"
      :title="notification.title"
      :context="notification.context"
      :type="notification.type"
      :noclear="notification.noclear"
      :toast-length="notification.toastLength"
      :style="notification.style"
      :animate="notification.animate"
      :message="notification.message"
      :notification-instance-id="notification.notificationInstanceId"
      :css-class="notification.class"
      @closed="removeNotification(notification.id)"
    >
      <div v-html="$sanitize(notification.message)"/>
    </Notification>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import NotificationsStore from './Notifications.store';
import Notification from './Notification.vue';

export default defineComponent({
  props: {
    group: String,
  },
  components: {
    Notification,
  },
  computed: {
    notifications() {
      return NotificationsStore.state.notifications.filter((n) => {
        if (this.group) {
          return this.group === n.group;
        }

        return !n.group;
      });
    },
  },
  methods: {
    removeNotification(id: string) {
      NotificationsStore.remove(id);
    },
  },
});
</script>