Skip to content

Commit cc69f80

Browse files
authored
Merge pull request DouglasNeuroInformatics#1520 from DouglasNeuroInformatics/feat/playground-version
feat(playground): show the ODC version in the actions menu
2 parents 1b32faa + 792bc88 commit cc69f80

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

apps/playground/src/components/Header/ActionsDropdown/ActionsDropdown.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export const ActionsDropdown = () => {
8181
{t({ en: 'Restore Defaults', fr: 'Restaurer les paramètres par défaut' })}
8282
</button>
8383
</DropdownMenu.Item>
84+
<DropdownMenu.Separator />
85+
<DropdownMenu.Label className="text-muted-foreground text-xs font-normal">
86+
{t({ en: 'ODC Version', fr: 'Version ODC' })} {__APP_VERSION__}
87+
</DropdownMenu.Label>
8488
</DropdownMenu.Content>
8589
</DropdownMenu>
8690
<UserSettingsDialog isOpen={showUserSettingsDialog} setIsOpen={setShowUserSettingsDialog} />

apps/playground/src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
const __APP_VERSION__: string;
12
const __GITHUB_REPO_URL__: string;

apps/playground/vite.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import fs from 'fs';
12
import path from 'path';
23

34
import runtime from '@opendatacapture/vite-plugin-runtime';
45
import tailwindcss from '@tailwindcss/vite';
56
import react from '@vitejs/plugin-react-swc';
67
import { defineConfig } from 'vite';
78

9+
// Read straight from the monorepo root rather than through `@opendatacapture/release-info`: that
10+
// package pulls in `@opendatacapture/schemas`, which ships raw TypeScript, and loading it here would
11+
// mean running this config under tsx as `apps/web` does.
12+
const { version } = JSON.parse(fs.readFileSync(path.resolve(import.meta.dirname, '../../package.json'), 'utf-8')) as {
13+
version: string;
14+
};
15+
816
export default defineConfig(({ mode }) => ({
917
build: {
1018
chunkSizeWarningLimit: 1000,
@@ -16,6 +24,7 @@ export default defineConfig(({ mode }) => ({
1624
target: 'es2022'
1725
},
1826
define: {
27+
__APP_VERSION__: JSON.stringify(version),
1928
__GITHUB_REPO_URL__: `'${process.env.GITHUB_REPO_URL ?? '#'}'`
2029
},
2130
optimizeDeps: {

0 commit comments

Comments
 (0)