Skip to content

Commit 4177754

Browse files
authored
Add build revision and copyright to the UI (#35)
* add build revision to appshell * fix README * fix revision on mobile
1 parent 061f12d commit 4177754

File tree

7 files changed

+56
-20
lines changed

7 files changed

+56
-20
lines changed

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ common_params = --no-confirm-changeset \
2424
--s3-prefix $(application_key) \
2525
--resolve-s3
2626

27+
GIT_HASH := $(shell git rev-parse --short HEAD)
28+
2729
.PHONY: build clean
2830

2931
check_account_prod:
@@ -49,11 +51,11 @@ clean:
4951

5052
build: src/ cloudformation/ docs/
5153
yarn -D
52-
yarn build
54+
VITE_BUILD_HASH=$(GIT_HASH) yarn build
5355
sam build --template-file cloudformation/main.yml
5456

5557
local:
56-
yarn run dev
58+
VITE_BUILD_HASH=$(GIT_HASH) yarn run dev
5759

5860
deploy_prod: check_account_prod build
5961
aws sts get-caller-identity --query Account --output text
@@ -62,19 +64,19 @@ deploy_prod: check_account_prod build
6264
deploy_dev: check_account_dev build
6365
sam deploy $(common_params) --parameter-overrides $(run_env)=dev $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)"
6466

65-
install_test_deps:
67+
install:
6668
yarn -D
6769

68-
test_live_integration: install_test_deps
70+
test_live_integration: install
6971
yarn test:live
7072

71-
test_unit: install_test_deps
73+
test_unit: install
7274
yarn typecheck
7375
yarn lint
7476
yarn prettier
7577
yarn test:unit
7678

77-
test_e2e: install_test_deps
79+
test_e2e: install
7880
yarn playwright install
7981
yarn test:e2e
8082

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ This repository is split into multiple parts:
77
## Getting Started
88
You will need node>=20 installed, as well as the AWS CLI and the AWS SAM CLI. The best way to work with all of this is to open the environment in a container within your IDE (VS Code should prompt you to do so: use "Clone in Container" for best performance). This container will have all needed software installed.
99

10-
Then, run `yarn` to install all packages, and `yarn dev` to start the UI and API servers! The UI will be accessible on `http://localhost:5173/` and the API on `http://localhost:8080/`.
10+
Then, run `make install` to install all packages, and `make local` to start the UI and API servers! The UI will be accessible on `http://localhost:5173/` and the API on `http://localhost:8080/`.
1111

1212
**Note: there is currently a known performance issue with running the UI development server in a container. If your requests are timing out, try going to `src/ui` and running `yarn preview` to generate a non development server build.**

src/ui/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default function App() {
1414
key: 'acm-manage-color-scheme',
1515
defaultValue: preferredColorScheme,
1616
});
17-
1817
return (
1918
<ColorSchemeContext.Provider value={{ colorScheme, onChange: setColorScheme }}>
2019
<MantineProvider withGlobalClasses withCssVariables forceColorScheme={colorScheme}>

src/ui/components/AppShell/index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { useNavigate } from 'react-router-dom';
2323
import { useAuth } from '../AuthContext/index.js';
2424
import { HeaderNavbar } from '../Navbar/index.js';
2525
import { AuthenticatedProfileDropdown } from '../ProfileDropdown/index.js';
26+
import { getCurrentRevision } from '@ui/util/revision.js';
2627

2728
interface AcmAppShellProps {
2829
children: ReactNode;
@@ -172,14 +173,24 @@ const AcmAppShell: React.FC<AcmAppShellProps> = ({
172173
<HeaderNavbar />
173174
</AppShell.Header>
174175
<AppShell.Navbar p="sm">
175-
<SidebarNavItems items={navItems} visible={showSidebar} active={active} />
176-
<br />
177-
<Divider label="Other Services" />
178-
<SidebarNavItems items={extLinks} visible={showSidebar} active={active} />
179-
<Group hiddenFrom="sm">
180-
<Divider />
181-
<AuthenticatedProfileDropdown userData={userData || {}} />
182-
</Group>
176+
<AppShell.Section grow>
177+
<SidebarNavItems items={navItems} visible={showSidebar} active={active} />
178+
<br />
179+
<Divider label="Other Services" />
180+
<SidebarNavItems items={extLinks} visible={showSidebar} active={active} />
181+
<Group hiddenFrom="sm">
182+
<Divider />
183+
<AuthenticatedProfileDropdown userData={userData || {}} />
184+
</Group>
185+
</AppShell.Section>
186+
<AppShell.Section>
187+
<Text size="xs" fw={500}>
188+
&copy; {new Date().getFullYear()} ACM @ UIUC
189+
</Text>
190+
<Text size="xs" fw={500}>
191+
Revision <code>{getCurrentRevision()}</code>
192+
</Text>
193+
</AppShell.Section>
183194
</AppShell.Navbar>
184195
<AppShell.Main>
185196
{showLoader ? (

src/ui/components/Navbar/index.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
'use client';
22

3-
import { Group, Divider, Box, Burger, Drawer, ScrollArea, rem } from '@mantine/core';
3+
import {
4+
Group,
5+
Divider,
6+
Box,
7+
Burger,
8+
Drawer,
9+
ScrollArea,
10+
rem,
11+
AppShell,
12+
Text,
13+
} from '@mantine/core';
414
import { useDisclosure } from '@mantine/hooks';
515
import { useNavigate } from 'react-router-dom';
616

717
import { extLinks, navItems, renderNavItems } from '../AppShell/index.js';
8-
import { AuthContextData, useAuth } from '../AuthContext/index.js';
18+
import { useAuth } from '../AuthContext/index.js';
919
import { DarkModeSwitch } from '../DarkModeSwitch/index.js';
1020
import { AuthenticatedProfileDropdown } from '../ProfileDropdown/index.js';
1121

1222
import LogoBadge from './Logo.js';
1323
import classes from './index.module.css';
24+
import { getCurrentRevision } from '@ui/util/revision.js';
1425

1526
const HeaderNavbar: React.FC = () => {
1627
const [drawerOpened, { toggle: toggleDrawer, close: closeDrawer }] = useDisclosure(false);
17-
const { isLoggedIn, userData } = useAuth();
28+
const { userData } = useAuth();
1829
const navigate = useNavigate();
1930
return (
2031
<Box>
@@ -46,6 +57,14 @@ const HeaderNavbar: React.FC = () => {
4657
{renderNavItems(extLinks, '', navigate)}
4758
<Divider my="sm" />
4859
{userData ? <AuthenticatedProfileDropdown userData={userData} /> : null}
60+
<Box px={{ base: 'md' }}>
61+
<Text size="xs" fw={500}>
62+
&copy; {new Date().getFullYear()} ACM @ UIUC
63+
</Text>
64+
<Text size="xs" fw={500}>
65+
Revision <code>{getCurrentRevision()}</code>
66+
</Text>
67+
</Box>
4968
</ScrollArea>
5069
</Drawer>
5170
</Box>

src/ui/util/revision.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function getCurrentRevision() {
2+
return import.meta.env.VITE_BUILD_HASH
3+
? import.meta.env.VITE_BUILD_HASH.substring(0, 7)
4+
: 'unknown';
5+
}

src/ui/vite.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import path from 'path';
66

77

88
export default defineConfig({
9-
define:{'process.env': process.env},
9+
define: {'process.env': {AWS_REGION: process.env.AWS_REGION}},
1010
plugins: [react(), tsconfigPaths()],
1111
resolve: {
1212
preserveSymlinks: true,

0 commit comments

Comments
 (0)