feat(mobile): doc property journal duplicated action (#8820)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Checkbox, DatePicker, Menu, PropertyValue } from '@affine/component';
|
import { Checkbox, DatePicker, Menu, PropertyValue } from '@affine/component';
|
||||||
|
import { MobileJournalConflictList } from '@affine/core/mobile/pages/workspace/detail/menu/journal-conflicts';
|
||||||
import { JournalService } from '@affine/core/modules/journal';
|
import { JournalService } from '@affine/core/modules/journal';
|
||||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||||
@@ -15,6 +16,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|||||||
import * as styles from './journal.css';
|
import * as styles from './journal.css';
|
||||||
import type { PropertyValueProps } from './types';
|
import type { PropertyValueProps } from './types';
|
||||||
|
|
||||||
|
const stopPropagation = (e: React.MouseEvent) => e.stopPropagation();
|
||||||
export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
|
||||||
@@ -75,10 +77,6 @@ export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
|||||||
|
|
||||||
const handleOpenDuplicate = useCallback(
|
const handleOpenDuplicate = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
// todo: open duplicate dialog for mobile
|
|
||||||
if (BUILD_CONFIG.isMobileEdition) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
workbench.openSidebar();
|
workbench.openSidebar();
|
||||||
view.activeSidebarTab('journal');
|
view.activeSidebarTab('journal');
|
||||||
@@ -141,13 +139,25 @@ export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{checked && conflict ? (
|
{checked && conflict ? (
|
||||||
<div
|
BUILD_CONFIG.isMobileEdition ? (
|
||||||
data-testid="conflict-tag"
|
<Menu items={<MobileJournalConflictList date={selectedDate} />}>
|
||||||
className={styles.duplicateTag}
|
<div
|
||||||
onClick={handleOpenDuplicate}
|
data-testid="conflict-tag"
|
||||||
>
|
className={styles.duplicateTag}
|
||||||
{t['com.affine.page-properties.property.journal-duplicated']()}
|
onClick={stopPropagation}
|
||||||
</div>
|
>
|
||||||
|
{t['com.affine.page-properties.property.journal-duplicated']()}
|
||||||
|
</div>
|
||||||
|
</Menu>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
data-testid="conflict-tag"
|
||||||
|
className={styles.duplicateTag}
|
||||||
|
onClick={handleOpenDuplicate}
|
||||||
|
>
|
||||||
|
{t['com.affine.page-properties.property.journal-duplicated']()}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</PropertyValue>
|
</PropertyValue>
|
||||||
|
|||||||
@@ -112,6 +112,23 @@ const ConflictList = ({ docRecords }: { docRecords: DocRecord[] }) => {
|
|||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MobileJournalConflictList = ({ date }: { date: string }) => {
|
||||||
|
const docRecordList = useService(DocsService).list;
|
||||||
|
const journalService = useService(JournalService);
|
||||||
|
const docs = useLiveData(
|
||||||
|
useMemo(() => journalService.journalsByDate$(date), [journalService, date])
|
||||||
|
);
|
||||||
|
const docRecords = useLiveData(
|
||||||
|
docRecordList.docs$.map(records =>
|
||||||
|
records.filter(v => {
|
||||||
|
return docs.some(doc => doc.id === v.id);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return <ConflictList docRecords={docRecords} />;
|
||||||
|
};
|
||||||
|
|
||||||
const ConflictListMenuItem = ({ docRecords }: { docRecords: DocRecord[] }) => {
|
const ConflictListMenuItem = ({ docRecords }: { docRecords: DocRecord[] }) => {
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user