-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Service nav permissions #16038
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
base: develop
Are you sure you want to change the base?
Service nav permissions #16038
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 |
|---|---|---|
|
|
@@ -4,15 +4,32 @@ import CareIcon from "@/CAREUI/icons/CareIcon"; | |
|
|
||
| import { NavMain } from "@/components/ui/sidebar/nav-main"; | ||
|
|
||
| import { getPermissions } from "@/common/Permissions"; | ||
| import { usePermissions } from "@/context/PermissionContext"; | ||
| import useCurrentLocation from "@/pages/Facility/locations/utils/useCurrentLocation"; | ||
| import useCurrentFacility from "@/pages/Facility/utils/useCurrentFacility"; | ||
| import { CalendarIcon, Logs } from "lucide-react"; | ||
|
|
||
| export function LocationNav() { | ||
| const { t } = useTranslation(); | ||
|
|
||
| const { facilityId } = useCurrentFacility(); | ||
| const { locationId } = useCurrentLocation(); | ||
| const { facilityId, facility } = useCurrentFacility(); | ||
| const { locationId, location } = useCurrentLocation(); | ||
| const { hasPermission } = usePermissions(); | ||
| const { | ||
| canListFacilityLocations, | ||
| canReadServiceRequest, | ||
| canReadSupplyDelivery, | ||
| canReadInventory, | ||
| canReadSupplyRequest, | ||
| canViewSchedule, | ||
| canViewAppointments, | ||
| canListTokens, | ||
| } = getPermissions(hasPermission, location?.permissions ?? []); | ||
| const { canViewAsPharmacist } = getPermissions( | ||
| hasPermission, | ||
| facility?.permissions ?? [], | ||
| ); | ||
|
|
||
| const baseUrl = `/facility/${facilityId}/locations/${locationId}`; | ||
|
|
||
|
|
@@ -23,11 +40,13 @@ export function LocationNav() { | |
| name: t("beds"), | ||
| url: `${baseUrl}/beds`, | ||
| icon: <CareIcon icon="l-bed" />, | ||
| visibility: canListFacilityLocations, | ||
| }, | ||
| { | ||
| name: t("laboratory"), | ||
| url: `${baseUrl}/laboratory`, | ||
| icon: <CareIcon icon="l-microscope" />, | ||
| visibility: canReadServiceRequest, | ||
| children: [ | ||
| { | ||
| name: t("service_requests"), | ||
|
|
@@ -39,64 +58,78 @@ export function LocationNav() { | |
| name: t("pharmacy"), | ||
| url: `${baseUrl}/pharmacy`, | ||
| icon: <CareIcon icon="l-medical-drip" />, | ||
| visibility: canViewAsPharmacist || canReadSupplyDelivery, | ||
|
Contributor
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. Tighten pharmacy workflow visibility to pharmacy-specific permission. Lines 61, 71, and 76 allow 🔒 Proposed fix- visibility: canViewAsPharmacist || canReadSupplyDelivery,
+ visibility: canViewAsPharmacist,
@@
- visibility: canViewAsPharmacist || canReadSupplyDelivery,
+ visibility: canViewAsPharmacist,
@@
- visibility: canReadSupplyDelivery,
+ visibility: canViewAsPharmacist,Also applies to: 71-71, 76-76 🤖 Prompt for AI Agents |
||
| children: [ | ||
| { | ||
| name: t("prescription_queue"), | ||
| url: `${baseUrl}/medication_requests`, | ||
| visibility: canViewAsPharmacist, | ||
| }, | ||
| { | ||
| name: "℞ " + t("dispense"), | ||
| url: `${baseUrl}/medication_dispense`, | ||
| visibility: canViewAsPharmacist || canReadSupplyDelivery, | ||
| }, | ||
| { | ||
| name: t("medication_return"), | ||
| url: `${baseUrl}/medication_return`, | ||
| visibility: canReadSupplyDelivery, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: t("inventory"), | ||
| url: `${baseUrl}/inventory/summary`, | ||
| icon: <CareIcon icon="l-shop" />, | ||
| visibility: | ||
| canReadInventory || canReadSupplyRequest || canReadSupplyDelivery, | ||
| children: [ | ||
| { | ||
| name: t("items"), | ||
| url: `${baseUrl}/inventory/summary`, | ||
| visibility: canReadInventory, | ||
| }, | ||
| { | ||
| header: t("internal_transfers"), | ||
| name: t("to_receive"), | ||
| url: `${baseUrl}/inventory/internal/receive/`, | ||
| visibility: canReadSupplyRequest || canReadSupplyDelivery, | ||
| }, | ||
| { | ||
| name: t("to_dispatch"), | ||
| url: `${baseUrl}/inventory/internal/dispatch/`, | ||
| visibility: canReadSupplyRequest || canReadSupplyDelivery, | ||
| }, | ||
| { | ||
| header: t("external_supply"), | ||
| name: t("purchase_orders"), | ||
| url: `${baseUrl}/inventory/external/orders/outgoing`, | ||
| visibility: canReadSupplyRequest, | ||
| }, | ||
| { | ||
| name: t("purchase_deliveries"), | ||
| url: `${baseUrl}/inventory/external/deliveries/incoming`, | ||
| visibility: canReadSupplyDelivery, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: t("schedule"), | ||
| url: `${baseUrl}/schedule`, | ||
| icon: <CalendarIcon />, | ||
| visibility: canViewSchedule, | ||
| }, | ||
| { | ||
| name: t("appointments"), | ||
| url: `${baseUrl}/appointments`, | ||
| icon: <CareIcon icon="d-calendar" />, | ||
| visibility: canViewAppointments, | ||
| }, | ||
| { | ||
| name: t("queues"), | ||
| url: `${baseUrl}/queues`, | ||
| icon: <Logs />, | ||
| visibility: canListTokens, | ||
| }, | ||
| ]} | ||
| /> | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: ohcnetwork/care_fe
Length of output: 156
🏁 Script executed:
Repository: ohcnetwork/care_fe
Length of output: 10215
Use consistent
facility.permissionsacross navigation components for uniform permission checking.Line 31 uses
facility?.permissions, butsrc/pages/Facility/services/HealthcareServiceShow.tsxLine 134 andsrc/components/ui/sidebar/facility/service/service-nav.tsxLine 29 usefacility?.root_org_permissions. All other usages in the codebase (22+ locations) follow thefacility?.permissionspattern. This inconsistency can cause permission-based navigation visibility to diverge if only one permission field is populated.🤖 Prompt for AI Agents