Skip to content

Commit 5297107

Browse files
committed
feat: add SECO_GARAGE_MODE support to hide sidebar
- Add set-seco-garage-mode.sh entrypoint script that patches data-seco-garage-mode in index.html at container startup - Register script in frontend Dockerfile under /docker-entrypoint.d/ - Add data-seco-garage-mode="false" attribute to index.html meta tag - Export isSecoGarageMode constant from api/index.ts - Read isSecoGarageMode in App.tsx to conditionally render the sidebar, topbar, and footer - Expose SECO_GARAGE_MODE env var in docker-compose.yml frontend service Signed-off-by: Jasmina <jasmina.piric@secomind.com>
1 parent e0dbfe2 commit 5297107

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

docker-compose.yml

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-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.
@@ -92,6 +92,7 @@ services:
9292
context: frontend
9393
environment:
9494
BACKEND_URL: http://api.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}/
95+
SECO_GARAGE_MODE: ${SECO_GARAGE_MODE:-false}
9596
restart: on-failure
9697
labels:
9798
- "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 set-seco-garage-mode.sh /docker-entrypoint.d/set-seco-garage-mode.sh

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-seco-garage-mode="false"
2728
/>
2829
<meta charset="utf-8" />
2930
<meta name="viewport" content="width=device-width, initial-scale=1" />

frontend/set-seco-garage-mode.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-seco-garage-mode=\"false\"/data-seco-garage-mode=\"${SECO_GARAGE_MODE:-false}\"/g" \
9+
/usr/share/nginx/html/index.html

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 { isSecoGarageMode } 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 && !isSecoGarageMode && (
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 && !isSecoGarageMode && (
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 && !isSecoGarageMode && (
156157
<Footer
157158
appName={"Edgehog Device Manager"}
158159
appVersion={version}

frontend/src/api/index.ts

Lines changed: 4 additions & 2 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.
@@ -86,6 +86,8 @@ const applicationMetatag: HTMLElement = document.head.querySelector(
8686
const backendUrl =
8787
applicationMetatag.dataset?.backendUrl || "http://localhost:4000";
8888

89+
const isSecoGarageMode = applicationMetatag.dataset?.secoGarageMode === "true";
90+
8991
try {
9092
new URL(backendUrl);
9193
} catch {
@@ -316,4 +318,4 @@ const relayEnvironment = (session: Session) => {
316318
};
317319

318320
export type { FetchGraphQL };
319-
export { fetchGraphQL, relayEnvironment };
321+
export { fetchGraphQL, relayEnvironment, isSecoGarageMode };

0 commit comments

Comments
 (0)