@webitel/ui-sdk 26.4.69 → 26.4.71
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/dist/{contacts-CJxt5atR.js → contacts-BOuQKoDp.js} +2 -2
- package/dist/{index-CONQTTQp.js → index-Cq6SdyOJ.js} +1 -1
- package/dist/{index-XXRSOohq.js → index-ch54BXzp.js} +1 -1
- package/dist/{install-Dq6Xzj7N.js → install-a-C0Uz5X.js} +44 -38
- package/dist/{isObject-BI2QDiNt.js → isObject-B9X5X8ug.js} +1 -1
- package/dist/ui-sdk.js +1 -1
- package/dist/ui-sdk.umd.cjs +34 -30
- package/dist/{useVidstackSrc-Djb6KDgP.js → useVidstackSrc-DrM-wOlo.js} +1 -1
- package/dist/{vidstack-Bq6c3Bam-CrjywxX-.js → vidstack-Bq6c3Bam-B5VDRBw5.js} +3 -3
- package/dist/{vidstack-D2pY00kU-DvPC2ESM.js → vidstack-D2pY00kU-DJmibeBt.js} +3 -3
- package/dist/{vidstack-DDXt6fpN-CDO8xMej.js → vidstack-DDXt6fpN-D-MJ1xZx.js} +2 -2
- package/dist/{vidstack-D_-9AA6_-B5njLdbU.js → vidstack-D_-9AA6_-DoM3btjD.js} +2 -2
- package/dist/{vidstack-DqAw8m9J-DYSE2hHC.js → vidstack-DqAw8m9J-DS-MlVMa.js} +1 -1
- package/dist/{vidstack-audio-DZQDzdLw.js → vidstack-audio-CRGh5Tj-.js} +2 -2
- package/dist/{vidstack-dash-DvUOZdpr.js → vidstack-dash-BzRvYTyV.js} +4 -4
- package/dist/{vidstack-google-cast-Dm3jBuU8.js → vidstack-google-cast-BQ9oWxZg.js} +4 -4
- package/dist/{vidstack-hls-BC6EbBSE.js → vidstack-hls-DPux1IQI.js} +4 -4
- package/dist/{vidstack-video-DAwnmp8l.js → vidstack-video-D122wTEc.js} +3 -3
- package/dist/{vidstack-vimeo-CvMjTf1x.js → vidstack-vimeo-eYPalti9.js} +4 -4
- package/dist/{vidstack-youtube-COvmMHYi.js → vidstack-youtube-DRYZy9nN.js} +3 -3
- package/dist/{wt-action-bar-_7ZHyxxh.js → wt-action-bar-DIlVDjAl.js} +1 -1
- package/dist/{wt-button-select-u6m5lUsm.js → wt-button-select-BUUoLjiC.js} +1 -1
- package/dist/{wt-call-media-action-BpjCjt1Q.js → wt-call-media-action-CfXNHg73.js} +1 -1
- package/dist/{wt-chat-emoji-DlcRu7FP.js → wt-chat-emoji-CUtTN1q_.js} +2 -2
- package/dist/{wt-confirm-dialog-Dcfy0_Dh.js → wt-confirm-dialog-DxMG0CHg.js} +1 -1
- package/dist/{wt-context-menu-CfvK47LT.js → wt-context-menu-W4XuT5R2.js} +1 -1
- package/dist/{wt-copy-action-dQYyxKI8.js → wt-copy-action-B-fdVV78.js} +1 -1
- package/dist/{wt-datepicker-_jKTZEYe.js → wt-datepicker-DJwSA6aU.js} +1 -1
- package/dist/{wt-display-chip-items-DEyKDhPh.js → wt-display-chip-items-C0TJavRb.js} +1 -1
- package/dist/{wt-dual-panel-erhboDAz.js → wt-dual-panel-BdelktL7.js} +1 -1
- package/dist/{wt-dummy-C6iAgiXM.js → wt-dummy-DuLtIKMP.js} +1 -1
- package/dist/{wt-error-page-Bfl_LRhh.js → wt-error-page-B4pbqoOI.js} +1 -1
- package/dist/{wt-expansion-card-DMxFDx4x.js → wt-expansion-card-BavIcBK_.js} +1 -1
- package/dist/{wt-expansion-panel-mbH-v55W.js → wt-expansion-panel-B59aDFEZ.js} +1 -1
- package/dist/{wt-filters-panel-wrapper-DYLimgQe.js → wt-filters-panel-wrapper-BfQYzZs0.js} +1 -1
- package/dist/{wt-galleria-DtQdYbAk.js → wt-galleria-hedkglRb.js} +1 -1
- package/dist/{wt-inline-add-panel-BZQ9uASA.js → wt-inline-add-panel-B_kPpP1_.js} +1 -1
- package/dist/{wt-navigation-menu-xCV8Zzgb.js → wt-navigation-menu-CpTy3E68.js} +1 -1
- package/dist/{wt-notifications-bar-xlUz2DdN.js → wt-notifications-bar-BNPfk1iC.js} +2 -2
- package/dist/{wt-pagination-BcAOJYQV.js → wt-pagination-BClxscNy.js} +1 -1
- package/dist/{wt-player-gefGvHwU.js → wt-player-Ch-mSg17.js} +2 -2
- package/dist/{wt-screen-recordings-action-Dzdp2_qq.js → wt-screen-recordings-action--s_MsjZw.js} +1 -1
- package/dist/{wt-search-bar-C1cR9-U9.js → wt-search-bar-CV5VvUNu.js} +1 -1
- package/dist/{wt-selection-popup-CPlbwICi.js → wt-selection-popup-CDDJ7AwF.js} +1 -1
- package/dist/{wt-send-message-popup-B85JZJI9.js → wt-send-message-popup-By-IM3st.js} +3 -3
- package/dist/{wt-start-page-BTSyTNEG.js → wt-start-page-CbBRuRv9.js} +1 -1
- package/dist/{wt-status-select-BZ4k_L9V.js → wt-status-select-CVNTiFRz.js} +1 -1
- package/dist/{wt-stepper-BN5w-5zY.js → wt-stepper-CPBypZZh.js} +1 -1
- package/dist/{wt-table-C36drCHg.js → wt-table-V7R9cmj3.js} +1 -1
- package/dist/{wt-table-actions-D4PXoofe.js → wt-table-actions-DdQDLaDm.js} +1 -1
- package/dist/{wt-table-column-select-1PQXgyFT.js → wt-table-column-select-BWDKZosT.js} +2 -2
- package/dist/{wt-tabs-B4iyoQ60.js → wt-tabs-CgJRC1CS.js} +1 -1
- package/dist/{wt-tags-input-CsE5LvoM.js → wt-tags-input-CxDztdx9.js} +2 -2
- package/dist/{wt-timepicker-DA9oY8x2.js → wt-timepicker-CqrQfVeK.js} +1 -1
- package/dist/{wt-tree-CY7FMdbj.js → wt-tree-DJ0XlSS7.js} +2 -2
- package/dist/{wt-tree-table-CNH8s-WE.js → wt-tree-table-D3SrPnc8.js} +1 -1
- package/dist/{wt-type-extension-value-input-DX8QoEo0.js → wt-type-extension-value-input-CMfYqYAw.js} +3 -3
- package/dist/{wt-vidstack-player-D3StpoLu.js → wt-vidstack-player-Ca6Oy-ne.js} +10 -10
- package/package.json +1 -1
- package/src/modules/UserNotifications/maps/userNotificationConfigsMap.ts +24 -7
- package/src/modules/UserNotifications/stores/__tests__/userNotificationsStore.spec.ts +160 -93
- package/src/modules/UserNotifications/stores/userNotificationsStore.ts +81 -48
- package/src/modules/UserNotifications/types/UserNotifications.ts +5 -8
- package/src/modules/Userinfo/api/UserinfoAPI.ts +1 -0
- package/src/modules/Userinfo/stores/userinfoStore.ts +9 -6
- package/src/plugins/primevue/theme/components/textarea/textarea.js +4 -0
- package/types/modules/UserNotifications/maps/userNotificationConfigsMap.d.ts +3 -1
- package/types/modules/UserNotifications/stores/userNotificationsStore.d.ts +9 -104
- package/types/modules/UserNotifications/types/UserNotifications.d.ts +5 -8
- package/types/modules/Userinfo/api/UserinfoAPI.d.ts +1 -0
- package/types/modules/Userinfo/stores/userinfoStore.d.ts +7 -4
- package/types/plugins/primevue/theme/components/textarea/textarea.d.ts +2 -0
|
@@ -1,118 +1,185 @@
|
|
|
1
1
|
import { ApiUserWarningId } from '@webitel/api-services/gen/models';
|
|
2
2
|
import { createPinia, setActivePinia } from 'pinia';
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import eventBus from '../../../../scripts/eventBus';
|
|
5
|
+
import { getUserWarnings } from '../../api/UserNotifications';
|
|
6
|
+
import { createUserNotificationsStore } from '../userNotificationsStore';
|
|
7
7
|
|
|
8
|
-
// Mocks for modules used by the store
|
|
9
8
|
vi.mock('../../api/UserNotifications', () => {
|
|
10
9
|
return {
|
|
11
10
|
getUserWarnings: vi.fn(),
|
|
12
11
|
};
|
|
13
12
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
vi.mock('../../../../scripts/eventBus', () => ({
|
|
14
|
+
default: {
|
|
15
|
+
$emit: vi.fn(),
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const mockedGetUserWarnings = vi.mocked(getUserWarnings);
|
|
20
|
+
const STORAGE_KEY = 'usersWithShownNotifications';
|
|
21
|
+
const TEST_USER_ID = 'user-123';
|
|
22
|
+
|
|
23
|
+
const mockPasswordWarning = {
|
|
24
|
+
id: ApiUserWarningId.PasswordExpiresSoon,
|
|
25
|
+
warningData: {
|
|
26
|
+
passwordExpiry: {
|
|
27
|
+
daysRemaining: 3,
|
|
22
28
|
},
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
$emit: emitMock,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mockLicenseWarning = {
|
|
33
|
+
id: ApiUserWarningId.LicenseExpiresSoon,
|
|
34
|
+
warningData: {
|
|
35
|
+
licenseExpiry: {
|
|
36
|
+
daysRemaining: 5,
|
|
37
|
+
licenseName: 'Enterprise',
|
|
33
38
|
},
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
import eventBus from '../../../../scripts/eventBus';
|
|
38
|
-
import { getUserWarnings } from '../../api/UserNotifications';
|
|
39
|
-
import { USER_NOTIFICATION_CONFIGS_MAP } from '../../maps/userNotificationConfigsMap';
|
|
40
|
-
import { createUserNotificationsStore } from '../userNotificationsStore';
|
|
41
|
-
|
|
42
|
-
describe('createUserNotificationsStore', () => {
|
|
43
|
-
let useStore: ReturnType<typeof createUserNotificationsStore>;
|
|
44
|
-
let pinia: ReturnType<typeof createPinia>;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
45
41
|
|
|
42
|
+
describe('userNotificationsStore', () => {
|
|
46
43
|
beforeEach(() => {
|
|
44
|
+
setActivePinia(createPinia());
|
|
45
|
+
localStorage.clear();
|
|
47
46
|
vi.clearAllMocks();
|
|
48
|
-
|
|
49
|
-
pinia = createPinia();
|
|
50
|
-
const app = createApp({});
|
|
51
|
-
app.use(pinia);
|
|
52
|
-
setActivePinia(pinia);
|
|
53
|
-
|
|
54
|
-
useStore = createUserNotificationsStore();
|
|
47
|
+
vi.useFakeTimers();
|
|
55
48
|
});
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
describe('showNotifications', () => {
|
|
51
|
+
it('does not show notifications that the user is already in storage', async () => {
|
|
52
|
+
localStorage.setItem(
|
|
53
|
+
STORAGE_KEY,
|
|
54
|
+
JSON.stringify([
|
|
55
|
+
TEST_USER_ID,
|
|
56
|
+
]),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const useStore = createUserNotificationsStore();
|
|
60
|
+
const store = useStore();
|
|
61
|
+
|
|
62
|
+
await store.showNotifications(TEST_USER_ID);
|
|
63
|
+
|
|
64
|
+
expect(getUserWarnings).not.toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('shows notifications and saves the user in storage', async () => {
|
|
68
|
+
mockedGetUserWarnings.mockResolvedValue({
|
|
69
|
+
warnings: [
|
|
70
|
+
mockPasswordWarning,
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const useStore = createUserNotificationsStore();
|
|
75
|
+
const store = useStore();
|
|
76
|
+
|
|
77
|
+
await store.showNotifications(TEST_USER_ID);
|
|
78
|
+
vi.runAllTimers();
|
|
79
|
+
|
|
80
|
+
expect(eventBus.$emit).toHaveBeenCalledWith(
|
|
81
|
+
'notification',
|
|
82
|
+
expect.objectContaining({
|
|
83
|
+
type: 'info',
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const stored = JSON.parse(localStorage.getItem(STORAGE_KEY));
|
|
88
|
+
expect(stored).toContain(TEST_USER_ID);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('Do not ignore API notifications by turning an empty array', async () => {
|
|
92
|
+
mockedGetUserWarnings.mockResolvedValue({
|
|
93
|
+
warnings: [],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const useStore = createUserNotificationsStore();
|
|
97
|
+
const store = useStore();
|
|
98
|
+
|
|
99
|
+
await store.showNotifications(TEST_USER_ID);
|
|
100
|
+
vi.runAllTimers();
|
|
101
|
+
|
|
102
|
+
expect(eventBus.$emit).not.toHaveBeenCalled();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('Do not save if the id is not found in the map config', async () => {
|
|
106
|
+
mockedGetUserWarnings.mockResolvedValue({
|
|
107
|
+
warnings: [
|
|
108
|
+
{
|
|
109
|
+
id: 'unknown_warning',
|
|
110
|
+
warningData: {},
|
|
67
111
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const useStore = createUserNotificationsStore();
|
|
116
|
+
const store = useStore();
|
|
117
|
+
|
|
118
|
+
await store.showNotifications(TEST_USER_ID);
|
|
119
|
+
vi.runAllTimers();
|
|
71
120
|
|
|
72
|
-
|
|
121
|
+
expect(eventBus.$emit).not.toHaveBeenCalled();
|
|
122
|
+
});
|
|
73
123
|
|
|
74
|
-
|
|
124
|
+
it('shows some notifications', async () => {
|
|
125
|
+
mockedGetUserWarnings.mockResolvedValue({
|
|
126
|
+
warnings: [
|
|
127
|
+
mockPasswordWarning,
|
|
128
|
+
mockLicenseWarning,
|
|
129
|
+
],
|
|
130
|
+
});
|
|
75
131
|
|
|
76
|
-
|
|
77
|
-
|
|
132
|
+
const useStore = createUserNotificationsStore();
|
|
133
|
+
const store = useStore();
|
|
78
134
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
?.localeKey,
|
|
85
|
-
);
|
|
86
|
-
expect(getUserWarnings).toHaveBeenCalledOnce();
|
|
135
|
+
await store.showNotifications(TEST_USER_ID);
|
|
136
|
+
vi.runAllTimers();
|
|
137
|
+
|
|
138
|
+
expect(eventBus.$emit).toHaveBeenCalledTimes(2);
|
|
139
|
+
});
|
|
87
140
|
});
|
|
88
141
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
142
|
+
describe('clearShownUserNotifications', () => {
|
|
143
|
+
it('clear localStorage', async () => {
|
|
144
|
+
localStorage.setItem(
|
|
145
|
+
STORAGE_KEY,
|
|
146
|
+
JSON.stringify([
|
|
147
|
+
TEST_USER_ID,
|
|
148
|
+
'user-456',
|
|
149
|
+
]),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const useStore = createUserNotificationsStore();
|
|
153
|
+
const store = useStore();
|
|
154
|
+
|
|
155
|
+
store.clearShownUserNotifications(TEST_USER_ID);
|
|
156
|
+
|
|
157
|
+
const stored = JSON.parse(localStorage.getItem(STORAGE_KEY));
|
|
158
|
+
expect(stored).not.toContain(TEST_USER_ID);
|
|
159
|
+
expect(stored).toContain('user-456');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('after clearShownUserNotifications notifications display again', async () => {
|
|
163
|
+
localStorage.setItem(
|
|
164
|
+
STORAGE_KEY,
|
|
165
|
+
JSON.stringify([
|
|
166
|
+
TEST_USER_ID,
|
|
167
|
+
]),
|
|
168
|
+
);
|
|
169
|
+
mockedGetUserWarnings.mockResolvedValue({
|
|
170
|
+
warnings: [
|
|
171
|
+
mockPasswordWarning,
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const useStore = createUserNotificationsStore();
|
|
176
|
+
const store = useStore();
|
|
177
|
+
|
|
178
|
+
store.clearShownUserNotifications(TEST_USER_ID);
|
|
179
|
+
await store.showNotifications(TEST_USER_ID);
|
|
180
|
+
vi.runAllTimers();
|
|
181
|
+
|
|
182
|
+
expect(eventBus.$emit).toHaveBeenCalled();
|
|
183
|
+
});
|
|
117
184
|
});
|
|
118
185
|
});
|
|
@@ -1,74 +1,107 @@
|
|
|
1
1
|
import type { ApiUserWarning } from '@webitel/api-services/gen/models';
|
|
2
2
|
import { defineStore } from 'pinia';
|
|
3
|
-
import {
|
|
3
|
+
import { ref } from 'vue';
|
|
4
4
|
import i18n from '../../../locale/i18n';
|
|
5
5
|
import eventBus from '../../../scripts/eventBus';
|
|
6
6
|
import { getUserWarnings } from '../api/UserNotifications';
|
|
7
7
|
import { USER_NOTIFICATION_CONFIGS_MAP } from '../maps/userNotificationConfigsMap';
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '../types/UserNotifications';
|
|
8
|
+
import type { NotificationsType } from '../types/UserNotifications';
|
|
9
|
+
|
|
10
|
+
const STORAGE_KEY = 'usersWithShownNotifications';
|
|
12
11
|
|
|
13
12
|
export const createUserNotificationsStore = () => {
|
|
14
13
|
const namespace = 'userNotifications';
|
|
15
14
|
|
|
16
15
|
const store = defineStore(namespace, () => {
|
|
17
|
-
const
|
|
16
|
+
const notifications = ref<NotificationsType[]>([]);
|
|
17
|
+
|
|
18
|
+
const getStoredUsers = (): string[] => {
|
|
19
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
20
|
+
return stored ? JSON.parse(stored) : [];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const isShownUserNotifications = (userId: string): boolean =>
|
|
24
|
+
getStoredUsers().includes(userId);
|
|
18
25
|
|
|
19
|
-
const
|
|
20
|
-
|
|
26
|
+
const setShownUserNotifications = (userId: string) => {
|
|
27
|
+
const shown = getStoredUsers();
|
|
28
|
+
localStorage.setItem(
|
|
29
|
+
STORAGE_KEY,
|
|
30
|
+
JSON.stringify([
|
|
31
|
+
...new Set([
|
|
32
|
+
...shown,
|
|
33
|
+
userId,
|
|
34
|
+
]),
|
|
35
|
+
]),
|
|
36
|
+
);
|
|
21
37
|
};
|
|
22
38
|
|
|
23
|
-
const
|
|
39
|
+
const clearShownUserNotifications = (userId: string) => {
|
|
40
|
+
const shown = getStoredUsers().filter((id: string) => id !== userId);
|
|
41
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(shown));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const fetchNotifications = async (): Promise<ApiUserWarning[]> => {
|
|
24
45
|
const response = await getUserWarnings();
|
|
25
|
-
|
|
26
|
-
(response && (response.warnings as ApiUserWarning[])) ?? [];
|
|
46
|
+
return (response?.warnings as ApiUserWarning[]) ?? [];
|
|
27
47
|
};
|
|
28
48
|
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
.map((
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
type: config.type,
|
|
38
|
-
localeKey: config.localeKey,
|
|
39
|
-
days: config.getDays(notification.warningData),
|
|
40
|
-
shown: false,
|
|
41
|
-
};
|
|
49
|
+
const mapNotifications = (array: ApiUserWarning[]) => {
|
|
50
|
+
return array
|
|
51
|
+
.map((warning) => {
|
|
52
|
+
const map = USER_NOTIFICATION_CONFIGS_MAP.get(warning.id);
|
|
53
|
+
if (!map) return null;
|
|
54
|
+
return map(warning);
|
|
42
55
|
})
|
|
43
56
|
.filter(Boolean) as NotificationsType[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const emitNotification = ({
|
|
60
|
+
type,
|
|
61
|
+
localeKey,
|
|
62
|
+
params,
|
|
63
|
+
}: NotificationsType) => {
|
|
64
|
+
const locale = localStorage.getItem('lang') || i18n.global.locale.value;
|
|
65
|
+
setTimeout(
|
|
66
|
+
() =>
|
|
67
|
+
eventBus.$emit('notification', {
|
|
68
|
+
type,
|
|
69
|
+
text: i18n.global.t(
|
|
70
|
+
`systemNotifications.warnings.${localeKey}`,
|
|
71
|
+
{
|
|
72
|
+
...params,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
locale,
|
|
76
|
+
},
|
|
77
|
+
),
|
|
78
|
+
}),
|
|
79
|
+
100,
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const showNotifications = async (userId: string) => {
|
|
84
|
+
try {
|
|
85
|
+
if (isShownUserNotifications(userId)) return;
|
|
86
|
+
|
|
87
|
+
const apiNotifications = await fetchNotifications();
|
|
88
|
+
notifications.value = mapNotifications(apiNotifications);
|
|
89
|
+
|
|
90
|
+
if (!notifications.value?.length) return;
|
|
91
|
+
|
|
92
|
+
notifications.value.forEach((notification) => {
|
|
93
|
+
emitNotification(notification);
|
|
60
94
|
});
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
|
|
96
|
+
setShownUserNotifications(userId);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
63
100
|
};
|
|
64
101
|
|
|
65
102
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** internal for devtools/debug */
|
|
70
|
-
rawNotifications,
|
|
71
|
-
notifications,
|
|
103
|
+
showNotifications,
|
|
104
|
+
clearShownUserNotifications,
|
|
72
105
|
};
|
|
73
106
|
});
|
|
74
107
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
localeKey: string;
|
|
5
|
-
getDays: (warningData: number) => number;
|
|
1
|
+
interface UserNotificationsConfigsParams {
|
|
2
|
+
amount?: number;
|
|
3
|
+
name?: string;
|
|
6
4
|
}
|
|
7
5
|
|
|
8
6
|
interface NotificationsType {
|
|
9
7
|
type: 'info' | 'warning' | 'error';
|
|
10
8
|
localeKey: string;
|
|
11
|
-
|
|
12
|
-
shown?: boolean;
|
|
9
|
+
params?: UserNotificationsConfigsParams;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export type { NotificationsType,
|
|
12
|
+
export type { NotificationsType, UserNotificationsConfigsParams };
|
|
@@ -37,10 +37,8 @@ export const createUserinfoStore = () => {
|
|
|
37
37
|
const { initialize: initializeSettingsStore } = settingsStore;
|
|
38
38
|
const { timezone } = storeToRefs(settingsStore);
|
|
39
39
|
const userNotificationsStore = useUserNotificationsStore();
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
show: showUserNotifications,
|
|
43
|
-
} = userNotificationsStore;
|
|
40
|
+
const { showNotifications, clearShownUserNotifications } =
|
|
41
|
+
userNotificationsStore;
|
|
44
42
|
|
|
45
43
|
const userId = ref();
|
|
46
44
|
const userInfo = ref();
|
|
@@ -48,11 +46,10 @@ export const createUserinfoStore = () => {
|
|
|
48
46
|
const initialize = async () => {
|
|
49
47
|
const session = await getSession();
|
|
50
48
|
const access = await getUiVisibilityAccess();
|
|
51
|
-
await initializeUserNotificationsStore();
|
|
52
49
|
|
|
53
50
|
userId.value = session.userId;
|
|
54
51
|
userInfo.value = pick(session, [
|
|
55
|
-
'
|
|
52
|
+
'domain',
|
|
56
53
|
'username',
|
|
57
54
|
'permissions',
|
|
58
55
|
'userId',
|
|
@@ -72,10 +69,15 @@ export const createUserinfoStore = () => {
|
|
|
72
69
|
await initializeSettingsStore();
|
|
73
70
|
};
|
|
74
71
|
|
|
72
|
+
const showUserNotifications = () => showNotifications(userId.value);
|
|
73
|
+
const clearStorageNotifications = (id?: string) =>
|
|
74
|
+
clearShownUserNotifications(id ?? userId.value);
|
|
75
|
+
|
|
75
76
|
const logoutUser = async () => {
|
|
76
77
|
const authUrl = import.meta.env.VITE_AUTH_URL;
|
|
77
78
|
if (!authUrl) throw new Error('No authUrl for LOGOUT provided');
|
|
78
79
|
await logout();
|
|
80
|
+
clearStorageNotifications();
|
|
79
81
|
window.location.href = authUrl;
|
|
80
82
|
};
|
|
81
83
|
|
|
@@ -98,6 +100,7 @@ export const createUserinfoStore = () => {
|
|
|
98
100
|
hasApplicationVisibility,
|
|
99
101
|
logoutUser,
|
|
100
102
|
showUserNotifications,
|
|
103
|
+
clearStorageNotifications,
|
|
101
104
|
};
|
|
102
105
|
});
|
|
103
106
|
|
|
@@ -8,6 +8,10 @@ const textarea = {
|
|
|
8
8
|
colorScheme: TextareaScheme.colorScheme,
|
|
9
9
|
|
|
10
10
|
css: ({ dt }) => `
|
|
11
|
+
.p-textarea.p-invalid:enabled:hover {
|
|
12
|
+
border-color: ${dt('textarea.invalidHoverBorderColor')};
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
.wt-textarea__textarea {
|
|
12
16
|
${generateWtTypographyCustomCss({
|
|
13
17
|
dt,
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { ApiUserWarningId } from '@webitel/api-services/gen/models';
|
|
2
|
+
import type { NotificationsType } from '../types/UserNotifications';
|
|
3
|
+
export declare const USER_NOTIFICATION_CONFIGS_MAP: Map<ApiUserWarningId, (warningId: ApiUserWarningId) => NotificationsType>;
|
|
@@ -1,105 +1,10 @@
|
|
|
1
|
-
import type { ApiUserWarning } from '@webitel/api-services/gen/models';
|
|
2
|
-
import type { NotificationsType } from '../types/UserNotifications';
|
|
3
1
|
export declare const createUserNotificationsStore: () => import("pinia").StoreDefinition<"userNotifications", Pick<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
expiresAt?: string;
|
|
14
|
-
licenseName?: string;
|
|
15
|
-
};
|
|
16
|
-
passwordExpiry?: {
|
|
17
|
-
daysRemaining?: string;
|
|
18
|
-
expiresAt?: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}[], ApiUserWarning[] | {
|
|
22
|
-
detail?: string;
|
|
23
|
-
id?: import("@webitel/api-services/gen/models").ApiUserWarningId;
|
|
24
|
-
warningData?: {
|
|
25
|
-
licenseExpiry?: {
|
|
26
|
-
daysRemaining?: string;
|
|
27
|
-
expiresAt?: string;
|
|
28
|
-
licenseName?: string;
|
|
29
|
-
};
|
|
30
|
-
passwordExpiry?: {
|
|
31
|
-
daysRemaining?: string;
|
|
32
|
-
expiresAt?: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}[]>;
|
|
36
|
-
notifications: import("vue").ComputedRef<NotificationsType[]>;
|
|
37
|
-
}, "rawNotifications">, Pick<{
|
|
38
|
-
initialize: () => Promise<void>;
|
|
39
|
-
show: () => void;
|
|
40
|
-
/** internal for devtools/debug */
|
|
41
|
-
rawNotifications: import("vue").Ref<{
|
|
42
|
-
detail?: string;
|
|
43
|
-
id?: import("@webitel/api-services/gen/models").ApiUserWarningId;
|
|
44
|
-
warningData?: {
|
|
45
|
-
licenseExpiry?: {
|
|
46
|
-
daysRemaining?: string;
|
|
47
|
-
expiresAt?: string;
|
|
48
|
-
licenseName?: string;
|
|
49
|
-
};
|
|
50
|
-
passwordExpiry?: {
|
|
51
|
-
daysRemaining?: string;
|
|
52
|
-
expiresAt?: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
}[], ApiUserWarning[] | {
|
|
56
|
-
detail?: string;
|
|
57
|
-
id?: import("@webitel/api-services/gen/models").ApiUserWarningId;
|
|
58
|
-
warningData?: {
|
|
59
|
-
licenseExpiry?: {
|
|
60
|
-
daysRemaining?: string;
|
|
61
|
-
expiresAt?: string;
|
|
62
|
-
licenseName?: string;
|
|
63
|
-
};
|
|
64
|
-
passwordExpiry?: {
|
|
65
|
-
daysRemaining?: string;
|
|
66
|
-
expiresAt?: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}[]>;
|
|
70
|
-
notifications: import("vue").ComputedRef<NotificationsType[]>;
|
|
71
|
-
}, "notifications">, Pick<{
|
|
72
|
-
initialize: () => Promise<void>;
|
|
73
|
-
show: () => void;
|
|
74
|
-
/** internal for devtools/debug */
|
|
75
|
-
rawNotifications: import("vue").Ref<{
|
|
76
|
-
detail?: string;
|
|
77
|
-
id?: import("@webitel/api-services/gen/models").ApiUserWarningId;
|
|
78
|
-
warningData?: {
|
|
79
|
-
licenseExpiry?: {
|
|
80
|
-
daysRemaining?: string;
|
|
81
|
-
expiresAt?: string;
|
|
82
|
-
licenseName?: string;
|
|
83
|
-
};
|
|
84
|
-
passwordExpiry?: {
|
|
85
|
-
daysRemaining?: string;
|
|
86
|
-
expiresAt?: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
}[], ApiUserWarning[] | {
|
|
90
|
-
detail?: string;
|
|
91
|
-
id?: import("@webitel/api-services/gen/models").ApiUserWarningId;
|
|
92
|
-
warningData?: {
|
|
93
|
-
licenseExpiry?: {
|
|
94
|
-
daysRemaining?: string;
|
|
95
|
-
expiresAt?: string;
|
|
96
|
-
licenseName?: string;
|
|
97
|
-
};
|
|
98
|
-
passwordExpiry?: {
|
|
99
|
-
daysRemaining?: string;
|
|
100
|
-
expiresAt?: string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
}[]>;
|
|
104
|
-
notifications: import("vue").ComputedRef<NotificationsType[]>;
|
|
105
|
-
}, "show" | "initialize">>;
|
|
2
|
+
showNotifications: (userId: string) => Promise<void>;
|
|
3
|
+
clearShownUserNotifications: (userId: string) => void;
|
|
4
|
+
}, never>, Pick<{
|
|
5
|
+
showNotifications: (userId: string) => Promise<void>;
|
|
6
|
+
clearShownUserNotifications: (userId: string) => void;
|
|
7
|
+
}, never>, Pick<{
|
|
8
|
+
showNotifications: (userId: string) => Promise<void>;
|
|
9
|
+
clearShownUserNotifications: (userId: string) => void;
|
|
10
|
+
}, "showNotifications" | "clearShownUserNotifications">>;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
localeKey: string;
|
|
5
|
-
getDays: (warningData: number) => number;
|
|
1
|
+
interface UserNotificationsConfigsParams {
|
|
2
|
+
amount?: number;
|
|
3
|
+
name?: string;
|
|
6
4
|
}
|
|
7
5
|
interface NotificationsType {
|
|
8
6
|
type: 'info' | 'warning' | 'error';
|
|
9
7
|
localeKey: string;
|
|
10
|
-
|
|
11
|
-
shown?: boolean;
|
|
8
|
+
params?: UserNotificationsConfigsParams;
|
|
12
9
|
}
|
|
13
|
-
export type { NotificationsType,
|
|
10
|
+
export type { NotificationsType, UserNotificationsConfigsParams };
|
|
@@ -5,6 +5,7 @@ declare const getSession: () => Promise<{
|
|
|
5
5
|
scope: ScopeAccessApiResponseItem[];
|
|
6
6
|
permissions: GlobalAccessApiResponseItem[];
|
|
7
7
|
userId: string;
|
|
8
|
+
domain: string;
|
|
8
9
|
license: WebitelLicenseInfo[];
|
|
9
10
|
}>;
|
|
10
11
|
declare const getUiVisibilityAccess: () => Promise<VisibilityAccess>;
|