mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: document issues (#6069)
This commit is contained in:
parent
7626cfd546
commit
242faee2f5
@ -13,7 +13,6 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { ReactComponent as CloseIcon } from '@/assets/close.svg';
|
import { ReactComponent as CloseIcon } from '@/assets/close.svg';
|
||||||
import { ReactComponent as DeleteIcon } from '@/assets/trash.svg';
|
import { ReactComponent as DeleteIcon } from '@/assets/trash.svg';
|
||||||
import './template.scss';
|
import './template.scss';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
|
|
||||||
function AsTemplate ({
|
function AsTemplate ({
|
||||||
viewName,
|
viewName,
|
||||||
@ -37,7 +36,9 @@ function AsTemplate ({
|
|||||||
loading,
|
loading,
|
||||||
} = useLoadTemplate(viewId);
|
} = useLoadTemplate(viewId);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const handleBack = useCallback(() => {
|
||||||
|
window.location.href = `${decodeURIComponent(viewUrl)}`;
|
||||||
|
}, [viewUrl]);
|
||||||
const handleSubmit = useCallback(async (data: AsTemplateFormValue) => {
|
const handleSubmit = useCallback(async (data: AsTemplateFormValue) => {
|
||||||
if (!service || !selectedCreatorId || selectedCategoryIds.length === 0) return;
|
if (!service || !selectedCreatorId || selectedCategoryIds.length === 0) return;
|
||||||
const formData: UploadTemplatePayload = {
|
const formData: UploadTemplatePayload = {
|
||||||
@ -50,8 +51,6 @@ function AsTemplate ({
|
|||||||
view_url: viewUrl,
|
view_url: viewUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('formData', formData);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (template) {
|
if (template) {
|
||||||
await service?.updateTemplate(template.view_id, formData);
|
await service?.updateTemplate(template.view_id, formData);
|
||||||
@ -71,14 +70,14 @@ function AsTemplate ({
|
|||||||
window.open(`${url}/template-center/${selectedCategoryIds[0]}/${viewId}`, '_blank');
|
window.open(`${url}/template-center/${selectedCategoryIds[0]}/${viewId}`, '_blank');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
navigate(-1);
|
handleBack();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
notify.error(error.toString());
|
notify.error(error.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [service, selectedCreatorId, selectedCategoryIds, viewId, isNewTemplate, isFeatured, viewUrl, template, t, navigate, loadTemplate]);
|
}, [service, selectedCreatorId, selectedCategoryIds, viewId, isNewTemplate, isFeatured, viewUrl, template, t, handleBack, loadTemplate]);
|
||||||
|
|
||||||
const submitRef = React.useRef<HTMLInputElement>(null);
|
const submitRef = React.useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@ -114,9 +113,7 @@ function AsTemplate ({
|
|||||||
<div className={'flex flex-col gap-4 w-full h-full overflow-hidden'}>
|
<div className={'flex flex-col gap-4 w-full h-full overflow-hidden'}>
|
||||||
<div className={'flex items-center justify-between'}>
|
<div className={'flex items-center justify-between'}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={handleBack}
|
||||||
navigate(-1);
|
|
||||||
}}
|
|
||||||
variant={'outlined'}
|
variant={'outlined'}
|
||||||
color={'inherit'}
|
color={'inherit'}
|
||||||
endIcon={<CloseIcon className={'w-4 h-4'} />}
|
endIcon={<CloseIcon className={'w-4 h-4'} />}
|
||||||
@ -179,9 +176,12 @@ function AsTemplate ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{deleteModalOpen && <DeleteTemplate id={viewId} onDeleted={() => {
|
{deleteModalOpen &&
|
||||||
navigate(-1);
|
<DeleteTemplate
|
||||||
}} open={deleteModalOpen} onClose={() => setDeleteModalOpen(false)}
|
id={viewId}
|
||||||
|
onDeleted={handleBack}
|
||||||
|
open={deleteModalOpen}
|
||||||
|
onClose={() => setDeleteModalOpen(false)}
|
||||||
/>}
|
/>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -76,12 +76,17 @@ export const DatabaseTabs = forwardRef<HTMLDivElement, DatabaseTabBarProps>(
|
|||||||
|
|
||||||
const showActions = !hideConditions && layout !== DatabaseViewLayout.Calendar;
|
const showActions = !hideConditions && layout !== DatabaseViewLayout.Calendar;
|
||||||
|
|
||||||
const getSelectedTabWidth = useCallback(() => {
|
const getSelectedTabIndicatorProps = useCallback(() => {
|
||||||
const selectedTab = document.getElementById(`view-tab-${selectedViewId}`);
|
const selectedTab = document.getElementById(`view-tab-${selectedViewId}`);
|
||||||
|
|
||||||
if (!selectedTab) return;
|
if (!selectedTab) return;
|
||||||
|
|
||||||
return selectedTab.clientWidth;
|
return {
|
||||||
|
style: {
|
||||||
|
width: selectedTab.clientWidth,
|
||||||
|
left: selectedTab.offsetLeft,
|
||||||
|
},
|
||||||
|
};
|
||||||
}, [selectedViewId]);
|
}, [selectedViewId]);
|
||||||
|
|
||||||
if (viewIds.length === 0) return null;
|
if (viewIds.length === 0) return null;
|
||||||
@ -99,11 +104,7 @@ export const DatabaseTabs = forwardRef<HTMLDivElement, DatabaseTabBarProps>(
|
|||||||
allowScrollButtonsMobile
|
allowScrollButtonsMobile
|
||||||
value={selectedViewId}
|
value={selectedViewId}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
TabIndicatorProps={{
|
TabIndicatorProps={getSelectedTabIndicatorProps()}
|
||||||
style: {
|
|
||||||
width: getSelectedTabWidth(),
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{viewIds.map((viewId) => {
|
{viewIds.map((viewId) => {
|
||||||
const view = views?.get(viewId) as YDatabaseView | null;
|
const view = views?.get(viewId) as YDatabaseView | null;
|
||||||
|
@ -41,13 +41,28 @@ function CollabView ({ doc }: CollabViewProps) {
|
|||||||
const loadView = usePublishContext()?.loadView;
|
const loadView = usePublishContext()?.loadView;
|
||||||
const isTemplateThumb = usePublishContext()?.isTemplateThumb;
|
const isTemplateThumb = usePublishContext()?.isTemplateThumb;
|
||||||
|
|
||||||
|
const className = useMemo(() => {
|
||||||
|
const classList = ['relative w-full flex-1'];
|
||||||
|
|
||||||
|
if (isTemplateThumb && layout !== ViewLayout.Document) {
|
||||||
|
classList.push('flex justify-center h-full');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layoutClassName) {
|
||||||
|
classList.push(layoutClassName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return classList.join(' ');
|
||||||
|
}, [isTemplateThumb, layout, layoutClassName]);
|
||||||
|
|
||||||
if (!doc || !View) {
|
if (!doc || !View) {
|
||||||
return <ComponentLoading />;
|
return <ComponentLoading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={style}
|
<div
|
||||||
className={`relative w-full ${isTemplateThumb ? 'flex justify-center h-full' : 'flex-1'} ${layoutClassName}`}
|
style={style}
|
||||||
|
className={className}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
doc={doc}
|
doc={doc}
|
||||||
|
Loading…
Reference in New Issue
Block a user