@applica-software-guru/react-admin 1.3.128 → 1.3.130

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.3.128",
3
+ "version": "1.3.130",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@applica-software-guru/crud-client": "1.1.*",
75
- "@applica-software-guru/iam-client": "1.0.*",
75
+ "@applica-software-guru/iam-client": "1.1.*",
76
76
  "@testing-library/jest-dom": "^5.16.5",
77
77
  "@testing-library/react": "^14.0.0",
78
78
  "@types/node": "^18.7.6",
@@ -38,7 +38,15 @@ function Error(props: ErrorBoundaryProps) {
38
38
  <Stack alignItems="center" px={2} py={{ xs: 4, sm: 8 }} spacing={2} textAlign="center">
39
39
  {title && <Title title={title} />}
40
40
  <img src={imgSrc} style={{ width: '100%', maxWidth: 450, marginTop: theme.spacing(4) }} />
41
- <Typography variant="h2">{translate(isProduction ? 'ra.page.error' : error.message, { _: error.message })}</Typography>
41
+ <Typography
42
+ variant="h2"
43
+ sx={{
44
+ whiteSpace: 'pre-wrap',
45
+ wordBreak: 'break-word'
46
+ }}
47
+ >
48
+ {translate(isProduction ? 'ra.page.error' : error.message, { _: error.message })}
49
+ </Typography>
42
50
  {!isProduction && <Typography variant="caption">{translate('ra.message.error_more_info')}</Typography>}
43
51
  {errorInfo && (
44
52
  <Typography
@@ -3,7 +3,7 @@ import { Avatar } from '../../@extended';
3
3
  import { Card, Collapse, List, ListItem, ListItemProps, ListItemIcon, ListItemText, ListItemButton, ListItemAvatar } from '@mui/material';
4
4
  import { useSetActiveItem, useSyncWithLocation } from './Provider';
5
5
  import { IItem } from './types';
6
- import { useCallback, useMemo, useState } from 'react';
6
+ import { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import { useChildren, useIsActive, useNavigateForm } from './hooks';
8
8
  import { ExpandLess, ExpandMore } from '@mui/icons-material';
9
9
  import { getLevel } from './utils';
@@ -57,6 +57,12 @@ function NavMenuItem(props: INavMenuItemProps) {
57
57
  hasIcon = icon !== undefined,
58
58
  listItemProps = _.omit(props, ['label', 'icon', 'selected', 'badge']);
59
59
 
60
+ useEffect(() => {
61
+ if (selected && !open) {
62
+ setOpen(selected);
63
+ }
64
+ }, [selected, open, setOpen]);
65
+
60
66
  return (
61
67
  <>
62
68
  <ListItem {...listItemProps} disablePadding>
@@ -61,18 +61,15 @@ function reducer(state: IState, action: IAction): IState {
61
61
  case ActionType.SET_ACTIVE_ITEM:
62
62
  return _.includes(getItemsIds(state.items), payload) ? _.extend(newState, { activeItem: payload }) : newState;
63
63
  case ActionType.ADD_ITEM: {
64
- const id = payload.id,
65
- items = _.chain(newState.items)
64
+ const { id } = payload;
65
+ return _.extend(newState, {
66
+ items: _.chain(newState.items)
66
67
  .clone()
67
68
  .reject((item: IItem) => item.id === id)
68
69
  .concat([payload])
69
70
  .orderBy((item) => item.index)
70
- .value();
71
- _.extend(newState, { items: items });
72
- if (newState.activeItem === undefined) {
73
- _.extend(newState, { activeItem: payload.id });
74
- }
75
- return newState;
71
+ .value()
72
+ });
76
73
  }
77
74
  case ActionType.REMOVE_ITEM: {
78
75
  const id = _.isString(payload) ? payload : payload.id,
@@ -6,7 +6,11 @@ import { useNavigate } from 'react-router';
6
6
 
7
7
  function useIsActive(id: string): boolean {
8
8
  const activeItem = useActiveItem();
9
- return id === activeItem || isChild(id, activeItem ?? '');
9
+ if (activeItem === undefined) {
10
+ return false;
11
+ } else {
12
+ return id === activeItem || isChild(id, activeItem);
13
+ }
10
14
  }
11
15
 
12
16
  function useChildren(id?: string): Array<IItem> {
@@ -36,10 +36,6 @@ function createI18nProvider(data: ICreateI18nProviderData): Promise<any> {
36
36
  getLanguages = (): Promise<Locale> => {
37
37
  return fetch(`${apiUrl}/i18n/languages`, { headers: headers, method: 'get' })
38
38
  .then((response) => response.json())
39
- .then((response) => {
40
- const { responseCode, locales } = response;
41
- return responseCode !== 'ok' ? defaultLanguages : locales;
42
- })
43
39
  .catch(() => {
44
40
  return Promise.resolve(defaultLanguages);
45
41
  });