Merge branch 'feat/poc' into feat/datacenter

This commit is contained in:
JimmFly
2023-01-12 16:38:54 +08:00
31 changed files with 170 additions and 173 deletions
@@ -7,7 +7,7 @@ import {
StyledCloseButton,
} from './styles';
import CloseIcon from '@mui/icons-material/Close';
import { getWarningMessage, shouldShowWarning } from './utils';
import { useWarningMessage, shouldShowWarning } from './utils';
import EditorOptionMenu from './header-right-items/EditorOptionMenu';
import TrashButtonGroup from './header-right-items/TrashButtonGroup';
import ThemeModeSwitch from './header-right-items/theme-mode-switch';
@@ -22,7 +22,7 @@ const BrowserWarning = ({
}) => {
return (
<StyledBrowserWarning show={show}>
{getWarningMessage()}
{useWarningMessage()}
<StyledCloseButton onClick={onClose}>
<CloseIcon />
</StyledCloseButton>
@@ -25,7 +25,7 @@ export const QuickSearchButton = ({
const { triggerQuickSearchModal } = useModal();
const { t } = useTranslation();
return (
<Tooltip content={t('Switch to')} placement="bottom">
<Tooltip content={t('Jump to')} placement="bottom">
<StyledIconButtonWithAnimate
data-testid="header-quickSearchButton"
{...props}
+8 -7
View File
@@ -1,4 +1,5 @@
import getIsMobile from '@/utils/get-is-mobile';
import { Trans, useTranslation } from '@affine/i18n';
// Inspire by https://stackoverflow.com/a/4900484/8415727
const getChromeVersion = () => {
const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
@@ -19,20 +20,20 @@ export const shouldShowWarning = () => {
);
};
export const getWarningMessage = () => {
export const useWarningMessage = () => {
const { t } = useTranslation();
if (!getIsChrome()) {
return (
<span>
We recommend the <strong>Chrome</strong> browser for optimal experience.
<Trans i18nKey="recommendBrowser">
We recommend the <strong>Chrome</strong> browser for optimal
experience.
</Trans>
</span>
);
}
if (getChromeVersion() < minimumChromeVersion) {
return (
<span>
Please upgrade to the latest version of Chrome for the best experience.
</span>
);
return <span>{t('upgradeBrowser')}</span>;
}
return '';
};