mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
fix(core): open template doc on sidebar template entrance (#9766)
close AF-2135, AF-2136, AF-2138, AF-2133
This commit is contained in:
@@ -26,7 +26,6 @@ import { track } from '@affine/track';
|
||||
import type { Store } from '@blocksuite/affine/store';
|
||||
import {
|
||||
AllDocsIcon,
|
||||
GithubIcon,
|
||||
ImportIcon,
|
||||
JournalIcon,
|
||||
SettingsIcon,
|
||||
@@ -192,11 +191,6 @@ export const RootAppSidebar = memo((): ReactElement => {
|
||||
icon={<JournalIcon />}
|
||||
label={t['com.affine.app-sidebar.learn-more']()}
|
||||
/>
|
||||
<ExternalMenuLinkItem
|
||||
href="https://github.com/toeverything/affine"
|
||||
icon={<GithubIcon />}
|
||||
label={t['com.affine.app-sidebar.star-us']()}
|
||||
/>
|
||||
</div>
|
||||
</SidebarScrollableContainer>
|
||||
<SidebarContainer>
|
||||
|
||||
@@ -10,28 +10,16 @@ import { TemplateIcon, TemplateOutlineIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { useAsyncCallback } from '../hooks/affine-async-hooks';
|
||||
|
||||
export const TemplateDocEntrance = () => {
|
||||
const t = useI18n();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const docsService = useService(DocsService);
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
const enabled = useLiveData(featureFlagService.flags.enable_template_doc.$);
|
||||
|
||||
const toggleMenu = useCallback(() => {
|
||||
setMenuOpen(prev => !prev);
|
||||
}, []);
|
||||
|
||||
const createDocFromTemplate = useAsyncCallback(
|
||||
async (templateId: string) => {
|
||||
const docId = await docsService.duplicateFromTemplate(templateId);
|
||||
workbench.openDoc(docId);
|
||||
},
|
||||
[docsService, workbench]
|
||||
);
|
||||
|
||||
if (!enabled) {
|
||||
return null;
|
||||
}
|
||||
@@ -49,10 +37,11 @@ export const TemplateDocEntrance = () => {
|
||||
align: 'end',
|
||||
alignOffset: -4,
|
||||
sideOffset: 16,
|
||||
style: { width: 280 },
|
||||
}}
|
||||
items={
|
||||
<TemplateListMenuContentScrollable
|
||||
onSelect={createDocFromTemplate}
|
||||
asLink
|
||||
suffixItems={
|
||||
<>
|
||||
<MenuSeparator />
|
||||
|
||||
Reference in New Issue
Block a user