-
Notifications
You must be signed in to change notification settings - Fork 211
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
(feat) Left hand navigation to queue by status table component #984
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
53c4d45
(feat) add queue navigation to left nav
mseaton f105b6f
use configurable link
mseaton 09b6efa
use configurable link
mseaton c8cd402
add extension
mseaton f4f55d7
Lint fixes
mseaton 9f87e15
css fixes
chibongho 0d84dc3
refactor to use react-router-dom APIs more
chibongho eefe222
more css
chibongho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/esm-service-queues-app/src/queue-table/queue-table-by-status-menu.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { SideNavMenu } from '@carbon/react'; | ||
import { ConfigurableLink } from '@openmrs/esm-framework'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { type Queue } from '../types'; | ||
import { useQueues } from '../hooks/useQueues'; | ||
import classNames from 'classnames'; | ||
import { BrowserRouter, useMatch, generatePath } from 'react-router-dom'; | ||
import styles from './queue-table-by-status-menu.scss'; | ||
|
||
// (Non-standard UI) A menu in the left nav to display a list of queues. Intended to be used | ||
// by slotting into the left nav as an extension | ||
export default function QueueTableByStatusMenu() { | ||
const { t } = useTranslation(); | ||
const { queues } = useQueues(); | ||
|
||
return ( | ||
<SideNavMenu title={t('serviceQueues', 'Service Queues')} className={styles.queueTableByStatusNavMenu}> | ||
<BrowserRouter> | ||
{queues.map((queue) => ( | ||
<QueueTableByStatusLink queue={queue} /> | ||
))} | ||
</BrowserRouter> | ||
</SideNavMenu> | ||
); | ||
} | ||
|
||
function QueueTableByStatusLink({ queue }: { queue: Queue }) { | ||
const path = `${window.spaBase}/home/service-queues/queue-table-by-status/:uuid`; | ||
const matcher = useMatch({ path, end: false }); | ||
const uuid = matcher?.params?.uuid; | ||
|
||
return ( | ||
<ConfigurableLink | ||
className={classNames('cds--side-nav__link', { | ||
'active-left-nav-link': queue.uuid == uuid, | ||
})} | ||
to={generatePath(path, { uuid: queue.uuid })}> | ||
{queue.display} | ||
</ConfigurableLink> | ||
); | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/esm-service-queues-app/src/queue-table/queue-table-by-status-menu.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.queueTableByStatusNavMenu { | ||
// override `li` element styles from <SideNavMenu> | ||
// (since none of the items in side nav is `li`) | ||
line-height: 0px; | ||
display: block; | ||
|
||
:global(.active-left-nav-link) { | ||
// override padding for sub-menu items | ||
padding-left: 1.75rem !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm forgetting, why do we need to have the slot listed in the meta here?
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.
It's just the way the home page app extensions work. I think it basically serves to connect the link component with the dashboard component that it renders.
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.
That's right, @mseaton