@applica-software-guru/react-admin 1.0.60 → 1.0.61

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.0.60",
3
+ "version": "1.0.61",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,3 +1,4 @@
1
+ import { AdminProps, AuthProvider, DataProvider } from 'react-admin';
1
2
  import { AppConfigProvider, MenuConfigProvider, MenuPropTypes, ThemeConfigProvider } from './contexts';
2
3
  import { CatchResult, useCliErrorCatcher } from './dev';
3
4
  import { Layout, LoginPage, MainIcon, Notification, SmallIcon } from './components';
@@ -5,7 +6,6 @@ import React, { useMemo } from 'react';
5
6
  import { createI18nProvider, useI18nCatcher, useI18nLanguages } from './i18n';
6
7
 
7
8
  import Admin from './Admin';
8
- import { AdminProps } from 'react-admin';
9
9
  import { I18nCatcherBodyBuilderResultProps } from './i18n/useI18nCatcher';
10
10
  import { MenuProps } from 'src/types';
11
11
  import PropTypes from 'prop-types';
@@ -85,13 +85,14 @@ export type ApplicaAdminProps = AdminProps & {
85
85
  /**
86
86
  * Il provider di autenticazione da utilizzare nell'applicazione.
87
87
  */
88
- dataProvider: any;
88
+ dataProvider: DataProvider;
89
89
  /**
90
90
  * Il provider di dati da utilizzare nell'applicazione.
91
91
  */
92
- authProvider: any;
92
+ authProvider: AuthProvider;
93
93
  /**
94
94
  * Indica il nome della risorsa REST da utilizzare per la gestione delle notifiche.
95
+ * @default "entities/notification"
95
96
  * @example
96
97
  * // In questo caso, le notifiche verranno gestite tramite la risorsa "entities/notification"
97
98
  * <ApplicaAdmin notification="entities/notification" />
@@ -102,18 +103,33 @@ export type ApplicaAdminProps = AdminProps & {
102
103
  * Se le notifiche sono abilitate comparirà automaticamente un'icona in alto a destra nell'header.
103
104
  *
104
105
  * @example
105
- * // In questo caso, le notifiche verranno disabilitate
106
- * <ApplicaAdmin disableNotification />
106
+ * <ApplicaAdmin enableNotification />
107
107
  */
108
- disableNotification: boolean;
108
+ enableNotification: boolean;
109
109
  /**
110
110
  * Indica se la schermata di registrazione deve essere disabilitata.
111
+ * Se abilitata è necessario registrare una pagina, nelle rotte, che punti a /register
112
+ *
113
+ * @example
114
+ * // Pagina di base realizzata da Applica
115
+ * import { RegisterPage } from "@applica-software-guru/react-admin";
116
+ * <CustomRoutes noLayout>
117
+ * <Route path="/register" component={RegisterPage} />
118
+ * </CustomRoutes>
111
119
  */
112
- disableSignup: boolean;
120
+ enableRegistration: boolean;
113
121
  /**
114
122
  * Indica se la schermata di recupero password deve essere disabilitata.
123
+ * Se abilitata è necessario registrare una pagina, nelle rotte, che punti a /recover
124
+ *
125
+ * @example
126
+ * // Pagina di base realizzata da Applica
127
+ * import { RecoverPage } from "@applica-software-guru/react-admin";
128
+ * <CustomRoutes noLayout>
129
+ * <Route path="/recover" component={RecoverPage} />
130
+ * </CustomRoutes>
115
131
  */
116
- disableForgotPassword: boolean;
132
+ enablePasswordRecover: boolean;
117
133
  };
118
134
 
