@enso-ui/notifications 2.0.6 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enso-ui/notifications",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
4
4
  "description": "Basic notifications package",
5
5
  "main": "src/bulma/pages/Index.vue",
6
6
  "scripts": {
@@ -25,6 +25,7 @@
25
25
  "@enso-ui/dropdown": "^3.0",
26
26
  "@enso-ui/toastr": "^3.0",
27
27
  "@enso-ui/ui": "^5.0",
28
+ "@enso-ui/transitions": "^2.0",
28
29
  "@fortawesome/fontawesome-svg-core": "^1.2.2",
29
30
  "@fortawesome/free-solid-svg-icons": "^5.2.0",
30
31
  "@fortawesome/vue-fontawesome": "3.0.0-5",
@@ -13,13 +13,15 @@
13
13
  </a>
14
14
  </div>
15
15
  <div class="level-item">
16
- <a :class="['button animated fadeIn', {'is-loading': loading}]"
17
- @click="fetch">
18
- <span>{{ i18n('Reload') }}</span>
19
- <span class="icon is-small">
20
- <fa icon="sync"/>
21
- </span>
22
- </a>
16
+ <fade>
17
+ <a :class="['button', {'is-loading': loading}]"
18
+ @click="fetch">
19
+ <span>{{ i18n('Reload') }}</span>
20
+ <span class="icon is-small">
21
+ <fa icon="sync"/>
22
+ </span>
23
+ </a>
24
+ </fade>
23
25
  </div>
24
26
  <div class="level-item is-marginless"
25
27
  v-if="notifications.length">
@@ -74,6 +76,7 @@
74
76
  </template>
75
77
 
76
78
  <script>
79
+ import { Fade } from '@enso-ui/transitions';
77
80
  import debounce from 'lodash/debounce';
78
81
  import { mapState } from 'vuex';
79
82
  import { FontAwesomeIcon as Fa } from '@fortawesome/vue-fontawesome';
@@ -81,6 +84,7 @@ import { library } from '@fortawesome/fontawesome-svg-core';
81
84
  import {
82
85
  faClock, faBell, faCheck, faTrashAlt, faSpinner, faSync,
83
86
  } from '@fortawesome/free-solid-svg-icons';
87
+ import eventBus from '@enso-ui/ui/src/core/services/eventBus';
84
88
  import format from '@enso-ui/ui/src/modules/plugins/date-fns/format';
85
89
  import formatDistance from '@enso-ui/ui/src/modules/plugins/date-fns/formatDistance';
86
90
 
@@ -91,7 +95,7 @@ export default {
91
95
 
92
96
  inject: ['errorHandler', 'i18n', 'route', 'routerErrorHandler'],
93
97
 
94
- components: { Fa },
98
+ components: { Fa, Fade },
95
99
 
96
100
  data: () => ({
97
101
  paginate: 200,
@@ -130,7 +134,7 @@ export default {
130
134
  axios.patch(this.route('core.notifications.read', notification.id))
131
135
  .then(({ data }) => {
132
136
  notification.read_at = data.read_at;
133
- this.$root.$emit('read-notification', notification);
137
+ eventBus.$emit('read-notification', notification);
134
138
 
135
139
  if (notification.data.path && notification.data.path !== '#') {
136
140
  this.$router.push({ path: notification.data.path })
@@ -150,18 +154,18 @@ export default {
150
154
 
151
155
  this.unreadCount = 0;
152
156
 
153
- this.$root.$emit('read-all-notifications');
157
+ eventBus.$emit('read-all-notifications');
154
158
  },
155
159
  destroyAll() {
156
160
  axios.delete(this.route('core.notifications.destroyAll')).then(() => {
157
161
  this.notifications = [];
158
- this.$root.$emit('destroy-all-notifications');
162
+ eventBus.$emit('destroy-all-notifications');
159
163
  }).catch(this.errorHandler);
160
164
  },
161
165
  destroy(notification, index) {
162
166
  axios.delete(this.route('core.notifications.destroy', notification.id)).then(() => {
163
167
  this.notifications.splice(index, 1);
164
- this.$root.$emit('destroy-notification', notification);
168
+ eventBus.$emit('destroy-notification', notification);
165
169
  }).catch(this.errorHandler);
166
170
  },
167
171
  timeFromNow(date) {
@@ -4,6 +4,7 @@ import {
4
4
  mapState, mapGetters, mapActions,
5
5
  } from 'vuex';
6
6
  import Favico from 'favico.js';
7
+ import eventBus from '@enso-ui/ui/src/core/services/eventBus';
7
8
  import format from '@enso-ui/ui/src/modules/plugins/date-fns/format';
8
9
  import formatDistance from '@enso-ui/ui/src/modules/plugins/date-fns/formatDistance';
9
10
 
@@ -58,7 +59,7 @@ export default {
58
59
  methods: {
59
60
  ...mapActions('websockets', ['connect']),
60
61
  addBusListeners() {
61
- this.$root.$on('read-notification', notification => {
62
+ eventBus.$on('read-notification', notification => {
62
63
  this.unread = Math.max(--this.unread, 0);
63
64
  const existing = this.notifications
64
65
  .find(({ id }) => id === notification.id);
@@ -68,9 +69,9 @@ export default {
68
69
  }
69
70
  });
70
71
 
71
- this.$root.$on('read-all-notifications', () => this.updateAll());
72
+ eventBus.$on('read-all-notifications', () => this.updateAll());
72
73
 
73
- this.$root.$on('destroy-notification', notification => {
74
+ eventBus.$on('destroy-notification', notification => {
74
75
  if (!notification.read_at) {
75
76
  this.unread = Math.max(--this.unread, 0);
76
77
  }
@@ -83,7 +84,7 @@ export default {
83
84
  }
84
85
  });
85
86
 
86
- this.$root.$on('destroy-all-notifications', () => {
87
+ eventBus.$on('destroy-all-notifications', () => {
87
88
  this.notifications = [];
88
89
  this.unread = 0;
89
90
  });
@@ -18,7 +18,6 @@ export default {
18
18
  created() {
19
19
  if (this.toastrPosition) {
20
20
  this.toastr.defaults({ position: this.toastrPosition }).reset();
21
- this.$toastr.defaults({ position: this.toastrPosition }).reset();
22
21
  }
23
22
  },
24
23
 
@@ -27,7 +26,6 @@ export default {
27
26
  update(position) {
28
27
  this.setToastrPosition(position);
29
28
  this.toastr.defaults({ position }).reset();
30
- this.$toastr.defaults({ position }).reset();
31
29
  },
32
30
  },
33
31