@fluxo-dev/shell 0.0.25 → 0.0.26

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/index.esm.js CHANGED
@@ -2,13 +2,13 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { useState, Suspense, forwardRef, createElement as createElement$2, useEffect, createContext, useContext, useLayoutEffect, useRef, useCallback, useMemo, memo, isValidElement, cloneElement, useImperativeHandle, lazy } from 'react';
4
4
  import { useSelector, Provider } from 'react-redux';
5
- import { useLocation, Navigate, matchPath, Outlet, useNavigate, Link, Route, useSearchParams, createBrowserRouter, RouterProvider } from 'react-router-dom';
6
- import { FluxoClientSys, AppType, AppState, FluxoStateDispatcher, UserService, AppMenuContextType, ApiKeyService, DomainRoleService, EmailServerProviderType } from '@fluxo-dev/api-client-base';
7
- import { AccessDenied, DataCard, NoData, ConfirmModal, ShellPage, ErrorPage as ErrorPage$1, WaitData, FlxRoutes } from '@fluxo-dev/ui-components';
5
+ import { useLocation, Navigate, Outlet, useNavigate, Link, Route, useSearchParams, createBrowserRouter, RouterProvider } from 'react-router-dom';
6
+ import { DataCard, NoData, ConfirmModal, ShellPage, ErrorPage as ErrorPage$1, WaitData, FlxRoutes } from '@fluxo-dev/ui-components';
8
7
  import { ModuleLoader } from '@fluxo-dev/shell-mfe';
9
8
  import { Text, TextInput, ActionIcon, useMantineTheme, AppShell, Stack, Group, Burger, Badge, Drawer, NavLink, Popover, Avatar, Center, Divider, Button, Anchor, Tooltip, Space, useMantineColorScheme, UnstyledButton, Box, ThemeIcon, Collapse, ScrollArea, rem, Loader, Grid, PasswordInput, ColorSwatch, FileButton, NumberInput, Alert, ColorInput, Checkbox, Modal, Switch, Select, Chip, LoadingOverlay, Image as Image$1, Menu, Textarea, Table, MultiSelect, Card, MantineProvider } from '@mantine/core';
10
9
  import { openSpotlight, Spotlight } from '@mantine/spotlight';
11
10
  import { useOs, useHotkeys, useIdle } from '@mantine/hooks';
11
+ import { AppType, AppState, FluxoStateDispatcher, FluxoClientSys, UserService, AppMenuContextType, ApiKeyService, DomainRoleService, EmailServerProviderType } from '@fluxo-dev/api-client-base';
12
12
  import { showNotification, Notifications } from '@mantine/notifications';
13
13
  import { useAppSelector, store as store$4 } from '@fluxo-dev/state';
14
14
  import { useForm } from '@mantine/form';
@@ -2214,36 +2214,13 @@ function ProtectedRoute(_a) {
2214
2214
  const {
2215
2215
  loggedIn
2216
2216
  } = useSelector(state => state.user);
2217
- const {
2218
- routeRules
2219
- } = useSelector(state => state.routeRules);
2220
- const navigation = useLocation();
2217
+ useLocation();
2221
2218
  if (!loggedIn) {
2222
2219
  return jsx(Navigate, {
2223
2220
  to: "/auth/login",
2224
2221
  replace: true
2225
2222
  });
2226
2223
  }
2227
- let accessDenied = false;
2228
- let requiredPermissions = [];
2229
- routeRules.forEach(routeRule => {
2230
- const match = matchPath(`${routeRule.route}`, navigation.pathname);
2231
- if (match) {
2232
- if (routeRule.permissions.length === 0) {
2233
- return;
2234
- } else {
2235
- const res = FluxoClientSys.Instance.security.currentUser.hasPermissions(routeRule.permissions);
2236
- if (!res) {
2237
- accessDenied = true;
2238
- requiredPermissions = routeRule.permissions;
2239
- return;
2240
- }
2241
- }
2242
- }
2243
- });
2244
- if (accessDenied) return jsx(AccessDenied, {
2245
- requiredPermissions: requiredPermissions
2246
- });
2247
2224
  return children;
2248
2225
  }
2249
2226
 
@@ -4078,22 +4055,6 @@ var IconReportSearch = createReactComponent("report-search", "IconReportSearch",
4078
4055
  ["path", { d: "M18.5 19.5l2.5 2.5", key: "svg-6" }]
4079
4056
  ]);
4080
4057
 
