-
Notifications
You must be signed in to change notification settings - Fork 16
Topcoder Admin App - Consolidate Gamification #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { baseDetailPath, createBadgePath } from '~/apps/gamification-admin' | ||
import { AppSubdomain, ToolTitle } from '~/config' | ||
import { | ||
lazyLoad, | ||
|
@@ -9,9 +10,11 @@ import { | |
|
||
import { | ||
billingAccountRouteId, | ||
gamificationAdminRouteId, | ||
manageChallengeRouteId, | ||
manageReviewRouteId, | ||
permissionManagementRouteId, | ||
platformRouteId, | ||
rootRoute, | ||
userManagementRouteId, | ||
} from './config/routes.config' | ||
|
@@ -107,6 +110,17 @@ const PermissionAddGroupMembersPage: LazyLoadedComponent = lazyLoad( | |
'PermissionAddGroupMembersPage', | ||
) | ||
|
||
const Platform: LazyLoadedComponent = lazyLoad(() => import('./platform/Platform')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming the variable |
||
const BadgeDetailPage: LazyLoadedComponent = lazyLoad( | ||
() => import('../../gamification-admin/src/pages/badge-detail/BadgeDetailPage'), | ||
) | ||
const BadgeListingPage: LazyLoadedComponent = lazyLoad( | ||
() => import('../../gamification-admin/src/pages/badge-listing/BadgeListingPage'), | ||
) | ||
const CreateBadgePage: LazyLoadedComponent = lazyLoad( | ||
() => import('../../gamification-admin/src/pages/create-badge/CreateBadgePage'), | ||
) | ||
|
||
export const toolTitle: string = ToolTitle.admin | ||
|
||
export const adminRoutes: ReadonlyArray<PlatformRoute> = [ | ||
|
@@ -256,6 +270,29 @@ export const adminRoutes: ReadonlyArray<PlatformRoute> = [ | |
id: permissionManagementRouteId, | ||
route: permissionManagementRouteId, | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
element: ( | ||
<BadgeListingPage | ||
rootPage={`${rootRoute}/${platformRouteId}/${gamificationAdminRouteId}`} | ||
/> | ||
), | ||
route: gamificationAdminRouteId, | ||
}, | ||
{ | ||
element: <CreateBadgePage />, | ||
route: `${gamificationAdminRouteId}${createBadgePath}`, | ||
}, | ||
{ | ||
element: <BadgeDetailPage />, | ||
route: `${gamificationAdminRouteId}${baseDetailPath}/:id`, | ||
}, | ||
], | ||
element: <Platform />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
id: platformRouteId, | ||
route: platformRouteId, | ||
}, | ||
], | ||
domain: AppSubdomain.admin, | ||
element: <AdminApp />, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,15 @@ | |
@include ltelg { | ||
padding: $sp-4; | ||
} | ||
|
||
&.isPlatformPage { | ||
padding: 0; | ||
background-color: white; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a variable for the |
||
|
||
@include ltelg { | ||
padding: 0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
import { FC, PropsWithChildren } from 'react' | ||
import { FC, PropsWithChildren, useMemo } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
import classNames from 'classnames' | ||
|
||
import { platformRouteId } from '~/apps/admin/src/config/routes.config' | ||
import { ContentLayout } from '~/libs/ui' | ||
|
||
import { SystemAdminTabs } from '../Tab' | ||
|
||
import styles from './Layout.module.scss' | ||
|
||
export const NullLayout: FC<PropsWithChildren> = props => ( | ||
<>{props.children}</> | ||
) | ||
export const NullLayout: FC<PropsWithChildren> = props => <>{props.children}</> | ||
|
||
export const Layout: FC<PropsWithChildren> = props => ( | ||
<ContentLayout | ||
innerClass={styles.contantentLayoutInner} | ||
outerClass={styles.contentLayoutOuter} | ||
> | ||
<div className={styles.layout}> | ||
<SystemAdminTabs /> | ||
export const Layout: FC<PropsWithChildren> = props => { | ||
const { pathname }: { pathname: string } = useLocation() | ||
const isPlatformPage = useMemo( | ||
() => pathname.indexOf(platformRouteId) >= 0, | ||
[pathname], | ||
) | ||
|
||
<div className={styles.main}> | ||
{props.children} | ||
return ( | ||
<ContentLayout | ||
innerClass={styles.contantentLayoutInner} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in class name: |
||
outerClass={styles.contentLayoutOuter} | ||
> | ||
<div className={styles.layout}> | ||
<SystemAdminTabs /> | ||
|
||
<div | ||
className={classNames(styles.main, { | ||
[styles.isPlatformPage]: isPlatformPage, | ||
})} | ||
> | ||
{props.children} | ||
</div> | ||
</div> | ||
</div> | ||
</ContentLayout> | ||
) | ||
</ContentLayout> | ||
) | ||
} | ||
|
||
export default Layout |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ import _ from 'lodash' | |
import { TabsNavItem } from '~/libs/ui' | ||
import { | ||
billingAccountRouteId, | ||
gamificationAdminRouteId, | ||
manageChallengeRouteId, | ||
manageReviewRouteId, | ||
permissionManagementRouteId, | ||
platformRouteId, | ||
userManagementRouteId, | ||
} from '~/apps/admin/src/config/routes.config' | ||
|
||
|
@@ -50,6 +52,16 @@ export const SystemAdminTabsConfig: TabsNavItem[] = [ | |
id: permissionManagementRouteId, | ||
title: 'Permission Management', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
id: `${platformRouteId}/${gamificationAdminRouteId}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a template literal for |
||
title: 'Badges', | ||
}, | ||
], | ||
id: platformRouteId, | ||
title: 'Platform', | ||
}, | ||
] | ||
|
||
export function getTabIdFromPathName(pathname: string): string { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Wrapper for permission managment | ||
*/ | ||
import { FC, useContext, useMemo } from 'react' | ||
import { Outlet, Routes } from 'react-router-dom' | ||
|
||
import { routerContext, RouterContextData } from '~/libs/core' | ||
|
||
import { adminRoutes } from '../admin-app.routes' | ||
import { platformRouteId } from '../config/routes.config' | ||
|
||
/** | ||
* The router outlet with layout. | ||
*/ | ||
export const Platform: FC = () => { | ||
const childRoutes = useChildRoutes() | ||
|
||
return ( | ||
<> | ||
<Outlet /> | ||
<Routes>{childRoutes}</Routes> | ||
</> | ||
) | ||
} | ||
|
||
function useChildRoutes(): Array<JSX.Element> | undefined { | ||
const { getRouteElement }: RouterContextData = useContext(routerContext) | ||
const childRoutes = useMemo( | ||
() => adminRoutes[0].children | ||
?.find(r => r.id === platformRouteId) | ||
?.children?.map(getRouteElement), | ||
[], // eslint-disable-line react-hooks/exhaustive-deps -- missing dependency: getRouteElement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
) | ||
return childRoutes | ||
} | ||
|
||
export default Platform |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export * from './game-badge.model' | ||
export * from './hooks/use-get-game-badges-page.hook' | ||
export * from './hooks/use-gamification-breadcrumb.hook' | ||
export * from './hooks/use-get-game-badge-details.hook' | ||
export * from './member-autocomplete' | ||
export * from './pagination' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ export interface BadgeCreatedModalProps { | |
badge: GameBadge | ||
isOpen: boolean | ||
onClose: () => void | ||
rootPage: string; | ||
} | ||
|
||
const BadgeCreatedModal: FC<BadgeCreatedModalProps> = (props: BadgeCreatedModalProps) => { | ||
|
@@ -52,7 +53,7 @@ const BadgeCreatedModal: FC<BadgeCreatedModalProps> = (props: BadgeCreatedModalP | |
label='View' | ||
primary | ||
size='lg' | ||
to={badgeDetailPath(props.badge.id)} | ||
to={badgeDetailPath(props.rootPage, props.badge.id)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
/> | ||
<Button | ||
label='Create a new badge' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,14 @@ | ||
import { AppSubdomain, EnvironmentConfig } from '~/config' | ||
import { lazyLoad, LazyLoadedComponent, PlatformRoute, UserRole } from '~/libs/core' | ||
|
||
import { toolTitle } from './GamificationAdmin' | ||
|
||
const GamificationAdmin: LazyLoadedComponent = lazyLoad(() => import('./GamificationAdmin')) | ||
const BadgeDetailPage: LazyLoadedComponent = lazyLoad(() => import('./pages/badge-detail/BadgeDetailPage')) | ||
const BadgeListingPage: LazyLoadedComponent = lazyLoad(() => import('./pages/badge-listing/BadgeListingPage')) | ||
const CreateBadgePage: LazyLoadedComponent = lazyLoad(() => import('./pages/create-badge/CreateBadgePage')) | ||
|
||
export const rootRoute: string = ( | ||
EnvironmentConfig.SUBDOMAIN === AppSubdomain.gamificationAdmin ? '' : `/${AppSubdomain.gamificationAdmin}` | ||
) | ||
export const baseDetailPath: string = '/badge-detail' | ||
export const createBadgePath: string = '/create-badge' | ||
|
||
export function badgeDetailPath(badgeId: string, view?: 'edit' | 'award'): string { | ||
return `${rootRoute}${baseDetailPath}/${badgeId}${!!view ? `#${view}` : ''}` | ||
export function badgeDetailPath( | ||
rootPage: string, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
badgeId: string, | ||
view?: 'edit' | 'award', | ||
): string { | ||
return `${rootPage}${baseDetailPath}/${badgeId}${!!view ? `#${view}` : ''}` | ||
} | ||
|
||
export const createBadgeRoute: string = `${rootRoute}${createBadgePath}` | ||
|
||
export const gamificationAdminRoutes: ReadonlyArray<PlatformRoute> = [ | ||
{ | ||
authRequired: true, | ||
children: [ | ||
{ | ||
element: <BadgeListingPage />, | ||
route: '/', | ||
}, | ||
{ | ||
element: <CreateBadgePage />, | ||
route: createBadgePath, | ||
}, | ||
{ | ||
element: <BadgeDetailPage />, | ||
route: `${baseDetailPath}/:id`, | ||
}, | ||
], | ||
domain: AppSubdomain.gamificationAdmin, | ||
element: <GamificationAdmin />, | ||
id: toolTitle, | ||
rolesRequired: [ | ||
UserRole.gamificationAdmin, | ||
], | ||
route: rootRoute, | ||
}, | ||
] | ||
export const createBadgeRoute: (rootPage: string) => string = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider providing a more descriptive name for the |
||
rootPage: string, | ||
) => `${rootPage}${createBadgePath}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement for
baseDetailPath
andcreateBadgePath
should be verified to ensure these paths are correct and that the modules exist in the specified location. If these are new modules, ensure they are properly implemented and tested.