Skip to content
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

(BREAKING) O3-3191: Move LeftNav into primary navigation app #978

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ibacher
Copy link
Member

@ibacher ibacher commented Apr 18, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

This extracts the LeftNav component from the styleguide into the primary navigation app, with the idea being that we have a single left nav that changes contents as the user browses.

This means that the API functions (now migrated to esm-state instead of esm-styleguide) setLeftNav() and unsetLeftNav() are quite important. Essentially a page opts into using the LeftNav by calling setLeftNav() to declare the slot. The LeftNav is only shown when there is at least one extension bound to the declared slot. So although the left nav is now a single component, it can contextually change which links are shown based on the extension slot name.

NB This also means that the hamburger menu is only shown if there are any extensions mounted in the nav.

TODO: Figure out when it makes sense to fire an automated call to unsetLeftNav() this probably needs to be done in the page mount() call. I'll play with that.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3191

Other

PRs are coming for Home and Patient Chart. Patient Chart, in particular, will require some work to make this happen.

Also, if you test out this PR right now, you'll probably see no real changes (other than a weird rendering of an empty bar on the home page); it does appear to work, but the left nav items in Home and Chart are currently rendered over the nav bar.

Related PRs: openmrs/openmrs-contrib-json-schemas#10

Copy link
Contributor

github-actions bot commented Apr 18, 2024

Size Change: -628 kB (-16.61%) 👏

Total Size: 3.15 MB

