Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: add template button to publish page (#6809)
Kilu.Hef526df98c7a1
diff --git a/frontend/appflowy_web_app/src/components/_shared/more-actions/MoreActions.tsx b/frontend/appflowy_web_app/src/components/_shared/more-actions/MoreActions.tsxindex 55a617849d..00d8982be9 100644--- a/frontend/appflowy_web_app/src/components/_shared/more-actions/MoreActions.tsx+++ b/frontend/appflowy_web_app/src/components/_shared/more-actions/MoreActions.tsx@@ -36,6 +36,7 @@ function MoreActions () {onClose={handleClose}slotProps={{ root: { className: 'text-sm' } }}>+<MoreActionsContentitemClicked={() => {handleClose();diff --git a/frontend/appflowy_web_app/src/components/publish/header/RightMenu.tsx b/frontend/appflowy_web_app/src/components/publish/header/RightMenu.tsxindex 1418cea204..66e51ac432 100644--- a/frontend/appflowy_web_app/src/components/publish/header/RightMenu.tsx+++ b/frontend/appflowy_web_app/src/components/publish/header/RightMenu.tsx@@ -1,19 +1,41 @@import MoreActions from '@/components/_shared/more-actions/MoreActions';import { openOrDownload } from '@/utils/open_schema';-import { Divider, Tooltip } from '@mui/material';-import React from 'react';+import { Divider, IconButton, Tooltip } from '@mui/material';+import React, { useCallback, useContext } from 'react';import { ReactComponent as Logo } from '@/assets/logo.svg';import { Duplicate } from '@/components/publish/header/duplicate';import { useTranslation } from 'react-i18next';+import { PublishContext } from '@/application/publish';+import { useCurrentUser } from '@/components/main/app.hooks';+import { ReactComponent as TemplateIcon } from '@/assets/template.svg';function RightMenu () {const { t } = useTranslation();+ const viewMeta = useContext(PublishContext)?.viewMeta;+ const viewId = viewMeta?.view_id;+ const viewName = viewMeta?.name;++ const handleTemplateClick = useCallback(() => {+ const url = `${window.origin}${window.location.pathname}`;++ window.open(`${window.origin}/as-template?viewUrl=${encodeURIComponent(url)}&viewName=${viewName || ''}&viewId=${viewId || ''}`, '_blank');+ }, [viewId, viewName]);++ const currentUser = useCurrentUser();++ const isAppFlowyUser = currentUser?.email?.endsWith('@appflowy.io');return (<><MoreActions /><Duplicate />-+ {isAppFlowyUser && (+ <Tooltip title={t('template.asTemplate')}>+ <IconButton onClick={handleTemplateClick} size={'small'}>+ <TemplateIcon />+ </IconButton>+ </Tooltip>+ )}<Dividerorientation={'vertical'}className={'mx-2'}