chore(trading): add git hash and tag into settings view (#5207)

This commit is contained in:
Matthew Russell 2023-11-13 21:17:17 -08:00 committed by GitHub
parent 374890dc08
commit 132f2e4b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import { Switch, ToastPositionSetter } from '@vegaprotocol/ui-toolkit';
import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
import { useTelemetryApproval } from '../../lib/hooks/use-telemetry-approval'; import { useTelemetryApproval } from '../../lib/hooks/use-telemetry-approval';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import classNames from 'classnames';
export const Settings = () => { export const Settings = () => {
const { theme, setTheme } = useThemeSwitcher(); const { theme, setTheme } = useThemeSwitcher();
@ -31,6 +32,18 @@ export const Settings = () => {
<SettingsGroup label={t('Toast location')}> <SettingsGroup label={t('Toast location')}>
<ToastPositionSetter /> <ToastPositionSetter />
</SettingsGroup> </SettingsGroup>
<SettingsGroup inline={false} label={t('App information')}>
<dl className="text-sm grid grid-cols-2 gap-1">
{process.env.GIT_TAG && (
<>
<dt className="text-muted">{t('Version')}</dt>
<dd>{process.env.GIT_TAG}</dd>
</>
)}
<dt className="text-muted">{t('Git commit hash')}</dt>
<dd className="break-words">{process.env.GIT_COMMIT}</dd>
</dl>
</SettingsGroup>
</div> </div>
); );
}; };
@ -39,16 +52,22 @@ const SettingsGroup = ({
label, label,
helpText, helpText,
children, children,
inline = true,
}: { }: {
label: string; label: string;
helpText?: string;
children: ReactNode; children: ReactNode;
helpText?: string;
inline?: boolean;
}) => { }) => {
return ( return (
<div className="flex justify-between items-start mb-4"> <div
<div className="w-3/4"> className={classNames('mb-4 gap-2', {
'flex items-start justify-between gap-2': inline,
})}
>
<div className={classNames({ 'w-3/4': inline, 'mb-2': !inline })}>
<label className="text-sm">{label}</label> <label className="text-sm">{label}</label>
{helpText && <p className="text-muted text-xs">{helpText}</p>} {helpText && <p className="text-xs text-muted">{helpText}</p>}
</div> </div>
{children} {children}
</div> </div>

View File

@ -1,3 +1,4 @@
const childProcess = require('child_process');
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const withNx = require('@nx/next/plugins/with-nx'); const withNx = require('@nx/next/plugins/with-nx');
const { withSentryConfig } = require('@sentry/nextjs'); const { withSentryConfig } = require('@sentry/nextjs');
@ -10,6 +11,20 @@ const sentryWebpackOptions = {
token: SENTRY_AUTH_TOKEN, token: SENTRY_AUTH_TOKEN,
}; };
const commitHash = childProcess
.execSync('git rev-parse HEAD')
.toString()
.trim();
// Get the tag of the last commit
const commitLog = childProcess
.execSync('git log --decorate --oneline -1')
.toString()
.trim();
const tagMatch = commitLog.match(/tag: ([^,)]+)/);
const tag = tagMatch ? tagMatch[1] : '';
/** /**
* @type {import('@nx/next/plugins/with-nx').WithNxOptions} * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
**/ **/
@ -20,6 +35,10 @@ const nextConfig = {
svgr: false, svgr: false,
}, },
pageExtensions: ['page.tsx', 'page.jsx'], pageExtensions: ['page.tsx', 'page.jsx'],
env: {
GIT_COMMIT: commitHash,
GIT_TAG: tag,
},
}; };
module.exports = SENTRY_AUTH_TOKEN module.exports = SENTRY_AUTH_TOKEN