feat: improved about screen info

more info and copy to clipboard
pull/3083/head
William Grant 11 months ago
parent f68fc684fe
commit fe64b26012

@ -3,6 +3,7 @@
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require('electron');
const url = require('url'); const url = require('url');
const os = require('os');
const i18n = require('./ts/util/i18n'); const i18n = require('./ts/util/i18n');
const config = url.parse(window.location.toString(), true).query; const config = url.parse(window.location.toString(), true).query;
@ -12,6 +13,8 @@ const localeMessages = ipcRenderer.sendSync('locale-data');
window.theme = config.theme; window.theme = config.theme;
window.i18n = i18n.setupi18n(locale, localeMessages); window.i18n = i18n.setupi18n(locale, localeMessages);
window.getOSRelease = () =>
`${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`;
window.getEnvironment = () => config.environment; window.getEnvironment = () => config.environment;
window.getVersion = () => config.version; window.getVersion = () => config.version;
window.getCommitHash = () => config.commitHash; window.getCommitHash = () => config.commitHash;
@ -25,6 +28,4 @@ window.Signal = {
}, },
}; };
window.closeAbout = () => ipcRenderer.send('close-about');
require('./ts/util/logging'); require('./ts/util/logging');

@ -26,7 +26,8 @@ window.getEnvironment = () => config.environment;
require('./ts/util/logging'); require('./ts/util/logging');
window.getOSRelease = () => `${os.type()} ${os.release} ${os.platform()}`; window.getOSRelease = () =>
`${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`;
window.getCommitHash = () => config.commitHash; window.getCommitHash = () => config.commitHash;
window.closeDebugLog = () => ipcRenderer.send('close-debug-log'); window.closeDebugLog = () => ipcRenderer.send('close-debug-log');

@ -2,24 +2,35 @@ import { useEffect } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { SessionTheme } from '../themes/SessionTheme'; import { SessionTheme } from '../themes/SessionTheme';
import { switchThemeTo } from '../themes/switchTheme'; import { switchThemeTo } from '../themes/switchTheme';
import { SessionToastContainer } from './SessionToastContainer';
import { Flex } from './basic/Flex';
import { SessionButtonType } from './basic/SessionButton';
import { CopyToClipboardButton } from './buttons/CopyToClipboardButton';
const StyledContent = styled.div` const StyledContent = styled(Flex)`
background-color: var(--background-primary-color); background-color: var(--background-primary-color);
color: var(--text-primary-color); color: var(--text-primary-color);
text-align: center; text-align: center;
font-family: var(--font-default); font-family: var(--font-default);
font-size: 14px; font-size: var(--font-size-sm);
height: 100%; height: 100%;
width: 100%; width: 100%;
a {
color: var(--text-primary-color);
}
img { img {
padding: 12px; margin: var(--margins-lg) 0 var(--margins-md);
margin-top: 1rem;
} }
a { .session-button {
color: var(--text-primary-color); font-size: var(--font-size-sm);
font-weight: 400;
min-height: var(--font-size-sm);
height: font-size: var(--font-size-sm);
margin-bottom: var(--margins-xs;
} }
`; `;
@ -34,35 +45,63 @@ export const AboutView = () => {
states.push(window.getAppInstance()); states.push(window.getAppInstance());
} }
const versionInfo = `v${window.getVersion()}`;
const commitInfo = `Commit ${window.getCommitHash()}` || '';
const osInfo = `${window.getOSRelease()}`;
useEffect(() => { useEffect(() => {
if (window.theme) { if (window.theme) {
void switchThemeTo({ void switchThemeTo({
theme: window.theme, theme: window.theme,
usePrimaryColor: true,
}); });
} }
}, []); }, []);
return ( return (
<SessionTheme> <SessionTheme>
<StyledContent> <SessionToastContainer />
<StyledContent
container={true}
flexDirection={'column'}
justifyContent={'center'}
alignItems={'center'}
>
<img src="images/session/session_icon.png" width="250" height="250" alt="session icon" /> <img src="images/session/session_icon.png" width="250" height="250" alt="session icon" />
<div className="version">{`v${window.getVersion()}`}</div> <CopyToClipboardButton
<div className="commitHash">{window.getCommitHash() || ''}</div> className="version"
<div className="environment">{states.join(' - ')}</div> text={versionInfo}
<div> copyContent={versionInfo}
<a href="https://getsession.org">getsession.org</a> buttonType={SessionButtonType.Simple}
</div> />
<CopyToClipboardButton
className="commitHash"
text={commitInfo}
copyContent={commitInfo}
buttonType={SessionButtonType.Simple}
/>
<CopyToClipboardButton
className="os"
text={osInfo}
copyContent={osInfo}
buttonType={SessionButtonType.Simple}
/>
<CopyToClipboardButton
className="environment"
text={states.join(' - ')}
copyContent={states.join(' - ')}
buttonType={SessionButtonType.Simple}
/>
<a href="https://getsession.org">https://getsession.org</a>
<br />
<a className="privacy" href="https://getsession.org/privacy-policy">
{window.i18n('privacyPolicy')}
</a>
<a className="privacy" href="https://getsession.org/terms-of-service/">
{window.i18n('termsOfService')}
</a>
<br /> <br />
<div>
<a className="privacy" href="https://getsession.org/privacy-policy">
Privacy Policy
</a>
<br />
<a className="privacy" href="https://getsession.org/terms-of-service/">
Terms of Service
</a>
</div>
</StyledContent> </StyledContent>
</SessionTheme> </SessionTheme>
); );

