mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat(RoleForm): service full access.
This commit is contained in:
@@ -64,6 +64,15 @@ function GlobalErrors({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (globalErrors.userInactive) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: 'The authorized user is inactive.',
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
onDismiss: () => {
|
||||||
|
globalErrorsSet({ userInactive: false });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function RoleFormHeader() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
{/* ---------- name ---------- */}
|
{/* ---------- Name ---------- */}
|
||||||
<FastField name={'role_name'}>
|
<FastField name={'role_name'}>
|
||||||
{({ field, meta: { error, touched } }) => (
|
{({ field, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
@@ -39,7 +39,7 @@ export function RoleFormHeader() {
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/* ---------- description ---------- */}
|
{/* ---------- Description ---------- */}
|
||||||
<FastField name={'role_description'}>
|
<FastField name={'role_description'}>
|
||||||
{({ field, meta: { error, touched } }) => (
|
{({ field, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ function RolesForm({
|
|||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
handleDeleteErrors(errors);
|
handleDeleteErrors(errors);
|
||||||
};
|
};
|
||||||
if (isNewMode) {
|
if (isNewMode) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { DATATYPES_LENGTH } from 'common/dataTypes';
|
|||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
role_name: Yup.string().required().label(intl.get('roles.label.role_name_')),
|
role_name: Yup.string().required().label(intl.get('roles.label.role_name_')),
|
||||||
role_description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
role_description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
|
|
||||||
permissions: Yup.object().shape({
|
permissions: Yup.object().shape({
|
||||||
subject: Yup.string(),
|
subject: Yup.string(),
|
||||||
ability: Yup.string(),
|
ability: Yup.string(),
|
||||||
|
|||||||
@@ -55,10 +55,14 @@ export const transformPermissionsToObject = (permissions) => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const transformToObject = (role) => {
|
export const transformToObject = (role) => {
|
||||||
|
const permissions = transformPermissionsToObject(role.permissions);
|
||||||
|
const serviceFullAccess = getInitialServicesFullAccess(permissions);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
role_name: role.name,
|
role_name: role.name,
|
||||||
role_description: role.description,
|
role_description: role.description,
|
||||||
permissions: transformPermissionsToObject(role.permissions),
|
permissions,
|
||||||
|
serviceFullAccess,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ export default function useApiRequest() {
|
|||||||
if (lockedError) {
|
if (lockedError) {
|
||||||
setGlobalErrors({ transactionsLocked: { ...lockedError.data } });
|
setGlobalErrors({ transactionsLocked: { ...lockedError.data } });
|
||||||
}
|
}
|
||||||
|
if (data.errors.find(e => e.type === 'USER_INACTIVE')) {
|
||||||
|
setGlobalErrors({ userInactive: true });
|
||||||
|
setLogout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user