mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-12-02 04:18:14 +08:00
feat: support ai writer (#69)
* feat: support ai writer * feat: support duplicate page * feat: support upgrade AI Max
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { Origins } from '@/components/_shared/popover';
|
||||
import DeletePageConfirm from '@/components/app/view-actions/DeletePageConfirm';
|
||||
import MovePagePopover from '@/components/app/view-actions/MovePagePopover';
|
||||
import { Button } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ReactComponent as DeleteIcon } from '@/assets/trash.svg';
|
||||
import { ViewLayout } from '@/application/types';
|
||||
import { ReactComponent as DuplicateIcon } from '@/assets/duplicate.svg';
|
||||
import { ReactComponent as MoveToIcon } from '@/assets/move_to.svg';
|
||||
import { ReactComponent as DeleteIcon } from '@/assets/trash.svg';
|
||||
import { notify } from '@/components/_shared/notify';
|
||||
import { Origins } from '@/components/_shared/popover';
|
||||
import { useAppHandlers, useAppView, useCurrentWorkspaceId } from '@/components/app/app.hooks';
|
||||
import DeletePageConfirm from '@/components/app/view-actions/DeletePageConfirm';
|
||||
import MovePagePopover from '@/components/app/view-actions/MovePagePopover';
|
||||
import { useService } from '@/components/main/app.hooks';
|
||||
import { Button, CircularProgress } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
function MoreActionsContent({ itemClicked, viewId, movePopoverOrigins, onDeleted }: {
|
||||
itemClicked?: () => void;
|
||||
@@ -17,18 +21,40 @@ function MoreActionsContent({ itemClicked, viewId, movePopoverOrigins, onDeleted
|
||||
const { t } = useTranslation();
|
||||
const [movePopoverAnchorEl, setMovePopoverAnchorEl] = useState<null | HTMLElement>(null);
|
||||
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
|
||||
const service = useService();
|
||||
const workspaceId = useCurrentWorkspaceId();
|
||||
const view = useAppView(viewId);
|
||||
const layout = view?.layout;
|
||||
const [duplicateLoading, setDuplicateLoading] = useState(false);
|
||||
const {
|
||||
refreshOutline,
|
||||
} = useAppHandlers();
|
||||
const handleDuplicateClick = async() => {
|
||||
if(!workspaceId || !service) return;
|
||||
setDuplicateLoading(true);
|
||||
try {
|
||||
await service.duplicateAppPage(workspaceId, viewId);
|
||||
|
||||
void refreshOutline?.();
|
||||
// eslint-disable-next-line
|
||||
} catch(e: any) {
|
||||
notify.error(e.message);
|
||||
} finally {
|
||||
setDuplicateLoading(false);
|
||||
}
|
||||
|
||||
itemClicked?.();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={'flex flex-col gap-2 more-actions'}>
|
||||
<Button
|
||||
size={'small'}
|
||||
className={'px-3 hidden py-1 justify-start '}
|
||||
className={`px-3 py-1 ${layout === ViewLayout.AIChat ? 'hidden' : ''} justify-start `}
|
||||
color={'inherit'}
|
||||
onClick={() => {
|
||||
itemClicked?.();
|
||||
}}
|
||||
|
||||
startIcon={<DuplicateIcon />}
|
||||
onClick={handleDuplicateClick}
|
||||
disabled={duplicateLoading}
|
||||
startIcon={duplicateLoading ? <CircularProgress size={14} /> : <DuplicateIcon />}
|
||||
>{t('button.duplicate')}</Button>
|
||||
<Button
|
||||
size={'small'}
|
||||
|
||||
Reference in New Issue
Block a user