Skip to content

Commit

Permalink
✨(version) convey version information to the /config endpoint and footer
Browse files Browse the repository at this point in the history
We add the machinery to get version information and display it discreetly.
  • Loading branch information
Laurent Bossavit authored and Laurent Bossavit committed Nov 17, 2024
1 parent 7e4a820 commit 64499a8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/core/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def get(self, request):
GET /api/v1.0/config/
Return a dictionary of public settings.
"""
array_settings = ["LANGUAGES", "FEATURES", "RELEASE"]
array_settings = ["LANGUAGES", "FEATURES", "RELEASE", "COMMIT"]
dict_settings = {}
for setting in array_settings:
dict_settings[setting] = getattr(settings, setting)
Expand Down
18 changes: 18 additions & 0 deletions src/backend/people/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ def get_release():
except FileNotFoundError:
return "NA" # Default: not available

def get_commit():
"""
Get the current commit of the application
"""
try:
with open(os.path.join(BASE_DIR, "version.json"), encoding="utf8") as version:
return json.load(version)["commit"]
except FileNotFoundError:
return "NA" # Default: not available


class Base(Configuration):
"""
Expand Down Expand Up @@ -488,6 +498,14 @@ def RELEASE(self):
"""
return get_release()

# pylint: disable=invalid-name
@property
def COMMIT(self):
"""
Return the commit information.
"""
return get_release()

# pylint: disable=invalid-name
@property
def PARLER_LANGUAGES(self):
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/desk/src/core/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface Config {
LANGUAGES: [string, string][];
RELEASE: string;
COMMIT: string;
FEATURES: {
TEAMS_DISPLAY: boolean;
};
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/apps/desk/src/features/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useConfigStore } from '@/core';

import IconLink from './assets/external-link.svg';

import frontVersion from '../../../version.json';

const BlueStripe = styled.div`
position: absolute;
height: 2px;
Expand Down Expand Up @@ -141,6 +143,17 @@ export const Footer = () => {
))}
</Box>

<Text
as="p"
$size="m"
$margin={{ top: 'big' }}
$variation="600"
$display="hidden"
>
You've found the hidden app version information ! Well done ! back
commit is: {config?.COMMIT}; front commit is: {frontVersion?.commit}
</Text>

<Text
as="p"
$size="m"
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/apps/desk/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source":"people",
"version":"version",
"commit":"commit",
"build": "NA"
}

0 comments on commit 64499a8

Please sign in to comment.