mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-22 07:02:18 +03:00
feat(core): update import entry in all page and page list (#8814)
This commit is contained in:
parent
87520e9bf9
commit
6f5c61b8b6
@ -6,11 +6,11 @@ import {
|
||||
Scrollable,
|
||||
useConfirmModal,
|
||||
} from '@affine/component';
|
||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||
import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import type { Tag } from '@affine/core/modules/tag';
|
||||
import { TagService } from '@affine/core/modules/tag';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { isNewTabTrigger } from '@affine/core/utils';
|
||||
import type { Collection } from '@affine/env/filter';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
@ -41,31 +41,54 @@ import { PageListNewPageButton } from './page-list-new-page-button';
|
||||
|
||||
export const PageListHeader = () => {
|
||||
const t = useI18n();
|
||||
const { workspaceService } = useServices({
|
||||
WorkspaceService,
|
||||
});
|
||||
const { workspaceService, workspaceDialogService, workbenchService } =
|
||||
useServices({
|
||||
WorkspaceService,
|
||||
WorkspaceDialogService,
|
||||
WorkbenchService,
|
||||
});
|
||||
|
||||
const workbench = workbenchService.workbench;
|
||||
const workspace = workspaceService.workspace;
|
||||
const { importFile, createEdgeless, createPage } = usePageHelper(
|
||||
workspace.docCollection
|
||||
);
|
||||
const { createEdgeless, createPage } = usePageHelper(workspace.docCollection);
|
||||
|
||||
const title = useMemo(() => {
|
||||
return t['com.affine.all-pages.header']();
|
||||
}, [t]);
|
||||
|
||||
const onImportFile = useAsyncCallback(async () => {
|
||||
const options = await importFile();
|
||||
if (options.isWorkspaceFile) {
|
||||
track.allDocs.header.actions.createWorkspace({
|
||||
control: 'import',
|
||||
});
|
||||
} else {
|
||||
track.allDocs.header.actions.createDoc({
|
||||
control: 'import',
|
||||
});
|
||||
}
|
||||
}, [importFile]);
|
||||
const handleOpenDocs = useCallback(
|
||||
(result: {
|
||||
docIds: string[];
|
||||
entryId?: string;
|
||||
isWorkspaceFile?: boolean;
|
||||
}) => {
|
||||
const { docIds, entryId, isWorkspaceFile } = result;
|
||||
// If the imported file is a workspace file, open the entry page.
|
||||
if (isWorkspaceFile && entryId) {
|
||||
workbench.openDoc(entryId);
|
||||
} else if (!docIds.length) {
|
||||
return;
|
||||
}
|
||||
// Open all the docs when there are multiple docs imported.
|
||||
if (docIds.length > 1) {
|
||||
workbench.openAll();
|
||||
} else {
|
||||
// Otherwise, open the only doc.
|
||||
workbench.openDoc(docIds[0]);
|
||||
}
|
||||
},
|
||||
[workbench]
|
||||
);
|
||||
|
||||
const onImportFile = useCallback(() => {
|
||||
track.$.header.importModal.open();
|
||||
workspaceDialogService.open('import', undefined, payload => {
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
handleOpenDocs(payload);
|
||||
});
|
||||
}, [workspaceDialogService, handleOpenDocs]);
|
||||
|
||||
return (
|
||||
<div className={styles.docListHeader}>
|
||||
|
@ -1,30 +0,0 @@
|
||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||
import { MenuItem } from '@affine/core/modules/app-sidebar/views';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import type { DocCollection } from '@blocksuite/affine/store';
|
||||
import { ImportIcon } from '@blocksuite/icons/rc';
|
||||
|
||||
import { usePageHelper } from '../blocksuite/block-suite-page-list/utils';
|
||||
|
||||
const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
||||
const t = useI18n();
|
||||
const { importFile } = usePageHelper(docCollection);
|
||||
|
||||
const onImportFile = useAsyncCallback(async () => {
|
||||
const options = await importFile();
|
||||
track.$.navigationPanel.workspaceList[
|
||||
options.isWorkspaceFile ? 'createWorkspace' : 'createDoc'
|
||||
]({
|
||||
control: 'import',
|
||||
});
|
||||
}, [importFile]);
|
||||
|
||||
return (
|
||||
<MenuItem icon={<ImportIcon />} onClick={onImportFile}>
|
||||
{t['Import']()}
|
||||
</MenuItem>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImportPage;
|
@ -1,5 +1,4 @@
|
||||
import { usePageHelper } from '@affine/core/components/blocksuite/block-suite-page-list/utils';
|
||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||
import {
|
||||
AllPageListOperationsMenu,
|
||||
PageDisplayMenu,
|
||||
@ -7,12 +6,15 @@ import {
|
||||
} from '@affine/core/components/page-list';
|
||||
import { Header } from '@affine/core/components/pure/header';
|
||||
import { WorkspaceModeFilterTab } from '@affine/core/components/pure/workspace-mode-filter-tab';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { isNewTabTrigger } from '@affine/core/utils';
|
||||
import type { Filter } from '@affine/env/filter';
|
||||
import { track } from '@affine/track';
|
||||
import { PlusIcon } from '@blocksuite/icons/rc';
|
||||
import { useServices, WorkspaceService } from '@toeverything/infra';
|
||||
import clsx from 'clsx';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import * as styles from './all-page.css';
|
||||
|
||||
@ -25,26 +27,49 @@ export const AllPageHeader = ({
|
||||
filters: Filter[];
|
||||
onChangeFilters: (filters: Filter[]) => void;
|
||||
}) => {
|
||||
const { workspaceService } = useServices({
|
||||
WorkspaceService,
|
||||
});
|
||||
const { workspaceService, workspaceDialogService, workbenchService } =
|
||||
useServices({
|
||||
WorkspaceService,
|
||||
WorkspaceDialogService,
|
||||
WorkbenchService,
|
||||
});
|
||||
const workbench = workbenchService.workbench;
|
||||
const workspace = workspaceService.workspace;
|
||||
const { importFile, createEdgeless, createPage } = usePageHelper(
|
||||
workspace.docCollection
|
||||
const { createEdgeless, createPage } = usePageHelper(workspace.docCollection);
|
||||
|
||||
const handleOpenDocs = useCallback(
|
||||
(result: {
|
||||
docIds: string[];
|
||||
entryId?: string;
|
||||
isWorkspaceFile?: boolean;
|
||||
}) => {
|
||||
const { docIds, entryId, isWorkspaceFile } = result;
|
||||
// If the imported file is a workspace file, open the entry page.
|
||||
if (isWorkspaceFile && entryId) {
|
||||
workbench.openDoc(entryId);
|
||||
} else if (!docIds.length) {
|
||||
return;
|
||||
}
|
||||
// Open all the docs when there are multiple docs imported.
|
||||
if (docIds.length > 1) {
|
||||
workbench.openAll();
|
||||
} else {
|
||||
// Otherwise, open the only doc.
|
||||
workbench.openDoc(docIds[0]);
|
||||
}
|
||||
},
|
||||
[workbench]
|
||||
);
|
||||
|
||||
const onImportFile = useAsyncCallback(async () => {
|
||||
const options = await importFile();
|
||||
if (options.isWorkspaceFile) {
|
||||
track.allDocs.header.actions.createWorkspace({
|
||||
control: 'import',
|
||||
});
|
||||
} else {
|
||||
track.allDocs.header.actions.createDoc({
|
||||
control: 'import',
|
||||
});
|
||||
}
|
||||
}, [importFile]);
|
||||
const onImportFile = useCallback(() => {
|
||||
track.$.header.importModal.open();
|
||||
workspaceDialogService.open('import', undefined, payload => {
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
handleOpenDocs(payload);
|
||||
});
|
||||
}, [workspaceDialogService, handleOpenDocs]);
|
||||
|
||||
return (
|
||||
<Header
|
||||
|
@ -1,22 +1,22 @@
|
||||
{
|
||||
"ar": 79,
|
||||
"ca": 6,
|
||||
"ar": 76,
|
||||
"ca": 5,
|
||||
"da": 6,
|
||||
"de": 29,
|
||||
"de": 28,
|
||||
"en": 100,
|
||||
"es-AR": 14,
|
||||
"es-CL": 16,
|
||||
"es": 14,
|
||||
"fr": 70,
|
||||
"fr": 67,
|
||||
"hi": 2,
|
||||
"it": 1,
|
||||
"ja": 93,
|
||||
"ko": 83,
|
||||
"ja": 90,
|
||||
"ko": 80,
|
||||
"pl": 0,
|
||||
"pt-BR": 90,
|
||||
"ru": 77,
|
||||
"sv-SE": 5,
|
||||
"pt-BR": 87,
|
||||
"ru": 74,
|
||||
"sv-SE": 4,
|
||||
"ur": 3,
|
||||
"zh-Hans": 95,
|
||||
"zh-Hant": 92
|
||||
}
|
||||
"zh-Hans": 91,
|
||||
"zh-Hant": 88
|
||||
}
|
@ -1312,7 +1312,7 @@
|
||||
"com.affine.sidebarSwitch.collapse": "Collapse sidebar",
|
||||
"com.affine.sidebarSwitch.expand": "Expand sidebar",
|
||||
"com.affine.snapshot.import-export.enable": "Snapshot Imp. & Exp.",
|
||||
"com.affine.snapshot.import-export.enable.desc": "Snapshot import and export support. When your document has a data error, turn this on and ask the AFFiNE team for help. Once enabled you can find the Snapshot Export Import option in the document's More menu.",
|
||||
"com.affine.snapshot.import-export.enable.desc": "Once enabled you can find the Snapshot Export Import option in the document's More menu.",
|
||||
"com.affine.star-affine.cancel": "Maybe later",
|
||||
"com.affine.star-affine.confirm": "Star on GitHub",
|
||||
"com.affine.star-affine.description": "Are you finding our app useful and enjoyable? We'd love your support to keep improving! A great way to help us out is by giving us a star on GitHub. This simple action can make a big difference and helps us continue to deliver the best experience for you.",
|
||||
|
@ -1312,7 +1312,7 @@
|
||||
"com.affine.sidebarSwitch.collapse": "折叠侧边栏",
|
||||
"com.affine.sidebarSwitch.expand": "展开侧边栏",
|
||||
"com.affine.snapshot.import-export.enable": "启用快照导入导出",
|
||||
"com.affine.snapshot.import-export.enable.desc": "支持快照导入和导出。当您的文档出现数据错误时,请启用此功能并寻求 AFFiNE 团队的帮助。启用后,您可以在文档的更多菜单中找到快照导出导入选项。",
|
||||
"com.affine.snapshot.import-export.enable.desc": "启用后,您可以在文档的更多菜单中找到快照导出导入选项。",
|
||||
"com.affine.star-affine.cancel": "稍后",
|
||||
"com.affine.star-affine.confirm": "在 GitHub 点亮星标",
|
||||
"com.affine.star-affine.description": "您觉得我们的应用程序有用且有趣吗? 我们希望得到您的支持,以不断进步! 帮助我们的一个好方法是在 GitHub 给我们一颗星。 这个简单的行动可以给我们很大的激励,并帮助我们继续为您提供最佳体验。",
|
||||
|
@ -1312,7 +1312,7 @@
|
||||
"com.affine.sidebarSwitch.collapse": "收起側欄",
|
||||
"com.affine.sidebarSwitch.expand": "展開側欄",
|
||||
"com.affine.snapshot.import-export.enable": "啟用快照匯入匯出",
|
||||
"com.affine.snapshot.import-export.enable.desc": "支援快照匯入和匯出。當您的文件出現資料錯誤時,請啟用此功能並尋求 AFFiNE 團隊的協助。啟用後,您可以在文件的更多選單中找到快照匯出匯入選項。",
|
||||
"com.affine.snapshot.import-export.enable.desc": "啟用後,您可以在文件的更多選單中找到快照匯出匯入選項。",
|
||||
"com.affine.star-affine.cancel": "稍後",
|
||||
"com.affine.star-affine.confirm": "在 GitHub 點亮星標",
|
||||
"com.affine.star-affine.description": "您覺得我們的應用程序有用且有趣嗎?我們希望得到您的支持,以不斷進步!幫助我們的一個好方法是在 GitHub 給我們一顆星。這個簡單的行動可以給我們很大的激勵,並幫助我們繼續為您提供最佳體驗。",
|
||||
|
Loading…
Reference in New Issue
Block a user