fix(core): disable creating linked doc in sidebar when show linked is off (#13191)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * The "add linked page" icon button in the navigation panel is now only visible if enabled in your app settings. * **Enhancements** * The navigation panel dynamically updates the available operations based on your sidebar settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
} from '@affine/component';
|
} from '@affine/component';
|
||||||
import { usePageHelper } from '@affine/core/blocksuite/block-suite-page-list/utils';
|
import { usePageHelper } from '@affine/core/blocksuite/block-suite-page-list/utils';
|
||||||
import { Guard } from '@affine/core/components/guard';
|
import { Guard } from '@affine/core/components/guard';
|
||||||
|
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
|
||||||
import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper';
|
import { useBlockSuiteMetaHelper } from '@affine/core/components/hooks/affine/use-block-suite-meta-helper';
|
||||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||||
import { IsFavoriteIcon } from '@affine/core/components/pure/icons';
|
import { IsFavoriteIcon } from '@affine/core/components/pure/icons';
|
||||||
@@ -56,6 +57,7 @@ export const useNavigationPanelDocNodeOperations = (
|
|||||||
|
|
||||||
const [addLinkedPageLoading, setAddLinkedPageLoading] = useState(false);
|
const [addLinkedPageLoading, setAddLinkedPageLoading] = useState(false);
|
||||||
const docRecord = useLiveData(docsService.list.doc$(docId));
|
const docRecord = useLiveData(docsService.list.doc$(docId));
|
||||||
|
const { appSettings } = useAppSettingHelper();
|
||||||
|
|
||||||
const { createPage } = usePageHelper(
|
const { createPage } = usePageHelper(
|
||||||
workspaceService.workspace.docCollection
|
workspaceService.workspace.docCollection
|
||||||
@@ -149,20 +151,26 @@ export const useNavigationPanelDocNodeOperations = (
|
|||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
...(appSettings.showLinkedDocInSidebar
|
||||||
index: 0,
|
? [
|
||||||
inline: true,
|
{
|
||||||
view: (
|
index: 0,
|
||||||
<IconButton
|
inline: true,
|
||||||
size="16"
|
view: (
|
||||||
icon={<PlusIcon />}
|
<IconButton
|
||||||
tooltip={t['com.affine.rootAppSidebar.explorer.doc-add-tooltip']()}
|
size="16"
|
||||||
onClick={handleAddLinkedPage}
|
icon={<PlusIcon />}
|
||||||
loading={addLinkedPageLoading}
|
tooltip={t[
|
||||||
disabled={addLinkedPageLoading}
|
'com.affine.rootAppSidebar.explorer.doc-add-tooltip'
|
||||||
/>
|
]()}
|
||||||
),
|
onClick={handleAddLinkedPage}
|
||||||
},
|
loading={addLinkedPageLoading}
|
||||||
|
disabled={addLinkedPageLoading}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
index: 50,
|
index: 50,
|
||||||
view: (
|
view: (
|
||||||
@@ -258,6 +266,7 @@ export const useNavigationPanelDocNodeOperations = (
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
addLinkedPageLoading,
|
addLinkedPageLoading,
|
||||||
|
appSettings.showLinkedDocInSidebar,
|
||||||
docId,
|
docId,
|
||||||
favorite,
|
favorite,
|
||||||
handleAddLinkedPage,
|
handleAddLinkedPage,
|
||||||
|
|||||||
Reference in New Issue
Block a user