Filename Size Change
packages/apps/esm-primary-navigation-app/dist/553.js 0 B -23.3 kB (removed) 🏆
packages/apps/esm-primary-navigation-app/dist/958.js 0 B -22.7 kB (removed) 🏆
packages/framework/esm-framework/dist/openmrs-esm-framework.js 265 kB -211 kB (-44.41%) 🎉
packages/shell/esm-app-shell/dist/openmrs.acad29d7c0751f45.js 0 B -383 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
packages/apps/esm-devtools-app/dist/344.js 27.3 kB 0 B
packages/apps/esm-devtools-app/dist/630.js 2.69 kB 0 B
packages/apps/esm-devtools-app/dist/667.js 6.96 kB 0 B
packages/apps/esm-devtools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-devtools-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-devtools-app/dist/875.js 9.86 kB 0 B
packages/apps/esm-devtools-app/dist/884.js 15.2 kB 0 B
packages/apps/esm-devtools-app/dist/889.js 162 kB +5.7 kB (+3.64%)
packages/apps/esm-devtools-app/dist/988.js 328 B 0 B
packages/apps/esm-devtools-app/dist/main.js 3.14 kB 0 B
packages/apps/esm-devtools-app/dist/openmrs-esm-devtools-app.js 3.19 kB 0 B
packages/apps/esm-implementer-tools-app/dist/15.js 62.2 kB 0 B
packages/apps/esm-implementer-tools-app/dist/271.js 716 B 0 B
packages/apps/esm-implementer-tools-app/dist/319.js 637 B 0 B
packages/apps/esm-implementer-tools-app/dist/426.js 24.8 kB 0 B
packages/apps/esm-implementer-tools-app/dist/460.js 735 B 0 B
packages/apps/esm-implementer-tools-app/dist/482.js 15.2 kB 0 B
packages/apps/esm-implementer-tools-app/dist/528.js 133 kB 0 B
packages/apps/esm-implementer-tools-app/dist/56.js 3.07 kB 0 B
packages/apps/esm-implementer-tools-app/dist/560.js 13.9 kB 0 B
packages/apps/esm-implementer-tools-app/dist/574.js 560 B 0 B
packages/apps/esm-implementer-tools-app/dist/587.js 2.92 kB 0 B
packages/apps/esm-implementer-tools-app/dist/620.js 126 kB 0 B
packages/apps/esm-implementer-tools-app/dist/625.js 562 B 0 B
packages/apps/esm-implementer-tools-app/dist/644.js 717 B 0 B
packages/apps/esm-implementer-tools-app/dist/657.js 7.01 kB 0 B
packages/apps/esm-implementer-tools-app/dist/71.js 6.97 kB 0 B
packages/apps/esm-implementer-tools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-implementer-tools-app/dist/757.js 560 B 0 B
packages/apps/esm-implementer-tools-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-implementer-tools-app/dist/791.js 284 B 0 B
packages/apps/esm-implementer-tools-app/dist/807.js 559 B 0 B
packages/apps/esm-implementer-tools-app/dist/833.js 681 B 0 B
packages/apps/esm-implementer-tools-app/dist/86.js 6.71 kB 0 B
packages/apps/esm-implementer-tools-app/dist/889.js 162 kB +5.7 kB (+3.64%)
packages/apps/esm-implementer-tools-app/dist/main.js 79 kB 0 B
packages/apps/esm-implementer-tools-app/dist/openmrs-esm-implementer-tools-app.js 3.31 kB 0 B
packages/apps/esm-login-app/dist/111.js 1.22 kB 0 B
packages/apps/esm-login-app/dist/126.js 2.5 kB 0 B
packages/apps/esm-login-app/dist/173.js 1.22 kB 0 B
packages/apps/esm-login-app/dist/224.js 256 B 0 B
packages/apps/esm-login-app/dist/236.js 272 B 0 B
packages/apps/esm-login-app/dist/240.js 364 B 0 B
packages/apps/esm-login-app/dist/271.js 718 B 0 B
packages/apps/esm-login-app/dist/272.js 264 B 0 B
packages/apps/esm-login-app/dist/319.js 679 B 0 B
packages/apps/esm-login-app/dist/336.js 234 B 0 B
packages/apps/esm-login-app/dist/363.js 30.5 kB 0 B
packages/apps/esm-login-app/dist/460.js 737 B 0 B
packages/apps/esm-login-app/dist/539.js 298 B 0 B
packages/apps/esm-login-app/dist/56.js 3.06 kB 0 B
packages/apps/esm-login-app/dist/574.js 577 B 0 B
packages/apps/esm-login-app/dist/625.js 579 B 0 B
packages/apps/esm-login-app/dist/627.js 257 B 0 B
packages/apps/esm-login-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-login-app/dist/644.js 718 B 0 B
packages/apps/esm-login-app/dist/667.js 6.96 kB 0 B
packages/apps/esm-login-app/dist/673.js 284 B 0 B
packages/apps/esm-login-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-login-app/dist/757.js 660 B 0 B
packages/apps/esm-login-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-login-app/dist/807.js 897 B 0 B
packages/apps/esm-login-app/dist/833.js 684 B 0 B
packages/apps/esm-login-app/dist/836.js 22.5 kB 0 B
packages/apps/esm-login-app/dist/884.js 15.2 kB 0 B
packages/apps/esm-login-app/dist/889.js 162 kB +5.7 kB (+3.64%)
packages/apps/esm-login-app/dist/main.js 57 kB 0 B
packages/apps/esm-login-app/dist/openmrs-esm-login-app.js 3.37 kB 0 B
packages/apps/esm-offline-tools-app/dist/271.js 1.18 kB 0 B
packages/apps/esm-offline-tools-app/dist/319.js 1.13 kB 0 B
packages/apps/esm-offline-tools-app/dist/460.js 1.29 kB 0 B
packages/apps/esm-offline-tools-app/dist/56.js 3.07 kB 0 B
packages/apps/esm-offline-tools-app/dist/574.js 1.04 kB 0 B
packages/apps/esm-offline-tools-app/dist/59.js 56.5 kB 0 B
packages/apps/esm-offline-tools-app/dist/625.js 1.04 kB 0 B
packages/apps/esm-offline-tools-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-offline-tools-app/dist/644.js 1.18 kB 0 B
packages/apps/esm-offline-tools-app/dist/667.js 6.96 kB 0 B
packages/apps/esm-offline-tools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-offline-tools-app/dist/757.js 1.2 kB 0 B
packages/apps/esm-offline-tools-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-offline-tools-app/dist/807.js 1.11 kB 0 B
packages/apps/esm-offline-tools-app/dist/833.js 1.21 kB 0 B
packages/apps/esm-offline-tools-app/dist/884.js 15.2 kB 0 B
packages/apps/esm-offline-tools-app/dist/889.js 162 kB +5.7 kB (+3.64%)
packages/apps/esm-offline-tools-app/dist/922.js 90.9 kB 0 B
packages/apps/esm-offline-tools-app/dist/main.js 147 kB 0 B
packages/apps/esm-offline-tools-app/dist/openmrs-esm-offline-tools-app.js 3.29 kB 0 B
packages/apps/esm-primary-navigation-app/dist/271.js 267 B 0 B
packages/apps/esm-primary-navigation-app/dist/319.js 237 B 0 B
packages/apps/esm-primary-navigation-app/dist/460.js 264 B 0 B
packages/apps/esm-primary-navigation-app/dist/556.js 24.3 kB 0 B
packages/apps/esm-primary-navigation-app/dist/574.js 230 B 0 B
packages/apps/esm-primary-navigation-app/dist/625.js 232 B 0 B
packages/apps/esm-primary-navigation-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-primary-navigation-app/dist/644.js 267 B 0 B
packages/apps/esm-primary-navigation-app/dist/667.js 6.97 kB 0 B
packages/apps/esm-primary-navigation-app/dist/735.js 2.64 kB 0 B
packages/apps/esm-primary-navigation-app/dist/757.js 238 B 0 B
packages/apps/esm-primary-navigation-app/dist/762.js 7.61 kB +1 B (+0.01%)
packages/apps/esm-primary-navigation-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-primary-navigation-app/dist/807.js 290 B 0 B
packages/apps/esm-primary-navigation-app/dist/833.js 257 B 0 B
packages/apps/esm-primary-navigation-app/dist/884.js 15.2 kB 0 B
packages/apps/esm-primary-navigation-app/dist/889.js 162 kB +5.7 kB (+3.64%)
packages/apps/esm-primary-navigation-app/dist/972.js 24.4 kB 0 B
packages/apps/esm-primary-navigation-app/dist/main.js 50.1 kB +2.52 kB (+5.29%) 🔍
packages/apps/esm-primary-navigation-app/dist/openmrs-esm-primary-navigation-app.js 3.23 kB 0 B
packages/framework/esm-api/dist/openmrs-esm-api.js 16.3 kB 0 B
packages/framework/esm-config/dist/openmrs-esm-module-config.js 8.02 kB 0 B
packages/framework/esm-context/dist/openmrs-esm-context.js 1.1 kB 0 B
packages/framework/esm-dynamic-loading/dist/openmrs-esm-dynamic-loading.js 2.75 kB 0 B
packages/framework/esm-error-handling/dist/openmrs-esm-error-handling.js 889 B 0 B
packages/framework/esm-extensions/dist/openmrs-esm-extensions.js 8 kB -102 B (-1.26%)
packages/framework/esm-feature-flags/dist/openmrs-esm-feature-flags.js 1.67 kB 0 B
packages/framework/esm-framework/dist/126.openmrs-esm-framework.js 2.47 kB 0 B
packages/framework/esm-framework/dist/278.openmrs-esm-framework.js 14.5 kB -2 B (-0.01%)
packages/framework/esm-framework/dist/530.openmrs-esm-framework.js 2.92 kB 0 B
packages/framework/esm-framework/dist/619.openmrs-esm-framework.js 6.49 kB 0 B
packages/framework/esm-framework/dist/645.openmrs-esm-framework.js 9.31 kB 0 B
packages/framework/esm-framework/dist/680.openmrs-esm-framework.js 0 B -6.13 kB (removed) 🏆
packages/framework/esm-framework/dist/735.openmrs-esm-framework.js 2.66 kB 0 B
packages/framework/esm-framework/dist/746.openmrs-esm-framework.js 6.13 kB 0 B
packages/framework/esm-framework/dist/788.openmrs-esm-framework.js 42.9 kB 0 B
packages/framework/esm-globals/dist/openmrs-esm-globals.js 770 B 0 B
packages/framework/esm-navigation/dist/openmrs-esm-navigation.js 9.35 kB 0 B
packages/framework/esm-offline/dist/openmrs-esm-offline.js 34.4 kB 0 B
packages/framework/esm-pages/dist/openmrs-esm-pages.js 7 kB 0 B
packages/framework/esm-react-utils/dist/openmrs-esm-react-utils.js 15.6 kB 0 B
packages/framework/esm-routes/dist/openmrs-esm-utils.js 1.46 kB 0 B
packages/framework/esm-state/dist/openmrs-esm-state.js 921 B 0 B
packages/framework/esm-styleguide/dist/openmrs-esm-styleguide.js 53.8 kB -31 B (-0.06%)
packages/framework/esm-translations/dist/openmrs-esm-core-translations.js 1.59 kB 0 B
packages/framework/esm-utils/dist/openmrs-esm-utils.js 11.1 kB 0 B
packages/shell/esm-app-shell/dist/044c3eefa9674ad6.js 6.91 kB 0 B
packages/shell/esm-app-shell/dist/11c63b65f96a8718.js 499 B 0 B
packages/shell/esm-app-shell/dist/1e0131662341578e.js 645 B 0 B
packages/shell/esm-app-shell/dist/2916d0aa7a9d5dc8.js 544 B 0 B
packages/shell/esm-app-shell/dist/2e49bd21ea50fd0d.js 0 B -1.58 kB (removed) 🏆
packages/shell/esm-app-shell/dist/3f6edf0e8b58a308.js 0 B -6.87 kB (removed) 🏆
packages/shell/esm-app-shell/dist/4a3e954c45d63305.js 645 B 0 B
packages/shell/esm-app-shell/dist/56c2295bc732ae32.js 722 B 0 B
packages/shell/esm-app-shell/dist/651172ae1548469c.js 499 B 0 B
packages/shell/esm-app-shell/dist/98343ad4bb547c48.js 499 B 0 B
packages/shell/esm-app-shell/dist/b5151d35f680b40a.js 0 B -3.82 kB (removed) 🏆
packages/shell/esm-app-shell/dist/b70440ff5c6f678e.js 2.98 kB 0 B
packages/shell/esm-app-shell/dist/ba933133ad512cac.js 499 B 0 B
packages/shell/esm-app-shell/dist/c90b843e2ccbab76.js 1.58 kB 0 B
packages/shell/esm-app-shell/dist/fa89289c9d9645c9.js 519 B 0 B
packages/shell/esm-app-shell/dist/openmrs.2ff868958cde1779.js 270 kB 0 B
packages/shell/esm-app-shell/dist/service-worker.js 45.9 kB +5 B (+0.01%)
packages/tooling/openmrs/dist/cli.js 2.88 kB 0 B
packages/tooling/openmrs/dist/commands/assemble.js 2.82 kB 0 B
packages/tooling/openmrs/dist/commands/build.js 1.34 kB 0 B
packages/tooling/openmrs/dist/commands/debug.js 545 B 0 B
packages/tooling/openmrs/dist/commands/develop.js 2.59 kB 0 B
packages/tooling/openmrs/dist/commands/index.js 438 B 0 B
packages/tooling/openmrs/dist/commands/start.js 851 B 0 B
packages/tooling/openmrs/dist/index.js 517 B 0 B
packages/tooling/openmrs/dist/runner.js 637 B 0 B
packages/tooling/openmrs/dist/utils/config.js 728 B 0 B
packages/tooling/openmrs/dist/utils/debugger.js 576 B 0 B
packages/tooling/openmrs/dist/utils/dependencies.js 648 B 0 B
packages/tooling/openmrs/dist/utils/helpers.js 395 B 0 B
packages/tooling/openmrs/dist/utils/importmap.js 3.07 kB 0 B
packages/tooling/openmrs/dist/utils/index.js 444 B 0 B
packages/tooling/openmrs/dist/utils/logger.js 368 B 0 B
packages/tooling/openmrs/dist/utils/npmConfig.js 830 B 0 B
packages/tooling/openmrs/dist/utils/untar.js 722 B 0 B
packages/tooling/openmrs/dist/utils/variables.js 192 B 0 B
packages/tooling/openmrs/dist/utils/webpack.js 278 B 0 B
packages/tooling/webpack-config/dist/index.js 3.61 kB 0 B

