Skip to content

Commit 0d883a1

Browse files
authored
Merge pull request #30 from TeamCodeStream/feature/react-error
NR-381373
2 parents 89bc57b + 53d1114 commit 0d883a1

File tree

5 files changed

+52
-22
lines changed

5 files changed

+52
-22
lines changed

.github/workflows/publish_image.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
FOSSA_API_KEY=${{ secrets.FOSSA_API_KEY }}
5151
NEW_RELIC_METADATA_COMMIT=${{ github.sha }}
5252
NEW_RELIC_METADATA_RELEASE_TAG=${{ github.ref_name }}
53+
NEW_RELIC_API_KEY=${{ secrets.NEW_RELIC_API_KEY }}
5354
5455
- name: Generate artifact attestation
5556
uses: actions/attest-build-provenance@v1

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ ARG BROWSER_TRUST_KEY
3030
ARG BROWSER_AGENT_ID
3131
ARG BROWSER_APPLICATION_ID
3232
ARG FOSSA_API_KEY
33+
ARG NEW_RELIC_API_KEY
3334

3435
ENV BROWSER_LICENSE_KEY=$BROWSER_LICENSE_KEY
3536
ENV BROWSER_ACCOUNT_ID=$BROWSER_ACCOUNT_ID
3637
ENV BROWSER_TRUST_KEY=$BROWSER_TRUST_KEY
3738
ENV BROWSER_AGENT_ID=$BROWSER_AGENT_ID
3839
ENV BROWSER_APPLICATION_ID=$BROWSER_APPLICATION_ID
3940
ENV FOSSA_API_KEY=$FOSSA_API_KEY
41+
ENV NEW_RELIC_API_KEY=$NEW_RELIC_API_KEY
4042

4143
RUN --mount=type=cache,target=/root/.gradle ./gradlew downloadNewRelicAgent --console=plain --info --no-daemon --no-watch-fs
4244
RUN --mount=type=cache,target=/root/.gradle ./gradlew build --console=plain --info --no-daemon --no-watch-fs
@@ -52,6 +54,16 @@ RUN if [ -z "$FOSSA_API_KEY" ] ; then \
5254
fossa analyze; \
5355
fi
5456

57+
RUN if [ -z "$NEW_RELIC_API_KEY" ] ; then \
58+
echo --SKIPPING SOURCE MAP UPLOAD ; \
59+
else \
60+
filename=$(ls /src/client/dist/assets/*.js | grep -v '.map.js' | xargs -n 1 basename) && \
61+
curl -H "Api-Key: $NEW_RELIC_API_KEY" \
62+
-F "sourcemap=/src/client/dist/assets/$filename.map" \
63+
-F "javascriptUrl=https://petclinic-demogorgon.staging-service.nr-ops.net/react/assets/$filename" \
64+
https://sourcemaps.service.newrelic.com/v2/applications/$BROWSER_APPLICATION_ID/sourcemaps ;\
65+
fi
66+
5567
FROM base AS final
5668
WORKDIR /app
5769
COPY --from=build /src/build/libs/petclinic-backend-1.0.0.jar .

client/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ToastContainer } from 'react-toastify';
33
import 'react-toastify/dist/ReactToastify.css';
44
import { OwnerDetails } from 'src/pages/OwnerDetails';
55
import { NavigationBar } from './navbar/NavigationBar';
6-
import { Error } from './pages/Error';
6+
import { ErrorPage } from './pages/ErrorPage.tsx';
77
import { FindOwner } from './pages/FindOwner';
88
import { Home } from './pages/Home';
99
import { OwnerForm } from './pages/OwnerForm';
@@ -30,7 +30,7 @@ function App() {
3030
/>
3131
<Routes>
3232
<Route index={true} path="/" element={<Home />} />
33-
<Route path="/oups" element={<Error />} />
33+
<Route path="/oups" element={<ErrorPage />} />
3434
<Route path="/home" element={<Home />} />
3535
<Route path="/vets" element={<Veterinarians />} />
3636
<Route path="owners">

client/src/pages/Error.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

client/src/pages/ErrorPage.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pets from '/src/assets/images/pets.png';
2+
3+
const mapping = new Map<number, string>([
4+
[1,"Dogs"],
5+
[2,"Cats"],
6+
[3,"Horses"],
7+
[4,"Iguanas"],
8+
[5,"Goblin Sharks"]
9+
])
10+
11+
export const ErrorPage = () => {
12+
const renderListItem = (index: number) => {
13+
const item = mapping.get(index);
14+
15+
if(!item){
16+
throw new Error(`No mapping found for index: ${index}`);
17+
}
18+
19+
return (
20+
<li>{item}</li>
21+
)
22+
}
23+
24+
return (
25+
<>
26+
<div className="row">
27+
<div className="col-md-12">
28+
<img className="img-responsive" src={pets} />
29+
</div>
30+
</div>
31+
<h3>We currently work with the following animal species:</h3>
32+
<ol>
33+
{[1,2,3,4,5,6].map(i => renderListItem(i))}
34+
</ol>
35+
</>
36+
);
37+
};

0 commit comments

Comments
 (0)