Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat(navbar): add icons to 'quick add' icon in navbar #2220

Merged
merged 2 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/__tests__/shared/components/navbar/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ describe('Navbar', () => {
const hamberger = hospitalRunNavbar.find('.nav-hamberger')
const { children } = hamberger.first().props() as any

expect(children[0].props.children).toEqual([undefined, 'dashboard.label'])
expect(children[1].props.children).toEqual([undefined, 'patients.newPatient'])
expect(children[children.length - 1].props.children).toEqual([undefined, 'settings.label'])
const [dashboardIcon, dashboardLabel] = children[0].props.children
const [newPatientIcon, newPatientLabel] = children[1].props.children
const [settingsIcon, settingsLabel] = children[children.length - 1].props.children

expect(dashboardIcon.props.icon).toEqual('dashboard')
expect(dashboardLabel).toEqual('dashboard.label')
expect(newPatientIcon.props.icon).toEqual('patient-add')
expect(newPatientLabel).toEqual('patients.newPatient')
expect(settingsIcon.props.icon).toEqual('setting')
expect(settingsLabel).toEqual('settings.label')
})

it('should not show an item if user does not have a permission', () => {
Expand Down Expand Up @@ -142,7 +149,10 @@ describe('Navbar', () => {
const addNew = hospitalRunNavbar.find('.nav-add-new')
const { children } = addNew.first().props() as any

expect(children[0].props.children).toEqual([undefined, 'patients.newPatient'])
const [icon, label] = children[0].props.children

expect(icon.props.icon).toEqual('patient-add')
expect(label).toEqual('patients.newPatient')
})

it('should not show a shortcut if user does not have a permission', () => {
Expand Down
1 change: 1 addition & 0 deletions src/shared/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Navbar = () => {
.map((page) => ({
type: 'link',
label: t(page.label),
icon: `${page.icon}`,
onClick: () => {
navigateTo(page.path)
},
Expand Down
12 changes: 11 additions & 1 deletion src/shared/components/navbar/pageMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Permissions from '../../model/Permissions'

type Page = { permission: Permissions | null; label: string; path: string }
type Page = { permission: Permissions | null; label: string; path: string; icon: string }

const pageMap: {
[key: string]: Page
Expand All @@ -9,51 +9,61 @@ const pageMap: {
permission: null,
label: 'dashboard.label',
path: '/',
icon: 'dashboard',
},
newPatient: {
permission: Permissions.WritePatients,
label: 'patients.newPatient',
path: '/patients/new',
icon: 'patient-add',
},
viewPatients: {
permission: Permissions.ReadPatients,
label: 'patients.patientsList',
path: '/patients',
icon: 'patients',
},
newAppointment: {
permission: Permissions.WriteAppointments,
label: 'scheduling.appointments.new',
path: '/appointments/new',
icon: 'appointment-add',
},
viewAppointments: {
permission: Permissions.ReadAppointments,
label: 'scheduling.appointments.schedule',
path: '/appointments',
icon: 'appointment',
},
newLab: {
permission: Permissions.RequestLab,
label: 'labs.requests.new',
path: '/labs/new',
icon: 'add',
},
viewLabs: {
permission: Permissions.ViewLabs,
label: 'labs.requests.label',
path: '/labs',
icon: 'lab',
},
newIncident: {
permission: Permissions.ReportIncident,
label: 'incidents.reports.new',
path: '/incidents/new',
icon: 'add',
},
viewIncidents: {
permission: Permissions.ViewIncidents,
label: 'incidents.reports.label',
path: '/incidents',
icon: 'incident',
},
settings: {
permission: null,
label: 'settings.label',
path: '/settings',
icon: 'setting',
},
}

Expand Down