mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
feat: add sync panel (#1485)
This commit is contained in:
@@ -22,6 +22,7 @@ import { CollaborationPanel } from './panel/collaboration';
|
|||||||
import { ExportPanel } from './panel/export';
|
import { ExportPanel } from './panel/export';
|
||||||
import { GeneralPanel } from './panel/general';
|
import { GeneralPanel } from './panel/general';
|
||||||
import { PublishPanel } from './panel/publish';
|
import { PublishPanel } from './panel/publish';
|
||||||
|
import { SyncPanel } from './panel/sync';
|
||||||
import {
|
import {
|
||||||
StyledIndicator,
|
StyledIndicator,
|
||||||
StyledSettingContainer,
|
StyledSettingContainer,
|
||||||
@@ -52,6 +53,12 @@ const panelMap = {
|
|||||||
name: 'General',
|
name: 'General',
|
||||||
ui: GeneralPanel,
|
ui: GeneralPanel,
|
||||||
},
|
},
|
||||||
|
[settingPanel.Sync]: {
|
||||||
|
name: 'Sync',
|
||||||
|
enable: (flavour: RemWorkspaceFlavour) =>
|
||||||
|
flavour === RemWorkspaceFlavour.AFFINE,
|
||||||
|
ui: SyncPanel,
|
||||||
|
},
|
||||||
[settingPanel.Collaboration]: {
|
[settingPanel.Collaboration]: {
|
||||||
name: 'Collaboration',
|
name: 'Collaboration',
|
||||||
ui: CollaborationPanel,
|
ui: CollaborationPanel,
|
||||||
@@ -67,6 +74,7 @@ const panelMap = {
|
|||||||
} satisfies {
|
} satisfies {
|
||||||
[Key in SettingPanel]: {
|
[Key in SettingPanel]: {
|
||||||
name: string;
|
name: string;
|
||||||
|
enable?: (flavour: RemWorkspaceFlavour) => boolean;
|
||||||
ui: React.FC<PanelProps>;
|
ui: React.FC<PanelProps>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -140,7 +148,7 @@ export const WorkspaceSettingDetail: React.FC<
|
|||||||
>
|
>
|
||||||
<StyledTabButtonWrapper>
|
<StyledTabButtonWrapper>
|
||||||
{Object.entries(panelMap).map(([key, value]) => {
|
{Object.entries(panelMap).map(([key, value]) => {
|
||||||
if (!isAffine && key === 'Sync') {
|
if ('enable' in value && !value.enable(workspace.flavour)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { Content, FlexWrapper, styled } from '@affine/component';
|
||||||
|
import { Trans, useTranslation } from '@affine/i18n';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { useCurrentUser } from '../../../../../hooks/current/use-current-user';
|
||||||
|
import { useBlockSuiteWorkspaceAvatarUrl } from '../../../../../hooks/use-blocksuite-workspace-avatar-url';
|
||||||
|
import { useBlockSuiteWorkspaceName } from '../../../../../hooks/use-blocksuite-workspace-name';
|
||||||
|
import { RemWorkspaceFlavour } from '../../../../../shared';
|
||||||
|
import { WorkspaceAvatar } from '../../../../pure/footer';
|
||||||
|
import { PanelProps } from '../../index';
|
||||||
|
|
||||||
|
export const StyledWorkspaceName = styled('span')(({ theme }) => {
|
||||||
|
return {
|
||||||
|
fontWeight: '400',
|
||||||
|
fontSize: theme.font.h6,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const SyncPanel: React.FC<PanelProps> = ({ workspace }) => {
|
||||||
|
if (workspace.flavour !== RemWorkspaceFlavour.AFFINE) {
|
||||||
|
throw new TypeError('SyncPanel can only be used with Affine workspace');
|
||||||
|
}
|
||||||
|
const [name] = useBlockSuiteWorkspaceName(workspace.blockSuiteWorkspace);
|
||||||
|
const [avatar] = useBlockSuiteWorkspaceAvatarUrl(
|
||||||
|
workspace.blockSuiteWorkspace
|
||||||
|
);
|
||||||
|
const user = useCurrentUser();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FlexWrapper alignItems="center" style={{ marginBottom: '12px' }}>
|
||||||
|
<WorkspaceAvatar
|
||||||
|
size={32}
|
||||||
|
name={name}
|
||||||
|
avatar={avatar}
|
||||||
|
style={{ marginRight: '12px' }}
|
||||||
|
/>
|
||||||
|
<StyledWorkspaceName>{name}</StyledWorkspaceName>
|
||||||
|
|
||||||
|
<Content weight={500}>{t('is a Cloud Workspace')}</Content>
|
||||||
|
</FlexWrapper>
|
||||||
|
<Trans i18nKey="Cloud Workspace Description">
|
||||||
|
All data will be synchronised and saved to the AFFiNE account
|
||||||
|
{{
|
||||||
|
email: user?.email,
|
||||||
|
}}
|
||||||
|
</Trans>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -94,8 +94,7 @@ export const settingPanel = {
|
|||||||
Collaboration: 'collaboration',
|
Collaboration: 'collaboration',
|
||||||
Publish: 'publish',
|
Publish: 'publish',
|
||||||
Export: 'export',
|
Export: 'export',
|
||||||
// TODO: add it back for desktop version
|
Sync: 'sync',
|
||||||
// Sync = 'sync'
|
|
||||||
} as const;
|
} as const;
|
||||||
export const settingPanelValues = [...Object.values(settingPanel)] as const;
|
export const settingPanelValues = [...Object.values(settingPanel)] as const;
|
||||||
export type SettingPanel = (typeof settingPanel)[keyof typeof settingPanel];
|
export type SettingPanel = (typeof settingPanel)[keyof typeof settingPanel];
|
||||||
|
|||||||
Reference in New Issue
Block a user