119
135
  /**
@@ -162,9 +178,9 @@ const ApplicaAdmin = ({
162
178
  dataProvider,
163
179
  authProvider,
164
180
  notification,
165
- disableNotification,
166
- disableSignup,
167
- disableForgotPassword,
181
+ enableNotification,
182
+ enableRegistration,
183
+ enablePasswordRecover,
168
184
  ...props
169
185
  }: ApplicaAdminProps) => {
170
186
  const languages = useI18nLanguages({
@@ -204,11 +220,16 @@ const ApplicaAdmin = ({
204
220
  });
205
221
  const login = useMemo(() => {
206
222
  if (React.isValidElement(loginPage)) {
207
- // @ts-ignore
208
- return React.cloneElement(loginPage, { name, version, enableSignup: !disableSignup, enablePasswordForgot: !disableForgotPassword });
223
+ return React.cloneElement(loginPage, {
224
+ // @ts-ignore
225
+ name,
226
+ version,
227
+ enableRegistration,
228
+ enablePasswordRecover
229
+ });
209
230
  }
210
231
  return loginPage;
211
- }, [loginPage, name, version, disableSignup, disableForgotPassword]);
232
+ }, [loginPage, name, version, enableRegistration, enablePasswordRecover]);
212
233
  const layout = useMemo(
213
234
  () => (props: any) => {
214
235
  const _logoMain = name ? <MainIcon title={name} /> : logoMain;
@@ -221,11 +242,11 @@ const ApplicaAdmin = ({
221
242
  logoMain={_logoMain}
222
243
  logoIcon={_logoIcon}
223
244
  notification={notification}
224
- disableNotification={disableNotification}
245
+ enableNotification={enableNotification}
225
246
  />
226
247
  );
227
248
  },
228
- [logoMain, logoIcon, name, version, notification, disableNotification]
249
+ [logoMain, logoIcon, name, version, notification, enableNotification]
229
250
  );
230
251
 
231
252
  if (languages?.loading) {
@@ -266,9 +287,9 @@ ApplicaAdmin.defaultProps = {
266
287
  development: false,
267
288
  version: '0.0.0',
268
289
  notification: 'entities/notification',
269
- disableNotification: false,
270
- disableSignup: false,
271
- disableForgotPassword: false,
290
+ enableNotification: false,
291
+ enableRegistration: false,
292
+ enableForgotPassword: false,
272
293
  loginPage: <LoginPage version="0.0.0" name="Applica" redirectTo="/" />
273
294
  };
274
295
 
@@ -286,9 +307,9 @@ ApplicaAdmin.propTypes = {
286
307
  authProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
287
308
  dataProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
288
309
  notification: PropTypes.string,
289
- disableNotification: PropTypes.bool,
290
- disableSignup: PropTypes.bool,
291
- disableForgotPassword: PropTypes.bool
310
+ enableNotification: PropTypes.bool,
311
+ enableRegistration: PropTypes.bool,
312
+ enableForgotPassword: PropTypes.bool
292
313
  };
293
314
 
294
315
  export default ApplicaAdmin;
@@ -8,7 +8,7 @@ import Notification from './Notification';
8
8
  import Profile from './Profile';
9
9
  import PropTypes from 'prop-types';
10
10
 
11
- const HeaderContent = ({ logoMain, logoIcon, notification, disableNotification }) => {
11
+ const HeaderContent = ({ logoMain, logoIcon, notification, enableNotification }) => {
12
12
  const matchesXs = useMediaQuery((theme) => theme.breakpoints.down('md'));
13
13
  const { isHorizontalLayout, menuOrientation } = useThemeConfig();
14
14
  const { drawerOpen } = useMenuConfig();
@@ -19,7 +19,7 @@ const HeaderContent = ({ logoMain, logoIcon, notification, disableNotification }
19
19
  {matchesXs && <Box sx={{ width: '100%', ml: 1 }} />}
20
20
 
21
21
  <LoadingIndicator />
22
- {!disableNotification && <Notification resource={notification} />}
22
+ {enableNotification && <Notification resource={notification} />}
23
23
  {!matchesXs && <Profile />}
24
24
  {matchesXs && <MobileSection />}
25
25
  </>
@@ -30,7 +30,7 @@ HeaderContent.propTypes = {
30
30
  logoMain: PropTypes.node,
31
31
  logoIcon: PropTypes.node,
32
32
  notification: PropTypes.string,
33
- disableNotification: PropTypes.bool
33
+ enableNotification: PropTypes.bool
34
34
  };
35
35
 
36
36
  export default HeaderContent;
@@ -9,14 +9,14 @@ import { useMemo } from 'react';
9
9
  import { useTheme } from '@mui/material/styles';
10
10
  import { useThemeConfig } from '../../../hooks';
11
11
 
12
- const Header = ({ open, logoMain, logoIcon, handleDrawerToggle, notification, disableNotification }) => {
12
+ const Header = ({ open, logoMain, logoIcon, handleDrawerToggle, notification, enableNotification }) => {
13
13
  const theme = useTheme();
14
14
  const downLG = useMediaQuery(theme.breakpoints.down('lg'));
15
15
  const { menuOrientation, isHorizontalLayout } = useThemeConfig();
16
16
 
17
17
  const isHorizontal = isHorizontalLayout(menuOrientation) && !downLG;
18
18
  const headerContent = useMemo(
19
- () => <HeaderContent logoMain={logoMain} logoIcon={logoIcon} notification={notification} disableNotification={disableNotification} />,
19
+ () => <HeaderContent logoMain={logoMain} logoIcon={logoIcon} notification={notification} enableNotification={enableNotification} />,
20
20
  [logoMain, logoIcon, notification]
21
21
  );
22
22
 
@@ -75,7 +75,7 @@ Header.propTypes = {
75
75
  logoMain: PropTypes.node,
76
76
  logoIcon: PropTypes.node,
77
77
  notification: PropTypes.string,
78
- disableNotification: PropTypes.bool
78
+ enableNotification: PropTypes.bool
79
79
  };
80
80
 
81
81
  export default Header;
@@ -13,7 +13,7 @@ import { Outlet } from 'react-router-dom';
13
13
  import PropTypes from 'prop-types';
14
14
  import { useTheme } from '@mui/material/styles';
15
15
 
16
- const Layout = ({ children, name, version, logoMain, logoIcon, notification, disableNotification }) => {
16
+ const Layout = ({ children, name, version, logoMain, logoIcon, notification, enableNotification }) => {
17
17
  const theme = useTheme();
18
18
  const { openDrawer } = useMenuConfig();
19
19
  const { isLoading, navigation, breadcrumbs } = useBreadcrumbs();
@@ -49,7 +49,7 @@ const Layout = ({ children, name, version, logoMain, logoIcon, notification, dis
49
49
  logoMain={logoMain}
50
50
  logoIcon={logoIcon}
51
51
  notification={notification}
52
- disableNotification={disableNotification}
52
+ enableNotification={enableNotification}
53
53
  />
54
54
  {!isHorizontal ? (
55
55
  <Drawer open={open} handleDrawerToggle={handleDrawerToggle} logoMain={logoMain} logoIcon={logoIcon} />
@@ -97,7 +97,7 @@ Layout.propTypes = {
97
97
  logoMain: PropTypes.node,
98
98
  logoIcon: PropTypes.node,
99
99
  notification: PropTypes.string,
100
- disableNotification: PropTypes.bool
100
+ enableNotification: PropTypes.bool
101
101
  };
102
102
 
103
103
  export default Layout;
@@ -22,7 +22,7 @@ export type LoginPageProps = BaseAuthProps & {
22
22
  * <Route path="/recover" component={RecoverPage} />
23
23
  * </CustomRoutes>
24
24
  */
