Skip to content

Commit 77c7ad1

Browse files
committed
feat: Add option to hide navigation elements
- Add hide-navigation-elements.sh entrypoint script that patches data-hide-navigation-elements in index.html at container startup - Register script in frontend Dockerfile under /docker-entrypoint.d/ - Add data-hide-navigation-elements="false" attribute to index.html meta tag - Export hideNavigationElements constant from api/index.ts - Read hideNavigationElements in App.tsx to conditionally render the sidebar, topbar, and footer - Expose HIDE_NAVIGATION_ELEMENTS env var in docker-compose.yml Signed-off-by: Jasmina <jasmina.piric@secomind.com>
1 parent 9bff1b3 commit 77c7ad1

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ services:
9090
context: frontend
9191
environment:
9292
BACKEND_URL: http://api.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}/
93+
HIDE_NAVIGATION_ELEMENTS: ${HIDE_NAVIGATION_ELEMENTS:-false}
9394
restart: on-failure
9495
labels:
9596
- "traefik.enable=true"

frontend/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2021-2025 SECO Mind Srl
1+
# SPDX-FileCopyrightText: 2021-2026 SECO Mind Srl
22
# SPDX-License-Identifier: Apache-2.0
33
FROM node:24.11.0 AS builder
44

@@ -13,3 +13,4 @@ FROM nginx:1
1313
COPY --from=builder /app/build/ /usr/share/nginx/html/
1414
ADD nginx.conf /etc/nginx/conf.d/default.conf
1515
ADD set-backend-url.sh /docker-entrypoint.d/set-backend-url.sh
16+
ADD hide-navigation-elements.sh /docker-entrypoint.d/hide-navigation-elements.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# SPDX-FileCopyrightText: 2026 SECO Mind Srl
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# This will replace the default value in index.html
6+
# ${SECO_GARAGE_MODE:-false} uses the environment variable if set, otherwise defaults to false
7+
8+
sed -i "s/data-hide-navigation-elements=\"false\"/data-hide-navigation-elements=\"${HIDE_NAVIGATION_ELEMENTS:-false}\"/g" \
9+
/usr/share/nginx/html/index.html

frontend/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This file is part of Edgehog.
33
4-
Copyright 2021-2024 SECO Mind Srl
4+
Copyright 2021-2026 SECO Mind Srl
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
2424
name="application-name"
2525
content="Edgehog"
2626
data-backend-url="http://localhost:4000/"
27+
data-hide-navigation-elements="false"
2728
/>
2829
<meta charset="utf-8" />
2930
<meta name="viewport" content="width=device-width, initial-scale=1" />

frontend/src/App.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of Edgehog.
33
*
4-
* Copyright 2021-2025 SECO Mind Srl
4+
* Copyright 2021-2026 SECO Mind Srl
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -70,6 +70,7 @@ import DeploymentCampaign from "@/pages/DeploymentCampaign";
7070
import DeploymentCampaignCreate from "@/pages/DeploymentCampaignCreate";
7171
import Deployment from "@/pages/Deployment";
7272

73+
import { hideNavigationElements } from "@/api";
7374
import { bugs, repository, version } from "../package.json";
7475

7576
type RouterRule = {
@@ -139,20 +140,20 @@ function App() {
139140

140141
return (
141142
<div data-testid="app" className="d-flex vh-100 flex-column">
142-
{auth.isAuthenticated && (
143+
{auth.isAuthenticated && !hideNavigationElements && (
143144
<header className="flex-grow-0">
144145
<Topbar />
145146
</header>
146147
)}
147148
<main className="vh-100 flex-grow-1 d-flex overflow-hidden">
148-
{auth.isAuthenticated && (
149+
{auth.isAuthenticated && !hideNavigationElements && (
149150
<aside className="flex-grow-0 flex-shrink-0 overflow-auto">
150151
<Sidebar />
151152
</aside>
152153
)}
153154
<section className="flex-grow-1 overflow-auto">{RouterElement}</section>
154155
</main>
155-
{auth.isAuthenticated && (
156+
{auth.isAuthenticated && !hideNavigationElements && (
156157
<Footer
157158
appName={"Edgehog Device Manager"}
158159
appVersion={version}

frontend/src/api/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of Edgehog.
33
*
4-
* Copyright 2021-2025 SECO Mind Srl
4+
* Copyright 2021-2026 SECO Mind Srl
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -80,11 +80,14 @@ type PhoenixMessage = [
8080
PhoenixPayload,
8181
];
8282

83-
const applicationMetatag: HTMLElement = document.head.querySelector(
83+
const applicationMetatag: HTMLElement | null = document.head.querySelector(
8484
"[name=application-name]",
85-
)!;
85+
);
8686
const backendUrl =
87-
applicationMetatag.dataset?.backendUrl || "http://localhost:4000";
87+
applicationMetatag?.dataset?.backendUrl || "http://localhost:4000";
88+
89+
const hideNavigationElements =
90+
applicationMetatag?.dataset?.hideNavigationElements === "true";
8891

8992
try {
9093
new URL(backendUrl);
@@ -316,4 +319,4 @@ const relayEnvironment = (session: Session) => {
316319
};
317320

318321
export type { FetchGraphQL };
319-
export { fetchGraphQL, relayEnvironment };
322+
export { fetchGraphQL, relayEnvironment, hideNavigationElements };

0 commit comments

Comments
 (0)