Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x | import { default as Link } from '@/components/TabLink';
import { showReportDialog } from '@/components/ReportDialog';
import { i18n } from '@/helpers/i18n';
import { getAvailableUpdate } from '@/helpers/updates';
import GitHubIcon from '@/icons/GitHubIcon';
import { ThemeContext } from '@/themes';
import ArticleIcon from '@mui/icons-material/Article';
import BrowserUpdatedIcon from '@mui/icons-material/BrowserUpdated';
import BugReportIcon from '@mui/icons-material/BugReport';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import PrivacyTipIcon from '@mui/icons-material/PrivacyTip';
import SignalWifiConnectedNoInternet4Icon from '@mui/icons-material/SignalWifiConnectedNoInternet4';
import WebIcon from '@mui/icons-material/Web';
import Divider from '@mui/material/Divider';
import Modal from '@mui/material/Modal';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import { useContext, useState } from 'react';
import styles from './AboutModal.module.scss';
import {
AboutContributorItem,
AboutModalBox,
AboutModalLink,
AboutModalLinkContainer,
} from './StyledComponents';
import { Logger } from '@/utils/Logger';
import { getErrorMessage } from '@/helpers/exceptions';
const logger = new Logger('AboutModal');
/**
* AboutModal component that displays information about the application.
* Shows the application title, description, and contributor information in a modal dialog.
*
* The contributor list is loaded from `src/data/contributors.json`;
* entries render in the order they appear in that file. Static layout styles
* (positioning, text alignment, contributor font size) live in the sibling
* `AboutModal.module.scss`. Theme-dependent styles (palette, spacing, radius,
* shadow, typography scale) live in the `AboutModalBox` / `AboutContributorItem`
* styled components in `StyledComponents.ts`.
* @component
* @category Components
* @param props - Component props.
* - `aboutOpen` - Whether the modal is open.
* - `setAboutOpen` - Setter to close the modal.
* @example
* ```tsx
* <AboutModal aboutOpen={isOpen} setAboutOpen={setIsOpen} />
* ```
* @source
*/
export default function AboutModal({
aboutOpen,
setAboutOpen,
}: {
aboutOpen: boolean;
setAboutOpen: (open: boolean) => void;
}) {
// Trusted static build-time JSON whose shape matches Contributor.
const entries = __APP_CONTRIBUTORS__;
const themeContext = useContext(ThemeContext);
const [updateIcon, setUpdateIcon] = useState<React.ReactNode>(
<BrowserUpdatedIcon sx={{ fontSize: 16 }} />,
);
const logoSrc =
themeContext?.mode === 'dark'
? '/static/images/logo/ChemPal-logo-inverted.svg'
: '/static/images/logo/ChemPal-logo.svg';
const handleCheckForUpdates = () => {
void (async () => {
try {
const update = await getAvailableUpdate();
setUpdateIcon(
update ? (
<BrowserUpdatedIcon sx={{ fontSize: 16, color: 'warning.main' }} />
) : (
<CheckCircleIcon sx={{ fontSize: 16, color: 'success.main' }} />
),
);
} catch (error) {
logger.error(`Failed to check for updates: ${getErrorMessage(error)}`, { error });
setUpdateIcon(
<SignalWifiConnectedNoInternet4Icon sx={{ fontSize: 16, color: 'error.main' }} />,
);
}
})();
};
return (
<Modal
data-testid="about-modal"
open={aboutOpen}
onClose={() => setAboutOpen(false)}
aria-labelledby="application-title"
aria-describedby="application-description"
>
<AboutModalBox className={styles['about-box']} onClick={(e) => e.stopPropagation()}>
<img src={logoSrc} alt={i18n('about_logo_alt')} className={styles['about-logo']} />
<Typography
id="application-title"
variant="h6"
component="h2"
className={styles['about-title']}
>
{i18n('about_title')}
</Typography>
<Typography
variant="subtitle2"
gutterBottom
sx={{ alignItems: 'center', textAlign: 'center' }}
>
{__APP_VERSION__}{' '}
<Link
href="#"
onClick={handleCheckForUpdates}
sx={{ marginLeft: 1, verticalAlign: 'top' }}
>
{updateIcon}
</Link>
</Typography>
<AboutModalLinkContainer>
<AboutModalLink
data-testid="github-button"
href={__APP_REPOSITORY__}
target="_blank"
title={i18n('about_repository_link_title')}
rel="noopener noreferrer"
>
<GitHubIcon />
</AboutModalLink>
<AboutModalLink
data-testid="homepage-button"
href={__APP_HOMEPAGE__}
target="_blank"
title={i18n('about_homepage_link_title')}
rel="noopener noreferrer"
>
<WebIcon />
</AboutModalLink>
<AboutModalLink
data-testid="wiki-button"
href={__APP_WIKI__}
target="_blank"
title={i18n('about_wiki_link_title')}
rel="noopener noreferrer"
>
<ArticleIcon />
</AboutModalLink>
<AboutModalLink
data-testid="privacy-button"
href={__APP_PRIVACY__}
target="_blank"
title={i18n('about_privacy_link_title')}
rel="noopener noreferrer"
>
<PrivacyTipIcon />
</AboutModalLink>
<AboutModalLink
data-testid="bugs-button"
href={__APP_BUGS__}
target="_blank"
title={i18n('about_bugs_link_title')}
rel="noopener noreferrer"
onClick={(e: React.MouseEvent) => {
// Open the prefilled report dialog instead of the bare issues page.
e.preventDefault();
void showReportDialog();
}}
>
<BugReportIcon />
</AboutModalLink>
</AboutModalLinkContainer>
<Typography
id="application-description"
variant="subtitle2"
gutterBottom
sx={{ mt: 0.5, display: 'block' }}
>
{i18n('about_description')}
</Typography>
<Divider sx={{ color: 'primary.main', my: 2 }}>
<Typography variant="overline" gutterBottom sx={{ display: 'block' }}>
{i18n('about_contributors')}
</Typography>
</Divider>
<Stack
direction="row"
useFlexGap
className={styles['about-contributor-stack']}
sx={{ gap: 2 }}
>
{entries.map((entry) => (
<AboutContributorItem key={entry.name}>
<Link data-testid={entry.name} href={entry.url}>
<Typography
sx={{ color: 'text.secondary' }}
className={styles['about-contributor-link']}
>
{entry.name}
</Typography>
</Link>
</AboutContributorItem>
))}
</Stack>
</AboutModalBox>
</Modal>
);
}
|