compressed-size-action

@@ -1,31 +1,10 @@
/** @module @category UI */
import React from 'react';
import { ExtensionSlot, useStore } from '@openmrs/esm-react-utils';
import { createGlobalStore } from '@openmrs/esm-state';
import { ExtensionSlot, useStore, leftNavStore } from '@openmrs/esm-framework/src/internal';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've run into very esoteric problems with this. What happened in my case was that it seemed that Jest would come across this line, load the internal library, which loads the entire styleguide/index, which at some point loads some SVGs, and Jest sees the SVGs and crashes with syntax errors. Importing from the sub-libraries directly avoids that problem.

package.json Outdated Show resolved Hide resolved
const appMenuItems = useConnectedExtensions('app-menu-slot');
const { slotName: leftNavSlot } = useStore(leftNavStore);
const leftNavItems = useConnectedExtensions(leftNavSlot);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another pattern to consider is one I introduce in #979: using the featureName of the root component for the slot name. So like the feature name for patient chart is patient-chart. If we add featureName to ComponentContext then you can just get that context and make the slot name like left-nav-${featureName}-slot.

I have no opinion on whether that pattern is better or worse for this use case, I just want to put it out there that it's an option.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I'm going to play around with that. Right now, the major problem with this PR is the need to manually call setLeftNav() and unsetLeftNav(), and this would give us a clean way of having the left nav just "magically" supported.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I love that after like five years of extremely marginal existence featureName is suddenly becoming very useful

