fix: add tip for database page (#7090)

This commit is contained in:
Kilu.He 2024-12-30 15:46:39 +08:00 committed by GitHub
parent d9b3f3f6c6
commit 256d015967
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 77 additions and 29 deletions

View File

@ -31,7 +31,10 @@ const InfoSnackbar = forwardRef<HTMLDivElement, InfoSnackbarProps>(
};
return (
<SnackbarContent ref={ref} className={'flex items-center justify-center'}>
<SnackbarContent
ref={ref}
className={'flex items-center justify-center'}
>
<Paper className={`relative flex flex-col gap-4 border p-5 ${getBorderColor(type)}`}>
<div className={'flex w-full items-center justify-between text-base font-medium'}>
<div className={'flex flex-1 items-center gap-2 text-left font-semibold'}>
@ -39,13 +42,18 @@ const InfoSnackbar = forwardRef<HTMLDivElement, InfoSnackbarProps>(
<div>{title}</div>
</div>
<div className={'relative -right-1.5'}>
<IconButton size={'small'} color={'inherit'} className={'h-6 w-6'} onClick={handleClose}>
<IconButton
size={'small'}
color={'inherit'}
className={'h-6 w-6'}
onClick={handleClose}
>
<CloseIcon className={'h-4 w-4'} />
</IconButton>
</div>
</div>
<div className={'mx-8 flex-1'}>{message}</div>
<div className={'flex-1'}>{message}</div>
{showActions && (
<div className={'flex w-full justify-end gap-4'}>
<Button
@ -64,7 +72,7 @@ const InfoSnackbar = forwardRef<HTMLDivElement, InfoSnackbarProps>(
</Paper>
</SnackbarContent>
);
}
},
);
export default InfoSnackbar;

View File

@ -9,7 +9,6 @@ import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useSt
import { useTranslation } from 'react-i18next';
import { ReactEditor, useReadOnly, useSlateStatic } from 'slate-react';
import { Element } from 'slate';
import { ReactComponent as TipIcon } from '@/assets/warning.svg';
export const DatabaseBlock = memo(
forwardRef<HTMLDivElement, EditorElementProps<DatabaseNode>>(({ node, children, ...attributes }, ref) => {
@ -159,13 +158,6 @@ export const DatabaseBlock = memo(
{children}
</div>
<div style={{
display: showActions ? 'flex' : 'none',
}}
className={'absolute text-text-caption break-words whitespace-pre-wrap top-0 left-0 z-[10] bg-content-blue-50 p-2 w-full min-h-[34px] rounded flex '}>
<TipIcon className={'relative top-1 w-4 h-4 mr-1'}/>
<span>Read-only: Use the AppFlowy app to create or edit database pages. This feature will be available soon.</span>
</div>
<TableContainer
paddingLeft={scrollLeft}
blockId={node.blockId}

View File

@ -1,17 +1,15 @@
import { UIVariant, ViewComponentProps, ViewLayout, ViewMetaProps, YDoc } from '@/application/types';
import Help from '@/components/_shared/help/Help';
import { notify } from '@/components/_shared/notify';
import { findView } from '@/components/_shared/outline/utils';
import {
AppContext,
useAppHandlers,
useAppOutline,
useAppViewId,
} from '@/components/app/app.hooks';
import { ReactComponent as TipIcon } from '@/assets/warning.svg';
import { AppContext, useAppHandlers, useAppOutline, useAppViewId } from '@/components/app/app.hooks';
import DatabaseView from '@/components/app/DatabaseView';
import { Document } from '@/components/document';
import RecordNotFound from '@/components/error/RecordNotFound';
import { getPlatform } from '@/utils/platform';
import { desktopDownloadLink, openAppFlowySchema } from '@/utils/url';
import { Button, Checkbox, FormControlLabel } from '@mui/material';
import React, { lazy, memo, Suspense, useCallback, useContext, useEffect, useMemo } from 'react';
const ViewHelmet = lazy(() => import('@/components/_shared/helmet/ViewHelmet'));
@ -20,6 +18,7 @@ function AppPage() {
const viewId = useAppViewId();
const outline = useAppOutline();
const ref = React.useRef<HTMLDivElement>(null);
const {
toView,
loadViewMeta,
@ -135,9 +134,59 @@ function AppPage() {
localStorage.setItem('last_view_id', viewId);
}, [View, viewId, doc]);
const layout = view?.layout;
useEffect(() => {
if (layout !== undefined && layout !== ViewLayout.Document && !localStorage.getItem('open_edit_tip')) {
notify.clear();
notify.info({
autoHideDuration: null,
type: 'info',
title: 'Edit in app',
message: <div className={'w-full gap-2 flex flex-col items-start'}>
<div>{`Editing databases is supported in AppFlowy's desktop and mobile apps`}
</div>
<div className={'text-sm flex items-center gap-2 text-text-caption'}>
<TipIcon className={'h-4 w-4 text-function-warning'} />
Don't have AppFlowy? <a
className={'text-fill-default hover:underline'}
href={desktopDownloadLink}
>Download</a></div>
<div className={'flex items-center max-sm:my-4 max-sm:flex-col mt-2 w-full justify-between'}>
<FormControlLabel
className={' max-sm:w-full'}
value="end"
onChange={(_e, value) => {
if (value) {
localStorage.setItem('open_edit_tip', 'true');
} else {
localStorage.removeItem('open_edit_tip');
}
}}
control={<Checkbox />}
label="Don't remind me again"
/>
<Button
color={'primary'}
className={'max-sm:w-full max-sm:py-4 max-sm:text-base'}
onClick={() => window.open(openAppFlowySchema, '_current')}
variant={'contained'}
>
Open in AppFlowy
</Button>
</div>
</div>,
showActions: false,
});
}
}, [layout]);
if (!viewId) return null;
return (
<div ref={ref} className={'relative w-full h-full'}>
<div
ref={ref}
className={'relative w-full h-full'}
>
{helmet}
{notFound ? (
@ -148,7 +197,6 @@ function AppPage() {
</div>
)}
{view && doc && <Help />}
</div>
);
}