mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
@@ -8,16 +8,22 @@ import {
|
||||
import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property';
|
||||
import { DocPropertyRow } from '@affine/core/components/doc-properties/table';
|
||||
import { DocDatabaseBacklinkInfo } from '@affine/core/modules/doc-info';
|
||||
import type {
|
||||
DatabaseRow,
|
||||
DatabaseValueCell,
|
||||
} from '@affine/core/modules/doc-info/types';
|
||||
import { DocsSearchService } from '@affine/core/modules/docs-search';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import { PlusIcon } from '@blocksuite/icons/rc';
|
||||
import {
|
||||
type DocCustomPropertyInfo,
|
||||
DocsService,
|
||||
LiveData,
|
||||
useLiveData,
|
||||
useServices,
|
||||
} from '@toeverything/infra';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import * as styles from './info-modal.css';
|
||||
import { LinksRow } from './links-row';
|
||||
@@ -49,6 +55,23 @@ export const InfoTable = ({
|
||||
)
|
||||
);
|
||||
|
||||
const onBacklinkPropertyChange = useCallback(
|
||||
(_row: DatabaseRow, cell: DatabaseValueCell, _value: unknown) => {
|
||||
track.$.docInfoPanel.databaseProperty.editProperty({
|
||||
type: cell.property.type$.value,
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const onPropertyAdded = useCallback((property: DocCustomPropertyInfo) => {
|
||||
setNewPropertyId(property.id);
|
||||
track.$.docInfoPanel.property.addProperty({
|
||||
type: property.type,
|
||||
control: 'at menu',
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{backlinks && backlinks.length > 0 ? (
|
||||
@@ -102,7 +125,7 @@ export const InfoTable = ({
|
||||
/>
|
||||
))}
|
||||
<Menu
|
||||
items={<CreatePropertyMenuItems onCreated={setNewPropertyId} />}
|
||||
items={<CreatePropertyMenuItems onCreated={onPropertyAdded} />}
|
||||
contentOptions={{
|
||||
onClick(e) {
|
||||
e.stopPropagation();
|
||||
@@ -120,7 +143,7 @@ export const InfoTable = ({
|
||||
</PropertyCollapsibleContent>
|
||||
</PropertyCollapsibleSection>
|
||||
<Divider size="thinner" />
|
||||
<DocDatabaseBacklinkInfo />
|
||||
<DocDatabaseBacklinkInfo onChange={onBacklinkPropertyChange} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
+15
-2
@@ -4,7 +4,13 @@ import { DocPropertyManager } from '@affine/core/components/doc-properties/manag
|
||||
import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property';
|
||||
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info';
|
||||
import { Trans, useI18n } from '@affine/i18n';
|
||||
import { FrameworkScope, type WorkspaceMetadata } from '@toeverything/infra';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
type DocCustomPropertyInfo,
|
||||
FrameworkScope,
|
||||
type WorkspaceMetadata,
|
||||
} from '@toeverything/infra';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useWorkspace } from '../../../../../components/hooks/use-workspace';
|
||||
import * as styles from './styles.css';
|
||||
@@ -12,10 +18,17 @@ import * as styles from './styles.css';
|
||||
const WorkspaceSettingPropertiesMain = () => {
|
||||
const t = useI18n();
|
||||
|
||||
const onCreated = useCallback((property: DocCustomPropertyInfo) => {
|
||||
track.$.settingsPanel.workspace.addProperty({
|
||||
type: property.type,
|
||||
control: 'at menu',
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={styles.main}>
|
||||
<div className={styles.listHeader}>
|
||||
<Menu items={<CreatePropertyMenuItems />}>
|
||||
<Menu items={<CreatePropertyMenuItems onCreated={onCreated} />}>
|
||||
<Button variant="primary">
|
||||
{t['com.affine.settings.workspace.properties.add_property']()}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user