@applica-software-guru/react-admin 1.0.59 → 1.0.60
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/README.md +1 -1
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/AuthBackground.d.ts +3 -0
- package/dist/components/AuthBackground.d.ts.map +1 -0
- package/dist/components/AuthCard.d.ts.map +1 -0
- package/dist/components/{ra-pages/LoginPage/AuthWrapper.d.ts → AuthWrapper.d.ts} +3 -1
- package/dist/components/AuthWrapper.d.ts.map +1 -0
- package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts +1 -1
- package/dist/components/ra-inputs/TextInput.d.ts +7 -6
- package/dist/components/ra-inputs/TextInput.d.ts.map +1 -1
- package/dist/components/ra-pages/LoginPage.d.ts +52 -0
- package/dist/components/ra-pages/LoginPage.d.ts.map +1 -0
- package/dist/components/ra-pages/RecoverPage.d.ts +12 -0
- package/dist/components/ra-pages/RecoverPage.d.ts.map +1 -0
- package/dist/components/ra-pages/RegisterPage.d.ts +11 -0
- package/dist/components/ra-pages/RegisterPage.d.ts.map +1 -0
- package/dist/components/ra-pages/index.d.ts +3 -1
- package/dist/components/ra-pages/index.d.ts.map +1 -1
- package/dist/components/ra-pages/types.d.ts +28 -0
- package/dist/components/ra-pages/types.d.ts.map +1 -0
- package/dist/hooks/useMenu.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +52 -52
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +7290 -7078
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +52 -52
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/ApplicaAdmin.tsx +2 -1
- package/src/assets/background.svg +58 -0
- package/src/components/AuthBackground.tsx +99 -0
- package/src/components/{ra-pages/LoginPage/AuthCard.jsx → AuthCard.jsx} +1 -1
- package/src/components/AuthWrapper.jsx +53 -0
- package/src/components/ra-inputs/{TextInput.jsx → TextInput.tsx} +5 -3
- package/src/components/ra-pages/LoginPage.tsx +153 -0
- package/src/components/ra-pages/RecoverPage.tsx +75 -0
- package/src/components/ra-pages/RegisterPage.tsx +78 -0
- package/src/components/ra-pages/index.ts +3 -2
- package/src/components/ra-pages/types.ts +26 -0
- package/src/hooks/useMenu.jsx +6 -5
- package/src/playground/App.jsx +10 -7
- package/src/playground/config.jsx +1 -0
- package/src/playground/menu.jsx +0 -8
- package/dist/components/ra-pages/LoginPage/AuthCard.d.ts.map +0 -1
- package/dist/components/ra-pages/LoginPage/AuthLogin.d.ts +0 -6
- package/dist/components/ra-pages/LoginPage/AuthLogin.d.ts.map +0 -1
- package/dist/components/ra-pages/LoginPage/AuthWrapper.d.ts.map +0 -1
- package/dist/components/ra-pages/LoginPage/Login.d.ts +0 -34
- package/dist/components/ra-pages/LoginPage/Login.d.ts.map +0 -1
- package/dist/components/ra-pages/LoginPage/index.d.ts +0 -3
- package/dist/components/ra-pages/LoginPage/index.d.ts.map +0 -1
- package/src/components/ra-pages/LoginPage/AuthLogin.jsx +0 -79
- package/src/components/ra-pages/LoginPage/AuthWrapper.jsx +0 -46
- package/src/components/ra-pages/LoginPage/Login.tsx +0 -61
- package/src/components/ra-pages/LoginPage/index.jsx +0 -3
- /package/dist/components/{ra-pages/LoginPage/AuthCard.d.ts → AuthCard.d.ts} +0 -0
package/src/hooks/useMenu.jsx
CHANGED
|
@@ -176,15 +176,17 @@ const createNodes = ({ userGroups, resources, permissions, translate, roles }) =
|
|
|
176
176
|
const useMenu = () => {
|
|
177
177
|
const resources = useResourceDefinitions();
|
|
178
178
|
const { isLoading: loadingIdentity, data: identity } = useGetIdentity();
|
|
179
|
-
|
|
179
|
+
// Utilizziamo l'identità come discriminante per chiedere a react-query, eventualmente, dati aggiornati.
|
|
180
|
+
// Il rischio, senza questo passaggio, è di ricevere dati precedenti che non consentono di caricare correttamente la UX.
|
|
181
|
+
const isAuthenticated = identity && identity.id > 0;
|
|
182
|
+
|
|
183
|
+
const { isLoading: loadingPermissions, permissions } = usePermissions(isAuthenticated);
|
|
180
184
|
const { groups: userGroups } = useMenuConfig();
|
|
181
185
|
const translate = useTranslate();
|
|
182
|
-
|
|
183
186
|
const menu = useMemo(() => {
|
|
184
187
|
if (loadingIdentity || !identity || identity === null || identity?.id <= 0) {
|
|
185
188
|
return null;
|
|
186
189
|
}
|
|
187
|
-
|
|
188
190
|
const roles = (identity?.roles || []).map((role) => role.id);
|
|
189
191
|
const groups = createNodes({
|
|
190
192
|
resources,
|
|
@@ -193,9 +195,8 @@ const useMenu = () => {
|
|
|
193
195
|
userGroups,
|
|
194
196
|
roles
|
|
195
197
|
});
|
|
196
|
-
|
|
197
198
|
return groups;
|
|
198
|
-
}, [loadingIdentity, identity, resources, permissions, translate, userGroups]);
|
|
199
|
+
}, [loadingIdentity, loadingPermissions, identity, resources, permissions, translate, userGroups]);
|
|
199
200
|
|
|
200
201
|
const isLoading = useMemo(() => loadingIdentity, [loadingIdentity]);
|
|
201
202
|
|
package/src/playground/App.jsx
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as entities from './entities';
|
|
4
4
|
|
|
5
|
-
import { API_URL, FILE_FIELDS } from './config';
|
|
6
|
-
import { ApplicaAdmin, HttpError, Resource } from '@applica-software-guru/react-admin';
|
|
5
|
+
import { API_URL, APP_NAME, FILE_FIELDS } from './config';
|
|
6
|
+
import { ApplicaAdmin, HttpError, RecoverPage, RegisterPage, Resource } from '@applica-software-guru/react-admin';
|
|
7
7
|
import { createAttachmentsParser, createDataProvider } from '@applica-software-guru/crud-client';
|
|
8
8
|
|
|
9
9
|
import { CustomPage } from './components/pages';
|
|
@@ -32,17 +32,20 @@ const App = () => {
|
|
|
32
32
|
dataProvider={dataProvider}
|
|
33
33
|
defaultLocale="it"
|
|
34
34
|
menu={menu}
|
|
35
|
-
name=
|
|
35
|
+
name={APP_NAME}
|
|
36
36
|
version={build.version}
|
|
37
|
-
disableSignup
|
|
38
|
-
disableForgotPassword
|
|
39
37
|
>
|
|
38
|
+
<CustomRoutes>
|
|
39
|
+
<Route path="/custom-page" element={<CustomPage />} />
|
|
40
|
+
</CustomRoutes>
|
|
41
|
+
|
|
40
42
|
<Resource name="entities/notification" {...entities.notification} />
|
|
41
43
|
<Resource name="entities/user" {...entities.user} />
|
|
42
44
|
<Resource name="entities/i18n-message" {...entities.i18nMessage} />
|
|
43
45
|
<Resource name="entities/device" {...entities.device} />
|
|
44
|
-
<CustomRoutes>
|
|
45
|
-
<Route path="/
|
|
46
|
+
<CustomRoutes noLayout>
|
|
47
|
+
<Route path="/register" element={<RegisterPage name={APP_NAME} version={build.version} />} />
|
|
48
|
+
<Route path="/recover" element={<RecoverPage name={APP_NAME} version={build.version} />} />
|
|
46
49
|
</CustomRoutes>
|
|
47
50
|
</ApplicaAdmin>
|
|
48
51
|
);
|
|
@@ -4,6 +4,7 @@ if (appUrl.endsWith(':3000/') || appUrl.indexOf(':51') !== -1) {
|
|
|
4
4
|
appUrl = 'http://localhost:8080/';
|
|
5
5
|
environment = 'DEVELOPER';
|
|
6
6
|
}
|
|
7
|
+
export const APP_NAME = 'RApplica';
|
|
7
8
|
export const APP_URL = appUrl;
|
|
8
9
|
export const API_URL = `${APP_URL}api`;
|
|
9
10
|
export const ENVIRONMENT = environment;
|
package/src/playground/menu.jsx
CHANGED
|
@@ -13,14 +13,6 @@ const config = [
|
|
|
13
13
|
type: 'item',
|
|
14
14
|
url: '/entities/notification',
|
|
15
15
|
icon: NotificationOutlined
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: 'entities/bom',
|
|
19
|
-
title: 'ra.menu.item.entities/bom',
|
|
20
|
-
type: 'item',
|
|
21
|
-
url: '/entities/bom',
|
|
22
|
-
resource: true,
|
|
23
|
-
icon: TableOutlined
|
|
24
16
|
}
|
|
25
17
|
]
|
|
26
18
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/ra-pages/LoginPage/AuthCard.jsx"],"names":[],"mappings":";AAKA;;;4CAqBC;;;;;;sBAxBqB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthLogin.d.ts","sourceRoot":"","sources":["../../../../../src/components/ra-pages/LoginPage/AuthLogin.jsx"],"names":[],"mappings":";AAMA;;;4CAsEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/components/ra-pages/LoginPage/AuthWrapper.jsx"],"names":[],"mappings":";AAOA;;;;4CA8BC;;;;;;;;sBAhCqB,YAAY"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
export type LoginProps = {
|
|
3
|
-
/**
|
|
4
|
-
* Versione dell'applicazione.
|
|
5
|
-
*/
|
|
6
|
-
version: string;
|
|
7
|
-
/**
|
|
8
|
-
* Nome dell'applicazione.
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* Indica se abilitare o meno la schermata di recupero password.
|
|
13
|
-
*/
|
|
14
|
-
enablePasswordForgot?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Indica se abilitare o meno la schermata di registrazione.
|
|
17
|
-
*/
|
|
18
|
-
enableSignup?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare const Login: {
|
|
21
|
-
({ version, name, enablePasswordForgot, enableSignup }: LoginProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
propTypes: {
|
|
23
|
-
version: PropTypes.Validator<string>;
|
|
24
|
-
name: PropTypes.Validator<string>;
|
|
25
|
-
enablePasswordForgot: PropTypes.Requireable<boolean>;
|
|
26
|
-
enableSignup: PropTypes.Requireable<boolean>;
|
|
27
|
-
};
|
|
28
|
-
defaultProps: {
|
|
29
|
-
enablePasswordForgot: boolean;
|
|
30
|
-
enableSignup: boolean;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export default Login;
|
|
34
|
-
//# sourceMappingURL=Login.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../../../src/components/ra-pages/LoginPage/Login.tsx"],"names":[],"mappings":"AAKA,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AACF,QAAA,MAAM,KAAK;4DAA2D,UAAU;;;;;;;;;;;CAqB/E,CAAC;AAaF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ra-pages/LoginPage/index.jsx"],"names":[],"mappings":";kBAAkB,SAAS"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { AnimateButton, TextInput } from '../../../components';
|
|
2
|
-
import { Button, CircularProgress, Grid, Link, Stack } from '@mui/material';
|
|
3
|
-
import { Form, required, useLogin, useNotify, useSafeSetState, useTranslate } from 'react-admin';
|
|
4
|
-
|
|
5
|
-
import { Link as RouterLink } from 'react-router-dom';
|
|
6
|
-
|
|
7
|
-
const AuthLogin = ({ enablePasswordForgot, ...props }) => {
|
|
8
|
-
const { redirectTo } = props;
|
|
9
|
-
const [loading, setLoading] = useSafeSetState(false);
|
|
10
|
-
const login = useLogin();
|
|
11
|
-
const translate = useTranslate();
|
|
12
|
-
const notify = useNotify();
|
|
13
|
-
|
|
14
|
-
const handleSubmit = (values) => {
|
|
15
|
-
setLoading(true);
|
|
16
|
-
login(values, redirectTo)
|
|
17
|
-
.then(() => {
|
|
18
|
-
setLoading(false);
|
|
19
|
-
})
|
|
20
|
-
.catch((error) => {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
notify(
|
|
23
|
-
typeof error === 'string' ? error : typeof error === 'undefined' || !error.message ? 'ra.auth.sign_in_error' : error.message,
|
|
24
|
-
{
|
|
25
|
-
type: 'error',
|
|
26
|
-
messageArgs: {
|
|
27
|
-
_: typeof error === 'string' ? error : error && error.message ? error.message : undefined
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return (
|
|
34
|
-
<Form onSubmit={handleSubmit}>
|
|
35
|
-
<Grid container>
|
|
36
|
-
<Grid item xs={12} sx={{ mb: 2 }}>
|
|
37
|
-
<TextInput
|
|
38
|
-
autoFocus
|
|
39
|
-
source="username"
|
|
40
|
-
label={translate('ra.auth.username')}
|
|
41
|
-
autoComplete="username"
|
|
42
|
-
validate={required()}
|
|
43
|
-
placeholder="user@company.name"
|
|
44
|
-
fullWidth
|
|
45
|
-
/>
|
|
46
|
-
</Grid>
|
|
47
|
-
<Grid item xs={12} sx={{ mb: 2 }}>
|
|
48
|
-
<TextInput
|
|
49
|
-
source="password"
|
|
50
|
-
label={translate('ra.auth.password')}
|
|
51
|
-
type="password"
|
|
52
|
-
autoComplete="current-password"
|
|
53
|
-
validate={required()}
|
|
54
|
-
placeholder={translate('ra.auth.password_placeholder')}
|
|
55
|
-
fullWidth
|
|
56
|
-
/>
|
|
57
|
-
</Grid>
|
|
58
|
-
</Grid>
|
|
59
|
-
{enablePasswordForgot && (
|
|
60
|
-
<Grid item xs={12} sx={{ mt: 1 }}>
|
|
61
|
-
<Stack direction="row" justifyContent="flex-end" alignItems="flex-end" spacing={2}>
|
|
62
|
-
<Link variant="h6" component={RouterLink} to={'/forgot-password'} color="text.primary">
|
|
63
|
-
{translate('ra.auth.forgot_password')}
|
|
64
|
-
</Link>
|
|
65
|
-
</Stack>
|
|
66
|
-
</Grid>
|
|
67
|
-
)}
|
|
68
|
-
<Grid item xs={12} sx={{ mt: 1 }}>
|
|
69
|
-
<AnimateButton>
|
|
70
|
-
<Button variant="contained" type="submit" color="primary" disabled={loading} fullWidth>
|
|
71
|
-
{loading ? <CircularProgress size={19} thickness={3} /> : translate('ra.auth.sign_in')}
|
|
72
|
-
</Button>
|
|
73
|
-
</AnimateButton>
|
|
74
|
-
</Grid>
|
|
75
|
-
</Form>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default AuthLogin;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Box, Grid } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
import AuthCard from './AuthCard';
|
|
4
|
-
import Footer from '../../Layout/Footer';
|
|
5
|
-
import MainIcon from '../../MainIcon';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
|
|
8
|
-
const AuthWrapper = ({ version, name, children }) => (
|
|
9
|
-
<Box sx={{ minHeight: '100vh' }}>
|
|
10
|
-
<Grid
|
|
11
|
-
container
|
|
12
|
-
direction="column"
|
|
13
|
-
justifyContent="flex-end"
|
|
14
|
-
sx={{
|
|
15
|
-
minHeight: '100vh'
|
|
16
|
-
}}
|
|
17
|
-
>
|
|
18
|
-
<Grid item xs={12} sx={{ ml: 3, mt: 3 }}>
|
|
19
|
-
<MainIcon title={name} />
|
|
20
|
-
</Grid>
|
|
21
|
-
<Grid item xs={12}>
|
|
22
|
-
<Grid
|
|
23
|
-
item
|
|
24
|
-
xs={12}
|
|
25
|
-
container
|
|
26
|
-
justifyContent="center"
|
|
27
|
-
alignItems="center"
|
|
28
|
-
sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
|
|
29
|
-
>
|
|
30
|
-
<Grid item>
|
|
31
|
-
<AuthCard>{children}</AuthCard>
|
|
32
|
-
</Grid>
|
|
33
|
-
</Grid>
|
|
34
|
-
<Footer name={name} version={version} />
|
|
35
|
-
</Grid>
|
|
36
|
-
</Grid>
|
|
37
|
-
</Box>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
AuthWrapper.propTypes = {
|
|
41
|
-
children: PropTypes.node,
|
|
42
|
-
version: PropTypes.string,
|
|
43
|
-
name: PropTypes.string
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default AuthWrapper;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Grid, Stack, Typography } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
import AuthLogin from './AuthLogin';
|
|
4
|
-
import AuthWrapper from './AuthWrapper';
|
|
5
|
-
import { Link } from 'react-router-dom';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import { useTranslate } from 'ra-core';
|
|
8
|
-
|
|
9
|
-
export type LoginProps = {
|
|
10
|
-
/**
|
|
11
|
-
* Versione dell'applicazione.
|
|
12
|
-
*/
|
|
13
|
-
version: string;
|
|
14
|
-
/**
|
|
15
|
-
* Nome dell'applicazione.
|
|
16
|
-
*/
|
|
17
|
-
name: string;
|
|
18
|
-
/**
|
|
19
|
-
* Indica se abilitare o meno la schermata di recupero password.
|
|
20
|
-
*/
|
|
21
|
-
enablePasswordForgot?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Indica se abilitare o meno la schermata di registrazione.
|
|
24
|
-
*/
|
|
25
|
-
enableSignup?: boolean;
|
|
26
|
-
};
|
|
27
|
-
const Login = ({ version, name, enablePasswordForgot, enableSignup }: LoginProps) => {
|
|
28
|
-
const translate = useTranslate();
|
|
29
|
-
return (
|
|
30
|
-
<AuthWrapper name={name} version={version}>
|
|
31
|
-
<Grid container spacing={3}>
|
|
32
|
-
<Grid item xs={12}>
|
|
33
|
-
<Stack direction="row" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
|
|
34
|
-
<Typography variant="h3">Login</Typography>
|
|
35
|
-
{enableSignup && (
|
|
36
|
-
<Typography component={Link} to={'/signup'} variant="body1" sx={{ textDecoration: 'none' }} color="primary">
|
|
37
|
-
{translate('ra.auth.signup')}
|
|
38
|
-
</Typography>
|
|
39
|
-
)}
|
|
40
|
-
</Stack>
|
|
41
|
-
</Grid>
|
|
42
|
-
<Grid item xs={12}>
|
|
43
|
-
<AuthLogin enablePasswordForgot={enablePasswordForgot} />
|
|
44
|
-
</Grid>
|
|
45
|
-
</Grid>
|
|
46
|
-
</AuthWrapper>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
Login.propTypes = {
|
|
51
|
-
version: PropTypes.string.isRequired,
|
|
52
|
-
name: PropTypes.string.isRequired,
|
|
53
|
-
enablePasswordForgot: PropTypes.bool,
|
|
54
|
-
enableSignup: PropTypes.bool
|
|
55
|
-
};
|
|
56
|
-
Login.defaultProps = {
|
|
57
|
-
enablePasswordForgot: true,
|
|
58
|
-
enableSignup: true
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default Login;
|
|
File without changes
|