OpenRailAssociation / osrd

An open source web application for railway infrastructure design, capacity analysis, timetabling and simulation
https://osrd.fr
GNU Lesser General Public License v3.0
415 stars 40 forks source link

front: Initialize authorization #7870

Open kmer2016 opened 1 week ago

kmer2016 commented 1 week ago

Close #7779

This PR Adds:

1. ProtectedRoute Components:

2. RoleBasedContent and PermissionBasedContent Components:

3. Custom Hooks: useCheckUserRole and useCheckPermissions:

4. Error 403 listener:

Future Integration:

codecov-commenter commented 1 week ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 8.57143% with 128 lines in your changes missing coverage. Please review.

Project coverage is 28.46%. Comparing base (e0f4f41) to head (9762b8b).

Files Patch % Lines
...t/src/common/authorization/components/Error403.tsx 0.00% 29 Missing and 1 partial :warning:
...common/authorization/components/ProtectedRoute.tsx 0.00% 23 Missing and 1 partial :warning:
...uthorization/components/PermissionBasedContent.tsx 0.00% 17 Missing and 1 partial :warning:
...mmon/authorization/components/RoleBasedContent.tsx 0.00% 17 Missing and 1 partial :warning:
...mon/authorization/hooks/useCheckUserPermissions.ts 0.00% 13 Missing and 1 partial :warning:
...src/common/authorization/hooks/useCheckUserRole.ts 0.00% 13 Missing and 1 partial :warning:
front/src/main/app.jsx 0.00% 5 Missing :warning:
front/src/reducers/authorization/listener.ts 66.66% 4 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #7870 +/- ## ============================================ - Coverage 28.49% 28.46% -0.03% Complexity 2059 2059 ============================================ Files 1254 1261 +7 Lines 154467 154606 +139 Branches 3047 3054 +7 ============================================ - Hits 44011 44006 -5 - Misses 108641 108778 +137 - Partials 1815 1822 +7 ``` | [Flag](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [core](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `75.00% <ø> (ø)` | | | [editoast](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `71.63% <ø> (-0.06%)` | :arrow_down: | | [front](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `9.97% <8.57%> (-0.01%)` | :arrow_down: | | [gateway](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `2.34% <ø> (ø)` | | | [railjson_generator](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `87.49% <ø> (ø)` | | | [tests](https://app.codecov.io/gh/OpenRailAssociation/osrd/pull/7870/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `72.93% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.