@lincros-ui/components 0.2.20 → 0.2.22
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/index.cjs +28 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -137
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,6 @@ var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
|
42
42
|
var TogglePrimitive = require('@radix-ui/react-toggle');
|
|
43
43
|
var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
|
|
44
44
|
var reactRouterDom = require('react-router-dom');
|
|
45
|
-
var menuPermissions = require('@/lib/menu-permissions');
|
|
46
45
|
var react = require('@tiptap/react');
|
|
47
46
|
var StarterKit = require('@tiptap/starter-kit');
|
|
48
47
|
var Image2 = require('@tiptap/extension-image');
|
|
@@ -4827,8 +4826,30 @@ var MenuPermissionLevel = /* @__PURE__ */ ((MenuPermissionLevel2) => {
|
|
|
4827
4826
|
MenuPermissionLevel2["ADMIN_ONLY"] = "ADMIN_ONLY";
|
|
4828
4827
|
MenuPermissionLevel2["MANAGER_OR_ADMIN"] = "MANAGER_OR_ADMIN";
|
|
4829
4828
|
MenuPermissionLevel2["MASTER_TENANT_ONLY"] = "MASTER_TENANT_ONLY";
|
|
4829
|
+
MenuPermissionLevel2["NON_MASTER_TENANT_ONLY"] = "NON_MASTER_TENANT_ONLY";
|
|
4830
4830
|
return MenuPermissionLevel2;
|
|
4831
4831
|
})(MenuPermissionLevel || {});
|
|
4832
|
+
|
|
4833
|
+
// src/lib/menu-permissions.ts
|
|
4834
|
+
var MANAGER_PROFILE_ID = 6;
|
|
4835
|
+
function canAccessMenu(user, permission, isMasterTenant) {
|
|
4836
|
+
if (!permission || permission === "ALL" /* ALL */) return true;
|
|
4837
|
+
if (!user) return false;
|
|
4838
|
+
const isAdmin = user.is_admin === true;
|
|
4839
|
+
const isManager = user.perfil_usuario_id === MANAGER_PROFILE_ID;
|
|
4840
|
+
switch (permission) {
|
|
4841
|
+
case "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */:
|
|
4842
|
+
return isAdmin || isManager;
|
|
4843
|
+
case "ADMIN_ONLY" /* ADMIN_ONLY */:
|
|
4844
|
+
return isAdmin;
|
|
4845
|
+
case "MASTER_TENANT_ONLY" /* MASTER_TENANT_ONLY */:
|
|
4846
|
+
return isMasterTenant === true;
|
|
4847
|
+
case "NON_MASTER_TENANT_ONLY" /* NON_MASTER_TENANT_ONLY */:
|
|
4848
|
+
return isMasterTenant !== true;
|
|
4849
|
+
default:
|
|
4850
|
+
return false;
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4832
4853
|
var STORAGE_KEY = "sidebar-expanded-menus";
|
|
4833
4854
|
function useSidebarState(routePaths) {
|
|
4834
4855
|
const location = reactRouterDom.useLocation();
|
|
@@ -5067,12 +5088,13 @@ function PasswordResetModal({
|
|
|
5067
5088
|
] })
|
|
5068
5089
|
] }) });
|
|
5069
5090
|
}
|
|
5070
|
-
function filterMenuItems(items, user) {
|
|
5071
|
-
return items.filter((item) =>
|
|
5091
|
+
function filterMenuItems(items, user, isMasterTenant) {
|
|
5092
|
+
return items.filter((item) => canAccessMenu(user, item.permission, isMasterTenant)).map((item) => {
|
|
5072
5093
|
if (item.subItems) {
|
|
5073
5094
|
const filteredSubItems = filterMenuItems(
|
|
5074
5095
|
item.subItems,
|
|
5075
|
-
user
|
|
5096
|
+
user,
|
|
5097
|
+
isMasterTenant
|
|
5076
5098
|
);
|
|
5077
5099
|
if (filteredSubItems.length === 0) {
|
|
5078
5100
|
return null;
|
|
@@ -5185,136 +5207,6 @@ function ControlSidebar({
|
|
|
5185
5207
|
}
|
|
5186
5208
|
}
|
|
5187
5209
|
};
|
|
5188
|
-
const defaultMenuItems = [
|
|
5189
|
-
{
|
|
5190
|
-
title: "Dashboard",
|
|
5191
|
-
url: routePaths.DASHBOARD,
|
|
5192
|
-
icon: lucideReact.Monitor,
|
|
5193
|
-
permission: "ALL" /* ALL */
|
|
5194
|
-
},
|
|
5195
|
-
{
|
|
5196
|
-
title: "Monitoramento de Rotas",
|
|
5197
|
-
url: routePaths.ROUTE_MONITORING,
|
|
5198
|
-
icon: lucideReact.Navigation,
|
|
5199
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5200
|
-
},
|
|
5201
|
-
{
|
|
5202
|
-
title: "Alertas",
|
|
5203
|
-
url: routePaths.ALERTS,
|
|
5204
|
-
icon: lucideReact.Bell,
|
|
5205
|
-
permission: "ALL" /* ALL */
|
|
5206
|
-
},
|
|
5207
|
-
{
|
|
5208
|
-
title: "Relat\xF3rios",
|
|
5209
|
-
url: routePaths.REPORTS,
|
|
5210
|
-
icon: lucideReact.BarChart3,
|
|
5211
|
-
permission: "ALL" /* ALL */
|
|
5212
|
-
},
|
|
5213
|
-
{
|
|
5214
|
-
title: "Configura\xE7\xF5es",
|
|
5215
|
-
icon: lucideReact.Settings,
|
|
5216
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */,
|
|
5217
|
-
subItems: [
|
|
5218
|
-
{
|
|
5219
|
-
title: "Configura\xE7\xF5es Gerais",
|
|
5220
|
-
url: routePaths.SETTINGS,
|
|
5221
|
-
icon: lucideReact.Settings,
|
|
5222
|
-
permission: "ALL" /* ALL */
|
|
5223
|
-
},
|
|
5224
|
-
{
|
|
5225
|
-
title: "Usu\xE1rios",
|
|
5226
|
-
icon: lucideReact.Users,
|
|
5227
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5228
|
-
subItems: [
|
|
5229
|
-
{
|
|
5230
|
-
title: "Gest\xE3o de Usu\xE1rios",
|
|
5231
|
-
url: routePaths.USER_MANAGEMENT,
|
|
5232
|
-
icon: lucideReact.UserCheck,
|
|
5233
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5234
|
-
},
|
|
5235
|
-
{
|
|
5236
|
-
title: "Perfis de Usu\xE1rio",
|
|
5237
|
-
url: routePaths.USER_PROFILES,
|
|
5238
|
-
icon: lucideReact.UserCog,
|
|
5239
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5240
|
-
},
|
|
5241
|
-
{
|
|
5242
|
-
title: "Permiss\xF5es",
|
|
5243
|
-
url: routePaths.PERMISSIONS_MANAGEMENT,
|
|
5244
|
-
icon: lucideReact.Shield,
|
|
5245
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5246
|
-
}
|
|
5247
|
-
]
|
|
5248
|
-
},
|
|
5249
|
-
{
|
|
5250
|
-
title: "Motoristas",
|
|
5251
|
-
url: routePaths.MOTORISTAS,
|
|
5252
|
-
icon: lucideReact.Car,
|
|
5253
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5254
|
-
},
|
|
5255
|
-
{
|
|
5256
|
-
title: "WhatsApp",
|
|
5257
|
-
icon: lucideReact.MessageCircle,
|
|
5258
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5259
|
-
subItems: [
|
|
5260
|
-
{
|
|
5261
|
-
title: "Configura\xE7\xF5es",
|
|
5262
|
-
url: routePaths.WHATSAPP_CONFIG,
|
|
5263
|
-
icon: lucideReact.Settings,
|
|
5264
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5265
|
-
},
|
|
5266
|
-
{
|
|
5267
|
-
title: "Triggers de Fluxo",
|
|
5268
|
-
url: routePaths.WHATSAPP_TRIGGERS,
|
|
5269
|
-
icon: lucideReact.Workflow,
|
|
5270
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5271
|
-
},
|
|
5272
|
-
{
|
|
5273
|
-
title: "Monitoramento",
|
|
5274
|
-
url: routePaths.WHATSAPP_MONITORING,
|
|
5275
|
-
icon: lucideReact.Monitor,
|
|
5276
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5277
|
-
}
|
|
5278
|
-
]
|
|
5279
|
-
},
|
|
5280
|
-
...isMasterTenant ? [] : [
|
|
5281
|
-
{
|
|
5282
|
-
title: "Unidades de Neg\xF3cio",
|
|
5283
|
-
url: routePaths.UNIDADES_NEGOCIO,
|
|
5284
|
-
icon: lucideReact.Building2,
|
|
5285
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5286
|
-
}
|
|
5287
|
-
],
|
|
5288
|
-
...isMasterTenant ? [
|
|
5289
|
-
{
|
|
5290
|
-
title: "Tenants",
|
|
5291
|
-
url: routePaths.TENANT_MANAGEMENT,
|
|
5292
|
-
icon: lucideReact.Database,
|
|
5293
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5294
|
-
}
|
|
5295
|
-
] : []
|
|
5296
|
-
]
|
|
5297
|
-
},
|
|
5298
|
-
{
|
|
5299
|
-
title: "Automa\xE7\xE3o",
|
|
5300
|
-
icon: lucideReact.Bot,
|
|
5301
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5302
|
-
subItems: [
|
|
5303
|
-
{
|
|
5304
|
-
title: "Fluxos de Automa\xE7\xE3o",
|
|
5305
|
-
url: routePaths.FLOWS,
|
|
5306
|
-
icon: lucideReact.Workflow,
|
|
5307
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5308
|
-
},
|
|
5309
|
-
{
|
|
5310
|
-
title: "Credenciais",
|
|
5311
|
-
url: routePaths.CREDENTIALS,
|
|
5312
|
-
icon: lucideReact.Key,
|
|
5313
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5314
|
-
}
|
|
5315
|
-
]
|
|
5316
|
-
}
|
|
5317
|
-
];
|
|
5318
5210
|
React37__namespace.default.useEffect(() => {
|
|
5319
5211
|
if (!currentTime) {
|
|
5320
5212
|
const timer = setInterval(() => {
|
|
@@ -5323,9 +5215,9 @@ function ControlSidebar({
|
|
|
5323
5215
|
return () => clearInterval(timer);
|
|
5324
5216
|
}
|
|
5325
5217
|
}, [currentTime]);
|
|
5326
|
-
const resolvedMenuItems = menuItemsProp ??
|
|
5218
|
+
const resolvedMenuItems = menuItemsProp ?? [];
|
|
5327
5219
|
const displayTime = currentTime || internalTime;
|
|
5328
|
-
const filteredMenuItems = filterMenuItems(resolvedMenuItems, user);
|
|
5220
|
+
const filteredMenuItems = filterMenuItems(resolvedMenuItems, user, isMasterTenant);
|
|
5329
5221
|
return /* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { className: "border-r border-gray-200", collapsible: "icon", children: [
|
|
5330
5222
|
/* @__PURE__ */ jsxRuntime.jsxs(SidebarHeader, { className: "border-b border-gray-200", children: [
|
|
5331
5223
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, { className: "ml-auto" }) }),
|