Copy link
Member

Choose a reason for hiding this comment

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

@ibacher It would be great if this also supported some sort of default-left-nav-slot, which would render if and only if no specific left nav is set. This would be different from the existing global nav slot, which always renders. This way, implementations could basically have a left nave that is consistent across all routes in the application, which is then replaced for specific routes (eg. patient chart).

@@ -42,7 +46,8 @@ const HeaderItems: React.FC = () => {
[],
);

const showHamburger = useMemo(() => !isDesktop(layout) && navMenuItems.length > 0, [navMenuItems.length, layout]);
const showLeftNav = useMemo(() => isDesktop(layout) && leftNavItems.length > 0, [leftNavItems.length, layout]);
const showHamburger = useMemo(() => !isDesktop(layout) && leftNavItems.length > 0, [leftNavItems.length, layout]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const showHamburger = useMemo(() => !isDesktop(layout) && leftNavItems.length > 0, [leftNavItems.length, layout]);
const showHamburger = useMemo(() => !isDesktop(layout) && leftNavItems.length > 0, [leftNavItems.length, layout]);

nit: showHamburgerMenu reads better here.

@ibacher
Copy link
Member Author

ibacher commented Apr 26, 2024

So, a question on this:

I was looking into the featureName thing @brandones suggested and it's not quite workable here because there's no guaranteed extension to pull from. That said, I came up with something similar which just uses the active page name to determine the default slot name. This matches what we already do in the chart (patient-chart-dashboard-slot) and, with a slight adjustment, the home page (home-dashboard-slot instead of homepage-dashboard-slot). I like this a lot because it eliminate the need to figure out how to call setNavSlot and unsetNavSlot appropriately.

However, this has two disadvantages:

  1. This results in a per-app left nav, meaning all pages in the same app would have the same left nav. Currently, this is a non-issue, since most apps have at most one page. The only exception (outside of stuff in core) is the registration app, and it makes sense that if there was a left nav for registration, they would share the same left nav. (The two pages in question are the "create a patient" and "edit a patient" pages).
  2. It's possible to have multiple active pages at the same time. This is effectively what we do for the implementer tools, dev tools, and primary navigation itself. Currently, my solution is just to hard-code ignoring those pages. This would mean, though, that the system wouldn't work correctly if anyone tried to add any similar custom pages.

It's possible to work around these. For example, I thought we could address 1 by adding a "name" property for pages, with some sort of fallback for legacy code. 2 could be addressed by associating a "type" with each page, maybe "Main Screen" and "Component" or something, so that we could remove the hard-coding and only look for "Main Screen" components. But I'm also not sure if the added properties are worth it to solve what are likely corner-cases.

Any opinions on this?

@mseaton
Copy link
Member

mseaton commented Apr 28, 2024

What about using the overall route to determine what nav extension slot to render? Similar to how the activation function works generally for pages, but applied to slots / extensions? And if multiple are matched, then the most specific wins?

Let's assume an extension slot base (suffix) of left-nav-slot.

So, when the url starts with <spaBasePath>/home, then you'd load extensions registered with home-left-nav-slot, and when the url starts with <spaBasePath>/patient you'd load extensions registered with patient-left-nav-slot, etc.

But if someone wanted a custom left nav for, say, service-queues, which would by default match up with the home slot at <spaBasePath>/home/service-queues, then one could register extensions at home-service-queues-left-nav-slot and this would take precedence. This avoids the "one nav per app" issue an also avoids the "multiple pages per route" issue.

This would also inherently allow for defining a global, default slot by registering extensions for the root url at <spaBasePath>/, which would load extensions from the left-nav-slot, which solves what I think will be the primary pattern we will want, which is to have one default / global nav (not something tied to "home"), which can then be overridden by one in patient chart. @ibacher

@brandones
Copy link
Collaborator

brandones commented Apr 28, 2024

Yeah, definitely an interesting idea, @mseaton . It might require a little more infrastructure around how we relate the app state to the URL, but that might be a good thing. I kind of prefer that to a solution which misbehaves if there are multiple apps per page.

I was looking into the featureName thing @brandones suggested and it's not quite workable here because there's no guaranteed extension to pull from.

Can you expand a bit on that @ibacher ? I don't understand.

@ibacher
Copy link
Member Author

ibacher commented Apr 29, 2024

Can you expand a bit on that @ibacher ? I don't understand.

Well, I was trying to do away with the need to call setLeftNav(). Without that call, there's no single local extension I could pick the feature name from, so we'd be stuck with a single slot for the left nav. Maybe that's desirable, but then need to rework how we do a different slot in the patient chart. (For the most part, I kind of imagine that we'd have separate navs for at least home, the patient chart, and maybe things that are sort-of external applications, like dispensing).

