fix(core): dont show config properties in peek view (#8594)

view service is undefined in center peek.
This commit is contained in:
pengx17
2024-10-24 09:18:13 +00:00
parent 4b6c4ed546
commit 2fc27f41f0

View File

@@ -23,6 +23,7 @@ import {
DocsService,
useLiveData,
useService,
useServiceOptional,
} from '@toeverything/infra';
import clsx from 'clsx';
import type React from 'react';
@@ -245,7 +246,7 @@ export const DocPropertiesTableBody = forwardRef<
const t = useI18n();
const docsService = useService(DocsService);
const workbenchService = useService(WorkbenchService);
const viewService = useService(ViewService);
const viewService = useServiceOptional(ViewService);
const properties = useLiveData(docsService.propertyList.sortedProperties$);
const [propertyCollapsed, setPropertyCollapsed] = useState(true);
@@ -312,20 +313,22 @@ export const DocPropertiesTableBody = forwardRef<
{t['com.affine.page-properties.add-property']()}
</Button>
</Menu>
<Button
variant="plain"
prefix={<PropertyIcon />}
className={clsx(
styles.propertyActionButton,
styles.propertyConfigButton
)}
onClick={() => {
viewService.view.activeSidebarTab('properties');
workbenchService.workbench.openSidebar();
}}
>
{t['com.affine.page-properties.config-properties']()}
</Button>
{viewService ? (
<Button
variant="plain"
prefix={<PropertyIcon />}
className={clsx(
styles.propertyActionButton,
styles.propertyConfigButton
)}
onClick={() => {
viewService.view.activeSidebarTab('properties');
workbenchService.workbench.openSidebar();
}}
>
{t['com.affine.page-properties.config-properties']()}
</Button>
) : null}
</div>
</PropertyCollapsibleContent>
</PropertyCollapsibleSection>