@enso-ui/notifications 3.0.2 → 3.1.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 laravel-enso
3
+ Copyright (c) 2026 laravel-enso
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -25,4 +25,4 @@ Thank you to all the notifications who already contributed to Enso!
25
25
 
26
26
  ## License
27
27
 
28
- [ISC](https://opensource.org/licenses/ISC)
28
+ [MIT](https://opensource.org/licenses/MIT)
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@enso-ui/notifications",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "Basic notifications package",
5
5
  "main": "src/bulma/pages/Index.vue",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/enso-ui/notifications.git"
@@ -15,34 +12,22 @@
15
12
  "vue"
16
13
  ],
17
14
  "author": "Adrian Ocneanu <aocneanu@gmail.com>",
18
- "license": "ISC",
15
+ "license": "MIT",
19
16
  "bugs": {
20
17
  "url": "https://github.com/enso-ui/notifications/issues"
21
18
  },
22
19
  "homepage": "https://github.com/enso-ui/notifications#readme",
23
20
  "dependencies": {
24
21
  "@enso-ui/directives": "^2.0",
25
- "@enso-ui/dropdown": "^3.0",
22
+ "@enso-ui/dropdown": "^4.0.0",
26
23
  "@enso-ui/toastr": "^3.0",
27
- "@enso-ui/ui": "^6.0",
24
+ "@enso-ui/ui": "^7.0.0",
28
25
  "@enso-ui/transitions": "^2.0",
29
- "@fortawesome/fontawesome-svg-core": "^1.2.2",
30
- "@fortawesome/free-solid-svg-icons": "^5.11.2",
31
- "@fortawesome/vue-fontawesome": "3.0.0-5",
26
+ "@fortawesome/fontawesome-svg-core": "^7.2.0",
27
+ "@fortawesome/free-solid-svg-icons": "^7.2.0",
28
+ "@fortawesome/vue-fontawesome": "3.1.3",
32
29
  "favico.js": "^0.3.10",
33
30
  "lodash": "^4.17.20",
34
- "vue": "^3.0",
35
- "vuex": "^4.0.0"
36
- },
37
- "devDependencies": {
38
- "@vue/cli-plugin-babel": "5.0.0-beta.6",
39
- "@vue/cli-plugin-eslint": "5.0.0-beta.6",
40
- "@vue/eslint-config-airbnb": "^5.0.0",
41
- "autoprefixer": "^9.6.1",
42
- "babel-eslint": "^10.0.1",
43
- "cross-env": "^6.0.0",
44
- "eslint": "^7.0.0",
45
- "eslint-import-resolver-alias": "^1.1.2",
46
- "eslint-plugin-vue": "^8.0.0"
31
+ "vue": "^3.0"
47
32
  }
48
33
  }
@@ -4,7 +4,7 @@
4
4
  events, fetch, loading, notifications, read,
5
5
  readAll, timeFromNow, unread, visitNotifications
6
6
  }">
7
- <navbar-item icon="bell"
7
+ <navbar-item :icon="faBell"
8
8
  :loading="loading"
9
9
  @show="fetch"
10
10
  @touch="visitNotifications"
@@ -16,66 +16,69 @@
16
16
  </span>
17
17
  </template>
18
18
  <template #default>
