refactor: move component into UI part (#1333)
This commit is contained in:
@@ -39,12 +39,12 @@ const WorkspaceDetail: React.FC = () => {
|
|||||||
return <PageLoading />;
|
return <PageLoading />;
|
||||||
}
|
}
|
||||||
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
||||||
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].PageDetail;
|
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
|
||||||
return (
|
return (
|
||||||
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
|
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
|
||||||
);
|
);
|
||||||
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
||||||
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].PageDetail;
|
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
|
||||||
return (
|
return (
|
||||||
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
|
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const AllPage: NextPageWithLayout = () => {
|
|||||||
return <PageLoading />;
|
return <PageLoading />;
|
||||||
}
|
}
|
||||||
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
||||||
const PageList = WorkspacePlugins[currentWorkspace.flavour].PageList;
|
const PageList = WorkspacePlugins[currentWorkspace.flavour].UI.PageList;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>
|
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>
|
||||||
@@ -58,7 +58,7 @@ const AllPage: NextPageWithLayout = () => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
||||||
const PageList = WorkspacePlugins[currentWorkspace.flavour].PageList;
|
const PageList = WorkspacePlugins[currentWorkspace.flavour].UI.PageList;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>
|
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ const SettingPage: NextPageWithLayout = () => {
|
|||||||
} else if (settingPanelValues.indexOf(currentTab as SettingPanel) === -1) {
|
} else if (settingPanelValues.indexOf(currentTab as SettingPanel) === -1) {
|
||||||
return <PageLoading />;
|
return <PageLoading />;
|
||||||
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
|
||||||
const Setting = WorkspacePlugins[currentWorkspace.flavour].SettingsDetail;
|
const Setting =
|
||||||
|
WorkspacePlugins[currentWorkspace.flavour].UI.SettingsDetail;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
@@ -139,7 +140,8 @@ const SettingPage: NextPageWithLayout = () => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
|
||||||
const Setting = WorkspacePlugins[currentWorkspace.flavour].SettingsDetail;
|
const Setting =
|
||||||
|
WorkspacePlugins[currentWorkspace.flavour].UI.SettingsDetail;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WorkspaceTitle icon={<SettingsIcon />}>
|
<WorkspaceTitle icon={<SettingsIcon />}>
|
||||||
|
|||||||
@@ -178,46 +178,48 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {
|
|||||||
return [...allWorkspaces];
|
return [...allWorkspaces];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PageDetail: ({ currentWorkspace, currentPageId }) => {
|
UI: {
|
||||||
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
|
PageDetail: ({ currentWorkspace, currentPageId }) => {
|
||||||
if (!page) {
|
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
|
||||||
throw new PageNotFoundError(
|
if (!page) {
|
||||||
currentWorkspace.blockSuiteWorkspace,
|
throw new PageNotFoundError(
|
||||||
currentPageId
|
currentWorkspace.blockSuiteWorkspace,
|
||||||
|
currentPageId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageDetailEditor
|
||||||
|
pageId={currentPageId}
|
||||||
|
blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
return (
|
PageList: ({ blockSuiteWorkspace, onOpenPage }) => {
|
||||||
<>
|
return (
|
||||||
<PageDetailEditor
|
<BlockSuitePageList
|
||||||
pageId={currentPageId}
|
onOpenPage={onOpenPage}
|
||||||
blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
|
blockSuiteWorkspace={blockSuiteWorkspace}
|
||||||
/>
|
/>
|
||||||
</>
|
);
|
||||||
);
|
},
|
||||||
},
|
SettingsDetail: ({
|
||||||
PageList: ({ blockSuiteWorkspace, onOpenPage }) => {
|
currentWorkspace,
|
||||||
return (
|
onChangeTab,
|
||||||
<BlockSuitePageList
|
currentTab,
|
||||||
onOpenPage={onOpenPage}
|
onDeleteWorkspace,
|
||||||
blockSuiteWorkspace={blockSuiteWorkspace}
|
onTransformWorkspace,
|
||||||
/>
|
}) => {
|
||||||
);
|
return (
|
||||||
},
|
<WorkspaceSettingDetail
|
||||||
SettingsDetail: ({
|
onDeleteWorkspace={onDeleteWorkspace}
|
||||||
currentWorkspace,
|
onChangeTab={onChangeTab}
|
||||||
onChangeTab,
|
currentTab={currentTab}
|
||||||
currentTab,
|
workspace={currentWorkspace}
|
||||||
onDeleteWorkspace,
|
onTransferWorkspace={onTransformWorkspace}
|
||||||
onTransformWorkspace,
|
/>
|
||||||
}) => {
|
);
|
||||||
return (
|
},
|
||||||
<WorkspaceSettingDetail
|
|
||||||
onDeleteWorkspace={onDeleteWorkspace}
|
|
||||||
onChangeTab={onChangeTab}
|
|
||||||
currentTab={currentTab}
|
|
||||||
workspace={currentWorkspace}
|
|
||||||
onTransferWorkspace={onTransformWorkspace}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,12 +51,11 @@ export interface WorkspacePlugin<Flavour extends RemWorkspaceFlavour> {
|
|||||||
// update: (workspace: FlavourToWorkspace[Flavour]) => Promise<void>;
|
// update: (workspace: FlavourToWorkspace[Flavour]) => Promise<void>;
|
||||||
list: () => Promise<FlavourToWorkspace[Flavour][]>;
|
list: () => Promise<FlavourToWorkspace[Flavour][]>;
|
||||||
};
|
};
|
||||||
|
UI: {
|
||||||
//#region UI
|
PageDetail: React.FC<PageDetailProps<Flavour>>;
|
||||||
PageDetail: React.FC<PageDetailProps<Flavour>>;
|
PageList: React.FC<PageListProps<Flavour>>;
|
||||||
PageList: React.FC<PageListProps<Flavour>>;
|
SettingsDetail: React.FC<SettingProps<Flavour>>;
|
||||||
SettingsDetail: React.FC<SettingProps<Flavour>>;
|
};
|
||||||
//#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspacePlugins = {
|
export const WorkspacePlugins = {
|
||||||
|
|||||||
@@ -104,46 +104,48 @@ export const LocalPlugin: WorkspacePlugin<RemWorkspaceFlavour.LOCAL> = {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PageDetail: ({ currentWorkspace, currentPageId }) => {
|
UI: {
|
||||||
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
|
PageDetail: ({ currentWorkspace, currentPageId }) => {
|
||||||
if (!page) {
|
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
|
||||||
throw new PageNotFoundError(
|
if (!page) {
|
||||||
currentWorkspace.blockSuiteWorkspace,
|
throw new PageNotFoundError(
|
||||||
currentPageId
|
currentWorkspace.blockSuiteWorkspace,
|
||||||
|
currentPageId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageDetailEditor
|
||||||
|
pageId={currentPageId}
|
||||||
|
blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
return (
|
PageList: ({ blockSuiteWorkspace, onOpenPage }) => {
|
||||||
<>
|
return (
|
||||||
<PageDetailEditor
|
<BlockSuitePageList
|
||||||
pageId={currentPageId}
|
onOpenPage={onOpenPage}
|
||||||
blockSuiteWorkspace={currentWorkspace.blockSuiteWorkspace}
|
blockSuiteWorkspace={blockSuiteWorkspace}
|
||||||
/>
|
/>
|
||||||
</>
|
);
|
||||||
);
|
},
|
||||||
},
|
SettingsDetail: ({
|
||||||
PageList: ({ blockSuiteWorkspace, onOpenPage }) => {
|
currentWorkspace,
|
||||||
return (
|
onChangeTab,
|
||||||
<BlockSuitePageList
|
currentTab,
|
||||||
onOpenPage={onOpenPage}
|
onDeleteWorkspace,
|
||||||
blockSuiteWorkspace={blockSuiteWorkspace}
|
onTransformWorkspace,
|
||||||
/>
|
}) => {
|
||||||
);
|
return (
|
||||||
},
|
<WorkspaceSettingDetail
|
||||||
SettingsDetail: ({
|
onDeleteWorkspace={onDeleteWorkspace}
|
||||||
currentWorkspace,
|
onChangeTab={onChangeTab}
|
||||||
onChangeTab,
|
currentTab={currentTab}
|
||||||
currentTab,
|
workspace={currentWorkspace}
|
||||||
onDeleteWorkspace,
|
onTransferWorkspace={onTransformWorkspace}
|
||||||
onTransformWorkspace,
|
/>
|
||||||
}) => {
|
);
|
||||||
return (
|
},
|
||||||
<WorkspaceSettingDetail
|
|
||||||
onDeleteWorkspace={onDeleteWorkspace}
|
|
||||||
onChangeTab={onChangeTab}
|
|
||||||
currentTab={currentTab}
|
|
||||||
workspace={currentWorkspace}
|
|
||||||
onTransferWorkspace={onTransformWorkspace}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user