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

Commit

Permalink
feat(navbar): add icons to 'quick add' icon in navbar (#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTan331 committed Jul 9, 2020
1 parent 5a2a433 commit 7e0aba7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/__tests__/shared/components/navbar/Navbar.test.tsx
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
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
@@ -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

1 comment on commit 7e0aba7

@vercel
Copy link

@vercel vercel bot commented on 7e0aba7 Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.