4081
- /**
4082
- * @tabler/icons-react v2.42.0 - MIT
4083
- */
4084
-
4085
- var IconRoute = createReactComponent("route", "IconRoute", [
4086
- ["path", { d: "M3 19a2 2 0 1 0 4 0a2 2 0 0 0 -4 0", key: "svg-0" }],
4087
- ["path", { d: "M19 7a2 2 0 1 0 0 -4a2 2 0 0 0 0 4z", key: "svg-1" }],
4088
- [
4089
- "path",
4090
- {
4091
- d: "M11 19h5.5a3.5 3.5 0 0 0 0 -7h-8a3.5 3.5 0 0 1 0 -7h4.5",
4092
- key: "svg-2"
4093
- }
4094
- ]
4095
- ]);
4096
-
4097
4058
  /**
4098
4059
  * @tabler/icons-react v2.42.0 - MIT
4099
4060
  */
@@ -20274,11 +20235,6 @@ function PermissionNavigator(props) {
20274
20235
  setDomainRolePermissions(res);
20275
20236
  setDomainRolePermissionLoaded(true);
20276
20237
  });
20277
- } else {
20278
- FluxoClientSys.Instance.security.routeRule.getPermissions(props.context.id).then(res => {
20279
- setDomainRolePermissions(res);
20280
- setDomainRolePermissionLoaded(true);
20281
- });
20282
20238
  }
20283
20239
  }, []);
20284
20240
  useEffect(() => {
@@ -20292,41 +20248,6 @@ function PermissionNavigator(props) {
20292
20248
  addOrRemovePermissionForDomainRole(permissionId);
20293
20249
  } else if (props.context.type === 'menu') {
20294
20250
  addOrRemovePermissionForMenu(permissionId);
20295
- } else if (props.context.type === 'route-rule') {
20296
- addOrRemovePermissionForRouteRule(permissionId);
20297
- }
20298
- };
20299
- const addOrRemovePermissionForRouteRule = menuItemId => {
20300
- if (selectedPermissionsIds.includes(menuItemId)) {
20301
- FluxoClientSys.Instance.security.routeRule.removePermission(+props.context.id, menuItemId).then(res => {
20302
- setSelectedPermissionsIds(selectedPermissionsIds.filter(p => p !== menuItemId));
20303
- showNotification({
20304
- title: "Permesso rimosso",
20305
- message: "Il permesso è stato rimosso correttamente",
20306
- color: "green"
20307
- });
20308
- }).catch(err => {
20309
- showNotification({
20310
- title: "Errore",
20311
- message: "Si è verificato un errore durante la rimozione del permesso",
20312
- color: "red"
20313
- });
20314
- });
20315
- } else {
20316
- FluxoClientSys.Instance.security.routeRule.addPermission(+props.context.id, menuItemId).then(res => {
20317
- setSelectedPermissionsIds([...selectedPermissionsIds, menuItemId]);
20318
- showNotification({
20319
- title: "Permesso aggiunto",
20320
- message: "Il permesso è stato aggiunto correttamente",
20321
- color: "green"
20322
- });
20323
- }).catch(err => {
20324
- showNotification({
20325
- title: "Errore",
20326
- message: "Si è verificato un errore durante l'aggiunta del permesso",
20327
- color: "red"
20328
- });
20329
- });
20330
20251
  }
20331
20252
  };
20332
20253
  const addOrRemovePermissionForMenu = menuItemId => {
@@ -29260,282 +29181,6 @@ function UsersGrid() {
29260
29181
  });
29261
29182
  }
29262
29183
 
