@buerokratt-ria/menu 0.2.0 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
3
  All changes to this project will be documented in this file.
4
+ ## [0.1.17] - 24-10-2024
5
+
6
+ - Add /delete to chat
7
+
8
+ ## [0.2.2] - 19-11-2024
9
+
10
+ - Refactor menu permissions
4
11
 
5
12
  ## [0.1.16] - 10-06-2024
6
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/menu",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Generic MainNavigation component that would be injected as dependency.",
5
5
  "main": "index.js",
6
6
  "scripts": {},
@@ -333,6 +333,13 @@
333
333
  "en": "Session length"
334
334
  },
335
335
  "path": "/session-length"
336
+ },
337
+ {
338
+ "label": {
339
+ "et": "Sõnunmite kustutamine",
340
+ "en": "Delete conversations"
341
+ },
342
+ "path": "/delete-conversations"
336
343
  }
337
344
  ]
338
345
  },
@@ -13,21 +13,29 @@ const useFilteredMenuItems = (countConf?: CountConf) => {
13
13
  });
14
14
 
15
15
  useEffect(() => {
16
- const filteredItems = items.filter((item) => {
17
- if (!data) {
18
- return;
16
+ if (!data) {
17
+ return;
18
+ }
19
+
20
+ const roles: any[] = data.response;
21
+ const rolePermissions = {
22
+ ROLE_ADMINISTRATOR: ["conversations", "training", "analytics", "services", "settings", "monitoring"],
23
+ ROLE_SERVICE_MANAGER: ["training", "services", "monitoring"],
24
+ ROLE_CUSTOMER_SUPPORT_AGENT: ["conversations", "monitoring"],
25
+ ROLE_CHATBOT_TRAINER: ["training", "monitoring"],
26
+ ROLE_ANALYST: ["analytics", "monitoring"],
27
+ };
28
+
29
+ let permissions = new Set();
30
+
31
+ roles.forEach((role) => {
32
+ if (rolePermissions[role]) {
33
+ rolePermissions[role].forEach((permission: any) => permissions.add(permission));
19
34
  }
20
- const role: any[] = data.response;
21
- if (role.includes('ROLE_ADMINISTRATOR'))
22
- return item.id;
23
- if (role.includes('ROLE_SERVICE_MANAGER'))
24
- return item.id != "settings" && item.id != "training";
25
- if (role.includes('ROLE_CUSTOMER_SUPPORT_AGENT'))
26
- return item.id != "settings" && item.id != "analytics";
27
- if (role.includes('ROLE_CHATBOT_TRAINER'))
28
- return item.id != "settings" && item.id != "conversations";
29
- if (role.includes('ROLE_ANALYST'))
30
- return item.id == "analytics" || item.id == "monitoring";
35
+ });
36
+
37
+ const filteredItems = items.filter((item: any) => {
38
+ return permissions.has(item.id);
31
39
  });
32
40
 
33
41
  setMenuItems(filteredItems ?? []);
@@ -16,7 +16,6 @@
16
16
  "skipLibCheck": true,
17
17
  "skipDefaultLibCheck": true,
18
18
  "baseUrl": ".",
19
- "jsx": "react"
20
19
  },
21
20
  "exclude": ["node_modules", "tmp"]
22
21
  }