25
- enablePasswordForgot?: boolean;
25
+ enablePasswordRecover?: boolean;
26
26
  /**
27
27
  * Indica se abilitare o meno la schermata di registrazione.
28
28
  * Se abilitato è opportuno registrare una rotta a /register con un componente
@@ -35,14 +35,14 @@ export type LoginPageProps = BaseAuthProps & {
35
35
  * <Route path="/register" component={RegisterPage} />
36
36
  * </CustomRoutes>
37
37
  */
38
- enableRegister?: boolean;
38
+ enableRegistration?: boolean;
39
39
  /**
40
40
  * Indica la pagina a cui reindirizzare l'utente dopo il login.
41
41
  * Se non specificata viene utilizzata la home page di react-admin.
42
42
  */
43
43
  redirectTo: string;
44
44
  };
45
- const LoginPage = ({ version, name, enablePasswordForgot, enableRegister, redirectTo, background }: LoginPageProps) => {
45
+ const LoginPage = ({ version, name, enablePasswordRecover, enableRegistration, redirectTo, background }: LoginPageProps) => {
46
46
  const [loading, setLoading] = useSafeSetState(false);
47
47
  const login = useLogin();
48
48
  const translate = useTranslate();
@@ -83,7 +83,7 @@ const LoginPage = ({ version, name, enablePasswordForgot, enableRegister, redire
83
83
  <Grid item xs={12}>
84
84
  <Stack direction="row" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
85
85
  <Typography variant="h3">Login</Typography>
86
- {enableRegister && (
86
+ {enableRegistration && (
87
87
  <Typography component={RouterLink} to={'/register'} variant="body1" sx={{ textDecoration: 'none' }} color="primary">
88
88
  {translate('ra.auth.register')}
89
89
  </Typography>
@@ -116,7 +116,7 @@ const LoginPage = ({ version, name, enablePasswordForgot, enableRegister, redire
116
116
  />
117
117
  </Grid>
118
118
  </Grid>
119
- {enablePasswordForgot && (
119
+ {enablePasswordRecover && (
120
120
  <Grid item xs={12} sx={{ mt: 1 }}>
121
121
  <Stack direction="row" justifyContent="flex-end" alignItems="flex-end" spacing={2}>
122
122
  <Link variant="h6" component={RouterLink} to={'/recover'} color="text.primary">
@@ -140,13 +140,13 @@ const LoginPage = ({ version, name, enablePasswordForgot, enableRegister, redire
140
140
  LoginPage.propTypes = {
141
141
  version: PropTypes.string.isRequired,
142
142
  name: PropTypes.string.isRequired,
143
- enablePasswordForgot: PropTypes.bool,
143
+ enablePasswordRecover: PropTypes.bool,
144
144
  enableRegister: PropTypes.bool,
145
145
  background: PropTypes.element
146
146
  };
147
147
  LoginPage.defaultProps = {
148
- enablePasswordForgot: true,
149
- enableRegister: true,
148
+ enablePasswordRecover: false,
149
+ enableRegister: false,
150
150
  background: <AuthBackground />
151
151
  };
152
152
 
@@ -34,6 +34,9 @@ const App = () => {
34
34
  menu={menu}
35
35
  name={APP_NAME}
36
36
  version={build.version}
37
+ enableNotification
38
+ enableRegistration
39
+ enablePasswordRecover
37
40
  >
38
41
  <CustomRoutes>
39
42
  <Route path="/custom-page" element={<CustomPage />} />