Skip to content

Commit dbf60c8

Browse files
committed
feat: implement role assignment wizard navigation and refactor route handling
1 parent 468b871 commit dbf60c8

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/authz-module/authz-home/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
55
import RolesPermissions from '../roles-permissions/RolesPermissions';
66
import AuthZLayout from '../components/AuthZLayout';
77

8+
import { buildWizardPath } from '../constants';
89
import messages from './messages';
910

1011
const AuthzHome = () => {
@@ -27,7 +28,7 @@ const AuthzHome = () => {
2728
<Button
2829
iconBefore={Plus}
2930
variant="primary"
30-
onClick={() => navigate('/authz/assign-role')}
31+
onClick={() => navigate(buildWizardPath())}
3132
key="assign-role"
3233
>
3334
{intl.formatMessage(messages['authz.manage.assign.role.button'])}

src/authz-module/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
export const ROUTES = {
2+
HOME_PATH: '/authz',
23
LIBRARIES_TEAM_PATH: '/libraries/:libraryId',
34
LIBRARIES_USER_PATH: '/libraries/:libraryId/:username',
45
ASSIGN_ROLE_WIZARD_PATH: '/assign-role',
56
};
67

8+
export const buildWizardPath = () => `${ROUTES.HOME_PATH}${ROUTES.ASSIGN_ROLE_WIZARD_PATH}`;
9+
710
export enum RoleOperationErrorStatus {
811
USER_NOT_FOUND = 'user_not_found',
912
USER_ALREADY_HAS_ROLE = 'user_already_has_role',

src/authz-module/wizard/AssignRoleWizardPage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
22
import { useIntl } from '@edx/frontend-platform/i18n';
33
import AssignRoleWizard from './AssignRoleWizard';
44
import AuthZLayout from '../components/AuthZLayout';
5-
import { useLibrary } from '../data/hooks';
65
import { ROUTES } from '../constants';
76
import messages from './messages';
87

@@ -12,19 +11,17 @@ const AssignRoleWizardPage = () => {
1211
const [searchParams] = useSearchParams();
1312
const initialUsers = searchParams.get('users') || '';
1413

15-
const homePath = '/authz';
16-
1714
return (
1815
<AuthZLayout
1916
context={{ id: '', title: '', org: '' }}
20-
navLinks={[{ label: intl.formatMessage(messages['wizard.page.breadcrumb']), to: homePath }]}
17+
navLinks={[{ label: intl.formatMessage(messages['wizard.page.breadcrumb']), to: ROUTES.HOME_PATH }]}
2118
activeLabel={intl.formatMessage(messages['wizard.page.title'])}
2219
pageTitle={intl.formatMessage(messages['wizard.page.title'])}
2320
pageSubtitle=""
2421
actions={[]}
2522
>
2623
<AssignRoleWizard
27-
onClose={() => navigate(homePath)}
24+
onClose={() => navigate(ROUTES.HOME_PATH)}
2825
initialUsers={initialUsers}
2926
/>
3027
</AuthZLayout>

0 commit comments

Comments
 (0)