So, when the url starts with /home, then you'd load extensions registered with home-left-nav-slot, and when the url starts with /patient you'd load extensions registered with patient-left-nav-slot, etc.

So, I generally agree that using the URL makes sense. I don't totally love defining multiple possible slots for nested URLs. E.g., for <spaBasePath>/home/service-queues, we have to check three slots; for the chart, we currently use URLs like <spaBasePath>/patient/:patientUuid/chart/:view, which could imply something four-slots deep. We'd also have to have a strategy to skip over the :patientUuid token, since I don't imagine there's any need for a per patient left nav slot.

Using just the first part of the URL might be tempting to avoid checking numerous possible slots when trying to figure out the left nav slot, but we'd have to figure out how we distinguish between the chart (<spaBasePath>/patient/:patientUuid/chart/:view) and the "Edit Patient Details" page (<spaBasePath>/patient/:patientUuid/edit).

The idea of using the mounted apps was to basically be able to leverage apps activeWhen() functions to determine when the slot needed to change.

@brandones
Copy link
Collaborator

Ohhhh right, of course, if the left nav is part of primary-navigation-app the feature name it receives would always be primary-navigation-app. Why do we want to move LeftNav into the primary navigation app, actually?

One solution is to leave the left nav as it is, exported by the styleguide, rather than moving it into the primary navigation app. And then the LeftNav component would get the feature name of the app which has used it. To render the "default" left nav it could take an optional prop like <LeftNav default />. OR instead of using the feature name it could take an optional prop <LeftNav name="patient-chart" /> which, when left blank, renders the default left nav. Either way we can get rid of the setLeftNav stuff and state management.

@ibacher ibacher force-pushed the breaking/move-left-nav-to-primary-nav branch from 256d749 to 6a8246f Compare May 10, 2024 12:54
@ibacher ibacher changed the title BREAKING: Move LeftNav into primary navigation app (BREAKING) O3-3191: Move LeftNav into primary navigation app May 13, 2024
return uniq(
mountedApps.map((page) => {
let pageName = page;
pageName = pageName.replace(/^@[^\/]*\/(?:esm-)?(.+)-app-page-.*$/, '$1');

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with '@/a-app-page-' and with many repetitions of 'a-app-page-'.
@ibacher ibacher force-pushed the breaking/move-left-nav-to-primary-nav branch from dc641c5 to 14f6b59 Compare May 13, 2024 19:31
@ibacher ibacher force-pushed the main branch 2 times, most recently from 8f994a6 to 9cee659 Compare July 22, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants