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

Create shared resource #1887

Merged
merged 30 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0af7414
working
nickbristow May 22, 2024
1f12e9e
add shared dir
nickbristow May 22, 2024
4ea023b
moved shared resources folder
nickbristow May 22, 2024
ed64d25
Merge branch 'main' into 1863/shared-accordion
nickbristow May 22, 2024
c2fb3a0
webpack test
nickbristow May 23, 2024
f3a1265
test
nickbristow May 30, 2024
aee86e6
test
nickbristow May 30, 2024
5ecbf8d
test
nickbristow May 30, 2024
47daf98
test
nickbristow May 30, 2024
d2211bb
test
nickbristow May 31, 2024
7893520
Update docker-compose.yml
nickbristow May 31, 2024
e1e0028
Update buildContainers.yaml
nickbristow May 31, 2024
e1ea0e4
test
nickbristow May 31, 2024
f25a0f5
another test
nickbristow May 31, 2024
9c284b7
remove symlinks if needed
nickbristow May 31, 2024
08cff87
tests
nickbristow May 31, 2024
69c07c8
tests
nickbristow May 31, 2024
4be10df
Merge branch 'main' into 1863/shared-accordion
nickbristow May 31, 2024
e9f7411
fix lighthouse
nickbristow Jun 3, 2024
90660f4
remove symlinks from lighthouse
nickbristow Jun 3, 2024
92eac58
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 3, 2024
cd762d1
update readme
nickbristow Jun 4, 2024
d4300af
fix package
nickbristow Jun 4, 2024
7b7a361
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 4, 2024
cfd9d20
Update Dockerfile
nickbristow Jun 4, 2024
92dab05
Update package.json
nickbristow Jun 4, 2024
a2c2f4d
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 5, 2024
b51b880
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 5, 2024
97a6930
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 7, 2024
441a15f
Merge branch 'main' into 1863/shared-accordion
nickbristow Jun 11, 2024
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
10 changes: 10 additions & 0 deletions .github/workflows/buildContainers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Remove symlinks (if needed)
if: ${{ matrix.container-to-build == 'ecr-viewer' }}
working-directory: ./containers/${{matrix.container-to-build}}/src/app/shared
run: rm -rf ./*

- name: Copy shared-resources (if needed)
if: ${{ matrix.container-to-build == 'ecr-viewer' }}
working-directory: ./containers/${{matrix.container-to-build}}
run: cp -r ../../shared-resources/src/ ./src/app/shared/

- name: Target branch in requirements.txt
working-directory: ./containers/${{matrix.container-to-build}}
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/lighthouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ jobs:
with:
node-version: "18"

- name: Remove symlinks
working-directory: ./containers/ecr-viewer/src/app/shared
run: rm -rf ./*

- name: Copy shared-resources (if needed)
working-directory: ./containers/ecr-viewer
run: cp -r ../../shared-resources/src/ ./src/app/shared/

- name: Change to the correct directory
run: cd containers/ecr-viewer

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 18 # Adjust the Node.js version as needed
- name: Remove symlinks
working-directory: ./containers/ecr-viewer/src/app/shared
run: rm -rf ./*
- name: Copy shared-resources
working-directory: ./containers/ecr-viewer
run: cp -r ../../shared-resources/src/ ./src/app/shared/
- name: Install dependencies
working-directory: ./containers/ecr-viewer # Navigate to your Node.js app directory
run: npm install
Expand Down Expand Up @@ -240,6 +246,12 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 18 # Adjust the Node.js version as needed
- name: Remove symlinks
working-directory: ./containers/ecr-viewer/src/app/shared
run: rm -rf ./*
- name: Copy shared-resources
working-directory: ./containers/ecr-viewer
run: cp -r ../../shared-resources/src/ ./src/app/shared/
- name: Install dependencies
working-directory: ./containers/ecr-viewer # Navigate to your Node.js app directory
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion containers/ecr-viewer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "server.js"]
CMD ["node", "server.js"]
3 changes: 2 additions & 1 deletion containers/ecr-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"private": true,
"scripts": {
"dev": "next dev",
"local-dev": "npm run setup-local-env && docker compose up db -d && docker-compose logs && export DATABASE_URL=postgres://postgres:pw@localhost:5432/ecr_viewer_db && npm run dev",
"local-dev": "npm run check-shared-resources && npm run setup-local-env && docker compose up db -d && docker-compose logs && export DATABASE_URL=postgres://postgres:pw@localhost:5432/ecr_viewer_db && npm run dev",
"check-shared-resources": "if [ ! -d ../../shared-resources/node_modules ]; then (cd ../../shared-resources && npm install) fi",
"setup-local-env": "./setup-env.sh",
"build": "next build",
"start": "next start",
Expand Down
1 change: 1 addition & 0 deletions containers/ecr-viewer/src/app/shared/src
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import EncounterDetails from "./Encounter";
import ClinicalInfo from "./ClinicalInfo";
import { Bundle } from "fhir/r4";
import React, { ReactNode } from "react";
import { Accordion } from "@trussworks/react-uswds";
import LabInfo from "@/app/view-data/components/LabInfo";
import { formatString } from "@/app/services/formatService";
import { evaluateEcrMetadata } from "../../services/ecrMetadataService";
import { evaluateLabInfoData } from "@/app/services/labsService";
import {
Expand All @@ -19,6 +17,7 @@ import {
evaluateProviderData,
} from "@/app/services/evaluateFhirDataService";
import { evaluateClinicalData } from "./common";
import AccordionContainer from "@/app/shared/src/accordion/AccordionContainer";

type AccordionContainerProps = {
children?: ReactNode;
Expand All @@ -33,7 +32,7 @@ type AccordionContainerProps = {
* @param props.fhirPathMappings - The path mappings used to extract information from the FHIR bundle.
* @returns The JSX element representing the accordion container.
*/
const AccordionContainer: React.FC<AccordionContainerProps> = ({
const AccordionContent: React.FC<AccordionContainerProps> = ({
fhirBundle,
fhirPathMappings,
}) => {
Expand Down Expand Up @@ -142,20 +141,6 @@ const AccordionContainer: React.FC<AccordionContainerProps> = ({
},
];

//Add id, adjust title
accordionItems.forEach((item, index) => {
let formattedTitle = formatString(item["title"]);
item["id"] = `${formattedTitle}_${index + 1}`;
item["title"] = <span id={formattedTitle}>{item["title"]}</span>;
accordionItems[index] = item;
});

return (
<Accordion
className="info-container"
items={accordionItems}
multiselectable={true}
/>
);
return <AccordionContainer accordionItems={accordionItems} />;
};
export default AccordionContainer;
export default AccordionContent;
4 changes: 2 additions & 2 deletions containers/ecr-viewer/src/app/view-data/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import AccordionContainer from "@/app/view-data/components/AccordionContainer";
import AccordionContent from "@/app/view-data/components/AccordionContent";
import { useSearchParams } from "next/navigation";
import React, { useEffect, useState } from "react";
import { Bundle } from "fhir/r4";
Expand Down Expand Up @@ -132,7 +132,7 @@ const ECRViewerPage: React.FC = () => {
</Grid>
</Grid>
</GridContainer>
<AccordionContainer
<AccordionContent
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this renaming

fhirPathMappings={mappings}
fhirBundle={fhirBundle}
/>
Expand Down
3 changes: 3 additions & 0 deletions shared-resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./node_modules
.next/
.env.local
35 changes: 35 additions & 0 deletions shared-resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Shared Modules for PHDI Containers

This folder contains shared modules that can be used across PHDI Next.js projects. Follow the instructions below to integrate these shared modules into other containers.

## Step 1: Sym link the folder to your container

From the repo you want to sym link to

Example:
```
ln -s ../../../../../shared-resources/src/ ./src/app/shared/
```

## Step 2: Install local requirements for shared-resources
In the shared resources folder run:
```
npm install
```

## Step 3: Update various build commands
Certain github build commands will need to be updated.

In order for docker to work, the files need to be located in the repo they are being used in. See these examples from build container.

```
- name: Remove symlinks (if needed)
if: ${{ matrix.container-to-build == 'ecr-viewer' }}
working-directory: ./containers/${{matrix.container-to-build}}/src/app/shared
run: rm -rf ./*

- name: Copy shared-resources (if needed)
if: ${{ matrix.container-to-build == 'ecr-viewer' }}
working-directory: ./containers/${{matrix.container-to-build}}
run: cp -r ../../shared-resources/src/ ./src/app/shared/
```
15 changes: 15 additions & 0 deletions shared-resources/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const nextJest = require("next/jest");

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});

// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
testEnvironment: "jest-environment-jsdom",
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig);
6 changes: 6 additions & 0 deletions shared-resources/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "@testing-library/jest-dom";
import { toHaveNoViolations } from "jest-axe";
import * as matchers from "jest-extended";

expect.extend(toHaveNoViolations);
expect.extend(matchers);
Loading
Loading