19
- <div class="notification-list"
20
- v-on="events">
21
- <a v-for="notification in notifications"
22
- :key="notification.id"
23
- class="navbar-item"
24
- @click="read(notification)">
25
- <p class="is-notification"
26
- :class="{
27
- 'has-text-grey-light': notification.read_at,
28
- 'is-bold': !notification.read_at,
29
- }">
30
- <fa v-if="notification.data.icon"
31
- :icon="notification.data.icon"/>
32
- {{ notification.data.body }}
33
- </p>
34
- <p>
35
- <small :class="{
36
- 'has-text-grey-light': notification.read_at,
37
- 'has-text-info': !notification.read_at,
38
- }">
39
- {{ timeFromNow(notification.created_at) }}
40
- </small>
41
- </p>
42
- </a>
43
- </div>
44
- <hr v-if="notifications.length > 0"
45
- class="navbar-divider">
46
- <nav v-if="notifications.length > 0"
47
- class="level navbar-item">
48
- <div class="level-left">
49
- <div class="level-item">
50
- <a class="button is-small is-info ml-1"
51
- @click="visitNotifications();$refs.navbarItem.hide()">
52
- <span>{{ i18n("See all") }}</span>
53
- <span class="icon is-small">
54
- <fa icon="eye"/>
55
- </span>
56
- </a>
57
- </div>
19
+ <div class="notifications-dropdown">
20
+ <div class="notification-list"
21
+ v-on="events">
22
+ <a v-for="notification in notifications"
23
+ :key="notification.id"
24
+ class="navbar-item"
25
+ @click="read(notification)">
26
+ <p class="is-notification"
27
+ :class="{
28
+ 'has-text-grey-light': notification.read_at,
29
+ 'is-bold': !notification.read_at,
30
+ }">
31
+ <fa v-if="notification.data.icon"
32
+ :icon="notification.data.icon"/>
33
+ {{ notification.data.body }}
34
+ </p>
35
+ <p>
36
+ <small :class="{
37
+ 'has-text-grey-light': notification.read_at,
38
+ 'has-text-info': !notification.read_at,
39
+ }">
40
+ {{ timeFromNow(notification.created_at) }}
41
+ </small>
42
+ </p>
43
+ </a>
58
44
  </div>
59
- <div class="level-right">
60
- <div class="level-item">
61
- <a class="button is-small is-success"
62
- @click="readAll">
63
- <span>{{ i18n("Mark all as read") }}</span>
64
- <span class="icon is-small">
65
- <fa icon="check"/>
66
- </span>
67
- </a>
45
+ <hr v-if="notifications.length > 0"
46
+ class="navbar-divider">
47
+ <nav v-if="notifications.length > 0"
48
+ class="level navbar-item">
49
+ <div class="level-left">
50
+ <div class="level-item">
51
+ <a class="button is-small is-info ml-1"
52
+ @click="visitNotifications();$refs.navbarItem.hide()">
53
+ <span>{{ i18n('See all') }}</span>
54
+ <span class="icon is-small">
55
+ <fa :icon="faEye"/>
56
+ </span>
57
+ </a>
58
+ </div>
68
59
  </div>
69
- </div>
70
- </nav>
71
- <a v-else class="navbar-item">
72
- <span v-if="unread || loading">
73
- {{ i18n("Loading...") }}
74
- </span>
75
- <span v-else-if="!unread">
76
- {{ i18n("You don't have any notifications") }}
77
- </span>
78
- </a>
60
+ <div class="level-right">
61
+ <div class="level-item">
62
+ <a class="button is-small is-success"
63
+ @click="readAll">
64
+ <span>{{ i18n('Mark all as read') }}</span>
65
+ <span class="icon is-small">
66
+ <fa :icon="faCheck"/>
67
+ </span>
68
+ </a>
69
+ </div>
70
+ </div>
71
+ </nav>
72
+ <a v-else
73
+ class="navbar-item">
74
+ <span v-if="unread || loading">
75
+ {{ i18n('Loading...') }}
76
+ </span>
77
+ <span v-else-if="!unread">
78
+ {{ i18n("You don't have any notifications") }}
79
+ </span>
80
+ </a>
81
+ </div>
79
82
  </template>
80
83
  </navbar-item>
81
84
  </template>
@@ -83,18 +86,12 @@
83
86
  </template>
84
87
 
85
88
  <script>
86
-
87
89
  import { clickOutside } from '@enso-ui/directives';
88
90
  import { FontAwesomeIcon as Fa } from '@fortawesome/vue-fontawesome';