@ -73,9 +73,9 @@ const DebugLogViewAndSave = () => {
const [content, setContent] = useState(window.i18n('loading')); const [content, setContent] = useState(window.i18n('loading'));
useEffect(() => { useEffect(() => {
const operatingSystemInfo = `Operating System: ${(window as any).getOSRelease()}`; const operatingSystemInfo = `Operating System ${window.getOSRelease()}`;
const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : ''; const commitHashInfo = window.getCommitHash() ? `Commit ${window.getCommitHash()}` : '';
// eslint-disable-next-line more/no-then // eslint-disable-next-line more/no-then
fetchNodeLog() fetchNodeLog()
@ -100,6 +100,7 @@ export const DebugLogView = () => {
if (window.theme) { if (window.theme) {
void switchThemeTo({ void switchThemeTo({
theme: window.theme, theme: window.theme,
usePrimaryColor: true,
}); });
} }
}, []); }, []);

@ -122,6 +122,7 @@ export type SessionButtonProps = {
children?: ReactNode; children?: ReactNode;
margin?: string; margin?: string;
reference?: any; reference?: any;
className?: string;
dataTestId?: string; dataTestId?: string;
}; };
@ -132,6 +133,7 @@ export const SessionButton = (props: SessionButtonProps) => {
? SessionButtonShape.None ? SessionButtonShape.None
: SessionButtonShape.Round, : SessionButtonShape.Round,
reference, reference,
className,
dataTestId, dataTestId,
buttonColor, buttonColor,
text, text,
@ -158,7 +160,8 @@ export const SessionButton = (props: SessionButtonProps) => {
buttonShape, buttonShape,
buttonType, buttonType,
buttonColor ?? '', buttonColor ?? '',
disabled && 'disabled' disabled && 'disabled',
className
)} )}
role="button" role="button"
onClick={onClickFn} onClick={onClickFn}

@ -1,15 +1,17 @@
import { isEmpty } from 'lodash';
import { useState } from 'react'; import { useState } from 'react';
import { useCopyToClipboard } from 'react-use'; import { useCopyToClipboard } from 'react-use';
import { ToastUtils } from '../../session/utils'; import { ToastUtils } from '../../session/utils';
import { SessionButton, SessionButtonProps } from '../basic/SessionButton'; import { SessionButton, SessionButtonProps } from '../basic/SessionButton';
type Props = Omit<SessionButtonProps, 'children' | 'text' | 'onClick'> & { type Props = Omit<SessionButtonProps, 'children' | 'onClick'> & {
copyContent: string; copyContent: string;
onCopyComplete?: (copiedValue: string | undefined) => void; onCopyComplete?: (copiedValue: string | undefined) => void;
className?: string;
}; };
export const CopyToClipboardButton = (props: Props) => { export const CopyToClipboardButton = (props: Props) => {
const { copyContent, onCopyComplete } = props; const { className, copyContent, onCopyComplete, text } = props;
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const [{ value }, copyToClipboard] = useCopyToClipboard(); const [{ value }, copyToClipboard] = useCopyToClipboard();
@ -17,7 +19,14 @@ export const CopyToClipboardButton = (props: Props) => {
return ( return (
<SessionButton <SessionButton
{...props} {...props}
text={copied ? window.i18n('copiedToClipboard') : window.i18n('editMenuCopy')} className={className}
text={
!isEmpty(text)
? text
: copied
? window.i18n('copiedToClipboard')
: window.i18n('editMenuCopy')
}
onClick={() => { onClick={() => {
copyToClipboard(copyContent); copyToClipboard(copyContent);
ToastUtils.pushCopiedToClipBoard(); ToastUtils.pushCopiedToClipBoard();

@ -612,7 +612,7 @@ async function showAbout() {
const options = { const options = {
width: 500, width: 500,
height: 500, height: 500,
resizable: true, resizable: false,
title: locale.messages.about, title: locale.messages.about,
autoHideMenuBar: true, autoHideMenuBar: true,
backgroundColor: classicDark['--background-primary-color'], backgroundColor: classicDark['--background-primary-color'],

1
ts/window.d.ts vendored

@ -78,6 +78,7 @@ declare global {
getAppInstance: () => string; getAppInstance: () => string;
getCommitHash: () => string | undefined; getCommitHash: () => string | undefined;
getVersion: () => string; getVersion: () => string;
getOSRelease: () => string;
setAutoHideMenuBar: (val: boolean) => void; setAutoHideMenuBar: (val: boolean) => void;
setMenuBarVisibility: (val: boolean) => void; setMenuBarVisibility: (val: boolean) => void;
contextMenuShown: boolean; contextMenuShown: boolean;

Loading…
Cancel
Save