Skip to content

Commit c04b025

Browse files
committed
Add discreet build version indicator to top bar
- Added BuildVersion component with timestamp, version, and commit info - Displays in top-right corner with subtle styling - Shows 'dev • timestamp' in development mode - Shows 'v1.0.0 • commit • timestamp' in production - Updated Dockerfile to inject build args (version, timestamp, commit SHA) - Updated GitHub Actions to pass build metadata to Docker - Helps identify when new deployments are live
1 parent 4da292f commit c04b025

File tree

7 files changed

+90
-40
lines changed

7 files changed

+90
-40
lines changed

.github/workflows/deploy-azure-publishprofile.yml

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

.github/workflows/docker-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ jobs:
5858
push: true
5959
tags: ${{ steps.meta.outputs.tags }}
6060
labels: ${{ steps.meta.outputs.labels }}
61+
build-args: |
62+
REACT_APP_VERSION=1.0.0
63+
REACT_APP_BUILD_TIME=${{ github.event.head_commit.timestamp }}
64+
REACT_APP_COMMIT_SHA=${{ github.sha }}
6165
cache-from: type=gha
6266
cache-to: type=gha,mode=max
6367
platforms: linux/amd64,linux/arm64

editor/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
FROM node:18-alpine AS build
33
WORKDIR /app
44

5+
# Build arguments for version info
6+
ARG REACT_APP_VERSION=1.0.0
7+
ARG REACT_APP_BUILD_TIME
8+
ARG REACT_APP_COMMIT_SHA
9+
10+
# Set environment variables for the build
11+
ENV REACT_APP_VERSION=$REACT_APP_VERSION
12+
ENV REACT_APP_BUILD_TIME=$REACT_APP_BUILD_TIME
13+
ENV REACT_APP_COMMIT_SHA=$REACT_APP_COMMIT_SHA
14+
515
# Copy package files first for better Docker layer caching
616
COPY package.json package-lock.json ./
717

@@ -12,7 +22,7 @@ RUN npm pkg delete devDependencies.@rollup/rollup-win32-x64-msvc && \
1222
# Copy source code
1323
COPY . .
1424

15-
# Build the application
25+
# Build the application with version info
1626
RUN npm run build
1727

1828
# Production stage
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { getBuildInfo, formatBuildInfo } from '../utils/buildInfo';
3+
4+
export const BuildVersion: React.FC = () => {
5+
const buildInfo = getBuildInfo();
6+
const buildText = formatBuildInfo(buildInfo);
7+
8+
return (
9+
<div
10+
className="build-version"
11+
title={`Build: ${buildText}`}
12+
>
13+
{buildText}
14+
</div>
15+
);
16+
};

editor/src/components/TopBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22
import { FacilitySelectorPortal } from './FacilitySelectorPortal';
3+
import { BuildVersion } from './BuildVersion';
34

45
interface Facility {
56
id: string;
@@ -48,7 +49,7 @@ export const TopBar: React.FC<TopBarProps> = ({
4849
</div>
4950
</div>
5051
<div className="top-bar-right">
51-
{/* Additional controls can go here */}
52+
<BuildVersion />
5253
</div>
5354
</div>
5455
</div>

editor/src/treeview.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,3 +1007,23 @@ pre::-webkit-scrollbar-thumb:hover { background:#c2ccd5; }
10071007
font-size: 14px;
10081008
}
10091009

1010+
/* Build Version Indicator */
1011+
.build-version {
1012+
font-size: 11px;
1013+
color: #999;
1014+
font-family: 'Courier New', Consolas, monospace;
1015+
-webkit-user-select: none;
1016+
user-select: none;
1017+
cursor: default;
1018+
opacity: 0.8;
1019+
padding: 3px 8px;
1020+
border-radius: 3px;
1021+
background-color: rgba(255, 255, 255, 0.1);
1022+
border: 1px solid rgba(255, 255, 255, 0.2);
1023+
transition: opacity 0.2s ease;
1024+
}
1025+
1026+
.build-version:hover {
1027+
opacity: 1;
1028+
}
1029+

editor/src/utils/buildInfo.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Build information utility
2+
export interface BuildInfo {
3+
version: string;
4+
timestamp: string;
5+
commit?: string;
6+
}
7+
8+
export const getBuildInfo = (): BuildInfo => {
9+
// In development, use current timestamp
10+
if (import.meta.env.DEV) {
11+
return {
12+
version: 'dev',
13+
timestamp: new Date().toISOString().slice(0, 16).replace('T', ' '),
14+
};
15+
}
16+
17+
// In production, these will be replaced by build process
18+
return {
19+
version: process.env.REACT_APP_VERSION || 'unknown',
20+
timestamp: process.env.REACT_APP_BUILD_TIME || new Date().toISOString().slice(0, 16).replace('T', ' '),
21+
commit: process.env.REACT_APP_COMMIT_SHA?.slice(0, 7) || undefined,
22+
};
23+
};
24+
25+
export const formatBuildInfo = (buildInfo: BuildInfo): string => {
26+
const { version, timestamp, commit } = buildInfo;
27+
28+
if (version === 'dev') {
29+
return `dev • ${timestamp}`;
30+
}
31+
32+
if (commit) {
33+
return `v${version}${commit}${timestamp}`;
34+
}
35+
36+
return `v${version}${timestamp}`;
37+
};

0 commit comments

Comments
 (0)