89
- import { library } from '@fortawesome/fontawesome-svg-core';
90
- import {
91
- faBell, faCheck, faEye, faCogs, faQuestion, faEnvelope, faFileExcel,
92
- } from '@fortawesome/free-solid-svg-icons';
91
+ import { faBell, faCheck, faEye } from '@fortawesome/free-solid-svg-icons';
93
92
  import NavbarItem from '@enso-ui/ui/src/bulma/components/navbar/NavbarItem.vue';
94
93
  import CoreNotifications from '../../../core/components/navbar/Notifications.vue';
95
94
 
96
- library.add(faBell, faCheck, faEye, faCogs, faQuestion, faEnvelope, faFileExcel);
97
-
98
95
  export default {
99
96
  name: 'Notifications',
100
97
 
@@ -103,17 +100,62 @@ export default {
103
100
  components: { CoreNotifications, Fa, NavbarItem },
104
101
 
105
102
  inject: ['i18n'],
103
+
104
+ data: () => ({
105
+ faBell,
106
+ faCheck,
107
+ faEye,
108
+ }),
106
109
  };
107
110
 
108
111
  </script>
109
112
 
110
113
  <style lang="scss">
111
114
  .navbar-item {
115
+ --notifications-surface: var(--bulma-scheme-main-bis);
116
+
117
+ .notifications-dropdown {
118
+ background-color: var(--notifications-surface) !important;
119
+ color: var(--bulma-text);
120
+ }
121
+
112
122
  .notification-list {
113
123
  width: 300px;
114
124
  overflow-x: hidden;
115
125
  max-height: 400px;
116
126
  overflow-y: auto;
127
+ background-color: var(--notifications-surface) !important;
128
+ }
129
+
130
+ .notifications-dropdown > .navbar-item,
131
+ .notifications-dropdown > .level.navbar-item,
132
+ .notification-list > .navbar-item {
133
+ background-color: transparent !important;
134
+ }
135
+
136
+ .notifications-dropdown > .navbar-item,
137
+ .notifications-dropdown > .level.navbar-item {
138
+ background-color: var(--notifications-surface) !important;
139
+ margin: 0;
140
+ }
141
+
142
+ .notifications-dropdown > .level.navbar-item {
143
+ padding: 1rem;
144
+ }
145
+
146
+ .notifications-dropdown > .level.navbar-item .level-item {
147
+ margin-bottom: 0;
148
+ }
149
+
150
+ .notification-list > .navbar-item:hover,
151
+ .notification-list > .navbar-item:focus,
152
+ .notification-list > .navbar-item.is-active {
153
+ background-color: var(--bulma-scheme-main-ter);
154
+ }
155
+
156
+ .notifications-dropdown > .navbar-divider {
157
+ background-color: var(--bulma-border);
158
+ margin: 0;
117
159
  }
118
160
 
119
161
  .is-notification {
@@ -1,17 +1,17 @@
1
1
  <template>
2
2
  <div class="level is-mobile">
3
3
  <div class="level-left">
4
- <div class="level-item is-marginless">
4
+ <div class="level-item m-0">
5
5
  {{ i18n('Notifications') }}
6
6
  </div>
7
7
  </div>
8
8
  <div class="level-right">
9
- <div class="level-item toastr-position">
9
+ <div class="level-item toastr-position settings-control-select">
10
10
  <core-toastr-position>
11
11
  <template #default="{ positions, toastrPosition, update }">
12
12
  <dropdown>
13
13
  <template #label>
14
- <figure class="image is-16x16 ml-1">
14
+ <figure class="image is-16x16">
15
15
  <img :src="`/images/corners/${toastrPosition}.svg`">
16
16
  </figure>
17
17
  </template>
@@ -47,12 +47,26 @@ export default {
47
47
  </script>
48
48
 
49
49
  <style lang="scss">
50
- .toastr-position .dropdown .dropdown-content {
50
+ .toastr-position {
51
+ .dropdown-trigger .button.input .image {
52
+ margin: 0;
53
+ }
54
+
55
+ .dropdown-trigger .button.input .image img,
56
+ .dropdown-content .dropdown-item .image img {
57
+ display: block;
58
+ width: 0.95rem;
59
+ height: 0.95rem;
60
+ margin: auto;
61
+ object-fit: contain;
62
+ }
63
+
64
+ .dropdown .dropdown-content {
51
65
  width: 4.6em;
52
- .items {
53
- figure {
54
- margin: auto;
55
- }
66
+
67
+ .items figure {
68
+ margin: auto;
56
69
  }
57
70
  }
71
+ }
58
72
  </style>
@@ -8,7 +8,7 @@
8
8
  @click="readAll">
9
9
  <span>{{ i18n("Mark all read") }}</span>
10
10
  <span class="icon is-small">
11
- <fa icon="check"/>
11
+ <fa :icon="faCheck"/>
12
12
  </span>
13
13
  </a>
14
14
  </div>
@@ -18,7 +18,7 @@
18
18
  @click="fetch">
19
19
  <span>{{ i18n('Reload') }}</span>
20
20
  <span class="icon is-small">
21
- <fa icon="sync"/>
21
+ <fa :icon="faArrowsRotate"/>
22
22
  </span>
23
23
  </a>
24
24
  </fade>
@@ -29,7 +29,7 @@
29
29
  @click="destroyAll">
30
30
  <span>{{ i18n("Clear all") }}</span>
31
31
  <span class="icon is-small">
32
- <fa icon="trash-alt"/>
32
+ <fa :icon="faTrashCan"/>
33
33
  </span>
34
34
  </a>
35
35
  </div>
@@ -56,7 +56,7 @@
56
56
  </span>
57
57
  <span class="is-pulled-right">
58
58
  <span class="icon is-small">
59
- <fa icon="clock"
59
+ <fa :icon="faClock"
60
60
  size="xs"/>
61
61
  </span>
62
62
  {{ timeFromNow(notification.created_at) }}
@@ -78,18 +78,14 @@
78
78
  <script>
79
79
  import { Fade } from '@enso-ui/transitions';
80
80
  import debounce from 'lodash/debounce';
81
- import { mapState } from 'vuex';
82
81
  import { FontAwesomeIcon as Fa } from '@fortawesome/vue-fontawesome';
83
- import { library } from '@fortawesome/fontawesome-svg-core';
84
82
  import {
85
- faClock, faBell, faCheck, faTrashAlt, faSpinner, faSync,
83
+ faClock, faCheck, faTrashCan, faArrowsRotate,
86
84
  } from '@fortawesome/free-solid-svg-icons';
87
85
  import eventBus from '@enso-ui/ui/src/core/services/eventBus';
88
86
  import format from '@enso-ui/ui/src/modules/plugins/date-fns/format';
89
87
  import formatDistance from '@enso-ui/ui/src/modules/plugins/date-fns/formatDistance';
90
88
 
91
- library.add(faClock, faBell, faCheck, faTrashAlt, faSpinner, faSync);
92
-
93
89
  export default {
94
90
  name: 'Index',
95
91
 
@@ -103,17 +99,16 @@ export default {
103
99
  ],
104
100
 
105
101
  data: () => ({
102
+ faArrowsRotate,
103
+ faCheck,
104
+ faClock,
105
+ faTrashCan,
106
106
  paginate: 200,
107
107
  notifications: [],
108
108
  offset: 0,
109
109
  loading: false,
110
110
  }),
111
111
 
112
- computed: {
113
- ...mapState(['user', 'meta']),
114
- ...mapState('layout', ['isTouch']),
115
- },
116
-
117
112
  created() {
118
113
  this.fetch = debounce(this.fetch, 500);
119
114
  this.fetch();
@@ -157,8 +152,6 @@ export default {
157
152
  notification.read_at = notification.read_at || format(new Date(), 'Y-M-D H:i:s');
158
153
  });
159
154
 
160
- this.unreadCount = 0;
161
-
162
155
  eventBus.$emit('read-all-notifications');
163
156
  },
164
157
  destroyAll() {
@@ -1,6 +1,7 @@
1
- import App from '@enso-ui/ui/src/core/app';
2
1
  import Notification from './components/navbar/Notifications.vue';
3
2
  import ToastPosition from './components/settings/ToastrPosition.vue';
4
3
 
5
- App.registerNavbarItem('notification', Notification, 300, 'core.notifications.count');
6
- App.registerSettingsItem('toaster-position', ToastPosition, 300);
4
+ export default App => {
5
+ App.registerNavbarItem('notification', Notification, 300, 'core.notifications.count');
6
+ App.registerSettingsItem('toaster-position', ToastPosition, 300);
7
+ };
@@ -1,12 +1,11 @@
1
1
  <script>
2
2
  import { debounce } from 'lodash';
3
- import {
4
- mapState, mapGetters, mapActions,
5
- } from 'vuex';
6
3
  import Favico from 'favico.js';
7
4
  import eventBus from '@enso-ui/ui/src/core/services/eventBus';
8
5
  import format from '@enso-ui/ui/src/modules/plugins/date-fns/format';
9
6
  import formatDistance from '@enso-ui/ui/src/modules/plugins/date-fns/formatDistance';
7
+ import { app } from '@enso-ui/ui/src/pinia/app';
8
+ import { websockets } from '@enso-ui/ui/src/pinia/websockets';
10
9
 
11
10
  export default {
12
11
  name: 'Notifications',
@@ -36,9 +35,12 @@ export default {
36
35
  }),
37
36
 
38
37
  computed: {
39
- ...mapGetters('websockets', ['channels']),
40
- ...mapGetters(['isWebview']),
41
- ...mapState(['user']),
38
+ channels() {
39
+ return websockets().channels;
40
+ },
41
+ isWebview() {
42
+ return app().isWebview;
43
+ },
42
44
  },
43
45
 
44
46
  watch: {
@@ -57,7 +59,6 @@ export default {
57
59
  },
58
60
 
59
61
  methods: {
60
- ...mapActions('websockets', ['connect']),
61
62
  addBusListeners() {
62
63
  eventBus.$on('read-notification', notification => {
63
64
  this.unread = Math.max(--this.unread, 0);
@@ -98,6 +99,9 @@ export default {
98
99
  this.fetch();
99
100
  }
100
101
  },
102
+ connect() {
103
+ return websockets().connect(app().meta.csrfToken);
104
+ },
101
105
  count() {
102
106
  this.http.get(this.route('core.notifications.count'))
103
107
  .then(({ data }) => (this.unread = data.count))
@@ -177,7 +181,7 @@ export default {
177
181
  this.unread = Math.max(--this.unread, 0);
178
182
  notification.read_at = data.read_at;
179
183
 
180
- if (notification.data.path !== '#') {
184
+ if (notification.data.path && notification.data.path !== '#') {
181
185
  this.$router.push({ path: notification.data.path })
182
186
  .catch(this.routerErrorHandler);
183
187
  }
@@ -1,6 +1,6 @@
1
1
  <script>
2
- import { mapGetters, mapActions } from 'vuex';
3
2
  import { positions } from '@enso-ui/toastr/config';
3
+ import { preferences } from '@enso-ui/ui/src/pinia/preferences';
4
4
 
5
5
  export default {
6
6
  name: 'ToastrPosition',
@@ -12,13 +12,14 @@ export default {
12
12
  }),
13
13
 
14
14
  computed: {
15
- ...mapGetters('preferences', ['toastrPosition']),
15
+ toastrPosition() {
16
+ return preferences().toastrPosition;
17
+ },
16
18
  },
17
19
 
18
20
  methods: {
19
- ...mapActions('preferences', ['setToastrPosition']),
20
21
  update(position) {
21
- this.setToastrPosition(position);
22
+ preferences().setToastrPosition(position);
22
23
  this.toastr.setup(position);
23
24
  },
24
25
  },