29263
- function RouteRuleCreateForm(props) {
29264
- const [identifier, setIdentifier] = useState('');
29265
- const createRouteRule = () => {
29266
- if (!identifier) return;
29267
- const command = {
29268
- scope: props.scope,
29269
- packageName: props.packageName,
29270
- route: identifier
29271
- };
29272
- FluxoClientSys.Instance.security.routeRule.create(command).then(() => {
29273
- showNotification({
29274
- title: 'Regola creata',
29275
- message: `La regola ${props.scope}.${props.packageName}.${identifier} è stato creata con successo.`,
29276
- color: 'green'
29277
- });
29278
- props.onCreated();
29279
- }).catch(() => {
29280
- showNotification({
29281
- title: 'Errore',
29282
- message: `Si è verificato un errore durante la creazione della regola ${props.scope}.${props.packageName}.${identifier}.`,
29283
- color: 'red'
29284
- });
29285
- });
29286
- };
29287
- return jsxs(Stack, {
29288
- children: [jsx(TextInput, {
29289
- label: "Identificatore",
29290
- placeholder: 'Es: create',
29291
- required: true,
29292
- onChange: v => setIdentifier(v.target.value)
29293
- }), jsxs("p", {
29294
- children: ["Rotta: ", `${props.scope}/${props.packageName}/${identifier}`]
29295
- }), jsx(Divider, {}), jsxs(Group, {
29296
- justify: 'right',
29297
- children: [jsx(Button, {
29298
- variant: 'subtle',
29299
- onClick: props.onCanceled,
29300
- children: "Annulla"
29301
- }), jsx(Button, {
29302
- disabled: !identifier,
29303
- onClick: createRouteRule,
29304
- children: "Salva"
29305
- })]
29306
- })]
29307
- });
29308
- }
29309
-
29310
- function RouteRuleGrid() {
29311
- const [permissionScopes, setPermissionScopes] = useState([]);
29312
- const [permissionScopesLoaded, setPermissionScopesLoaded] = useState(false);
29313
- const [currentScope, setCurrentScope] = useState(null);
29314
- const [currentPackageName, setCurrentPackageName] = useState(null);
29315
- const [routeRules, setRouteRules] = useState([]);
29316
- const [permissionLoading, setPermissionLoading] = useState(false);
29317
- const [currentRouteRule, setCurrentRouteRule] = useState();
29318
- const [managePermissionModalOpened, setManagePermissionModalOpened] = useState(false);
29319
- const [createRouteRuleModalOpened, setCreateRouteRuleModalOpened] = useState(false);
29320
- useEffect(() => {
29321
- loadPermissionScopes();
29322
- }, []);
29323
- useEffect(() => {
29324
- if (currentScope && currentPackageName) getRouteRulesForScope();else setRouteRules([]);
29325
- }, [currentScope, currentPackageName]);
29326
- const getRouteRulesForScope = () => {
29327
- if (!currentScope || !currentPackageName) {
29328
- return;
29329
- }
29330
- setPermissionLoading(true);
29331
- FluxoClientSys.Instance.security.routeRule.getRouteRulesForScope(currentScope, currentPackageName).then(res => {
29332
- setRouteRules(res);
29333
- setPermissionLoading(false);
29334
- });
29335
- };
29336
- const loadPermissionScopes = () => {
29337
- FluxoClientSys.Instance.security.permission.getPermissionScopes().then(res => {
29338
- setPermissionScopes(res);
29339
- setPermissionScopesLoaded(true);
29340
- });
29341
- };
29342
- const deleteRouteRule = routeRule => {
29343
- FluxoClientSys.Instance.security.routeRule.delete(routeRule.id.toString()).then(() => {
29344
- showNotification({
29345
- title: 'Regola eliminata',
29346
- message: `La regola ${routeRule.scope}.${routeRule.packageName}.${routeRule.route} è stato eliminata con successo.`,
29347
- color: 'green'
29348
- });
29349
- getRouteRulesForScope();
29350
- }).catch(() => {
29351
- showNotification({
29352
- title: 'Errore',
29353
- message: `Si è verificato un errore durante l'eliminazione della regola ${routeRule.scope}.${routeRule.packageName}.${routeRule.route}.`,
29354
- color: 'red'
29355
- });
29356
- });
29357
- };
29358
- const getScopes = () => {
29359
- if (permissionScopes === undefined) return [];
29360
- return [...new Set(permissionScopes.map(a => a.scope))];
29361
- };
29362
- const getPackageNames = scope => {
29363
- if (permissionScopes === undefined || !scope) return [];
29364
- return [...new Set(permissionScopes.filter(a => a.scope === scope).map(a => a.packageName))];
29365
- };
29366
- return jsxs(DataCard, {
29367
- title: 'Regole sulle rotte',
29368
- children: [jsxs(Stack, {
29369
- children: [jsxs(Grid, {
29370
- children: [jsx(Grid.Col, {
29371
- span: 6,
29372
- children: jsx(Select, {
29373
- data: getScopes(),
29374
- searchable: true,
29375
- placeholder: 'Seleziona uno scope',
29376
- value: currentScope,
29377
- label: 'Scope',
29378
- onChange: v => {
29379
- setCurrentScope(v);
29380
- setCurrentPackageName(null);
29381
- }
29382
- })
29383
- }), jsx(Grid.Col, {
29384
- span: 6,
29385
- children: jsx(Select, {
29386
- disabled: !currentScope,
29387
- searchable: true,
29388
- placeholder: 'Seleziona un package name',
29389
- data: getPackageNames(currentScope),
29390
- value: currentPackageName,
29391
- label: 'Package name',
29392
- onChange: v => {
29393
- setCurrentPackageName(v);
29394
- }
29395
- })
29396
- })]
29397
- }), jsx(Divider, {}), (currentScope && currentPackageName && !permissionLoading && routeRules.length) === 0 && jsxs(Stack, {
29398
- children: [jsx(Group, {
29399
- justify: 'right',
29400
- align: 'center',
29401
- children: jsx(Button, {
29402
- leftSection: jsx(IconPlus, {
29403
- size: 18
29404
- }),
29405
- onClick: () => setCreateRouteRuleModalOpened(true),
29406
- children: "Nuova regola"
29407
- })
29408
- }), jsx(Center, {
29409
- children: jsx(Text, {
29410
- size: 'md',
29411
- children: "Nessuna regola esistente."
29412
- })
29413
- })]
29414
- }), (!currentScope || !currentPackageName) && jsxs(Stack, {
29415
- align: 'center',
29416
- mt: 32,
29417
- mb: 32,
29418
- children: [jsx(IconCloudOff, {
29419
- color: 'gray',
29420
- size: 64
29421
- }), jsx(Center, {
29422
- children: jsx(Text, {
29423
- size: 'md',
29424
- children: "Seleziona uno scope e un package name per visualizzare i permessi associati."
29425
- })
29426
- })]
29427
- }), !permissionLoading && routeRules.length > 0 && jsxs(Stack, {
29428
- children: [jsx(Group, {
29429
- justify: 'right',
29430
- align: 'center',
29431
- children: jsx(Button, {
29432
- leftSection: jsx(IconPlus, {
29433
- size: 18
29434
- }),
29435
- onClick: () => setCreateRouteRuleModalOpened(true),
29436
- children: "Nuova regola"
29437
- })
29438
- }), jsxs(Table, {
29439
- highlightOnHover: true,
29440
- children: [jsx(Table.Thead, {
29441
- children: jsxs(Table.Tr, {
29442
- children: [jsx(Table.Th, {
29443
- children: "Id"
29444
- }), jsx(Table.Th, {
29445
- children: "Scope"
29446
- }), jsx(Table.Th, {
29447
- children: "Rotta"
29448
- }), jsx(Table.Th, {
29449
- children: "Permessi"
29450
- }), jsx(Table.Th, {
29451
- style: {
29452
- maxWidth: 80,
29453
- width: 80
29454
- },
29455
- children: "Azioni"
29456
- })]
29457
- })
29458
- }), jsx(Table.Tbody, {
29459
- children: routeRules.map((element, i) => {
29460
- return jsxs(Table.Tr, {
29461
- children: [jsx(Table.Td, {
29462
- children: element.id
29463
- }), jsx(Table.Td, {
29464
- children: `${element.scope}.${element.packageName}`
29465
- }), jsx(Table.Td, {
29466
- children: `/${element.scope}/${element.packageName}/${element.route}`
29467
- }), jsx(Table.Td, {
29468
- children: element.permissionsCount
29469
- }), jsx(Table.Td, {
29470
- style: {
29471
- maxWidth: 130,
29472
- width: 130
29473
- },
29474
- children: jsxs(Group, {
29475
- children: [jsx(ActionIcon, {
29476
- onClick: () => {
29477
- setCurrentRouteRule(element);
29478
- setManagePermissionModalOpened(true);
29479
- },
29480
- children: jsx(IconLock, {
29481
- size: 18
29482
- })
29483
- }), jsx(ActionIcon, {
29484
- onClick: () => {
29485
- deleteRouteRule(element);
29486
- },
29487
- children: jsx(IconTrash, {
29488
- size: 18
29489
- })
29490
- })]
29491
- })
29492
- })]
29493
- }, i);
29494
- })
29495
- })]
29496
- })]
29497
- })]
29498
- }), currentRouteRule && jsx(Modal, {
29499
- size: '60%',
29500
- centered: true,
29501
- opened: managePermissionModalOpened,
29502
- onClose: () => {
29503
- getRouteRulesForScope();
29504
- setManagePermissionModalOpened(false);
29505
- setCurrentRouteRule(undefined);
29506
- },
29507
- title: `Gestione permessi ${currentRouteRule.route}`,
29508
- children: jsx(PermissionNavigator, {
29509
- context: {
29510
- type: 'route-rule',
29511
- id: currentRouteRule.id.toString()
29512
- },
29513
- onUpdate: () => {}
29514
- })
29515
- }), jsx(Modal, {
29516
- size: '60%',
29517
- centered: true,
29518
- opened: createRouteRuleModalOpened,
29519
- onClose: () => {
29520
- getRouteRulesForScope();
29521
- setCreateRouteRuleModalOpened(false);
29522
- },
29523
- title: `Crea nuova regola`,
29524
- children: jsx(RouteRuleCreateForm, {
29525
- scope: currentScope,
29526
- packageName: currentPackageName,
29527
- onCreated: () => {
29528
- getRouteRulesForScope();
29529
- setCreateRouteRuleModalOpened(false);
29530
- },
29531
- onCanceled: () => {
29532
- setCreateRouteRuleModalOpened(false);
29533
- }
29534
- })
29535
- })]
29536
- });
29537
- }
29538
-
29539
29184
  function EmailServerConfiguration() {
29540
29185
  var _a, _b;
29541
29186
  const [configExists, setConfigExists] = useState(false);
@@ -29788,7 +29433,7 @@ function EmailServerConfiguration() {
29788
29433
  })]
