refactor: move component into UI part (#1333)

This commit is contained in:
Himself65 2023-03-05 23:42:09 -06:00 committed by GitHub
parent 45630669c7
commit d9b5744148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 95 additions and 90 deletions

View File

@ -39,12 +39,12 @@ const WorkspaceDetail: React.FC = () => {
return <PageLoading />;
}
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].PageDetail;
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
return (
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
);
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].PageDetail;
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
return (
<PageDetail currentWorkspace={currentWorkspace} currentPageId={pageId} />
);

View File

@ -47,7 +47,7 @@ const AllPage: NextPageWithLayout = () => {
return <PageLoading />;
}
if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
const PageList = WorkspacePlugins[currentWorkspace.flavour].PageList;
const PageList = WorkspacePlugins[currentWorkspace.flavour].UI.PageList;
return (
<>
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>
@ -58,7 +58,7 @@ const AllPage: NextPageWithLayout = () => {
</>
);
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
const PageList = WorkspacePlugins[currentWorkspace.flavour].PageList;
const PageList = WorkspacePlugins[currentWorkspace.flavour].UI.PageList;
return (
<>
<WorkspaceTitle icon={<FolderIcon />}>{t('All pages')}</WorkspaceTitle>

View File

@ -120,7 +120,8 @@ const SettingPage: NextPageWithLayout = () => {
} else if (settingPanelValues.indexOf(currentTab as SettingPanel) === -1) {
return <PageLoading />;
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.AFFINE) {
const Setting = WorkspacePlugins[currentWorkspace.flavour].SettingsDetail;
const Setting =
WorkspacePlugins[currentWorkspace.flavour].UI.SettingsDetail;
return (
<>
<Helmet>
@ -139,7 +140,8 @@ const SettingPage: NextPageWithLayout = () => {
</>
);
} else if (currentWorkspace.flavour === RemWorkspaceFlavour.LOCAL) {
const Setting = WorkspacePlugins[currentWorkspace.flavour].SettingsDetail;
const Setting =
WorkspacePlugins[currentWorkspace.flavour].UI.SettingsDetail;
return (
<>
<WorkspaceTitle icon={<SettingsIcon />}>

View File

@ -178,6 +178,7 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {
return [...allWorkspaces];
},
},
UI: {
PageDetail: ({ currentWorkspace, currentPageId }) => {
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
if (!page) {
@ -220,4 +221,5 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {
/>
);
},
},
};

View File

@ -51,12 +51,11 @@ export interface WorkspacePlugin<Flavour extends RemWorkspaceFlavour> {
// update: (workspace: FlavourToWorkspace[Flavour]) => Promise<void>;
list: () => Promise<FlavourToWorkspace[Flavour][]>;
};
//#region UI
UI: {
PageDetail: React.FC<PageDetailProps<Flavour>>;
PageList: React.FC<PageListProps<Flavour>>;
SettingsDetail: React.FC<SettingProps<Flavour>>;
//#endregion
};
}
export const WorkspacePlugins = {

View File

@ -104,6 +104,7 @@ export const LocalPlugin: WorkspacePlugin<RemWorkspaceFlavour.LOCAL> = {
return data;
},
},
UI: {
PageDetail: ({ currentWorkspace, currentPageId }) => {
const page = currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
if (!page) {
@ -146,4 +147,5 @@ export const LocalPlugin: WorkspacePlugin<RemWorkspaceFlavour.LOCAL> = {
/>
);
},
},
};