Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Route Extensibility #9043

Merged
merged 2 commits into from Oct 15, 2023
Merged

Admin Route Extensibility #9043

merged 2 commits into from Oct 15, 2023

Conversation

HexaField
Copy link
Member

@HexaField HexaField commented Oct 12, 2023

Summary

Projects can take advantage of the webappInjection API in xrengine.config.ts to add new routes

馃 Generated by Copilot at cfbf771

This pull request improves the admin dashboard functionality by using a new state for the allowed admin routes, refactoring the admin routes logic, and removing unused or outdated code. It also enhances the performance and readability of the admin dashboard components by using code splitting, simplifying the rendering logic, and using a new Redirect component. The main files affected are .env.local.default, appconfig.ts, adminRoutes.tsx, allowedRoutes.tsx, AllowedAdminRoutesState.tsx, DefaultAdminRoutes.tsx, DashboardMenuItem/index.tsx, and Redirect.tsx.

References

closes #insert number here

Explanation

馃 Generated by Copilot at cfbf771

  • Remove unused or deprecated config variables from .env.local.default file (link, link)
  • Rename DashboardItems file to DefaultAdminRoutes and export an object of default admin routes with name, scope, component, access, and icon properties (link)
  • Add a new file AllowedAdminRoutesState that defines a state for the allowed admin routes using Hyperflux library (link)
  • Modify AdminRoutes file to import and use the AllowedAdminRoutesState and the DefaultAdminRoutes to determine the user's access to each admin route based on their scopes (link, link, link)
  • Modify allowedRoutes file to use the allowed routes state from the AllowedAdminRoutesState, instead of the props passed from the adminRoutes file, and to render the matched route using the pathname and the access property of each route (link)
  • Add a new file Redirect that defines a Redirect component using the RouterState from the RouterService, and use it to redirect the user to a different route if the current route has a redirect property in the AllowedAdminRoutesState (link)
  • Modify DashboardMenuItem file to use the AllowedAdminRoutesState to render the sidebar items, instead of the useState and useEffect hooks, and to filter and map the sidebar items using the Object.entries and the access property of each route (link, link)
  • Remove the scopes object and property from the appconfig file, as they are now defined in the database and the user service (link, link)
  • Remove the Analytics component import from the AdminRoutes and DashboardMenuItem files, as it is no longer a separate component (link, link, link, link)

馃 Generated by Copilot at cfbf771

To make the admin routes more dynamic
We used Hyperflux and React.lazy
We added AllowedAdminRoutesState
And a Redirect component that's great
And cleaned up the config and appconfig.ts

QA Steps

List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.

Checklist

  • If this PR is still a WIP, convert to a draft
  • When this PR is ready, mark it as "Ready for review"
  • ensure all checks pass
  • Changes have been manually QA'd
  • Changes reviewed by at least 2 approved reviewers

@HexaField HexaField merged commit b71af6b into dev Oct 15, 2023
12 of 14 checks passed
@HexaField HexaField deleted the admin-extensibility branch October 15, 2023 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants