1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-17 01:17:29 +02:00

fix: update create role links and fix ts errors (#620)

* fix: update create role links and fix ts errors

* fix: update RBAC link in create and edit page
This commit is contained in:
Youssef Khedher 2022-01-21 12:18:44 +01:00 committed by GitHub
parent c06f22bd8a
commit 130319e07c
3 changed files with 12 additions and 10 deletions

View File

@ -48,7 +48,7 @@ const CreateProjectRole = () => {
confetti: true, confetti: true,
type: 'success', type: 'success',
}); });
} catch (e) { } catch (e: any) {
setToastApiError(e.toString()); setToastApiError(e.toString());
} }
} }
@ -64,7 +64,7 @@ const CreateProjectRole = () => {
}; };
const handleCancel = () => { const handleCancel = () => {
history.push('/admin/roles'); history.goBack();
}; };
return ( return (
@ -72,9 +72,9 @@ const CreateProjectRole = () => {
loading={loading} loading={loading}
title="Create project role" title="Create project role"
description="A project role can be description="A project role can be
customised to limit access customised to limit access
to resources within a project" to resources within a project"
documentationLink="https://docs.getunleash.io/" documentationLink="https://docs.getunleash.io/how-to/how-to-create-and-assign-custom-project-roles"
formatApiCode={formatApiCode} formatApiCode={formatApiCode}
> >
<ProjectRoleForm <ProjectRoleForm

View File

@ -16,7 +16,7 @@ const EditProjectRole = () => {
const { uiConfig } = useUiConfig(); const { uiConfig } = useUiConfig();
const { setToastData, setToastApiError } = useToast(); const { setToastData, setToastApiError } = useToast();
const { id } = useParams(); const { id } = useParams<{ id: string }>();
const { role } = useProjectRole(id); const { role } = useProjectRole(id);
const history = useHistory(); const history = useHistory();
@ -68,7 +68,7 @@ const EditProjectRole = () => {
const { refetch } = useProjectRole(id); const { refetch } = useProjectRole(id);
const { editRole, loading } = useProjectRolesApi(); const { editRole, loading } = useProjectRolesApi();
const handleSubmit = async e => { const handleSubmit = async (e: Event) => {
e.preventDefault(); e.preventDefault();
const payload = getProjectRolePayload(); const payload = getProjectRolePayload();
@ -81,18 +81,19 @@ const EditProjectRole = () => {
refetch(); refetch();
history.push('/admin/roles'); history.push('/admin/roles');
setToastData({ setToastData({
type: 'success',
title: 'Project role updated', title: 'Project role updated',
text: 'Your role changes will automatically be applied to the users with this role.', text: 'Your role changes will automatically be applied to the users with this role.',
confetti: true, confetti: true,
}); });
} catch (e) { } catch (e: any) {
setToastApiError(e.toString()); setToastApiError(e.toString());
} }
} }
}; };
const handleCancel = () => { const handleCancel = () => {
history.push('/admin/roles'); history.goBack();
}; };
return ( return (
@ -102,7 +103,7 @@ const EditProjectRole = () => {
description="A project role can be description="A project role can be
customised to limit access customised to limit access
to resources within a project" to resources within a project"
documentationLink="https://docs.getunleash.io/" documentationLink="https://docs.getunleash.io/how-to/how-to-create-and-assign-custom-project-roles"
formatApiCode={formatApiCode} formatApiCode={formatApiCode}
> >
<ProjectRoleForm <ProjectRoleForm

View File

@ -33,6 +33,7 @@ interface IProjectRoleForm {
errors: { [key: string]: string }; errors: { [key: string]: string };
submitButtonText: string; submitButtonText: string;
clearErrors: () => void; clearErrors: () => void;
validateNameUniqueness?: () => void;
getRoleKey: (permission: { id: number; environment?: string }) => string; getRoleKey: (permission: { id: number; environment?: string }) => string;
} }