29789
29434
  })]
29790
29435
  })
29791
- }), jsx(DataCard, {
29436
+ }), !configExists && jsx(DataCard, {
29792
29437
  title: "Test invio email",
29793
29438
  children: jsxs(Stack, {
29794
29439
  children: [jsx(Alert, {
@@ -29907,24 +29552,6 @@ function Settings(props) {
29907
29552
  size: 18
29908
29553
  }),
29909
29554
  description: 'Gestisci i permessi utente'
29910
- }, {
29911
- key: 'routes',
29912
- title: jsxs(Text, {
29913
- children: ["Regole sulle rotte ", jsx("small", {
29914
- children: jsx("b", {
29915
- children: "(Avanzato)"
29916
- })
29917
- })]
29918
- }),
29919
- onClick: () => {
29920
- window.location.hash = 'routes';
29921
- setCurrentTab('routes');
29922
- },
29923
- disabled: false,
29924
- icon: jsx(IconRoute, {
29925
- size: 18
29926
- }),
29927
- description: 'Gestisci le regole sulle rotte'
29928
29555
  }]
29929
29556
  }, {
29930
29557
  name: 'Comunicazioni',
@@ -30075,8 +29702,6 @@ function Settings(props) {
30075
29702
  return jsx(DomainRoleGrid, {});
30076
29703
  case 'permissions':
30077
29704
  return jsx(PermissionGrid, {});
30078
- case 'routes':
30079
- return jsx(RouteRuleGrid, {});
30080
29705
  case 'print-server':
30081
29706
  return jsx(PrintServerList, {});
30082
29707
  case 'email-configuration':
@@ -30744,7 +30369,6 @@ function FluxoShell(props) {
30744
30369
  FluxoStateDispatcher.dispatchSetSysFeatures(res.features);
30745
30370
  FluxoStateDispatcher.dispatchSetUserPermissions(res.permissions.map(a => a.fullIdentifier));
30746
30371
  FluxoStateDispatcher.dispatchSetUserDomainRoles(res.domainRoles);
30747
- FluxoStateDispatcher.dispatchSetRouteRules(res.routeRules);
30748
30372
  FluxoStateDispatcher.dispatchSetFrontends(props.frontends.map(a => ({
30749
30373
  id: a.id,
30750
30374
  name: a.name
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fluxo-dev/shell",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "peerDependencies": {
5
- "@fluxo-dev/shell-hub": "0.0.25",
6
- "@fluxo-dev/shell-korebi": "0.0.25",
7
- "@fluxo-dev/shell-mfe": "0.0.25",
8
- "@fluxo-dev/shell-printing": "0.0.25",
9
- "@fluxo-dev/shell-reporting": "0.0.25",
10
- "@fluxo-dev/shell-workflow": "0.0.25"
5
+ "@fluxo-dev/shell-hub": "0.0.26",
6
+ "@fluxo-dev/shell-korebi": "0.0.26",
7
+ "@fluxo-dev/shell-mfe": "0.0.26",
8
+ "@fluxo-dev/shell-printing": "0.0.26",
9
+ "@fluxo-dev/shell-reporting": "0.0.26",
10
+ "@fluxo-dev/shell-workflow": "0.0.26"
11
11
  },
12
12
  "module": "./index.esm.js",
13
13
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  export interface PermissionNavigatorProps {
2
2
  context: {
3
- type: 'domainRole' | 'menu' | 'route-rule';
3
+ type: 'domainRole' | 'menu';
4
4
  id: string;
5
5
  };
6
6
  onUpdate: (currentPermissionCount: number) => void;
@@ -1,7 +0,0 @@
1
- export interface RouteRuleCreateFormProps {
2
- scope: string;
3
- packageName: string;
4
- onCanceled: () => void;
5
- onCreated: () => void;
6
- }
7
- export declare function RouteRuleCreateForm(props: RouteRuleCreateFormProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare function RouteRuleGrid(): import("react/jsx-runtime").JSX.Element;